ItemStack - cannot rename.

Discussion in 'Plugin Development' started by finalblade1234, Mar 20, 2013.

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

    finalblade1234

    Hey im just making a test plugin called QuartzToolz.
    Here is my code:
    Code:
       
        ItemStack is = new ItemStack(Material.IRON_SWORD,1);
        is.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10);
        is.getItemMeta().setDisplayName(ChatColor.GREEN + "Quartz Sword");
       
        ShapedRecipe QuartzSword = new ShapedRecipe(is).shape(" @ "," @ "," * ").setIngredient('@', Material.QUARTZ).setIngredient('*', Material.BLAZE_ROD);
        getServer().addRecipe(QuartzSword);
    it does everything but renames the item to QuartzSword.
    Hope you can help =3
     
  2. Offline

    Sahee

    is.getItemMeta().setDisplayName(ChatColor.GREEN + "Quartz Sword"); <- This rename your item to QuartzSword
    What do you need? LOL
     
  3. Offline

    Wolftic

    ItemStack is= new ItemStack(Material.IRON_SWORD);
    ItemMeta isM = is.getItemMeta();
    isM.setDisplayName(name);
    is.setItemMeta(isM);
    this wil rename it.
     
    com. BOY likes this.
  4. finalblade1234
    getItemMeta() returns a copy of the ItemMeta class, you must store it and set it back to the item after you've modified it with setItemMeta().
     
  5. Offline

    finalblade1234

    Wolftic
    Works perfectly! thanks!
     
Thread Status:
Not open for further replies.

Share This Page