use of net.minecraft.server.MinecraftServer in project Almura by AlmuraDev.
the class ServerboundGuideOpenRequestPacketHandler method handleMessage.
@Override
public void handleMessage(ServerboundGuideOpenRequestPacket message, RemoteConnection connection, Platform.Type side) {
if (side.isServer() && connection instanceof PlayerConnection && Sponge.isServerAvailable()) {
final MinecraftServer server = (MinecraftServer) Sponge.getServer();
if (PacketUtil.checkThreadAndEnqueue(server, message, this, connection, side)) {
final Player player = ((PlayerConnection) connection).getPlayer();
if (!player.hasPermission("almura.guide.open") || player.hasPermission("almura.singleplayer") && MalisisCore.isObfEnv) {
player.sendMessage(Text.of(TextColors.WHITE, "Access denied, missing permission: ", TextColors.AQUA, "almura.guide.open", TextColors.WHITE, "."));
return;
}
// Open the GUI
this.network.sendTo(player, new ClientboundGuideOpenResponsePacket(GuideOpenType.PLAYER_INVOKED_KEYBIND, player.hasPermission("almura.guide.add"), player.hasPermission("almura.guide.remove"), player.hasPermission("almura.guide.modify"), true));
final Map<String, Page> pagesToSend = this.manager.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 switchToPageEntry = playerListings.stream().findFirst().orElse(null);
// Send the list of pages
this.network.sendTo(player, new ClientboundPageListingsPacket(playerListings, switchToPageEntry == null ? null : switchToPageEntry.getId()));
}
}
}
}
use of net.minecraft.server.MinecraftServer in project Almura by AlmuraDev.
the class ServerboundMembershipGuiOpenRequestPacketHandler method handleMessage.
@Override
public void handleMessage(ServerboundMembershipGuiOpenRequestPacket message, RemoteConnection connection, Platform.Type side) {
if (side.isServer() && connection instanceof PlayerConnection && Sponge.isServerAvailable()) {
final MinecraftServer server = (MinecraftServer) Sponge.getServer();
if (PacketUtil.checkThreadAndEnqueue(server, message, this, connection, side)) {
final PlayerConnection playerConnection = (PlayerConnection) connection;
final Player player = playerConnection.getPlayer();
membershipHandler.requestClientGui(player);
}
}
}
use of net.minecraft.server.MinecraftServer in project Almura by AlmuraDev.
the class ServerboundModifyItemsPacketHandler method handleMessage.
@Override
public void handleMessage(final ServerboundModifyItemsPacket message, final RemoteConnection connection, final Platform.Type side) {
if (side.isServer() && connection instanceof PlayerConnection && PacketUtil.checkThreadAndEnqueue((MinecraftServer) Sponge.getServer(), message, this, connection, side)) {
checkNotNull(message.type);
final Player player = ((PlayerConnection) connection).getPlayer();
switch(message.type) {
case SELLING:
this.storeManager.handleModifySellingItems(player, message.id, message.candidates);
break;
case BUYING:
this.storeManager.handleModifyBuyingItems(player, message.id, message.candidates);
break;
default:
throw new UnsupportedOperationException(message.type + " is not supported yet!");
}
}
}
use of net.minecraft.server.MinecraftServer in project Almura by AlmuraDev.
the class ServerboundModifyTitlePacketHandler method handleMessage.
@Override
public void handleMessage(final ServerboundModifyTitlePacket message, final RemoteConnection connection, final Platform.Type side) {
if (side.isServer() && connection instanceof PlayerConnection && PacketUtil.checkThreadAndEnqueue((MinecraftServer) Sponge.getServer(), message, this, connection, side)) {
checkNotNull(message.type);
final Player player = ((PlayerConnection) connection).getPlayer();
if (!player.hasPermission(Almura.ID + ".title.change")) {
this.notificationManager.sendPopupNotification(player, Text.of("Title Manager"), Text.of("Insufficient Permissions to change Title!"), 2);
return;
}
switch(message.type) {
case ADD:
this.titleManager.addTitle(player, message.id, message.permission, message.content, message.isHidden);
break;
case MODIFY:
this.titleManager.modifyTitle(player, message.id, message.permission, message.content, message.isHidden);
break;
case DELETE:
this.titleManager.deleteTitle(player, message.id);
}
}
}
use of net.minecraft.server.MinecraftServer in project Almura by AlmuraDev.
the class ServerboundModifyStorePacketHandler method handleMessage.
@Override
public void handleMessage(final ServerboundModifyStorePacket message, final RemoteConnection connection, final Platform.Type side) {
if (side.isServer() && connection instanceof PlayerConnection && PacketUtil.checkThreadAndEnqueue((MinecraftServer) Sponge.getServer(), message, this, connection, side)) {
checkNotNull(message.type);
final Player player = ((PlayerConnection) connection).getPlayer();
switch(message.type) {
case ADD:
this.storeManager.handleStoreAdd(player, message.id, message.name, message.permission, message.isHidden);
break;
case MODIFY:
this.storeManager.handleStoreModify(player, message.id, message.name, message.permission, message.isHidden);
break;
case DELETE:
this.storeManager.handleStoreDelete(player, message.id);
break;
default:
throw new UnsupportedOperationException(message.type + " is not supported yet!");
}
}
}
Aggregations