tr7zw / Item-NBT-API

Add custom NBT tags to Items/Tiles/Entities without NMS!
https://www.spigotmc.org/resources/item-entity-tile-nbt-api.7939/
MIT License
561 stars 77 forks source link

Cant put NBT on Doors #303

Open NaosV1 opened 3 days ago

NaosV1 commented 3 days ago

When I try to put NBT on a DOOR (1.12.2, WOODEN_DOOR or any type of doors) I get this error in my console :

org.bukkit.command.CommandException: Unhandled exception executing command 'base' in plugin InvasionBase v1.0-SNAPSHOT at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[server.jar:git-Spigot-79a30d7-f4830a1] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[server.jar:git-Spigot-79a30d7-f4830a1] at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648) ~[server.jar:git-Spigot-79a30d7-f4830a1] at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1401) [server.jar:git-Spigot-79a30d7-f4830a1] at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1236) [server.jar:git-Spigot-79a30d7-f4830a1] at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:45) [server.jar:git-Spigot-79a30d7-f4830a1] at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) [server.jar:git-Spigot-79a30d7-f4830a1] at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [server.jar:git-Spigot-79a30d7-f4830a1] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_312] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_312] at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [server.jar:git-Spigot-79a30d7-f4830a1] at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [server.jar:git-Spigot-79a30d7-f4830a1] at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [server.jar:git-Spigot-79a30d7-f4830a1] at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [server.jar:git-Spigot-79a30d7-f4830a1] at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [server.jar:git-Spigot-79a30d7-f4830a1] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312] Caused by: de.tr7zw.nbtapi.NbtApiException: [Selfchecked][2.13.2]Error while calling the method 'setTag', loaded: true, Enum: ITEMSTACK_SET_TAG, Passed Class: null Args: [{Tier:1,Life:5000}] at de.tr7zw.nbtapi.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:399) ~[?:?] at de.tr7zw.nbtapi.NBTReflectionUtil.setItemStackCompound(NBTReflectionUtil.java:202) ~[?:?] at de.tr7zw.nbtapi.NBTItem.setCompound(NBTItem.java:175) ~[?:?] at de.tr7zw.nbtapi.NBTReflectionUtil.setData(NBTReflectionUtil.java:674) ~[?:?] at de.tr7zw.nbtapi.NBTCompound.setInteger(NBTCompound.java:209) ~[?:?] at fr.naosisme.invasionbase.InvasionBase.giveTierBlock(InvasionBase.java:85) ~[?:?] at fr.naosisme.invasionbase.InvasionBaseCommand.onCommand(InvasionBaseCommand.java:120) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[server.jar:git-Spigot-79a30d7-f4830a1] ... 15 more Caused by: java.lang.NullPointerException at sun.reflect.GeneratedMethodAccessor47.invoke(Unknown Source) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_312] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_312] at de.tr7zw.nbtapi.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:396) ~[?:?] at de.tr7zw.nbtapi.NBTReflectionUtil.setItemStackCompound(NBTReflectionUtil.java:202) ~[?:?] at de.tr7zw.nbtapi.NBTItem.setCompound(NBTItem.java:175) ~[?:?] at de.tr7zw.nbtapi.NBTReflectionUtil.setData(NBTReflectionUtil.java:674) ~[?:?] at de.tr7zw.nbtapi.NBTCompound.setInteger(NBTCompound.java:209) ~[?:?] at fr.naosisme.invasionbase.InvasionBase.giveTierBlock(InvasionBase.java:85) ~[?:?] at fr.naosisme.invasionbase.InvasionBaseCommand.onCommand(InvasionBaseCommand.java:120) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[server.jar:git-Spigot-79a30d7-f4830a1] ... 15 more

    This is my code :
    public void giveTierBlock(Player player, Material material, int amount, int tier) {

    ItemStack item = new ItemStack(material, amount);
    ItemMeta meta = item.getItemMeta();

    int life = getConfig().getInt("tier." + tier);
    List<String> lore = new ArrayList<>();
    lore.add(" ");
    lore.add("§8[§7Tier§8] §c" + tier);
    lore.add("§8[§7HP§8] §c" + life);
    lore.add(" ");
    meta.setLore(lore);
    item.setItemMeta(meta);

    NBTItem nbti = new NBTItem(item, true);
    nbti.setInteger("Tier", tier);
    nbti.setInteger("Life", life);

    player.getInventory().addItem(nbti.getItem());

}

Works on everything but doors
tr7zw commented 3 days ago

Replace that deprecated usage of NBTItem with the correct syntax with NBT.modify.