Light-weight messing around custom items?

Discussion in 'Plugin Development' started by Quaro, May 9, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    Im searching for best way to check if itemstack is custom item and point somehow to it's wrapper class. What would you suggest?
  2. Offline


    1. if(player.getInventory().getItemInHand().getItemMeta().hasLore()){
    2. if(player.getInventory().getItemInHand().getItemMeta().getLore().contains(ChatColor.GOLD + "<LoreName>")){
    Is this what you are looking for?
  3. Offline


  4. Offline


    Quaro But isn't lore just managed by Bukkit (players can't edit their item's lore)? If you want to keep information in lore without letting the player know, you can NMS change the item packet and edit the lore (thats how EnchantmentAPI work)
  5. Offline


    Basically, i need way to get something (ex: id) from itemstack that i could use for getting custom item's wrapper class. But i don't want to put that "something" in public (visible).
  6. Offline


    You could try using metadata.
  7. Offline


  8. Offline


    Sorry to keep spamming my thread, but this question seems to be coming up a lot today!

    I don't think there is a clean lightweight way, unfortunately. There are two suggestions so far I really like from that thread:

    1. Use lore, but use ProtocolLib to override or remove the lore when sending the item to the client. That way you can store data the client can't see.

    2. Use item attributes- this one I'm not so sure about, you'd have to read desht's post on it, but basically it sounds like you can store some data in an attribute name (not the value).

    If you find any other good ideas, please add them to that thread or let me know.

    coasterman10 I think Bukkit metadata is only for entities, it won't work on items. Item metadata is something else entirely, basically lore/name/enchants/etc.
  9. Offline


    NathanWolf So, which would you suggest? Which one using you? Examples?
  10. Offline


    I wouldn't suggest doing it the way I'm doing it (raw NBT data storage).

    I don't really have a good suggestion, which is why I made that thread ;)
  11. Offline

    connor stone

    Id suggest using the lore, but only color codes, that way it will be saved in the lore and you can check for it later but it wont be seen by the player
  12. Offline


    Metadata tutorial (though weak):
    You can search around on Google or the search box on forums to find more information about metadata.

    EDIT: Turns out I overlooked ItemStacks and they don't actually support metadata. I'm really not sure how you could identify an itemstack specifically without either renaming it or adding lore.
  13. Offline


    NathanWolf likes this.
  14. Offline


    Vote here if you want it:

    That issue would be the basis for a PR, if I were to submit one. However the lack of traction on that issue and the general resistance to it is making me hesitant ... so vote it up :)
Thread Status:
Not open for further replies.

Share This Page