Solved Durability is set to 0

Discussion in 'Spigot Plugin Development' started by Minimigamer, Jan 17, 2020.

  1. Hey guys, this code should set the Durability of a used item to new.
    But its not really working it sets the Durability to 0 but maxDurability is set to the right number
    annyone know why ?

    Code (Text):

    ItemStack item = p.getInventory().getItemInMainHand();
            short maxDurability = item.getType().getMaxDurability();
    • Agree Agree x 1
  2. Strahan


    Also you realize setItemInHand is deprecated, and besides that it refers to the same hand as setItemInMainHand so you are essentially just setting their hand item to null then immediately placing the item in the same hand.
    • Agree Agree x 1
  3. I believe the durability variable is the durability used not the amount left.
  4. This is correct. When an item is first created, it has a durability of 0. As you use the item, the durability increases and the item breaks when the durability hits the max number of uses.