Adding a lore to an enchanted item.

Discussion in 'Plugin Development' started by minion325, Jun 28, 2017.

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

    minion325

    Hi there, I'm new to this forum so I'm not sure if this is the correct section for this post.
    My problem:
    Im trying to add a lore to an item after a user has enchanted it.
    Here is my code.
    https://pastebin.com/embed_iframe/wYrv89a4
    Also, i did register my events and put the @EventHandler
     
  2. Offline

    Zombie_Striker

    @minion325
    1. You have to store the instance of the item meta somewhere. You need to do this because you will need to call ItemStack#setItemMeta in order for the lore to change for the server side itemstack.
    2. After that, you will also need to re-set the item by using Inventory#setItem(SLOT, Itemstack) in order for the server side itemstack to take effect on the client side.
    3. Also, you will need to cancel the event in order for your changes to remain permanent. As this event is triggered before the enchantment occurs, bukkit will override any changes to the itemstack that happens in this event unless you cancel it. Also remember that you will have to handle all the effects such as XP given, the lapis removal, and the movement of the item, as canceling the event also stops bukkit from doing this as well.
     
  3. Offline

    minion325

    what is the itemslot for this
    http://imgur.com/a/iih61
     
  4. Offline

    Zombie_Striker

Thread Status:
Not open for further replies.

Share This Page