use of org.spongepowered.api.service.pagination.PaginationService in project Skree by Skelril.
the class PactScroll method onBlockInteract.
@Listener
public void onBlockInteract(InteractBlockEvent.Secondary.MainHand event, @Root Player player) {
Optional<ItemStack> optItemStack = player.getItemInHand(HandTypes.MAIN_HAND);
if (!optItemStack.isPresent()) {
return;
}
ItemStack itemStack = optItemStack.get();
if (itemStack.getItem() != this) {
return;
}
UserStorageService userService = Sponge.getServiceManager().provideUnchecked(UserStorageService.class);
PaginationService pagination = Sponge.getServiceManager().provideUnchecked(PaginationService.class);
List<Text> result = pactMap.getOrDefault(player.getUniqueId(), new ArrayList<>()).stream().map(userService::get).filter(Optional::isPresent).map(Optional::get).sorted((a, b) -> a.getName().compareToIgnoreCase(b.getName())).map(a -> Text.of((a.isOnline() ? TextColors.GREEN : TextColors.RED), a.getName())).collect(Collectors.toList());
pagination.builder().contents(result).title(Text.of(TextColors.GOLD, "Pact Members")).padding(Text.of(" ")).sendTo(player);
event.setUseBlockResult(Tristate.FALSE);
}
Aggregations