Solved Bukkit 1.13 tool durability?

Discussion in 'Plugin Development' started by JikaiNoTsubasa, Jan 30, 2019.

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

    JikaiNoTsubasa

    Hi all,

    we used to use ItemStack.setDurability but in 1.13 it's now deprecated so what can we use now?
    Can we increase the durability of an item or reset it?
    Thank you in advance
     
  2. Offline

    Esophose

    @JikaiNoTsubasa
    You're looking for the Damageable interface. If an ItemStack's ItemMeta implements Damageable, then you can cast it to a Damageable and use Damageable#setDamage to change the damage. Make sure to use ItemStack#setItemMeta on your ItemStack to apply the new damage value.

    Example:
    Code:
    ItemStack item = new ItemStack(Material.DIAMOND_SWORD, 1);
    Damageable meta = (Damageable) item.getItemMeta();
    meta.setDamage(500);
    item.setItemMeta(meta);
     
  3. Offline

    JikaiNoTsubasa

    Hi, thank you for your hint. I've finally solved this with the Lore. I've put a number of block it can mine and decrease it each time a block is broken.
    But I'll use your answer for another issue I have, thanks.
     
Thread Status:
Not open for further replies.

Share This Page