Plugin for saving ItemStack metadata/NBT after it is placed as a block

Discussion in 'Spigot Plugin Help' started by Thatsmusic99, Feb 9, 2020.

  1. This has personally been an ongoing issue for me for a while.

    For nearly 3 years now I've developed and maintained a heads plugin that allows the selling of heads (and a lot more but this bit is relevant to the thread). However, it has not been unusual for me to receive a complaint saying all NBT data in the head is lost after placing it and breaking it again, which I have to explain every time is not a problem on my end and is in fact the work of Minecraft itself: you place a diamond block with a custom name and lore, all of that is lost; the same goes for skulls, clearly. I've even made an option that prevents players from placing these heads, however, for those who want to show off those heads, it's not the most suitable option.

    In the past, I do recall something on Bukkit mentioning the practice of saving NBT/metadata before, and that someone made a utility for it. However, my searching skills look like they've gone down the drain or I simply can't find it anymore (this was about 3 years ago as well before I even released my plugin and decided I wasn't going to try and fix that issue, especially since I'd gone and made the same mistake almost everyone does and didn't learn Java before coding plugins, so I barely knew a thing it did). But I'm also wondering if someone has actually re-created that utility but in the form of a plugin of which I can recommend to users of my plugin complaining of the issue?

    I would be happy making my own if there's none available, although I'm trying to avoid this because I already work on two other major plugins (one which I plan to be extremely destructive with) and have another in developing, as well as a crap ton of schoolwork and revision to do, despite I'm mostly trying to achieve this in school hours. I won't ask for anyone to make it either; if it's an interesting concept to you and you want to try it yourself, go ahead, but I'm not paying anyone anything (especially since I don't have PayPal either).

    TL;DR: Is there a plugin out there - or even just a utility - that can save ItemStack NBT/metadata after that item is placed on the ground as a block, so that players using my plugin don't continuously report the same issue with me giving the same answer (Minecraft issue, not fixing)?
     
  2. Im actually gonna develop something like this, Ill send you the class code (im gonna do it in 1 class) when im done
     
    • Like Like x 1
  3. Awesome to hear, because despite how old this post is, it's still valid to this day. ;)

    P.S. - if you find it too hard to do, you don't have to shove it all into one class considering what Java is like. It doesn't have to be a private plugin directed at me either, I made the thread since I was asking if there was any public plugin I could advise people on so you can make it available to everyone.
     
    #3 Thatsmusic99, May 27, 2021
    Last edited: May 27, 2021
  4. Hi! VanillaTweaks (the plugin) has this functionality as a module.

    Here is the PersistentHeads.java class on GitHub, just in case you wanna include it in your plugin. :)
     
    • Like Like x 1
  5. I appreciate the response and it's nice to see this! I believe Purpur implemented a similar feature a while ago, which would've solved the problem on its own, but unfortunately because my plugin stores extra data inside of the head other than just the name and lore, this doesn't quite solve my problem. But I can always refer people to the VT plugin or Purpur if they only want the lore and name maintained.

    Worst case scenario I can resort to making a similar implementation of the class since I want to rewrite the plugin I mentioned earlier regardless, just can't work on it right now since I'm away as of currently.