Enchantment not appearing to be added?

Discussion in 'Plugin Development' started by Trevor1134, Jun 25, 2014.

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

    Trevor1134

    I have a listener, and after enough blocks are broken, an enchantment is added to the tool.
    I have:
    Code:
    ItemStack is = p.getItemInHand();
    is.addEnchantment(Enchantment.DIG_SPEED, 1);
    I also entered a debug line, and the code IS being executed, but the tool doesn't appear to change.
    If it may matter at all, I have a custom lore & display name.

    Thanks
     
  2. Offline

    jthort

    Trevor1134 When you are changing the custom lore and display name you can just take the metaData you use and do something like this
    Code:
     ItemStack testEnchant = new ItemStack (Material.BOW, 1);
            ItemMeta testEnchantMeta = testEnchant.getItemMeta();
            testEnchantMeta.addEnchant(Enchantment.ARROW_FIRE, 10, true);
         //add colors and what not
            testEnchant.setItemMeta(testEnchantMeta);
    Although it's hard to tell with the amount of information given it could be that you are adding the enchantment, then changing the meta and then it removes the previous data with the enchantment.
     
Thread Status:
Not open for further replies.

Share This Page