KubeJS

KubeJS

69M Downloads

Failing to save player data on server

TheQKnight opened this issue ยท 12 comments

commented

Minecraft Version

1.18.2

KubeJS Version

kubejs-fabric-1802.5.3-build.444.jar

Rhino Version

rhino-fabric-1802.1.13-build.175.jar

Architectury Version

architectury-4.4.68

Forge/Fabric Version

0.13.3

Describe your issue

On a server, every time a player logs out I am getting a Failed to save player data for X player error

When the player logs back in, the inventory resets back to how it was when the server started
image

Crash report/logs

No response

commented

Does this happen without KubeJS?
Do you have any scripts that could be affecting it at all?
Any other mods that you think might affect it?

commented

No other mods. Checking scripts right now, but this didnt happen before on version 386

commented

I think I found out what was causing the issue.

At some point around version 386, deleting persistent nbt data did not work. So for example, I had a spawn protection script which set a few persistent nbt strings on the player, then would later remove them if the spawn protection went away.

Usually this would be done by using the delete key, like below

delete event.entity.nbt.spawnProtected

This used to work on versions before 386, but now throws a syntax error in the scripts

The way I got around that in the newer versions was to set the data to null or undefined

event.entity.nbt.spawnProtected = null

This works specifically on version 386, but any other updates after that, it seems to fail to save player data if the player exits with a null or undefined set persistent nbt tag.

So apparently there is now no longer a way to remove persistent data from the player without causing some sort of issue.

commented

event.entity.nbt.remove("spawnProtected") should work just fine, as for delete, I wonder whether lat removed that from Rhino; it might be kind of nice to have custom "delete" handlers, but that's a Rhino thing, not a KubeJS thing

commented

There is also this error that seems to happen if any other entities in other chunks have their data set to null
image

commented

image

commented

Well yes, you're not supposed to set things to null when working inside NBT, ever

commented

The odd thing is we didn't change anything related to persistent entity data in a while, so this should definitely not be an issue with KubeJS anyways. It's either related to changes in Rhino, or completely unrelated to us

commented

Well this serves as a problem, because there are old entities in the world I am trying to update that have null nbt, that worked perfectly on older versions.

commented

And the world is now seemingly corrupt because of the kjs update

commented

Rhino, architectury and kjs are the only things i have updated