use of org.lanternpowered.server.inventory.AbstractSlot in project LanternServer by LanternPowered.
the class HandlerPlayInEditBook method handle.
@Override
public void handle(NetworkContext context, MessagePlayInEditBook message) {
final LanternPlayer player = context.getSession().getPlayer();
final AbstractSlot slot = player.getInventory().getHotbar().getSelectedSlot();
final ItemStack itemStack = slot.peek().orElse(null);
if (itemStack != null && itemStack.getType() == ItemTypes.WRITABLE_BOOK) {
itemStack.offer(Keys.BOOK_PAGES, message.getPages().stream().map(Text::of).collect(Collectors.toList()));
slot.set(itemStack);
}
}
Aggregations