BananaPuncher714 / NBTEditor

A single class NBT editor for items, skulls, mobs, and tile entities
MIT License
136 stars 30 forks source link

Unable to set values as of 1.20 #28

Closed Kunfury-blep closed 1 year ago

Kunfury-blep commented 1 year ago

Currently running v7.18.6 as of the most recent commit on Github.

The NBTEditor was working without issue in 1.19 but once updating to 1.20 of spigot, NBTEditor.set(ItemStack, Value, Keys...) is no longer working. No errors are thrown when set but the NBTEditor.Get(ItemStack, Keys...) always returns null (Or default 0 in the case of getInt).

BananaPuncher714 commented 1 year ago

Thanks for the report, I have not added support for 1.20 yet, but it is in my TODO list.

BananaPuncher714 commented 1 year ago

Can you try the following code to see if it prints out Hello, world! in the console? I have tested this on 7.18.6 and it seems to work fine, so I am not sure why it would not work for getting other types.

        {
            ItemStack item = new ItemStack( Material.DIAMOND_HOE );
            System.out.println( "Setting value..." );
            item = NBTEditor.set( item, "Hello, world!", "io", "github", "bananapuncher714", "nbteditor", "test" );
            System.out.println( "Getting value..." );
            System.out.println( NBTEditor.getString( item, "io", "github", "bananapuncher714", "nbteditor", "test" ) );
            System.out.println( NBTEditor.getNBTCompound( item ) );
        }
Kunfury-blep commented 1 year ago

Just finished testing, looks like the value is getting set, but the get methods are what are having the issue.

image

The tags are showing correctly in the getNBTCompound, but always seem to be null when using getString.

BananaPuncher714 commented 1 year ago

Ok thanks, I'll go over the code more thoroughly when I get the chance. I tested it on the latest build of Spigot 1.20.1 at the time, so I am not sure what exactly is wrong with your test.

Kunfury-blep commented 1 year ago

Ok thanks, I'll go over the code more thoroughly when I get the chance. I tested it on the latest build of Spigot 1.20.1 at the time, so I am not sure what exactly is wrong with your test.

Thank you for all your work! Just to rule out anything weird on my end, I've got every plugin besides the one using NBTEditor disabled and am still experiencing the same.

Currently running the server on paper-1.20.1-43.jar

If there's anything more that you'd like me to test please let me know!

giopalma commented 1 year ago

I tried it in Paper 1.20.1#55 and it works correctly

I tested using spigot 1.19 API

image

To test I put it directly into onEnable function

@Override
    public void onEnable() {
        ItemStack item = new ItemStack( Material.DIAMOND_HOE );
        System.out.println( "Setting value..." );
        item = NBTEditor.set( item, "Hello, world!", "io", "github", "bananapuncher714", "nbteditor", "test" );
        System.out.println( "Getting value..." );
        System.out.println( NBTEditor.getString( item, "io", "github", "bananapuncher714", "nbteditor", "test" ) );
        System.out.println( NBTEditor.getNBTCompound( item ) );
    }

Tried also with Spigot 1.20.1 API and works fine

Kunfury-blep commented 1 year ago

I ended up fully uninstalling my IDE and reimported everything back into it and the issue fixed itself! I have no idea what might have been causing it but everything is working without issue on 1.20+! Sorry for the trouble regarding this and I appreciate your assistance on it a ton!

Thank you for the amazing work 💜