Skip to content

Conversation

@Kqliber
Copy link

@Kqliber Kqliber commented Apr 25, 2025

Supports new max durability item component tag
Currently items with this tag will display with wrong value

return item.getType().getMaxDurability() - item.getDurability();
}

final Damageable meta = (Damageable) item.getItemMeta();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it unsafe to do such a cast here without checking if it actually is of type Damagable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, All ItemMeta implements Damageable https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java#172

Spigot is also doing the same in ItemStack#getDurability
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants