use of org.lanternpowered.server.inventory.AbstractOrderedInventory in project LanternServer by LanternPowered.
the class LanternPlayer method openInventory.
@Override
public Optional<Container> openInventory(Inventory inventory) {
checkNotNull(inventory, "inventory");
final LanternContainer container;
if (inventory instanceof LanternContainer) {
// You cannot open a player inventory container
if (inventory instanceof PlayerInventoryContainer) {
return Optional.empty();
}
container = (LanternContainer) inventory;
} else {
inventory.getInventoryProperty(GuiIdProperty.class).map(GuiIdProperty::getValue).orElseThrow(() -> new UnsupportedOperationException("Unsupported inventory type: " + inventory.getArchetype().getId()));
container = LanternContainer.construct(this.inventory, (AbstractOrderedInventory) inventory);
}
if (this.containerSession.setOpenContainer(container)) {
return Optional.of(container);
}
return Optional.empty();
}
Aggregations