ItemName wont set

Discussion in 'Plugin Development' started by DaanSander, Jan 17, 2015.

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

    DaanSander

    hey i have created a plugin so when i right click a iron shovel it would change the name but it wont change it i tried debugging it but that works fine

    code:
    Code:
    @EventHandler
        public void onRightClick(PlayerInteractEvent e) {
            Player p = e.getPlayer();
            if(e.getAction() == Action.RIGHT_CLICK_AIR) {
            if(p.getItemInHand().getType() == Material.IRON_SPADE) {
                p.sendMessage("Debug1");
                p.getInventory().getItemInHand().getItemMeta().setDisplayName("Right");
                p.sendMessage("Debug2");
            }
            }
        }
     
  2. Update the item / iventory .
     
  3. Offline

    WinX64

    getItemMeta will return a copy. You will have to set it back after editing, or it will have no effect.
     
    Konato_K likes this.
  4. Offline

    DaanSander

    updating the inventory wont work
     
Thread Status:
Not open for further replies.

Share This Page