Solved Storing data in itemstacks

Discussion in 'Spigot Plugin Help' started by squareluck, Jan 13, 2019.

  1. hey spigot community,
    I am making a plugin that has different tiers for different pieces of herioic armor. I am trying to figure out the best way without using lore/name/anything editable, to store the level. Advice/help would be appreciated.
     
  2. 1.13? Use CustomTagContainer.
     
  3. Alright, so a couple of follow up questions.
    1.) I think using nbt tags is the best. Could I store an integer value in an nbt tag. For example, a piece of armor has a level tag that has a value of one so its level one. It can be upgraded and "++" can be used.
    2.) If #1 is possible, how would I go about doing this without to many problems, (I am trying to figure out how to add it to my item builder class)
    3.) Is there a way to use the api without having the api on my actual server? Alternatively how would I make an nbt tag without the api.
     
  4. Which Minecraft version do you use?
     
  5. The version I am using to make this plugin is 1.8
     
  6. Using the NBT Api that I linked above, as long as it is compiled into your plugin's JAR file then you don't need to actually put the plugin into the server. If you are using maven, just set the scope of the dependency to "compile".
     
  7. 2008Choco

    Junior Mod

    For anyone who finds this thread in the future, 1.13.2 supplies an "NBT API" native to Bukkit. Saves persistent data in an item's NBT data with rather customizable (de/)serialization. @ysl3000 mentioned this but didn't provide any docs, so:

    See ItemMeta#getCustomTagContainer(): CustomItemTagContainer

    The struggle of being stuck on 1.8, eh OP? Feel free to invest in a 3rd party library instead as mentioned by @SANDST0RM. Alternatively, the more recommended approach is to update to the latest version of the API and use the newest features such as custom NBT. Works flawlessly and more efficiently than a 3rd party library would :)
     
  8. Trust me I would, the plugin is for a friend else it would be 1.13.


    Also, wdym by compiled into your plugins jar?
     
  9. I have a very simple NBT editor for items, tile entities, and entities that works with 1.8-1.13 which can be found here.

    The basic tutorial on how to use it can be found here.

    However, for 1.13, it is probably better to use Bukkit's NBT API.
     
  10. Hey man, I was just looking at that, just to be clear, I can store an int value in a simple tag?
     
  11. Yes, you can store all of the following:
    • Strings
    • Ints
    • Longs
    • Floats
    • Shorts
    • Bytes
    • Byte arrays
    • Int arrays
    Since you can store byte arrays, I supposed you can serialize any object as well. :)
     
  12. Alright, I believe this is solved. I am going to use BannanaPuncher's Api. I believe I have to add it as a plugin idk ill figure it out though. Thankyou all for the help.
     
  13. Do you have discord? I could help you with compiling it rather than having to use it as a plugin.
     
  14. Yeah I do LukeBen#7901
     

Share This Page