Solved How to hide items' lore? (ProtocolLib?)

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

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

    OrangeGuy

    I need to hide some items' lore(prevent them from sending to players' client, not remove it). I think ProtocolLib is the best way to do it, but after checked ProtocolLib's javadoc and example source codes, I have no idea. Can somebody tell me how to do it(with or without(?) protocolLib)? Thanks :rolleyes:.
     
  2. Offline

    TGRHavoc

    @OrangeGuy
    Why are you wanting to set lore then not allow the players to see it? If you're trying to make the item "carry" data in the form of Lore, I suggest doing Item.setMetadata( String metadataKey, MetadataValue newMetadataValue)
     
  3. Offline

    OrangeGuy

    How can I do that? Can you gimme a simple example?
     
  4. Offline

    TGRHavoc

    Get the item, do "item.setMetadata("KeyToLookFor", MetadataValue.asString("ThisIsTheValue");".
    Then you can check whether the item has metadata by doing Item.hasMetadata("KeyToLookFor"), this will return true if the item has that metadata.
     
  5. Offline

    Garris0n

    TGRHavoc He probably wants persistence if he's using lore.

    @OP ProtocolLib, yes. There is a tutorial on the plugin's page.
     
    NathanWolf likes this.
  6. Offline

    OrangeGuy

    OK. Is there any limitation of the value's length?

    Also, I am gonna add data to ItemStack.. But seems only Item(Entity) has setMetadata() method.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  7. Offline

    MCForger

    OrangeGuy
    What do you exactly want to save about the item?
     
  8. Offline

    OrangeGuy

    I use it to save a String. Which should be invisible to players, and I need to get it on InventoryClickEvent.

    Finally I got it working with ProtocolLib. But I wanna know if theres anyway to store String in ItemStack without using lore and ProtocolLib.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  9. Offline

    NathanWolf

    There are a few good suggestions in here, actually:

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

    It seems like your best bets are what you are doing now, or using Attribute name tags as desht suggests in that thread.

    You also technically don't need ProtocolLib, I guess you could implement the packet stuff yourself- not sure if you meant "Without ProtocolLib" or "Without packet hacks" :)
     
  10. Offline

    OrangeGuy

    Thanks. I think that I should keep using ProtocolLib, because im not gonna update my plugin everytimes a new CB comes out.

    (Outpost.) How can you connect your Minecraft account to bukkit forum?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
    NathanWolf likes this.
  11. Offline

    NathanWolf

    Look under your account settings (click "Personal Details" on your user drop-down)

    All the way at the bottom of the left sidebar is a "Manage Associations" area. You can link up your forum account with your DBO account and Minecraft account there (maybe some others, not sure?)
     
    OrangeGuy likes this.
Thread Status:
Not open for further replies.

Share This Page