!Removed debug message, improved inv calculation with ornaments

This commit is contained in:
Indyuce 2019-10-21 12:15:20 +02:00
parent fda2220c7c
commit d9def4d4ea
2 changed files with 13 additions and 10 deletions

View File

@ -20,15 +20,13 @@ public class DefaultPlayerInventory implements PlayerInventory {
for (ItemStack armor : player.getInventory().getArmorContents())
list.add(new EquippedItem(armor, EquipmentSlot.ARMOR));
if(MMOItems.plugin.getLanguage().iterateWholeInventory)
if (MMOItems.plugin.getLanguage().iterateWholeInventory)
for (ItemStack item : player.getInventory().getContents()) {
if(item != null && NBTItem.get(item).hasType())
if(NBTItem.get(item).getType().getEquipmentType() == EquipmentSlot.ANY) {
MMOItems.plugin.getLogger().info("Found: " + item.getType() + " with custom name: " + item.getItemMeta().getDisplayName());
list.add(new EquippedItem(item, EquipmentSlot.ANY));
}
NBTItem nbtItem;
if (item != null && (nbtItem = MMOItems.plugin.getNMS().getNBTItem(item)).hasType() && nbtItem.getType().getEquipmentType() == EquipmentSlot.ANY)
list.add(new EquippedItem(nbtItem, EquipmentSlot.ANY));
}
return list;
}
}

View File

@ -14,20 +14,25 @@ public interface PlayerInventory {
public List<EquippedItem> getInventory(Player player);
public class EquippedItem {
private final ItemStack item;
private final NBTItem item;
private final EquipmentSlot slot;
public EquippedItem(ItemStack item, EquipmentSlot slot) {
this(MMOItems.plugin.getNMS().getNBTItem(item), slot);
}
public EquippedItem(NBTItem item, EquipmentSlot slot) {
this.item = item;
this.slot = slot;
}
public NBTItem newNBTItem() {
return MMOItems.plugin.getNMS().getNBTItem(item);
return item;
}
public boolean matches(Type type) {
return slot == EquipmentSlot.ANY || (type.getEquipmentType() == EquipmentSlot.BOTH_HANDS ? slot.isHand() : slot == EquipmentSlot.BOTH_HANDS ? type.getEquipmentType().isHand() : slot == type.getEquipmentType());
return slot == EquipmentSlot.ANY
|| (type.getEquipmentType() == EquipmentSlot.BOTH_HANDS ? slot.isHand() : slot == EquipmentSlot.BOTH_HANDS ? type.getEquipmentType().isHand() : slot == type.getEquipmentType());
}
}
}