EssentialsX

EssentialsX

2M Downloads

View and modify the inventories of offline players

kmecpp opened this issue ยท 6 comments

commented

Could there be commands to view and modify offline players' inventories and enderchests?

Alternatively the /invsee and /echest commands could be expanded to work with offline players.

EDIT: Just realized this is the third issue asking for this. Sorry. Maybe instead of using NMS though, Essentials could just read directly from the player's NBT data file? That doesn't seem likely to change any time soon.

commented

This would be really helpful.

commented

There is still a possibility of the player logging in while you're viewing their ender chest/inventory, so the approach of manually reading player data wouldn't be ideal for modifying inventories. In addition, we can't be sure exactly when the server is finished writing to the file, so there's a chance we could read out-of-date or corrupted data.

commented

The data read only needs to happen once and the write only needs to happen once or potentially not at all if the user doesn't make any changes. So there should only be one read and maybe one write. The chances of a problem occurring are extremely slim in the first place and there are also many ways to avoid them.

For example, If the player logins while someone is editing their inventory, just replace the player's inventory with the one currently being edited (using Bukkit) and switch to online editing (no write needed).

I believe that the only time the server writes to the player's NBT file are when they quit so there shouldn't even be an issue with that because if they're quitting that means they were online in which can Essentials should be using the existing online inventory editing.

And reading from the file simultaneously shouldn't even be a problem because the OS can handle it.

commented

It doesn't really matter to me how it's implemented. I just think this would (#473 #98) be very useful to a lot of people and I do believe it can be done with zero or negligible overhead in existing code.

commented

It's not about how big or small the chances of a problem are, it's that the added overhead of dealing with all of these problems isn't worth the effort for the number of people who will use this. Honestly I'd much rather we used NMS via reflection than read and potentially modify player data without the server being aware. In addition, using a provider means that in theory we could support alternate server implementations that don't use vanilla data files or behave differently to Spigot (which is the implementation we generally target).

commented

Feel free to implement it since you say it's easy