Reading offline players
kangarko opened this issue ยท 3 comments
Hi there,
Matej here, I am trying to replace PowerNBT with this plugin. My desired situation is I want to edit an offline player's inventory. I know there's NBTFile class however I have a few questions before continuing:
-
To read the player nbt file is it safe to assume they are stored in the first world from Bukkit.getWorlds list?
-
How does the saving mechanism work?
-
How could I potentially get an ItemStack from NBTTag? See full code below, getItemFromNBT method.
This is my current code with PowerNBT imports removed:
Full code:
https://pastebin.com/9NEAEggJ
Thanks. A lot of people would benefit from this as I am using the code in the Confiscate plugin protecting against malicious items.
Matej
Is now part of the nbt-data-api. (Not done, but simple working with player files is implemented)
To read nbt files you can use "new NBTFile(file);", to get the file as a NBTCompound(or create it). For saving the NBTFile has a .save() method.
Now you can normally browse the nbt, and to get an ItemStack, there's the method "NBTItem.convertNBTtoItem(compound);" which will return a Bukkit ItemStack. For the inverse use "convertItemtoNBT".