ItemMeta, why wont my diamond sword change name??

Discussion in 'Plugin Development' started by joehot2000, Mar 5, 2013.

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

    joehot2000

    Hi, i have currently got this code, which is meant to change the name of the Diamond Sword to Diamond Sword [POISONOUS]

    But, it dosent seem to work? (and it DOES send the player the message at the bottom)

    if (player.getItemInHand().getType().equals(Material.DIAMOND_SWORD)){
    ItemMeta it = player.getItemInHand().getItemMeta();
    it.setDisplayName(it.getDisplayName() + ChatColor.GREEN + "[POISONOUS]");
    player.sendMessage(ChatColor.YELLOW + "Sucessfully enchanted diamond sword with " + ChatColor.GREEN + "[POISION]" + ChatColor.YELLOW + ".");
     
  2. Offline

    ZeusAllMighty11

    You have to do player.getItemInHand().setItemMeta(it)
     
  3. Offline

    joehot2000

    Ouch! i didnt even know that line of code existed!

    Thanks!!
     
Thread Status:
Not open for further replies.

Share This Page