item browser always regenerates the item

This commit is contained in:
Jules 2021-12-16 13:37:07 +01:00
parent 838c0fed23
commit 270389cf8f
2 changed files with 5 additions and 10 deletions

View File

@ -248,10 +248,7 @@ public class ItemBrowser extends PluginInventory {
} else {
if (event.getAction() == InventoryAction.PICKUP_ALL) {
// this refreshes the item if it's unstackable
ItemStack generatedItem = (NBTItem.get(item).getBoolean("UNSTACKABLE")) ? MMOItems.plugin.getItem(type, id, playerData)
: removeLastLoreLines(NBTItem.get(item));
getPlayer().getInventory().addItem(generatedItem);
getPlayer().getInventory().addItem(MMOItems.plugin.getItem(type, id, playerData));
getPlayer().playSound(getPlayer().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 2);
}
@ -259,10 +256,4 @@ public class ItemBrowser extends PluginInventory {
new ItemEdition(getPlayer(), MMOItems.plugin.getTemplates().getTemplate(type, id)).open();
}
}
private ItemStack removeLastLoreLines(NBTItem item) {
List<Component> lore = item.getLoreComponents();
item.setLoreComponents(lore.subList(0, lore.size() - 3));
return item.toItem();
}
}

View File

@ -95,6 +95,10 @@ public class DurabilityListener implements Listener {
}
}
/**
* This method is for all the items which have 0 max durability
* i.E which are not breakable hence the {@link Material#getMaxDurability()} call
*/
private void handleVanillaDamage(ItemStack stack, Player player, EquipmentSlot slot, int damage) {
DurabilityItem item = new DurabilityItem(player, stack);