Search in sources :

Example 1 with ClientboundClaimGuiResponsePacket

use of com.almuradev.almura.feature.claim.network.ClientboundClaimGuiResponsePacket in project Almura by AlmuraDev.

the class ServerClaimManager method openClientGUI.

public void openClientGUI(final Player player) {
    // GD won't start completely inDev, so I've added this to allow me to see the gui.
    if (SpongeImplHooks.isDeobfuscatedEnvironment()) {
        this.network.sendTo(player, new ClientboundClaimGuiResponsePacket(true, true, true));
    } else {
        final Claim claim = GriefDefender.getCore().getClaimManager(player.getWorld().getUniqueId()).getClaimAt(player.getLocation().getBlockPosition());
        if (claim != null) {
            sendUpdate(player, claim);
        }
        if (!Sponge.getPluginManager().isLoaded("griefdefender")) {
            this.serverNotificationManager.sendPopupNotification(player, notificationTitle, Text.of("GriefDefender not detected!"), 2);
            return;
        }
        if (!player.hasPermission(Almura.ID + ".claim.base")) {
            this.serverNotificationManager.sendPopupNotification(player, notificationTitle, Text.of("Insufficient Permissions to Manage Claim!"), 2);
            return;
        }
        if (claim != null) {
            final boolean isOwner = (claim.getOwnerUniqueId().equals(player.getUniqueId()));
            final boolean isTrusted = claim.isUserTrusted(player.getUniqueId(), TrustTypes.MANAGER);
            final boolean isAdmin = player.hasPermission(adminPermission);
            if (!isAdmin && claim.isWilderness()) {
                this.serverNotificationManager.sendPopupNotification(player, notificationTitle, Text.of("Insufficient permissions to open Claim Manager in Wilderness"), 5);
            } else {
                this.network.sendTo(player, new ClientboundClaimGuiResponsePacket(isOwner, isTrusted, isAdmin));
            }
        }
    }
}
Also used : Claim(com.griefdefender.api.claim.Claim) ClientboundClaimGuiResponsePacket(com.almuradev.almura.feature.claim.network.ClientboundClaimGuiResponsePacket)

Aggregations

ClientboundClaimGuiResponsePacket (com.almuradev.almura.feature.claim.network.ClientboundClaimGuiResponsePacket)1 Claim (com.griefdefender.api.claim.Claim)1