Cannot enchant item!

Discussion in 'Plugin Development' started by MaxFireIce, Nov 4, 2016.

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

    MaxFireIce

    I have looked all over the internet and cannot find out how to enchant my item.

    How would I set my item to have an enchantment, and while we are at it, how to make the enchantment invisible. Also, does anyone know how to add lore to an item and change the name of the item?

    I am trying to enchant this:
    Code:
    ItemStack legendary= new ItemStack(Material.BOOK, 1);
    I am trying to give lore to this:
    Code:
    Card fireballcard = new Card(Arrays.asList("Shoots a", "fireball"), ChatColor.RED + "Fireball", common);
    And i define the card object like this:
    Code:
    public Card(List<String> lore, String name, ItemStack type){
           }
     
  2. Offline

    PumpMelon

    You need to use an ItemMeta variable, from there you can set lore, display name, and lots of other things depending on which one you use.

    Code:
    ItemStack l = new ItemStack(Material.BOOK);
    ItemMeta lmeta = l.getItemMeta();
    lmeta.setDisplayName("name");
    lmeta.setLore(List<String>);
    l.setItemMeta(lmeta);
    l.addUnsafeEnchantment(Enchantment.SOMETHING, level);
    
     
  3. Offline

    MaxFireIce

    Now how would i add the item meta to the item stack?

    Oh, and i cant add anything to the item meta, however a can add an enchantment directly to the item meta...

    @PumpMelon
     
    Last edited: Nov 6, 2016
Thread Status:
Not open for further replies.

Share This Page