use of org.spongepowered.api.item.inventory.EmptyInventory in project LanternServer by LanternPowered.
the class AbstractEquipable method equip.
@Override
default boolean equip(EquipmentType type, @Nullable ItemStack equipment) {
checkNotNull(type, "type");
final Inventory inventory = getInventory().query(Holder.EQUIPMENT_INVENTORY_OPERATION);
if (inventory instanceof EmptyInventory) {
return false;
}
final AbstractSlot slot = (AbstractSlot) inventory.<IEquipmentInventory>first().getSlot(type).orElse(null);
if (slot == null) {
return false;
}
final InventoryTransactionResult result = slot.set(equipment);
return result.getType().equals(InventoryTransactionResult.Type.SUCCESS);
}
use of org.spongepowered.api.item.inventory.EmptyInventory in project LanternServer by LanternPowered.
the class AbstractEquipable method getEquipped.
@Override
default Optional<ItemStack> getEquipped(EquipmentType type) {
checkNotNull(type, "type");
final Inventory inventory = getInventory().query(Holder.EQUIPMENT_INVENTORY_OPERATION);
if (inventory instanceof EmptyInventory) {
return Optional.empty();
}
return inventory.peek();
}
use of org.spongepowered.api.item.inventory.EmptyInventory in project LanternServer by LanternPowered.
the class AbstractEquipable method canEquip.
@Override
default boolean canEquip(EquipmentType type, @Nullable ItemStack equipment) {
checkNotNull(type, "type");
final Inventory inventory = getInventory().query(Holder.EQUIPMENT_INVENTORY_OPERATION);
if (inventory instanceof EmptyInventory) {
return false;
}
final AbstractSlot slot = (AbstractSlot) inventory.<IEquipmentInventory>first().getSlot(type).orElse(null);
return slot != null && (equipment == null || slot.isValidItem(equipment));
}
Aggregations