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

    Quaro

    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

    DeluXeNationMC

    Quaro
    Code:java
    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

    Quaro

  4. Offline

    rfsantos1996

    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

    Quaro

    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

    coasterman10

    You could try using metadata.
     
  7. Offline

    Quaro

  8. Offline

    NathanWolf

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

    http://forums.bukkit.org/threads/custom-item-data.265410/

    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

    Quaro

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

    NathanWolf


    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

    coasterman10

    Metadata tutorial (though weak): http://wiki.bukkit.org/Plugin_Tutorial#Metadata
    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

    xTigerRebornx

    NathanWolf likes this.
  14. Offline

    NathanWolf


    Vote here if you want it:

    https://bukkit.atlassian.net/browse/BUKKIT-3221

    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