Repairing broken items

Discussion in 'Plugin Development' started by CakePvP, Mar 31, 2013.

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

    CakePvP

    I've been wondering how to fix this for a couple days.

    I've already tried to clone the item and add it back the inventory and I've also tried setting the durability to 0, which in theory would cancel the event.

    Current code:
    Code:
        @EventHandler
        public void onBreak(PlayerItemBreakEvent e) {
     
            Player player = e.getPlayer();
     
            ItemStack itemStack = e.getBrokenItem().clone();
     
            player.getInventory().addItem(itemStack);
     
            p.chat.sendMessage(player, "Repaired your §c§l" + e.getBrokenItem().getType().name());
     
        }
     
  2. Offline

    AeroUK

    You could try setting the durability higher when it reaches a certain level(?)
     
Thread Status:
Not open for further replies.

Share This Page