use of com.almuradev.almura.feature.guide.network.GuideOpenType in project Almura by AlmuraDev.
the class ServerPageManager method openGuideForPlayer.
public void openGuideForPlayer(Player player, GuideOpenType type, String pageName) {
this.network.sendTo(player, new ClientboundGuideOpenResponsePacket(// Specifies what called the open request.
type, player.hasPermission("almura.guide.add"), player.hasPermission("almura.guide.remove"), player.hasPermission("almura.guide.modify"), false));
final Map<String, Page> pagesToSend = this.getAvailablePagesFor(player);
if (pagesToSend.size() > 0) {
final List<PageListEntry> playerListings = pagesToSend.entrySet().stream().map(entry -> new PageListEntry(entry.getKey(), entry.getValue().getName())).collect(Collectors.toList());
final PageListEntry allPages = playerListings.stream().findFirst().orElse(null);
if (pageName != null) {
final Page page = getPage(pageName).orElse(null);
this.network.sendTo(player, new ClientboundPageListingsPacket(playerListings, page == null ? allPages.getId() : page.getId()));
} else {
this.network.sendTo(player, new ClientboundPageListingsPacket(playerListings, allPages == null ? null : allPages.getId()));
}
}
}
Aggregations