Custom Durability Rework

Mending better support
This commit is contained in:
Indyuce 2020-01-18 22:12:16 +01:00
parent 7e2a1e8d8b
commit c1840631d9
2 changed files with 8 additions and 1 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.Indyuce</groupId>
<artifactId>MMOItems</artifactId>
<version>5.2.1</version>
<version>5.2.2</version>
<name>MMOItems</name>
<description>A great item solution for your RPG server.</description>

View File

@ -115,6 +115,13 @@ public class DurabilityItem {
*/
double ratio = (double) durability / maxDurability;
int damage = (int) ((1. - ratio) * item.getType().getMaxDurability());
/*
* make sure the vanilla bar displays at least 1 damage so the item can
* always be mended
*/
damage = Math.max(ratio < 1 ? 1 : 0, damage);
ItemMeta meta = item.getItemMeta();
((Damageable) meta).setDamage(damage);
item.setItemMeta(meta);