I kinda need some help please

Discussion in 'Plugin Development' started by TeddyDev, Oct 27, 2014.

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

    TeddyDev

    Hey bukkit people!

    Can an experienced developer please help me out with something?

    I'm wanting to check if a player has a an item in there inventory, If they do im wanting to set a lore to the item.. So if i had a pickaxe nothing would happen, but if i had a sword it would put the specified lore onto the sword.

    Also can the code check for enchantments? E.G: If i added 'sharpnessI' it would add another line or lore saying i have added sharpnessI, and soo on.

    Is this possible and how the hell would i do this, Thanks :)
     
  2. Offline

    Totom3

    TeddyDev Have you checked out the Inventory interface ? Also, would just like to point out that enchantments are not stored as a lore line. If you want to add/remove/check for enchants on an ItemStack, then ItemMeta has the right methods for this.
     
  3. Offline

    97WaterPolo

    TeddyDev
    Well you would have to listen to an event or execute it on a command.

    for (ItemStack is : player.getInventory().getContents())
    if (is != null)
    if is.toString contains "SWORD"
    add enchantment to the item
    add lore to the item

    It seemed you wanted to do it for every sword, but if you want to do it for certain slots you can check the slots! :) Hopefully this is what you were talking about!
     
Thread Status:
Not open for further replies.

Share This Page