checking items with durability

Discussion in 'Spigot Plugin Development' started by Xuho, Apr 26, 2017.

  1. I'm working on a custom item plugin but I have a problem with items that have durability.
    I check if the player's hand item is similar to an item stack but, when the item misses durability, it didn't work.
    Code (Text):
    if (p.getItemInHand().isSimilar(is.pico1())) {
    Probably, it's a stupid thing but I could not find a solution.

    Thanks in advance and sorry for my English.
  2. You could try checking the name of the Item if you named it or try comparing the item lore

    Sent from my iPhone using Tapatalk
  3. Hmmm a hacky way of using it would be to temporarily set the durability of all items to full then reset them after the comparison.

    Otherwise you'll need to manually compare them,
    If itemInHand().getType() == is.getType()

    You would also need to take into account if the item has meta or has its display name changed.

    Sent from my iPhone using Tapatalk
  4. I was also going to diggers temporarily changing the durability but comparing the lore might be simpler.

    Sent from my iPhone using Tapatalk
  5. What are you comparing in terms of items? Do you have any metadata on the item or a displayname for the item?

    If so, you could compare through names
    Code (Text):
    Or you can compare types (material)
    Code (Text):
  6. I'll try to compare the lore.