Adding Enchantments to Items

Discussion in 'Plugin Development' started by Xerfox, Jan 25, 2014.

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


    How could I give an enchantment to an item that I am spawning into the player's inventory?

    Example: player.getInventory().addItem(newItemStack(Material.BOW).addEnchantment(Enchantment.ARROW_DAMAGE, 1));

    That code doesn't work. But why?

    I get an error on addItem(): "The method addItem(ItemStack...) in the type Inventory is not applicable for the arguments (void)"
  2. Offline


    1. ItemStack i1 = new ItemStack(Material.BREAD, 1);
    2. i1.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 1);
  3. Offline


    You should try defining the item seperately, and adding the enchantments to it, then putting the variable for your item in be additem method
  4. Offline


    Xerfox Try this
    1. Enchantment enchant = new EnchantmentWrapper(/*Enchantment ID*/);
    2. /*ItemStack*/.addEnchantment(enchant,/* level */);
  5. Offline


    Hi How I Can Create My Own Custom Enchantment ?
  6. Offline


  7. Offline


    :) Thanks.

    Ok Can You Make to me a feavor ?
    i wana the plugin i don't wana :( tutorial

    ( and sorry for bad english ( it's not my main language ) :) and thanks

    Please can you send the plugin :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page