#help-development

1 messages ยท Page 1509 of 1

wet breach
#

there is methods with ItemStack to get a copy

hardy swan
#

yea clone

wet breach
#

otherwise when interacting with the inventory, the itemstacks returned are not copies

hardy swan
#

you know sometimes I dun trust docs

#

but you are definitely right, they aint copies

wet breach
#

have to take into consideration most of the documentation is pretty old ๐Ÿ˜›

#

most of the time, the comments for methods don't get updated until someone spots a discrepancy lol

young knoll
#

Last I checked it still says ExactChoice only works for shaped recipes

#

But I remember someone showing me it working for a furnace recipe

gaunt hatch
#

Bam!, no more broken citizen needed. Made a way better npc system ๐Ÿ™‚

wet breach
#

nice

gaunt hatch
#

Made the NPC's client level, so it does not effect the server and also when they follow they follow you and only you on your client

#

With a new little GUI editing there info

wet breach
#

ah so you went the route of packets

gaunt hatch
wet breach
#

well good luck on your updating of it ๐Ÿ™‚

gaunt hatch
#

its already working in 1.17

wet breach
#

sure, but its going to break on every major version and maybe some minor versions

gaunt hatch
#

yea, but that happen more and more on everything even little stuff lol

wet breach
#

that is why I just stick with the API ๐Ÿ˜›

#

to much of a hassle dealing with NMS and reflection most of the time

gaunt hatch
#

No fun that way lol

quaint mantle
#

How do i add a library?

unreal quartz
#

depends what you're using

#

do you have a library card?

hardy swan
#

Why is there no MCE for java :(

unreal quartz
#

gonna need one of those to check out books

hardy swan
#

But may need to pay for the card tho

unreal quartz
#

i'm messing about lol

#

doesn't look like it's intended to be used that way, but i'm assuming you're not using maven/gradle correct?

hardy swan
#

Jitpack way to go

tribal holly
#

Hi i need to convert an InputStream into a ConfigurationFile someone konw how to do ? (i need to import a .yml from RESSOURCE folder and not data folder)

young knoll
#

YamlConfiguration.loadConfiguration

unreal quartz
#

it's no different than just reading a normal file, there is a method to load it

tribal holly
#

hahahaha

tribal holly
#
public InputStream getResource(@NotNull String filename)```
#

any other method

tribal holly
quaint mantle
unreal quartz
#

you use one or the other

hardy swan
#

Maven or gradle

young knoll
#

MavenGradleโ„ข๏ธ

hardy swan
#

Madle

#

Graven

#

Gravendor

humble stirrup
#

graven sounds very cool

hardy swan
#

20 points to gravendor

tribal holly
tribal holly
#

well i just google it...

hardy swan
#

Jinx

unreal quartz
#

you can read the input steam with an input stream reader, or a buffered stream, both of which that method accepts

#

again i'd recommend you read into java io

hardy swan
#

Buffered reader fastest reader

ivory sleet
#

True

#

Java nio > java io (:

digital rain
#

ok so i have a weird problem, this script makes all items generated items unenchanted, but for some reason after chest break it doesn say that the chest was broken as it should

#

any ideas why?

#

otherwise it works well

quaint mantle
lusty cipher
unreal quartz
digital rain
hardy swan
#

==

unreal quartz
#

double equals ==

lusty cipher
#

or what do you mean with say that the chest was broken as it should?

digital rain
hardy swan
#

=.=

unreal quartz
gaunt hatch
#

Does BlockDropItemEvent even fire on a chest break? I think that is player only

digital rain
#

it fires after chest break

#

like when the item drops

gaunt hatch
#

Yea but where does it get player from? It would fail there cause the item is dropped from the chest not a player

digital rain
gaunt hatch
#

that would be BlockBreakEvent not ItemDrop

hardy swan
#

BlockDropItemEvent

digital rain
#

hmm why is it blockitemdrop tho

young knoll
#

BlockDropItem event will fire for the chest item itself

#

Youโ€™ll want to use getBlockState though

sour rampart
#

How can I make a "/hub" command that teleport the player to a custom multiverse dimension?

unreal quartz
#

your local repo is like a normal repository which you specify yourself, but on your computer

digital rain
quaint mantle
#

Okay, tyyy!!

ANd are there any librarys which you would recommend?

hardy swan
#

Libraries are based on necessity

unreal quartz
#

spigot-api? lol i don't know what you want to do

lusty cipher
#

a quick java question:

class X {
  void print(String m) {
    Bukkit.getLogger().info(this.getClass().getSimpleName() + " " + m);
  }
}

class Y extends X {}

Does whenever calling y.print("gisdng") , does it print X: gisdng or Y: gisdng?

unreal quartz
#

X since it's not implemented in Y

quaint mantle
#

Yaaa i would need a library for Particles >:x

lusty cipher
stone light
#

Hello its me again the random kid who has no idea what they're doing, anyway I'm getting this error when running my plugin af anyone can help it would be greatly appreciated!

Fatal error trying to convert TerrorGames v0.9:me/TerrorGames/SurvivalGames/Main.class
java.lang.IllegalArgumentException: null

Caused by: java.lang.ClassFormatError: Incompatible magic value 3280651198 in class file me/TerrorGames/SurvivalGames/Main

digital rain
sour rampart
#

How can I make a "/hub" command that teleports the player who called it to a custom multiverse dimension?

wet breach
eternal oxide
lusty cipher
wet breach
#

nice, you have 3 devs responding to you now ๐Ÿ˜›

stone light
gaunt hatch
lusty cipher
torn shuttle
wet breach
eternal oxide
lusty cipher
#

Wth is this error?

hardy swan
wet breach
eternal oxide
#

You shoudl have seen his error yesterday on Java version

wet breach
#

ah so there is some backstory I am missing then

digital rain
#

also just a guick do you guys know how to quickly disable this and make it start instantly

chrome beacon
#

Update ๐Ÿ˜‰

tender horizon
#

how can i op one specific player in an spigot plugin

wet breach
hardy swan
#

Brrrr

stone sinew
digital rain
#

oh lol tysm

opal juniper
eternal oxide
opal juniper
#

๐Ÿ™ƒ

lusty cipher
#

@digital rain add -DIReallyKnowWhatIAmDoingISwear between your java -jar spigot-1.16.5.jar

opal juniper
#

between

wet breach
eternal oxide
lunar wedge
#

Does anyone know of some good YML file tutorials? My plugin requires me to have a really good understanding of them

opal juniper
#

If i have an itemstack name that has a colour to it how do i easily read it

#

cause it has the colour code on it

tender horizon
#

how can i op one specific player in an spigot plugin

ivory sleet
hardy swan
opal juniper
#

yeye - so how to remove

eternal oxide
opal juniper
#

i guess

hardy swan
#

Slice the first two chars

#

Lmao

opal juniper
hardy swan
#

Dun quote me

opal juniper
#

but not that reliable

#

but if it is just a string there isn't much you can do i guess

hardy swan
#

.substring

#

From index 2

opal juniper
#

is it inclusive?

hardy swan
#

Start inclusive, end no iirc

opal juniper
#

i bet that just does what solar was saying

eternal oxide
#

it removes all color codes

gaunt hatch
#

omg i take a phone call for work and there are like 20 new messages lol

opal juniper
#

you have not seen "peak hours"

gaunt hatch
#

not yet lol

lusty cipher
opal juniper
#

i wouldn't mind a per-player one like they have in the python discord

#

but it is more finnicky

lusty cipher
#

yeah a lot of big programming discords have them, I personally don't like them too much

gaunt hatch
#

If that where to happen the ones helping have to be vetted

lusty cipher
#

it's really weird sometimes, it relies on a bot that might fail or not be online, and there'd be like 4-8 channels for helpers to look through all

gaunt hatch
#

Cause you can get that one person who knows nothing lol

lusty cipher
#

so 2 main ones would be better

opal juniper
#

yeah fair

opal juniper
lusty cipher
#

yeah but python is one of the biggest languages that exist

opal juniper
#

yeah but the bot runs so well its so nice tho

lusty cipher
#

TypeScript has 13 channels open rn

opal juniper
#

like i think it is open src so a quick ctrl c ctrl v and we got a bot here

#

lmao

lusty cipher
#

The Java discord just has 6 channels open for anyone

opal juniper
#

that makes sense ^^

lusty cipher
#

And stuff like Flutter or the Fabric discord have topic specific ones

#

so like #help-nms for example

stone sinew
#

So I'm changing my old class to use reflection but can't get my setBlock method to work... The commented portion is the base I'm trying to turn into reflection...

public void setBlock(Location loc, Material type, int data, boolean physics) {
    try {
        Class<?> craftworldClass = getCraftWorld(loc).getClass();
        Method setTypeAndData = craftworldClass.getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
        setTypeAndData.invoke(craftworldClass, getBlockPosition(loc), generateBlockData(type), physics ? 3 : 2);
        
        //nmsWorld = org.bukkit.craftbukkit.v1_8_R3.CraftWorld.getHandle();
        //net.minecraft.server.v1_8_R3.World.setTypeAndData(new net.minecraft.server.v1_8_R3.BlockPosition, net.minecraft.server.v1_8_R3.Blocks.AIR.getBlockData(), physics ? 3 : 2);
        
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        e.printStackTrace();
    }
}
````getBlockPosition()` and `generateBlockData()` both have the correct output. Not understanding why its giving an error...
`java.lang.IllegalArgumentException: object is not an instance of declaring class`
opal juniper
#

but would be nice to weed out

lusty cipher
hardy swan
#

cuz his craftWorldClass is of unknown class?

stone sinew
gaunt hatch
#

It's so ify

#

use a swtich or else if man

hardy swan
hardy swan
stone sinew
gaunt hatch
#

yes but you do not need if statment for every check else if or switch that.

gaunt hatch
#

so its not

If ...

if ....

stone sinew
hardy swan
#

idk these classes haha, but you may want to uncomment your previous code to check if the classes you put in getMethod() are indeed the actual method signature

gaunt hatch
#

Reflection also might run into a issue where the object declare is not always the same with obfuscation and patch changes. So one method to it all may not work.

hardy swan
#

but even if so, it should be no such method exception o>o

gaunt hatch
#

its almost better to stay on the NMS layer

hardy swan
gaunt hatch
#

but you cant do that when its different version with different names cause then you are going to have multi methods that do the same thing the NMS layer did and making it more work then what is needed.

hardy swan
#

still, better than the really large chunk

gaunt hatch
#

You could make a interface that allows it to control it a little better with the version and you just update that version class file that is hook with the interface.

hardy swan
#

I just dun think sticking onto NMS imports solves the problems of using reflection

#

if there are patch changes, same thing applies to actual imports

gaunt hatch
#

never said it solved i said it would be cleaner then using reflection.

hardy swan
#

you gotta change it

gaunt hatch
#

reflection gets dirty fast!

stone sinew
#

Ok so I modified it a little

public void setBlock(Location loc, Material type, int data, boolean physics) {
    try {
        Class<?> craftworldClass = getCraftWorld(loc).getClass();
        Object blockData = generateBlockData(type);
        Object blockPos = getBlockPosition(loc);
        Method setTypeAndData = craftworldClass.getMethod("setTypeAndData", blockPos.getClass(), NMSBlockData, int.class);
        setTypeAndData.invoke(craftworldClass, blockPos, blockData, physics ? 3 : 2);
    
        //nmsWorld = org.bukkit.craftbukkit.v1_8_R3.CraftWorld.getHandle();
        //net.minecraft.server.v1_8_R3.World.setTypeAndData(new net.minecraft.server.v1_8_R3.BlockPosition, net.minecraft.server.v1_8_R3.Blocks.AIR.getBlockData(), physics ? 3 : 2);
    
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        e.printStackTrace();
    }
}

It looks like Method setTypeAndData = craftworldClass.getMethod("setTypeAndData", blockPos.getClass(), NMSBlockData, int.class); is correct but the invoke isn't...

gaunt hatch
#

and tbh with newer version of Java reflection is getting harder

ivory sleet
#

Is it?

gaunt hatch
#

all spigot has to do it make that a final field and your reflection will never work

hardy swan
#

NMSBlockData is a Class object right

stone sinew
#

yes

ivory sleet
#

I believe you can still change final fields

#

Just set them accessible

gaunt hatch
#

you can not access the modify object anymore in java 16+

#

thus can not edit the final field and does not work anymore

ivory sleet
#

Hmm aight I gotta try that

hardy swan
#

if so

ivory sleet
#

Afaik only true constants cannot be changed

hardy swan
#

then you should invoke on null

gaunt hatch
#

it throws modifiers not found

#

i can show the error

fiery inlet
#
[16:49:58 INFO]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
Disconnected from the target VM, address: '127.0.0.1:55471', transport: 'socket'

dahell? i accepted eula dafuq it means lol

stone sinew
hardy swan
#

yep

stone sinew
#

k one sec

ivory sleet
gaunt hatch
#
[14:51:33] [Server thread/WARN]: java.lang.NoSuchFieldException: modifiers
[14:51:33] [Server thread/WARN]:     at java.base/java.lang.Class.getDeclaredField(Class.java:2549)
[14:51:33] [Server thread/WARN]:     at net.beyondblocks.core.utilities.ReflectionUtilities.setPrivateFinal(ReflectionUtilities.java:63)
#

Cant be unsafe if it cant field the field at all.

ivory sleet
#

No I mean Unsafe

echo saddle
#
java.lang.NoClassDefFoundError: com/mojang/brigadier/arguments/FloatArgumentType
    at net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry$4.read(Commands.java:363)
    at net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry$4.read(Commands.java:355)
    at net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry.read(Commands.java:561)
    at net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry.access$000(Commands.java:307)
    at net.md_5.bungee.protocol.packet.Commands.read(Commands.java:84)
    at net.md_5.bungee.protocol.DefinedPacket.read(DefinedPacket.java:242)
    at net.md_5.bungee.protocol.MinecraftDecoder.decode(MinecraftDecoder.java:40)
    at net.md_5.bungee.protocol.MinecraftDecoder.decode(MinecraftDecoder.java:10)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:795)
    at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:480)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:378)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at java.lang.Thread.run(Thread.java:748)
07:50:24 [INFO] [klugemonkey] disconnected with: NoClassDefFoundError : com/mojang/brigadier/arguments/FloatArgumentType @ net.md_5.bungee.protocol.packet.Commands$ArgumentRegistry$4:363```
ivory sleet
#

sun misc Unsafe

gaunt hatch
#

hmm have not tired that

stone sinew
hardy swan
#

erm, the npe should not be caused by the first argument

stone sinew
#

Ill test one sec

ivory bay
#

does java SE 1.8 still works on spigot/paper 1.17?

gaunt hatch
#

Never used sun misc Unsafe before

hardy swan
#

on the topic of testing, how do you guys write unit test cases for plugins

gaunt hatch
#

I don't for Minecraft code. For work I use RanorexStudio

#

Make a test case and send to the QA team to clean up and put in there end to end testing

wanton fjord
ivory bay
#

yeah thats true sorry xD

stone sinew
unreal quartz
#

is setTypeAndData static?

hardy swan
#

yea

#

it is

wet breach
unreal quartz
#

where is the method coming from

stone sinew
# unreal quartz is `setTypeAndData` static?

((net.minecraft.server.v1_8_R3.World) nmsWorld).setTypeAndData(new net.minecraft.server.v1_8_R3.BlockPosition(l.getBlockX(), l.getBlockY(), l.getBlockZ()), net.minecraft.server.v1_8_R3.Blocks.AIR.getBlockData(), physics ? 3 : 2);

unreal quartz
#

well that doesn't mean it's static

#

if nmsWorld is an instance of it

stone sinew
#

Well I've tried both using a declaring class and not so ๐Ÿคท

maiden briar
#

https://paste.md-5.net/ayebenewic.java

channel.pipeline().addFirst(KEY_SERVER, new ChannelHandler(channel)); //Works
channel.pipeline().addBefore(KEY_SERVER, KEY_PLAYER, new ChannelHandler(channel)); //Exception

I am only receiving netty packets, no nms packets

fiery inlet
#
name: BarrySk
version: ${project.version}
main: com.barrysk.barrysk.barrysk.BarrySk
api-version: 1.16
authors: [ barry ]
description: First Skript addon by barry

it says invalid plugin.yml, why so

gaunt hatch
#

Yea going to make a note to look into unsafe

unreal quartz
dire marsh
hardy swan
#

ok my bad, idk why the craftworldClass in the invoke method lol

fiery inlet
#

ohh think i found the issue

ivory sleet
wet breach
fiery inlet
#

nah nvm

wet breach
fiery inlet
#

oh wtf it says it doesnt contain the plugin.yml

stone sinew
fiery inlet
#

literally has the plugin.yml in it wtf

unreal quartz
#

I'm assuming getCraftWorld(loc) returns the actual nms world object?

#

if so then it should work

stone sinew
#

java.lang.IllegalArgumentException: argument type mismatch

wet breach
unreal quartz
#

what is getCraftWorld

wet breach
#

and any other resource you want at the root of the jar

fiery inlet
#

it is in main

ebon siren
stone sinew
# unreal quartz what is `getCraftWorld`
public Object getCraftWorld(Location loc) {
    try {
        return getHandle.invoke(NMSCraftWorld.cast(loc.getWorld()), new Object[]{});
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        e.printStackTrace();
        return null;
    }
}
hardy swan
#

in your pom.xml

wet breach
dire marsh
#

gradle gang

fiery inlet
#

well im using that minecraft plugin on intellij

wet breach
#

that is fine, what does the pom look like?

fiery inlet
dusk flicker
#

dear lord use a paste

#

dont fill the channel

fiery inlet
#

my bad

ivory bay
dire marsh
#

yes

ivory bay
#

ok ty

wet breach
#
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

@fiery inlet remove this from the pom and it should fix your problem

hardy swan
echo saddle
#

is there a way to post a release without it being the latest for download, say like a beta?

plucky comet
#

Will this work with String.format()?```java
ResultSet result = statement.executeQuery(String.format("SELECT * FROM simpleEco WHERE uuid=%s", uuid.toString()));

wet breach
#

nope, just have to append the tag beta on it so people know and if you are using the spigot web API, a way to filter it out if you have an update checker thing @echo saddle

lunar wedge
#

I need something like a hashmap with a third dimention? What are those called?
Like
String, String: Value

wet breach
#

you need a 3 dimensional array?

hardy swan
#

HashMap<HashMap<>, sth>

fiery inlet
#

now it loads hurrah

wet breach
#

oh, hashmap in a hashmap

fiery inlet
#

but it still aint log sheit

#
@Override
    public void onEnable() {
        getServer().getConsoleSender().sendMessage(ChatColor.AQUA + "Debug,sk.");
        this.getCommand("test").setExecutor(this);

    }
#

or show up in /pl dafuq

wet breach
fiery inlet
#

i made all this in 1.8 which supposedly is harder

#

now i cant do this

#

why is it always so hard to start a project lol

hardy swan
#

have a boilerplate

fiery inlet
#

anyone know why it doesnt load?

hardy swan
#

any console messages?

fiery inlet
#

nothing

#

no errors, no logging

hardy swan
#

chances are it didn't even detect a plugin.yml

fiery inlet
#

well then it would say that wouldnt it

hardy swan
#

well, i can put any kind of jar in plugin folder

fiery inlet
#

does my pom have to be in resources

hardy swan
#

no messages will show up

chrome beacon
fiery inlet
#

ok gucci

#

plugin.yml is only thing in resources

#
name: BarrySk
version: ${project.version}
main: com.barrysk.barrysk.BarrySk
api-version: 1.16
authors: [ barry ]
description: First Skript addon by barry
#

simple

dusk flicker
#

does your main class extend JavaPlugin

fiery inlet
#

yup

hardy swan
#

but could still be excluded in your jar file

#

check the compiled jar

dusk flicker
#

^

wet breach
dusk flicker
#

can you send your full main class in a paste aswell

stone sinew
#

Ok so current code:

public void setBlock(Location loc, Material type, int data, boolean physics) {
    try {
        Class<?> craftworldClass = getCraftWorld(loc).getClass();
        Object blockData = generateBlockData(type);
        Object blockPos = getBlockPosition(loc);
        Method setTypeAndData = craftworldClass.getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
        pl.getLogger().warning("DEBUG >> blockPos: "+blockPos.toString()+" BlockData: "+blockData);
        setTypeAndData.invoke(getCraftWorld(loc), blockPos, blockData, physics ? 3 : 2);
        
        //nmsWorld = org.bukkit.craftbukkit.v1_8_R3.CraftWorld.getHandle();
        //net.minecraft.server.v1_8_R3.World.setTypeAndData(new net.minecraft.server.v1_8_R3.BlockPosition, net.minecraft.server.v1_8_R3.Blocks.AIR.getBlockData(), physics ? 3 : 2);
        
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        e.printStackTrace();
    }
}

And current error:```
DEBUG >> blockPos: BlockPosition{x=-23, y=103, z=320} BlockData: Block{minecraft:air}
java.lang.IllegalArgumentException: argument type mismatch

fiery inlet
#

now it doesnt contain plugin.yml again wtf

#

yet it does

ivory bay
#

uhh, i use the last version of eclipse but there is no java 16, the last one is java 15

hardy swan
wet breach
# fiery inlet yet it does

did you actually copy the new jar to the plugins directory and did you make sure to restart the server afterwards and not just use reload?

hardy swan
#

reload for testing

#

restart when testing fails

dusk flicker
#

dont reload

#

just dont do it

hardy swan
#

LOL

stone sinew
unreal quartz
fiery inlet
#

well its just

#

it doesnt detect plugin.yml

unreal quartz
#

i believe WorldServer is a subclass of World

wet breach
dusk flicker
#

true

stone sinew
fiery inlet
#

yeah well i dont know why it doesnt contain plugin.yml

wet breach
fiery inlet
#

new project

#

?

wet breach
#

that is, remove the build directory, not your project and then build it

fiery inlet
#

what delete src

wet breach
#

when you build

#

it is a separate directory then that of your src directory o.O

fiery inlet
#

out folder

stone sinew
# unreal quartz i believe `WorldServer` is a subclass of `World`
Method setTypeAndData = craftworldClass.getSuperclass().getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
pl.getLogger().warning("DEBUG >> blockPos: "+blockPos.toString()+" BlockData: "+blockData+" craftworldClass: "+craftworldClass.getName());
setTypeAndData.invoke(getCraftWorld(loc), blockPos, blockData, physics ? 3 : 2);
``` this didn't work either...
lunar wedge
#

How could I run a command the moment a player connects?

wet breach
#

@stone sinew int.class wouldn't you want this to be Integer instead?

stone sinew
wet breach
#

nothing to it really

stone sinew
wet breach
#

interesting

#

this is why I don't like messing with reflection ๐Ÿ˜›

unreal quartz
stone sinew
unreal quartz
#

whatever you're passing in might not be an instance of whatever NMSBlockData represents, or the other one

stone sinew
ivory sleet
wet breach
still niche
#

Where do I buy a factions plugin?

chrome beacon
#

Well it depends how much do you want to get scammed

unreal quartz
stone sinew
#

casts it to blockdata

unreal quartz
#

because it looks like the getType method already returns IBlockData, which is what you want

chrome beacon
stone sinew
plucky comet
#

'setString(int, java.lang.String)' in 'java.sql.PreparedStatement' cannot be applied to '(java.lang.String)' java statement.setString(uuid.toString());How do i fix this

still niche
chrome beacon
plucky comet
#
reparedStatement statement = connection.prepareStatement("SELECT * FROM simpleEco WHERE uuid=?");

            statement.setString(uuid.toString());```
unreal quartz
ivory sleet
#

setString(1,uud.toString) iirc

stone sinew
plucky comet
#

thx alot

wet breach
stone sinew
fiery inlet
#

finally it works

#

idk wtf was wrong

wet breach
unreal quartz
#

did you rename generateBlockData to getBlockData?

stone sinew
unreal quartz
#

i'm assuming generateBlockData works as intended then? since that's the one you actually use for this and not getBlockData

plucky comet
#

when i do uuid.toString() does it return it with the dashes or without the dashes

ivory sleet
#

with

#

ezbedwars

plucky comet
#

thx

unreal quartz
#

i have no idea then

gaunt hatch
#

ugh i hate this new tab menu since 1.9 ....

stone sinew
#

DEBUG >> blockPos: BlockPosition{x=-23, y=103, z=320} BlockData: **Block{minecraft:air}** craftworldClass: net.minecraft.server.v1_8_R3.World

#

Interesting.... java.lang.ClassCastException: Cannot cast net.minecraft.server.v1_8_R3.BlockAir to net.minecraft.server.v1_8_R3.IBlockData

Object craftWorld = getCraftWorld(loc);
Class<?> craftworldClass = craftWorld.getClass();
Object blockData = generateBlockData(type);
Object blockPos = getBlockPosition(loc);
Method setTypeAndData = craftworldClass.getSuperclass().getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
pl.getLogger().warning("DEBUG >> blockPos: "+blockPos.toString()+" BlockData: "+blockData+" craftworldClass: "+craftworldClass.getSuperclass().getName());
setTypeAndData.invoke(craftWorld, blockPos, NMSBlockData.cast(blockData), physics ? 3 : 2);
unreal quartz
#

sounds like blockData is wrong then

wet breach
#

well makes sense I suppose

#

BlockAir doesn't contain any data at least not that I recall anyways lol

stone sinew
wet breach
#

But isn't it blockstate that gets casted to blockdata and not the block type?

vital swift
#

bump still not fixed, waiting

stone sinew
#

How can I generate blockdata just based on material then?

wet breach
#

generating block data isn't the same as casting

stone sinew
wet breach
#

you would grab the blockstate if I am not mistaken

stone sinew
wet breach
#

or there you go

stone sinew
#

org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers.getBlock(Material.AIR).getBlockData()

#

FML

fiery inlet
#

i did something and idk what earlier lol

wet breach
fiery inlet
#

yup

#

which i didnt know how to fix

wet breach
#

there is a menu option for intelliJ to clear caches

#

usually start with the easiest and that is the build directory

#

and then if that don't work move onto the IDE options

fiery inlet
#

ok ty

#

btw

wet breach
#

since both IntelliJ and Maven use caching

fiery inlet
#

whats the best way of making/registering commands

#

i'd rather start making them right instead of having to change method later

wet breach
#

that is how I make most of my commands

#

they are usually just sub-commands of the main one

#

unless I have a command that doesn't fit being a subcommand

#

this way, I only need to register 1 command usually and can just easily add however many sub-commands I want ๐Ÿ˜‰

stone sinew
#

FINALLY!!!!!!

wet breach
#

hopefully I was of some help @stone sinew and as well as others lol

plucky comet
#

do i need res.next() or can i just do res.getfloat ```java
PreparedStatement statement = connection.prepareStatement("SELECT * FROM simpleEco WHERE uuid=?");
statement.setString(1, uuid.toString());
ResultSet result = statement.executeQuery();

        while (result.next()){
             double amount = result.getFloat("balance");```
wet breach
plucky comet
#

Im sorry I dont follow

wet breach
#

the moment next() is invoked, it will skip the first result if there is more then 1 result

fiery inlet
#

by subcommands, you mean /maincommand [subs]
like arguments?

plucky comet
#

ok

stone sinew
# wet breach hopefully I was of some help <@!152941891430776833> and as well as others lol

Yeah thanks to you, @unreal quartz and @hardy swan lol

public Object generateBlockData(Material type) {
    Object data = null;
    try {
        Method getBlock = NMSCraftMagicNumbers.getMethod("getBlock", Material.class);
        Object nmsBlock = getBlock.invoke(NMSCraftMagicNumbers, type);
        Method getBlockData = nmsBlock.getClass().getMethod("getBlockData");
        data = getBlockData.invoke(nmsBlock);
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        e.printStackTrace();
    }
    return data;
}

public void setBlock(Location loc, Material type, int data, boolean physics) {
    try {
        Object craftWorld = getCraftWorld(loc);
        Class<?> craftworldClass = craftWorld.getClass();
        Method setTypeAndData = craftworldClass.getSuperclass().getMethod("setTypeAndData", NMSBlockPosition, NMSBlockData, int.class);
        setTypeAndData.invoke(craftWorld, getBlockPosition(loc), generateBlockData(type), physics ? 3 : 2); 
    } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        e.printStackTrace();
    }
}
wet breach
vague oracle
wet breach
vague oracle
#

As in row one will always be empty

#

Even if other rows exists

plucky comet
stone sinew
#

Now I just gotta work out why the hell the same method I use on my test plugin takes 64ms and lags the server out but on my test plugin only takes .54ms

wet breach
vague oracle
#

It is

unreal quartz
#

youโ€™ll want to cache your resolved methods

hardy swan
#

Calling next() on 0 will lead you to the first entry

echo saddle
#

A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row;

plucky comet
#

so if im trying to get index 1 i need next

hardy swan
#

Actually idk what yall talking about lol, i just guess it is reader stuff

vague oracle
#

What you said is what I mean

stone sinew
wet breach
fiery inlet
#

so frost

@Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
        if (label.equalsIgnoreCase("Hello")) {
            if (sender instanceof Player){
                Player player = (Player) sender;
                player.sendTitle(ChatColor.translateAlternateColorCodes('&', "&7[ &e&lCOINS &7]"
                ), ChatColor.translateAlternateColorCodes('&', "&fHello"), 20, 100, 60);

            } else {
                sender.sendMessage(ChatColor.RED + "Only executable by a player!");
            }
        }

        return true;
    }

this is a bad way of doing it or?

wet breach
hardy swan
#

I sometimes wonder why people dun just use ยง directly

dusk flicker
#

I wouldent use nested if statements and you really shouldent check the label

dusk flicker
wet breach
fiery inlet
#

so how would i do it with cmd

dusk flicker
#

and because of that wont color the message

fiery inlet
#

if (cmd.equals("Hello")) {
?

hardy swan
#

it will actually color the message

dusk flicker
#

You shoulden't be needing to check them

fiery inlet
#

huh

hardy swan
#

that's what translateAlternateColorCodes is doing

fiery inlet
#

oh yeah i know

wet breach
#

@fiery inlet the link I gave you earlier contains quite a few command classes

fiery inlet
#

well that stuff just got confusing cuz it gave all kinds of errors

wet breach
#

it has a main command class, and then sub command classes

fiery inlet
#

then it wanted me to make a class

#

and idk ๐Ÿคฏ

wet breach
#

lol

#

well with cmd, you would do cmd.getName().equals("Hello")

vague oracle
#

Just create a static Chat.colour(String) in a utility class and make it use chatcolor.translate...

wet breach
#

so sometimes it works, and other times it will just print that character out instead

#

that is why there is methods to apply color or remove color

fiery inlet
#

this.getCommand("Hello").getExecutor(this);

is it not this that gets the command in

#

aswell as plugin.yml ?

hardy swan
fiery inlet
#

oh setExecutor

#

lol

wet breach
hardy swan
#

but the encoding part makes sense

wet breach
#

Java has issues sometimes when you use unicode characters in a string and expect it to be processed normally

hardy swan
#

then do the same issues apply to other languages with special characters?

wet breach
fiery inlet
#

Now it says unknown command, and doesnt log the thing anymore after making a command, wtf

main class
https://pastebin.com/Fp2en4WG

plugin.yml
https://pastebin.com/vpqfsAcW

fiery inlet
#

what is up with this stuff not working

#

getting stressfull, im losing hair

somber patio
#

I've heard there's treatments for that.

#

WDYM? Like if lerpx is -5 you want x to be 10?

minor garnet
#

-10

somber patio
#

Send the log again I think that would be useful

#

what's the output x in each case?

#

What are you trying to do? because AFAIK that code will always give you the exact same output no matter how many times you execute "run()"

stone sinew
#

Welp.... reflection is slower then I thought.

minor garnet
#

like: x + x + lerpx 'll getting the value of the x and sum with lerpx

somber patio
#

I'm still not sure what's going wrong here.

#

Or what you're trying to use this for. Could you explain more about what this is being used for? Or if someone else knows then feel free to jump in.

wet breach
#

looks like maybe for random teleporting

minor garnet
wet breach
#

@minor garnet first, stop using Math.random() everywhere and make an instance of it instead so you can re-use the object. Second, the way you have setup your algorithm you are not going to have much randomness

plucky comet
#

With the vault api what is the difference between createBank and createPlayerAccount

wet breach
minor garnet
wet breach
#

however, multiplying two negatives results in a positive because that is how math is done @minor garnet if you were wanting to keep the sign, then check for the sign then apply it afterwards

minor garnet
#

that's why I put it as
positive the value

wet breach
plucky comet
#

Yes

wet breach
#

then why are you worried about vault?

somber patio
#

How many times does this entire code run?

minor garnet
plucky comet
#

Its required. The client wants vault hook in

somber patio
#

OK say you added a print statement after

        final int miny = 1, maxy = 5,
                  minx = 1, maxx = 5;
#

How many times would that print statement run?

minor garnet
#

until lerp reaches the value of random

#

after that I would make the crosshairs go down

#

so reverse mode that I would subtract the value of y and x until I get to 0

wet breach
plucky comet
#

It does

wet breach
#

in that case, @plucky comet it does whatever you want it to

somber patio
#

@minor garnet Could you show more of the code? I'm struggling to understand how it's supposed to work.
I'm not sure why you have a BukkitRunnable in there.

minor garnet
#

in this case it goes up and down only

old cloud
#

Maybe I'm blind but where can I find the API changes for bungeecord (1.17)?

old cloud
#

Thanks ๐Ÿ‘

gaunt hatch
#

hahah i got NPC's to sit ๐Ÿ™‚

somber patio
#

@sand void So just to make sure I understand, what's supposed to happen is that you call cameraRecoil, the player's camera moves up a random amount over some number of ticks, then moves down to the start over the same number of ticks?

gaunt hatch
somber patio
#

Sorry!

sand void
#

no worries

somber patio
#

@minor garnet So just to make sure I understand, what's supposed to happen is that you call cameraRecoil, the player's camera moves up a random amount over some number of ticks, then moves down to the start over the same number of ticks?

#

But from looking at the code it looks like at the moment it only moves up and doesn't move back down?

minor garnet
#

it moves up and down

#
if (y >= ry) reverse = true;```
somber patio
#

yes I missed the two calls to camera()

#

My bad

minor garnet
#

its hard to explain because english is not my main language but

somber patio
#

So what's the issue then? Is it not doing what you want already?

minor garnet
#

when the number there on the ly is positive it goes down

#

I just want to solve the sum problem

#

I generate a negative or positive float if I add two negative numbers, it will be positive

#

actually i think i already know what i should do

somber patio
#

Oh I also missed the "old code" below the code snippet you sent most recently... Looks like I'm just a bit blind

novel lodge
#

How can I use a custom player head ?

quaint mantle
gaunt hatch
#

Does anyone know how to force the name of entity to not show and stay hidden?

#

<>.setCustomNameVisible(false); does not work

quaint mantle
#

NMS?

gaunt hatch
#

hmmmm

quaint mantle
#

I use constantly NBT-API

#

useful api

#

very useful

gaunt hatch
#

i hate 3rd party stuff

#

They take to long to update.

quaint mantle
#

it isn't

gaunt hatch
#

Or drop support w/e they want, or update with to many issues.

fiery inlet
#

Anyone here know the scary ambient sounds underwaters name?

wet breach
fiery inlet
#

its the same if i do Sound.

#

theres just 1 billion sounds xd

#

and idk which one is the right one

#

and there is nowhere that i can just listen to them

#

without testing all xd

wet breach
#

well, I mean you don't have that many for underwater ambient ones

fiery inlet
#

i went with lightning xd easy

#

one thing though

#
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (sender instanceof Player) {
            Player p = (Player) sender;
            ItemStack sword = new ItemStack(Material.NETHERITE_SWORD);

            ItemMeta meta = sword.getItemMeta();
            meta.setDisplayName("ยง7[ ยงeยงlGOD-SWORD ยง7]");
            meta.addEnchant(Enchantment.DAMAGE_ALL,50, false);
            meta.addEnchant(Enchantment.FIRE_ASPECT, 25, false);
            meta.addEnchant(Enchantment.FIRE_ASPECT, 10, false);
            sword.setItemMeta(meta);
            p.getInventory().addItem(sword);
            p.sendMessage("ยง7[ยงcยงlGOD-SWORDยง7]");
            p.playSound(p.getLocation(), Sound.ENTITY_LIGHTNING_BOLT_THUNDER,1, 1);
        }
        return true;
    }

no enchants are added dafuq

dusk flicker
#

did you register it

#

and are you actually getting the item

#

?jd

fiery inlet
#

yeah just no enchants

#

but with the name

#

the displayname is there, no enchants

dusk flicker
#

change the false's to true

#

in the addEnchant

fiery inlet
#

well its enchanted

#

just not exactly how it was meant to xd

old cloud
#

When was the chat API change made (net.md_5.bungee.api.chat.hover.content etc.)?

#

Because HoverEvent deprecated constructor .. :|

fiery inlet
#

how to strike lightning at location

vital ridge
#

Anybody knows where i could learn stuff like rotation matrix etc?

#

More math in general

fiery inlet
#

nvm found out

lusty cipher
somber patio
wind dune
#

I have a weird problem. When I send a BaseComponent the player sometimes receives the message but sometimes he do not receive the message. Why?

paper olive
#

Where is the flag that determines whether the dragon is going to drop an egg actually stored? Is it part of the dragon itself and thus the map?

slim kernel
#

Why am I getting teleported to a specific point all the time when I put that in the PlayerMoveEvent:

vector = event.getTo().subtract(event.getFrom()).toVector();
quiet ice
#

try to clone it beforehand

#

It appears that .getTo does not return a clone but the actual instance, and since #substrace mutates the object the player is teleported

eternal oxide
#

Yes, getTo is the actual location you will be going to.

#

not cloned

visual tide
#

anyone know a solution to maven complaining about this
using shade 3.3.0 snapshot

[WARNING]   - META-INF/LICENSE
[WARNING]   - META-INF/NOTICE
[WARNING] ItemBlacklist-0.3.2.jar, bstats-base-2.2.1.jar, bstats-bukkit-2.2.1.jar, commons-lang3-3.4.jar, maven-model-3.3.9.jar, plexus-utils-3.0.22.jar, semver4j-3.1.0.jar define 1 overlapping resource: 
[WARNING]   - META-INF/MANIFEST.MF
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/```
slim kernel
#

oh okay thank you

eternal oxide
#

I was well late there

quiet ice
eager sapphire
#

Does anyone know if I have to use Java 1.16 to compile my plugin if I'm building against remapped Spigot?
I seem to get some weird errors if not (cannot access classes, auxiliary classes, etc) but I would prefer not to lose compatibility with older Java versions.

quiet ice
#

Are you compiling against spigot-api or spigot?

eager sapphire
#

Everything looks ok until I try to build, but then I get errors trying to access any of the remapped NMS classes

quiet ice
#

And I assume that you assume that I know these errors

eager sapphire
#

(I did see Aniby was having the same error, but not sure they got a resolution and I don't wanna ping them)

#

It literally just says "Cannot access <class name of NMS class>" with no extra info. Not assuming you know anything ๐Ÿ™‚

quiet ice
#

compile or runtime?

eager sapphire
#

Compile

#
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project CompatibilityLib-v1_17_0: Compilation failure
[ERROR] /Users/nathan/Documents/Code/Bukkit/MagicPlugin/CompatibilityLib/v1_17_0/src/main/java/com/elmakers/mine/bukkit/utility/platform/v1_17_0/CompatibilityUtils.java:[112,25] error: cannot access BlockPos
[ERROR] 
#

Specifically that, but I was hoping someone would just generally know if Java 1.16 is required at compile time.

#

The post was unclear on this subject.

visual tide
# eternal oxide Post 7 <https://www.spigotmc.org/threads/problems-including-bstats-with-maven.37...

still

[WARNING] maven-model-3.3.9.jar, plexus-utils-3.0.22.jar define 2 overlapping resources: 
[WARNING]   - META-INF/LICENSE
[WARNING]   - META-INF/NOTICE
[WARNING] ItemBlacklist-0.3.2.jar, bstats-base-2.2.1.jar, bstats-bukkit-2.2.1.jar, commons-lang3-3.4.jar, maven-model-3.3.9.jar, plexus-utils-3.0.22.jar, semver4j-3.1.0.jar define 1 overlapping resource: 
[WARNING]   - META-INF/MANIFEST.MF
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/```
eternal oxide
#

so not shaded

visual tide
#

where do i set them as provided?

eternal oxide
#

?paste your pom

undone axleBOT
eternal oxide
#

you add a scope on yoru dependencies that you don;t need included

visual tide
quiet ice
visual tide
#

disable it and return maybe

quiet ice
#

beware, this could also lead to fatal errors in the disable block

eternal oxide
# visual tide

Why? xml <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-model</artifactId> <version>3.3.9</version> </dependency>

quiet ice
#

or just throw new RuntimeException()

visual tide
quiet ice
#

throwing exceptions on enable only disables the plugin

quaint mantle
quiet ice
#

Fix the LVT

quiet ice
#

Or change the configuration of the decompiler

#

Not entirely how the second scheme is called, could be jad-style varnames but idk for sure

quaint mantle
#

hmm, okay. thanks

quiet ice
#

no my bad, JVN was varx, so def. not it

fleet dirge
visual tide
eternal oxide
#

yes you have to only set to provided if its on your server

visual tide
slim kernel
#

have you an idea on how I could damage a player when getting thrown or he runs against a wall? I tried it with the MoveListener and get getTo() but that only works when the player is in the Block he "hits" like in grass...

quiet hearth
#

Could not load 'plugins\Scaffold.jar' in folder 'plugins': uses the space-character (0x20) in its name I got this error and Im not sure where the space is located

regal anchor
#

(north/south/east/west)

#

see if it is X or Z coordinate that will increase or decrease

slim kernel
#

but not a specific wall I just want to damage the player when he runs against a block

slim kernel
regal anchor
#

x OR z

slim kernel
#

yeah but then I would damage him really often i think so

regal anchor
#

you would have to check if it is a wall (> 2 blocks) on the same Y

#

otherwise yes it will damage in every ascending terrain

slim kernel
#

okay.. hmm

regal anchor
#

check your plugin.yml

quiet hearth
#

in the name?

regal anchor
#

yes ? maybe

opal juniper
#

Can I call an event that can only be โ€œheardโ€ from within the plugin I called it from?

#

Or - like make the class public to only the jar it is in or something like that

visual tide
proud basin
#

What's the chat event?

quaint mantle
proud basin
#

thank you

quaint mantle
#

You do this on chat event?

#

To open there menus

eternal oxide
#

java.lang.IllegalStateException: InventoryOpenEvent may only be triggered synchronously.

proud basin
quaint mantle
proud basin
#

If I'm correct you can check through that to see if a command has been ran

visual tide
sacred vector
#
Material.LEGACY_BURNING_FURNACE
``` Would this be for a furnace cooking something
#

?

visual tide
#

yes

sacred vector
#

okay because im trying to make furnaces cook faster

#

like setting the cook time, im going to assume

wraith rapids
#

you don't want to use legacy materials

sacred vector
#

its the only burning furnace option

wraith rapids
#

iirc whether a furnace is burning or not is now controlled by the block's state

#

it's no longer a separate material

sacred vector
#

so what should i use if i cant use legacy

wraith rapids
#

the block's state

sacred vector
#
                    Furnace furnace = (Furnace) block.getState();
                    furnace.setCookTime((short) 100);
#

so that getting the state then setting the cook time

wraith rapids
#

or, as bukkit calls it, the BlockData

proud basin
#

hi NNY: )

wraith rapids
#

chin and nose man

proud basin
#

You miss me

wraith rapids
#

did you get your problem solved

proud basin
#

yea

granite stirrup
#

holly shit

#

why does roblox use so much cpu

wraith rapids
#

roblox is gay

granite stirrup
#

yeah i dont play it

proud basin
#

does AsyncPlayerChatEvent not check for commands too?

wraith rapids
#

it's exclusively for chat iirc

chrome beacon
#

^^

proud basin
#

hm ok

granite stirrup
#

;-;

wraith rapids
#

use command preprocess event if you want to catch would-be-commands

proud basin
#

so I have to use PlayerCommandPreprocessEvent

chrome beacon
#

Yes

granite stirrup
#

but roblox uses like so much cpu

#

its using like 30-50%

proud basin
#

Roblox is a browser game right or does it have an app now?

granite stirrup
#

its not a browser game

visual tide
granite stirrup
wraith rapids
#

speaking of browser games

#

i'm itching to write a bot that uses like a headless browser or something to play some browser games

#

is travian still a thing?

proud basin
#

no

#

it's dead

shadow gazelle
#

?paste

undone axleBOT
shadow gazelle
#

What part of my code in the loop is causing this error?

[13:40:09] [Server thread/WARN]: [NathansEnchantments] Task #506 for NathansEnchantments v0.0.1 generated an exception
java.lang.ClassCastException: class java.util.Collections$UnmodifiableRandomAccessList cannot be cast to class org.bukkit.entity.Player (java.util.Collections$UnmodifiableRandomAccessList is in module java.base of loader 'bootstrap'; org.bukkit.entity.Player is in unnamed module of loader 'app')
    at me.nathan.enchants.Main$1.run(Main.java:49) ~[?:?]
    at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftTask.run(CraftTask.java:100) ~[patched_1.16.5.jar:git-Paper-776]
    at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468) ~[patched_1.16.5.jar:git-Paper-776]
    at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1427) ~[patched_1.16.5.jar:git-Paper-776]
    at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:436) ~[patched_1.16.5.jar:git-Paper-776]
    at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1342) ~[patched_1.16.5.jar:git-Paper-776]
    at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1130) ~[patched_1.16.5.jar:git-Paper-776]
    at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-776]
    at java.lang.Thread.run(Thread.java:834) [?:?]

Code:
https://paste.md-5.net/lupehurezi.java

sacred vector
#
    @EventHandler
    public void onFurnaceSmelt(FurnaceSmeltEvent e) {

            Furnace furnace = (Furnace) e.getBlock().getState();
            furnace.setCookTime((short) 100);

        }
    
``` So this would work
proud basin
#

at me.nathan.enchants.Main$1.run(Main.java:49) ~[?:?]

shadow gazelle
#

I know that something in the loop is causing it

proud basin
#

?paste

undone axleBOT
proud basin
#

Feel free to show us what you have to so we can help ๐Ÿ™‚

quaint mantle
#

ItemStack pickNew = ((Item) e).getItemStack();

chrome beacon
chrome beacon
shadow gazelle
#

It's the only way I was able to get it back into an item stack

wraith rapids
#

don't cast things if you don't know what you're doing

granite stirrup
shadow gazelle
#

I mean, what else am I supposed to do to make it an item stack?

wraith rapids
#

assuming e is an instanceof Item, that's fine

shadow gazelle
#

e is an entity

quaint mantle
#

an entity isnt always an item

wraith rapids
#

an entity could be an Item

#

but it could also not be an Item

#

check

granite stirrup
#

Player player = (Player) Bukkit.getOnlinePlayers(); wtf is this

wraith rapids
#

yeah, don't cast if you don't know what you're casting

#

Bukkit.getOnlinePlayers() returns a Collection<Player>

#

you can not cast Collection to Player

#

a Collection will never be a Player

#

a bucket full of oranges will never be an orange

visual tide
#

even if there is only one orange

shadow gazelle
#

Then how am I supposed to search the player?

visual tide
#

there will still be a bucket

wraith rapids
#

you iterate over the collection

#

you have multiple players

#

you need to do something for each player

#

for (Player player : Bukkit.getOnlinePlayers()) {

shadow gazelle
#
                for (Player player : Bukkit.getOnlinePlayers()){
                    for (Entity entity : player.getNearbyEntities(3, 3, 3)) {
                        if (entity instanceof Item && pick == Material.NETHERITE_PICKAXE || pick == Material.DIAMOND_PICKAXE || pick == Material.GOLDEN_PICKAXE || pick == Material.IRON_PICKAXE || pick == Material.STONE_PICKAXE || pick == Material.WOODEN_PICKAXE) {
                            Item i = (Item) entity;
                            for (Entity e : i.getNearbyEntities(1, 1, 1)) {
                                if (e instanceof Item && item.getItemMeta().getDisplayName() == ChatColor.LIGHT_PURPLE + "Telepathy Core") {
                                    e.remove();
                                    ItemStack pickNew = item.getItemStack();
                                    pickNew.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
                                    }
                                }
                            }
                        }
                    }
wraith rapids
#

are you trying to do a "enchant by dropping items on top of one another" thing

shadow gazelle
#

Yes, @wraith rapids

wraith rapids
#

listen to item drop events instead

plucky comet
#

Is there a way to simplify this line java if (args[0].equalsIgnoreCase("bal") || args[0].equalsIgnoreCase("balance"))

shadow gazelle
#

I was told that wasn't reliable

wraith rapids
#

checking every item near every player constantly is dumb

#

this isn't any more reliable

shadow gazelle
#

Okay

wraith rapids
#

if you want it to be super reliable, you would have to be a little bit smarter in order to not kill the server

#

something along the lines of iterating over all items in the world and populating a context map keyed by blockkey

gaunt hatch
#

Or do it on item drop

clear galleon
#

@plucky comet is "bal" the command name?

plucky comet
#

no

clear galleon
#

you could do

wraith rapids
#

create a set of aliases and check contains

clear galleon
#

args[0].substring(0,3).equals("bal")

#

or something like that

wraith rapids
#

more ideally, create a String -> Subcommand map

#

and call get

gaunt hatch
#

if you do ^ make sure you check the length cause if you type 2 characters and its looking for 3 (BOOM!)

clear galleon
#

im p sure if second index is out of bounds java doesnt care

wraith rapids
#

it does

gaunt hatch
#

it does

clear galleon
#

huh.

gaunt hatch
#

its not python

shadow gazelle
#

@wraith rapids how would I check for the book, now?

#
    @EventHandler()
    public void onItemDrop(PlayerDropItemEvent event) {
        ItemStack item = event.getItemDrop().getItemStack();
        if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
            return;
        if (!(item.getType() == Material.NETHERITE_PICKAXE || item.getType() == Material.DIAMOND_PICKAXE || item.getType() == Material.GOLDEN_PICKAXE || item.getType() == Material.IRON_PICKAXE || item.getType() == Material.STONE_PICKAXE || item.getType() == Material.WOODEN_PICKAXE) {
            return;
        } else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
            return;
        } else {
            for (Entity entity : )
        }
    }
#

I'm stuck on that

#

Basically, how do I make the pickaxe an entity that can be used to search nearby?

#

nvm

lunar schooner
#

Other note, might be esier to do item.getType().toString().endsWIth("PICKAXE"), rather than the individual pickaxe checks you do now

shadow gazelle
#

Oh

#

Thanks for the tip

wraith rapids
#

ideally you would use the material tag for pickaxes

#

as that is significantly faster

shadow gazelle
#

That still is the material

wraith rapids
#

what

shadow gazelle
#

Just if the material name ends with PICKAXE

wraith rapids
#

yes, that is slow

#

and it isn't guaranteed that every pickaxe ends in PICKAXE

#

use the tag

#

there's like a material tag somewhere for each of the tools and weapons

#

MaterialTags.PICKAXES.isTagged()

quiet ice
#

Why MaterialTags?

#

I am pretty sure what you are searching for is the Tag class

shadow gazelle
#

I can't find that anywhere in docs

quiet ice
#

well, interface but it is the same thing

#

I absolutely love that class btw

shadow gazelle
#

org.bukkit.Tag?

wraith rapids
#

i think MaterialTags is paper actually

quiet ice
#

Yep

shadow gazelle
#

Not there

quiet ice
#

There is also Bukkit.getTag iirc, but it is a bit overkill for our purposes

shadow gazelle
#

There's only mineable with pickaxe

wraith rapids
#

i don't know how to grab the pickaxe tag with spigot

#

assuming it even exists

quiet ice
#

Bukkit#getTag

#

There is cluster_max_harvestables which does the same thing from looking at it

shadow gazelle
#

I see Bukkit.getTag(s)

quiet ice
#

But it is only usefull if you also have datapacks or want user-defined tags

shadow gazelle
#

So basically useless here?

quiet ice
#

For hardcoding, use the Tag class

#

yep

shadow gazelle
quiet ice
#

there is no other tag class

wraith rapids
#

the Tag class doesn't seem to have a tag for pickaxes

shadow gazelle
#

^

quiet ice
#

It has cluster_max_harvestables though

shadow gazelle
#

The closest I see is NEEDS_DIAMOND_TOOL

quiet ice
#

Which according to the minecraft wiki has all the pickaxes listed

wraith rapids
#

what

#

what's a cluster max harvestable

shadow gazelle
#

That looks like 1.17 only

quiet ice
shadow gazelle
wraith rapids
#

and yeah clusters smell like 1.17

quiet ice
#

Ye

wraith rapids
#

that's not a list of pickaxes though

quiet ice
#

Most tags were created with 1.17; hopefully mojang keeps at it with adding tags

shadow gazelle
#

I'm working with 1.16.5

wraith rapids
#

that "cluster max harvestables" and "pickaxes" happen to align isn't guaranteed

quiet ice
#

Just use an EnumSet then and define them manually

wraith rapids
#

or use paper

quiet ice
#

meh. You're not wrong

shadow gazelle
#

This error has confused me way too many times :/

chrome beacon
#

Well yeah

#

You need to tell it which level to add

shadow gazelle
#

I know

#

Just every time I see that my brain like turns off

#

Well shit

#

Big brain time

wraith rapids
#

package.Class.method(X) cannot be applied to package.Class.method(Y) means you need a signature of X but you're giving it Y

#

the fully qualified class names make it cancer to read

#

but basically you just need to compare the parameters

#

Enchantment, int
vs
Enchantment

#

and the resolution becomes obvious

sacred vector
#
    @EventHandler
    void onFurnaceBoosterSmelt(FurnaceSmeltEvent event) {
            Furnace furnace = (Furnace) event.getBlock().getState();
            furnace.setCookTimeTotal((short) 1);
            furnace.setCookTime((short) 1);
            furnace.update();
        }
``` I just get a GUI error...
wraith rapids
#

"gui error"

sacred vector
#

like the furnace just duplicates its smelting gui

shadow gazelle
#

Alright, want to make 100% sure this will work. This should work, right?

    @EventHandler()
    public void onItemDrop(PlayerDropItemEvent event) {
        ItemStack item = event.getItemDrop().getItemStack();
        if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
            return;
        if (!(item.getType() == Material.NETHERITE_PICKAXE || item.getType() == Material.DIAMOND_PICKAXE || item.getType() == Material.GOLDEN_PICKAXE || item.getType() == Material.IRON_PICKAXE || item.getType() == Material.STONE_PICKAXE || item.getType() == Material.WOODEN_PICKAXE)) {
            return;
        } else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
            return;
        } else {
            for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
                ItemStack item2 = event.getItemDrop().getItemStack();
                if (e instanceof Item && item2.getItemMeta().getDisplayName().equals(ChatColor.LIGHT_PURPLE + "Telekinesis Core")) {
                    e.remove();
                    item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
                }
            }
        }
    }
#

It doesn't work

wraith rapids
#

when you drop an item, the item spawns at the player's head

eternal oxide
#

if (!item.getType.name().endsWith("_PICKAXE") return;

wraith rapids
#

you need to wait a second or two, like I told you yesterday, for the item to actually get dropped onto the ground

lusty cipher
#

anyone know how I can force the server to print full stacktraces? I legit am only seeing two lines, and it's not enough to trace my issue back

chrome beacon
#

It always prints full stacktraces

#

Unless you have something removing them

lusty cipher
#

"... 40 more"

chrome beacon
#

Are you using the Oracle JDK

lusty cipher
#

yeah, OpenJDK 16.0.1

#

oh apparently those lines ommited are just the ones that are above this

shadow gazelle
lusty cipher
#

well..... thanks windows terminal

vast sapphire
#

Can i mention Lua code here? idk what to do with this error

quaint mantle
#

Usually only spigot & bungeecord programming help, but go for it

vast sapphire
#

entities/gmod_wire_expression2/core/entity.lua:315: attempt to index local 'this' (a nil value)

#

Expression2 is used for creating lua chips in game

quaint mantle
#

can you send me the code, and not just the error

vast sapphire
#

yea sure

#

give me a min to load

#
@inputs 
@outputs Eang:angle Speed Spd AD
@persist EArr:array [User,E]:entity W A S D Shift Space M1 M2 Speed [RanC,RanF,RanB,RanL,RanR]:ranger WS AD C
@trigger 

runOnTick(1)
Mass = E:mass()

C++
User = E:driver()
W = User:keyPressed("w")
A = User:keyPressed("A")
S = User:keyPressed("S")
D = User:keyPressed("D")
Shift = User:keySprint()
Space = User:keyPressed("Space")

Speed = E:vel():length()

E = entity():isWeldedTo()


if(Space){
Spd = 0

}
elseif(Shift){
Spd = 100000000

}
else{
Spd = 30
}
E:applyForce(E:forward()*(W-S)*E:mass()*Spd)

if (A)
{E:applyAngForce(ang(0,30000,0)) }

if (D)
{E:applyAngForce(ang(0,-30000,0)) }

if(W){
        E:applyForce(E:forward():setZ(-0.30)*(Mass^1))
        if(Speed < 20){
        #entity():applyForce(vec(0,0,Mass))
        #entity():setMass(Mass/8)
        }else{entity():setMass(1)}
}
if(S){
        E:applyForce(E:forward():setZ(-0.30)*(Mass^1))
        if(Speed < 20){
        #entity():applyForce(vec(0,0,Mass))
        #entity():setMass(Mass/8)
        }else{entity():setMass(1)}
}
quaint mantle
#

wiremod?

vagrant stratus
#

gmod addon

wraith rapids
#

...40 more means that the 40 stack frames that were omitted have already been shown in the Caused by: blocks above

lusty cipher
shadow gazelle
#

Does this look okay @wraith rapids?

    @EventHandler()
    public void onItemDrop(PlayerDropItemEvent event) {
        new BukkitRunnable() {

            @Override
            public void run() {
                ItemStack item = event.getItemDrop().getItemStack();
                if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
                    return;
                if (!(item.getType().name().endsWith("_PICKAXE"))) {
                    return;
                } else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
                    return;
                } else {
                    for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
                        if (e instanceof Item && ((Item) e).getItemStack().getItemMeta().getDisplayName().equals("ยงdTelekinesis Core")) {
                            e.remove();
                            item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
                        }
                    }
                }
            }
        }.runTaskLater(this, 20 * 3);
    }
wraith rapids
#

using a bukkitrunnable is redundant

#

use the bukkit scheduler instead

#

other than that it should be fine

shadow gazelle
wraith rapids
#

no, i mean use the bukkit scheduler instead of bukkitrunnable

shadow gazelle
#

ohhh

wraith rapids
#

Bukkit.getScheduler().runTaskLater(plugin, () -> { code here }, time)

instead of

new BukkitRunnable() { @Override public void run() { code here } }.runTaskLater(plugin, time)

#

the bukkit runnable one creates an anonymous local class, which is slower, less readable, and fills your jar with redundant classes

shadow gazelle
#

Oh

wraith rapids
#

the bukkitrunnable one is used when you need to cancel a repeating task from within the task itself

#

in any other case it is useless

shadow gazelle
#

Like this?

    @EventHandler()
    public void onItemDrop(PlayerDropItemEvent event) {
        Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
            @Override
            public void run() {
                ItemStack item = event.getItemDrop().getItemStack();
                if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
                    return;
                if (!(item.getType().name().endsWith("_PICKAXE"))) {
                    return;
                } else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
                    return;
                } else {
                    for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
                        if (e instanceof Item && ((Item) e).getItemStack().getItemMeta().getDisplayName().equals("ยงdTelekinesis Core")) {
                            e.remove();
                            item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
                        }
                    }
                }
            }
        }, 0L, 70L);
    }
wraith rapids
#

almost

#

use a lambda instead of creating an anonymous local class implementing Runnable

#

() -> { code here }
instead of
new Runnable() { @Override public void run() { code here } }

shadow gazelle
#

Oh

wraith rapids
#

the reason you can't do that with a BukkitRunnable is because it's not an 1 method interface, so you can't substitute it with a lambda

shadow gazelle
#

What did I do wrong here?

    @EventHandler()
    public void onItemDrop(PlayerDropItemEvent event) {
        Bukkit.getScheduler().runTaskLater(this, () -> {

            @Override
            public void run() {
                ItemStack item = event.getItemDrop().getItemStack();
                if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
                    return;
                if (!(item.getType().name().endsWith("_PICKAXE"))) {
                    return;
                } else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
                    return;
                } else {
                    for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
                        if (e instanceof Item && ((Item) e).getItemStack().getItemMeta().getDisplayName().equals("ยงdTelekinesis Core")) {
                            e.remove();
                            item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
                        }
                    }
                }
            }
        }, 0L, 70L);
    }
hybrid spoke
#

or more like: what does not work like intended?

wraith rapids
#

let me reiterate

#

() -> { code here }
instead of
new Runnable() { @Override public void run() { code here } }

#

look at your code

shadow gazelle
#

Oh

wraith rapids
#

you're doing
() -> { @Override public void run() { code here } }

shadow gazelle
#

IntelliJ still shows the runTaskLater as couldn't resolve

        Bukkit.getScheduler().runTaskLater(this, () -> {
            ItemStack item = event.getItemDrop().getItemStack();
            if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
                return;
            if (!(item.getType().name().endsWith("_PICKAXE"))) {
                return;
            } else if (item.containsEnchantment(Enchants.TELEKINESIS)) {
                return;
            } else {
                for (Entity e : event.getItemDrop().getNearbyEntities(1, 1, 1)) {
                    if (e instanceof Item && ((Item) e).getItemStack().getItemMeta().getDisplayName().equals("ยงdTelekinesis Core")) {
                        e.remove();
                        item.addUnsafeEnchantment(Enchants.TELEKINESIS, 1);
                    }
                }
            }
        }, 0L, 70L);
wraith rapids
#

runTaskLater only takes one number

#

you are trying to call runTaskTimer

#

which takes 2 numbers

shadow gazelle
#

Alright

young knoll
#

I still don't know how I feel about proper enchantments vs PDC based enchantments

wraith rapids
#

proper enchantments do have some advantages

young knoll
#

I assume they work with books and the enchantment table automatically

wraith rapids
#

and anvils and the grindstone and all that jazz

young knoll
#

Yeah that does seem nice

wraith rapids
#

i see little reason to use the pdc for it beyond just the ease of use from not having to fuck with the registries and shit

shadow gazelle
#

@wraith rapids 70L should be 3.5 seconds, right?

young knoll
#

yes

wraith rapids
#

what's 70 divided by 20

shadow gazelle
#

Okay, making sure it goes by ticks

#

So something with the book check is broken

#

yay

young knoll
#

They way i'm using them right now they aren't really designed to be obtainable through normal means, so I guess PDC works well for this

wraith rapids
#

registering them in the bukkit enchantment registry doesn't actually register them in nms under the hood, I don't think

#

i'm not sure what manner of things that affects, and I haven't seen anyone actually register them in nms, just always in the bukkit registry

young knoll
#

NMS is pain

wraith rapids
#

yeah but you'd think something would require it to be in the nms enchant registry

#

it's strange that nobody does that

young knoll
#

And I'm still salty over the private static final ImmutableLists

wraith rapids
#

yeah well

#

if only we had reflection

young knoll
#

Indeed, I miss the dodgy reflection on the modifiers

#

I wish spigot had AccessTransformers

wraith rapids
#

i might have to fork paper for 1.17 for my server

young knoll
#

Someone bug Aikar to add Mixins :p

wraith rapids
#

with the way reflection is going and how aikar fucked up the timings backend, I don't think it's possible to do per-entity timings handlers anymore at all

shadow gazelle
#

I'm literally a dumbass

#
if (event.getPlayer().getGameMode() == GameMode.CREATIVE || event.getPlayer().getGameMode() == GameMode.SPECTATOR)
                return;
lusty cipher
#

there is no way (without caching the block interactions) to get the block of an inventory, is there?

shadow gazelle
#

I was in creative

wraith rapids
#

and I am very fond of my per-entity timings

#

getting the inventoryholder and casting to blockinventoryholder and getting location might work

#

or something along those lines

woven epoch
#

so I'm trying to make some particles rotate around a certain point, but for some reason, it's rotating around 0,0,0 in the world

lusty cipher
woven epoch
#

that's what it looks like, and the cursor is centered on 0,0,0

wraith rapids
#

you forgot to add the rotated location to the origin location

opal juniper
#

What scope does Bukkit.callEvent() call to. ie can an event that you have made urself by just extending Event be listened to by any other plugin? I thought it could but some1 said it couldnโ€™t

wraith rapids
#

a custom inventory could I guess set its inventoryholder as a blockinventoryholder

shadow gazelle
#

IT WORKS

#

Thank you for helping @wraith rapids

wraith rapids
#

pretty sure callevent works for all things extending event

#

i don't remember there being a specific variant for custom events provided by plugins

opal juniper
#

So it calls it so that anything can listen for it?

eternal oxide
#

yes, anthing that is registered to listen to it

opal juniper
#

Ok

wraith rapids
#

it asks the static HandlerList of that class about which EventHandlers are registered to it

#

and then invokes those handlers

woven epoch
#
//this is where the player is looking
Location loc = res.getHitPosition().toLocation(player.getWorld());
//this puts it up 3 blocks on y axis
Vector locv = loc.add(0,3,0).toVector();

//this displays the particles from the loop of coordinates (that should be added)
loc.getWorld().spawnParticle(Particle.HEART, locv.clone().add(new Vector(x,y,z)).toLocation(loc.getWorld()), 1);
locv.rotateAroundY(21.5);
lusty cipher
opal juniper
#

Is there a way to stop this ( like a private event )

wraith rapids
#

make the constructor private ig

opal juniper
#

Makes sense - ok thanks

eternal oxide
wraith rapids
#

also possible but maybe a bit overkill

opal juniper
#

Oh - thats more complicated than I wanted

#

Iโ€™ll have a look another time

#

Thanks

young knoll
#

I wish java added their new reflection security stuff as a startup flag

#

For anyone that actually wanted to use it