Fixed error message sometimes displaying when item is repaired by mending

This commit is contained in:
Jules 2024-07-13 03:00:06 -07:00
parent 600a53f931
commit 593abcb48e

View File

@ -88,7 +88,11 @@ public class DurabilityListener implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void mendEvent(PlayerItemMendEvent event) {
DurabilityItem durItem = new DurabilityItem(event.getPlayer(), event.getItem());
// Useless repair amount
if (event.getRepairAmount() <= 0) return;
final DurabilityItem durItem = new DurabilityItem(event.getPlayer(), event.getItem());
if (durItem.isValid()) {
event.getItem().setItemMeta(durItem.addDurability(event.getRepairAmount()).toItem().getItemMeta());
event.setCancelled(true);