Rename item's?

Discussion in 'Plugin Development' started by Firestrike, Aug 8, 2013.

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

    Firestrike

    I can't seem to add color to this item I am making?

    Code:java
    1.  
    2. }
    3. }
    4. else if(cmd.getName().equalsIgnoreCase("weapon")){
    5. if(!(sender instanceof Player)){
    6. sender.sendMessage(ChatColor.YELLOW+"No /Weapon command for you!");
    7. return true;
    8. }
    9. Player player = (Player)sender;
    10. ItemStack weapon = new ItemStack(Material.DIAMOND_SWORD, 1);
    11. ItemMeta im = itemstack.getItemMeta();
    12. im.setName(ChatColor.BLUE+"Spade");
    13. itemstack.setItemMeta(im);
    14. weapon.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10);
    15. weapon.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 100);
    16. weapon.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 5);
    17. weapon.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 100);
    18. weapon.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 100);
    19. weapon.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 100);
    20. }
     
  2. Firestrike
    Is the item name working at all? If yes, try setting the item meta after you add the enchantments, I've seen some conflict with them before.
     
  3. Offline

    Firestrike

    Still not working.
     
  4. Offline

    valon750

    Firestrike

    Where are you even casting the name itemstack... all I see is "weapon".
     
  5. Offline

    Firestrike

    It will now change the name of the item but the lore that a specified won't come up.

    Code:java
    1.  
    2. }
    3. else if(cmd.getName().equalsIgnoreCase("sword")){
    4. if(!(sender instanceof Player)){
    5. sender.sendMessage(ChatColor.YELLOW+"No /Sword command for you!");
    6. return true;
    7. }
    8. Player player = (Player)sender;
    9. ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
    10. item.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 5);
    11.  
    12. ItemMeta id = item.getItemMeta();
    13. id.setDisplayName(ChatColor.GOLD+ "Sword of Lightning");
    14.  
    15. ArrayList<String> lore = new ArrayList<String>();
    16. lore.addAll(id.getLore());
    17. lore.add("This is somthing");
    18. lore.add("This is somthing agian");
    19. id.setLore(lore);
    20.  
    21. item.setItemMeta(id);
    22. player.getInventory().addItem(item);
    23.  
    24. player.sendMessage(ChatColor.GOLD+"You just spawned a sword");
    25. }
     
  6. Offline

    Alex3543

    Code:
    ItemStack weapon = new ItemStack(Material.DIAMOND_SWORD, 1);
                    ItemMeta im = weapon.getItemMeta();
                    im.setDisplayName(ChatColor.BLUE+ "Spade");
                    weapon.setItemMeta(im);
                weapon.addUnsafeEnchantment(Enchantment.KNOCKBACK, 10);
                weapon.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 100);
                weapon.addUnsafeEnchantment(Enchantment.LOOT_BONUS_MOBS, 5);
                weapon.addUnsafeEnchantment(Enchantment.DAMAGE_UNDEAD, 100);
                weapon.addUnsafeEnchantment(Enchantment.DAMAGE_ARTHROPODS, 100);
                weapon.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 100);
     
  7. Offline

    Firestrike

    Fixed the lore I just had to remove this.

    Code:java
    1.  
    2. lore.addAll(id.getLore());
     
Thread Status:
Not open for further replies.

Share This Page