CitizensDev / Citizens2

Citizens - the premier plugin and API for creating server-side NPCs in Minecraft.
https://citizensnpcs.co
Open Software License 3.0
589 stars 313 forks source link

Cannot invoke "net.minecraft.nbt.NBTBase.clone()" because the return value of "java.util.Map$Entry.getValue()" is null #2683

Closed Andre601 closed 2 years ago

Andre601 commented 2 years ago

The output of command /version on my server is:

[21:28:59 INFO]: This server is running Paper version git-Paper-353 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) (Git: f2cb9cb)
You are 6 version(s) behind
Download the new version at: https://papermc.io/downloads
Previous version: git-Paper-273 (MC: 1.17.1)

The output of command /version citizens on my server is:

[21:29:42 INFO]: Citizens version 2.0.28-SNAPSHOT (build 2357)
[21:29:42 INFO]: Website: http://www.citizensnpcs.co
[21:29:42 INFO]: Author: fullwall

Full Log and Citizens configuration: https://paste.gg/p/Andre601/e5b61b1c3f154b7581a61453eba04629

Citizens is printing NullPointer exceptions when apparently loading NPCs. The full errors in question are the following:

[21:24:38] [Server thread/ERROR]: [Citizens] An exception occurred while the trait inventory was spawning for NPC ID 0.
[21:24:38] [Server thread/WARN]: java.lang.NullPointerException: Cannot invoke "net.minecraft.nbt.NBTBase.clone()" because the return value of "java.util.Map$Entry.getValue()" is null
[21:24:38] [Server thread/WARN]:    at net.minecraft.nbt.NBTTagCompound.clone(NBTTagCompound.java:397)
[21:24:38] [Server thread/WARN]:    at net.minecraft.world.item.ItemStack.cloneItemStack(ItemStack.java:662)
[21:24:38] [Server thread/WARN]:    at net.minecraft.world.item.ItemStack.cloneItemStack(ItemStack.java:653)
[21:24:38] [Server thread/WARN]:    at net.minecraft.network.protocol.game.PacketPlayOutSetSlot.<init>(PacketPlayOutSetSlot.java:21)
[21:24:38] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryPlayer.setItem(CraftInventoryPlayer.java:113)
[21:24:38] [Server thread/WARN]:    at Citizens.jar//net.citizensnpcs.api.trait.trait.Inventory.setContents(Inventory.java:212)
[21:24:38] [Server thread/WARN]:    at Citizens.jar//net.citizensnpcs.api.trait.trait.Inventory.onSpawn(Inventory.java:91)
[21:24:38] [Server thread/WARN]:    at Citizens.jar//net.citizensnpcs.npc.CitizensNPC.spawn(CitizensNPC.java:302)
[21:24:38] [Server thread/WARN]:    at Citizens.jar//net.citizensnpcs.npc.CitizensNPC.load(CitizensNPC.java:159)
[21:24:38] [Server thread/WARN]:    at Citizens.jar//net.citizensnpcs.api.npc.SimpleNPCDataStore.loadInto(SimpleNPCDataStore.java:59)
[21:24:38] [Server thread/WARN]:    at Citizens.jar//net.citizensnpcs.Citizens$CitizensLoadTask.run(Citizens.java:503)
[21:24:38] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101)
[21:24:38] [Server thread/WARN]:    at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483)
[21:24:38] [Server thread/WARN]:    at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1226)
[21:24:38] [Server thread/WARN]:    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319)
[21:24:38] [Server thread/WARN]:    at java.base/java.lang.Thread.run(Thread.java:831)
[21:24:38] [Server thread/INFO]: [Citizens] Loaded 3 NPCs.

and

[21:24:38] [Server thread/ERROR]: Entity threw exception at world:247.4481,21.0625,-10.6195
java.lang.NullPointerException: Cannot invoke "net.minecraft.nbt.NBTBase.clone()" because the return value of "java.util.Map$Entry.getValue()" is null
    at net.minecraft.nbt.CompoundTag.copy(CompoundTag.java:397) ~[app:?]
    at net.minecraft.world.item.ItemStack.cloneItemStack(ItemStack.java:662) ~[patched_1.17.1.jar:git-Paper-353]
    at net.minecraft.world.item.ItemStack.copy(ItemStack.java:653) ~[patched_1.17.1.jar:git-Paper-353]
    at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:166) ~[patched_1.17.1.jar:git-Paper-353]
    at net.minecraft.world.inventory.AbstractContainerMenu.triggerSlotListeners(AbstractContainerMenu.java:289) ~[app:?]
    at net.minecraft.world.inventory.AbstractContainerMenu.broadcastChanges(AbstractContainerMenu.java:234) ~[app:?]
    at net.minecraft.server.level.ServerPlayer.tick(ServerPlayer.java:637) ~[app:?]
    at net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC.tick(EntityHumanNPC.java:474) ~[Citizens.jar:?]
    at net.minecraft.server.level.ServerLevel.tickNonPassenger(ServerLevel.java:1120) ~[app:?]
    at net.minecraft.world.level.Level.guardEntityTick(Level.java:988) ~[app:?]
    at net.minecraft.server.level.ServerLevel.lambda$tick$7(ServerLevel.java:775) ~[app:?]
    at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:43) ~[patched_1.17.1.jar:git-Paper-353]
    at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:756) ~[app:?]
    at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1624) ~[patched_1.17.1.jar:git-Paper-353]
    at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:490) ~[patched_1.17.1.jar:git-Paper-353]
    at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1480) ~[patched_1.17.1.jar:git-Paper-353]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1279) ~[patched_1.17.1.jar:git-Paper-353]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-353]
    at java.lang.Thread.run(Thread.java:831) ~[?:?]
mcmonkey4eva commented 2 years ago
Andre601 commented 2 years ago
  • Please use https://paste.denizenscript.com/New/Log to pastebin your server log (we have a bot that can auto-scan logs when pasted there)
  • Please pastebin your Citizens/saves.yml file
  • That error looks like a corrupted item was equipped on an NPC

I can confirm that a NPC has an item in their main hand. This Item in general is a Player head with custom texture.

Here's the log: https://paste.denizenscript.com/View/89556 Saves.yml: https://paste.denizenscript.com/View/89557

From the view of the saves.yml would my personal guess be that the plugin confused skull owner with the actual texture value, as the texture seems to be empty and the owner contains the Base64 code.

For comparison is here the raw Data value used with a /give command to get the head:

{display:{Name:"{\"text\":\"Present (green)\"}"},SkullOwner:{Id:[I;1336659144,9587126,-1341101922,1377327008],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4Y2U3ZGViYTU2YjcyNmE4MzJiNjExMTVjYTE2MzM2MTM1OWMzMDQzNGY3ZDVlM2MzZmFhNmZlNDA1MiJ9fX0="}]}}} 1

So perhaps Citizens has issues parsing the [I;1336659144,9587126,-1341101922,1377327008] for the SkullOwner property?

mcmonkey4eva commented 2 years ago

So, first of all: your Citizens build is significantly outdated - update: https://ci.citizensnpcs.co/job/Citizens2/

Second: On my own test server, running Paper 336 and Citizens build 2395, I used the server console to execute: give mcmonkey4eva player_head{display:{Name:"{\"text\":\"Present (green)\"}"},SkullOwner:{Id:[I;1336659144,9587126,-1341101922,1377327008],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4Y2U3ZGViYT U2YjcyNmE4MzJiNjExMTVjYTE2MzM2MTM1OWMzMDQzNGY3ZDVlM2MzZmFhNmZlNDA1MiJ9fX0="}]}}} 1 (copy/pasted from your message with a give command tacked onto the beginning) and then /npc equip and put the "Present" into the NPCs hand, then /citizens save and checked the saves file and also reloaded - reloaded file, save data is perfectly correct.

In your saves file, the equipment trait (line 42) has a valid reference to the item, other than a owner: '' tacked on (that key shouldn't be there at all), and your inventory trait (line 15) is completely corrupt. I genuinely cannot think of any explanation for how that would happen. They're literally encoding the same ItemStack reference, there's no reason they should even be different. It seems almost like something manually messed with Citizens data?

Andre601 commented 2 years ago

So, first of all: your Citizens build is significantly outdated - update: https://ci.citizensnpcs.co/job/Citizens2/

Second: On my own test server, running Paper 336 and Citizens build 2395, I used the server console to execute: give mcmonkey4eva player_head{display:{Name:"{\"text\":\"Present (green)\"}"},SkullOwner:{Id:[I;1336659144,9587126,-1341101922,1377327008],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDA4Y2U3ZGViYT U2YjcyNmE4MzJiNjExMTVjYTE2MzM2MTM1OWMzMDQzNGY3ZDVlM2MzZmFhNmZlNDA1MiJ9fX0="}]}}} 1 (copy/pasted from your message with a give command tacked onto the beginning) and then /npc equip and put the "Present" into the NPCs hand, then /citizens save and checked the saves file and also reloaded - reloaded file, save data is perfectly correct.

In your saves file, the equipment trait (line 42) has a valid reference to the item, other than a owner: '' tacked on (that key shouldn't be there at all), and your inventory trait (line 15) is completely corrupt. I genuinely cannot think of any explanation for how that would happen. They're literally encoding the same ItemStack reference, there's no reason they should even be different. It seems almost like something manually messed with Citizens data?

I just used the lates available version on Spigot, so if anything is that place outdated too. Also, one thing could be that I used a custom item (Vanilla item with custom texture) on the NPC before but later on switched skin and equipment of it through the respective /npc commands.

How could I fix this? just remove the particular lines? Or should I completely remove that NPC section and create a new one instead?

Andre601 commented 2 years ago

Small update. I did download the latest dev build of Citizens and recreated the NPC (Deleted the entry while server was offline and created an NPC again using the /npc command)

The saves.yml seemed fine at first, texture and stuff where put correctly, but now after restarting the server do the exact same exceptions appear again.

Latest saves.yml: https://paste.helpch.at/aniyibujov.bash Latest Log: https://paste.helpch.at/iqurohaqep.md (Ignore the root warning. I'm in the process of making a dedicated user for the server stuff)

mcmonkey4eva commented 2 years ago

So... what exactly changes, between when it works and when it stops working?

I can save/restart multiple times without anything changing, so I don't think it's just simple repetition of restarts

Andre601 commented 2 years ago

So... what exactly changes, between when it works and when it stops working?

I can save/restart multiple times without anything changing, so I don't think it's just simple repetition of restarts

I can't say either... My best guess would be that another plugin may alter the item for some reason, but not sure which one any why... The only one I assume that could be responsible are either QuickShop (Chest shop plugin) or ItemsAdder (custom vanilla items) and I would go with second one.

But for now will I just not have the NPC hold any items in their inventory and see if that will solve anything.

mcmonkey4eva commented 2 years ago

Probably should see if you can replicate the issue without those plugins installed, to determine whether they're at fault.

See also https://wiki.citizensnpcs.co/Plugin_Conflict