EbonJaeger / perworldinventory-kt

Multi-world inventory plugin for Spigot written in Kotlin.
MIT License
46 stars 35 forks source link

Inventory lost when updating from 2.2.2 to 2.3.1 #146

Closed Kruize1 closed 5 years ago

Kruize1 commented 5 years ago

Describe the bug Taking a backup of data format 3 default.json, and inserting it into user's folder, results in items lost for that user when they log in.

To Reproduce Steps to reproduce the behavior:

  1. Take old data format 3 JSON
  2. Put into user's folder
  3. Start server and have user login
  4. download JSON
  5. observe
  6. JSON updated to data format 4, but all items are lost

Expected behavior Should convert to data format 4 and user should keep items

Plugin version

Server version Paper 1.14.2

Additional context and logs Add any other context about the problem here. Also post error messages and logs (use a service like Hastebin for logs, please!) in this area.

image

EbonJaeger commented 5 years ago

Is there an error of any sort in the console?

Kruize1 commented 5 years ago

No errors in console related to PWI

Kruize1 commented 5 years ago

I feel like maybe it's converting from 2.2.2 to a new format in 2.3.1 but it's losing all the items during the conversion process.

I noticed in the Diff, the formatting is different, when I compare them.

The notes for 2.30 mentioned a command to migrate data to the newest format. Maybe I need to run the command? Do you know what the command is?

image

EbonJaeger commented 5 years ago

The migration command is optional; everything is converted on the fly as players move around naturally, and it just does the same thing. All commands can be found here: https://github.com/EbonJaeger/perworldinventory-kt/wiki/Commands#general-commands

Could you show me the full converted file, to actually verify that something is missing?

Kruize1 commented 5 years ago

Sure thing!

Here's the old 2.2.2 file, I copy pasted this from a Diff I did, so it's easier to read: https://pastebin.com/JDrGntxZ

and here's the 2.3.1 file contents: https://pastebin.com/8z1LfzJk

EbonJaeger commented 5 years ago

In your original steps, what's happening between steps 3 and 4? Data is only converted when they change groups, log out, or die (since dying triggers a profile save). All the values in the newer file look like player defaults.

I also cannot reproduce this issue either by converting on the fly or with the migration command.

Kruize1 commented 5 years ago

Between steps 3 and 4 the user is just sitting there. Their inventory isn't there, so nothing really happens?

I download the JSON in the meantime and that's when I observe the results and the issue.

I did notice between the 2 files, the 2.2.2 file has "v": 1631

and 2.3.1 has "v": 1963

It almost feels like when they log in, whatever items they log in with overwrites the JSON before the conversion/migration happens.

So I have the 2.2.2 file ready on the server, with the items.

They login with nothing, it saves nothing, then the conversion happens?

I literally have the 2.2.2 file with their items, it just refuses to carry over the items to 2.3.1

Kruize1 commented 5 years ago

I tried a different approach!

1) I dropped in the old 2.2.2 file but kept the user offline. 2) While the user was offline, I ran the migration command /pwi migrate 3) I waited until I saw that the migration was completed successfully 4) I opened up the user's folder and my JSON looks MUCH better now!

https://pastebin.com/k9sFXDzk

You can see the correct data formatting at 4, the items seem to all be there. The "v": 1631 is now updated to "v": 1963

I feel like my theory is correct. The file somehow gets overwritten before the migration happens.

If you run the migration before the user logs on, there doesn't seem to be an issue.

I just need to wait for the user to log back on to confirm if this is 100% fixed.

Kruize1 commented 5 years ago

Ok... so he logged on and it wiped the JSON again....

I have no clue what's going on anymore...

Do you want to try converting and experimenting with the JSONs I provided?

I'm at my wits end...

Are you using 1.14.2 Paper like me?

EbonJaeger commented 5 years ago

1.13.2. It sounds a lot like something else (another plugin) is interfering.

Kruize1 commented 5 years ago

Are you able to try 1.14.2 Paper to see if it's an issue with Paper or 1.14.2 perhaps?

I could also give myself the JSON (as OP) and just change my name inside the file, and it should theoretically give me the items listed, right? I would bypass likely every plugin with that method

EbonJaeger commented 5 years ago

I tested it before release when I was first making the changes on 1.14.

You don't need to change any names, just plopping it in the PWI data folder for your UUID.

Kruize1 commented 5 years ago

So I can just take any JSON from any user and drop in into my own folder? No need to edit?

It will then give me the items from the JSON?

It really looks like it's doing things the other way around. It's overwriting the existing JSON with whatever the user has on them. If they have nothing on them, the JSON has nothing.

Is there any way to force the JSON down to the user as soon as they login? Or maybe a command to force JSON's on users?

Kruize1 commented 5 years ago

Also, just checking, you're using the same files as me, and it's actually working for you?

Kruize1 commented 5 years ago

Ok, I tried and it worked as OP for me.

So it has to be something...

Is there a permission I need to give users?

EbonJaeger commented 5 years ago

Not for PWI; it only has permissions to bypass inventory switching. Best bet is to check for other plugin changes. Definitely something else is messing with inventories.

Kruize1 commented 5 years ago

Ok, i'll close this for now then. I might add a comment later if I can find the cause. Might be useful for others, if they have a similar issue.