Search in sources :

Example 6 with Claim

use of com.griefdefender.api.claim.Claim in project Almura by AlmuraDev.

the class ServerboundClaimGuiSetSpawnRequestPacketHandler method handleMessage.

@Override
public void handleMessage(final ServerboundClaimGuiSetSpawnRequestPacket message, final RemoteConnection connection, final Platform.Type side) {
    if (side.isServer() && connection instanceof PlayerConnection && PacketUtil.checkThreadAndEnqueue((MinecraftServer) Sponge.getServer(), message, this, connection, side)) {
        final Player player = ((PlayerConnection) connection).getPlayer();
        final Claim claim = serverClaimManager.claimLookup(player, message.x, message.y, message.z, message.worldName);
        if (claim != null) {
            final boolean isOwner = (claim.getOwnerUniqueId().equals(player.getUniqueId()));
            final boolean isAdmin = player.hasPermission(ServerClaimManager.adminPermission);
            if (isOwner || isAdmin) {
                this.serverClaimManager.setSpawnLocation(player, claim);
                this.serverClaimManager.sendUpdateTo(player, claim, null, true, "setClaimSpawnGUIPacket");
                this.notificationManager.sendPopupNotification(player, ServerClaimManager.notificationTitle, Text.of("Spawn point set!"), 5);
            } else {
                this.notificationManager.sendPopupNotification(player, ServerClaimManager.notificationTitle, Text.of("Insufficient Permissions!"), 5);
            }
        }
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) PlayerConnection(org.spongepowered.api.network.PlayerConnection) Claim(com.griefdefender.api.claim.Claim) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 7 with Claim

use of com.griefdefender.api.claim.Claim in project Almura by AlmuraDev.

the class ServerboundClaimGuiToggleVisualsRequestPacketHandler method handleMessage.

@Override
public void handleMessage(final ServerboundClaimGuiToggleVisualsRequestPacket message, final RemoteConnection connection, final Platform.Type side) {
    if (side.isServer() && connection instanceof PlayerConnection && PacketUtil.checkThreadAndEnqueue((MinecraftServer) Sponge.getServer(), message, this, connection, side)) {
        final Player player = ((PlayerConnection) connection).getPlayer();
        final Claim claim = serverClaimManager.claimLookup(player, message.x, message.y, message.z, message.worldName);
        if (claim != null) {
            // if GP is loaded, claim should never be null.
            final boolean isOwner = (claim.getOwnerUniqueId().equals(player.getUniqueId()));
            final boolean isAdmin = player.hasPermission(ServerClaimManager.adminPermission);
            // if (isOwner || isAdmin) {
            this.serverClaimManager.toggleVisuals(player, claim, message.value);
            this.serverClaimManager.sendUpdateTo(player, claim, null, false, "claimGuiToggleVisuals");
        // } else {
        // this.notificationManager.sendPopupNotification(player, ServerClaimManager.notificationTitle, Text.of("Insufficient Permissions!"), 5);
        // }
        }
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) PlayerConnection(org.spongepowered.api.network.PlayerConnection) Claim(com.griefdefender.api.claim.Claim) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 8 with Claim

use of com.griefdefender.api.claim.Claim in project Almura by AlmuraDev.

the class ServerClaimManager method claimLookup.

public Claim claimLookup(final Player player, final double x, final double y, final double z, final String worldName) {
    final World world = Sponge.getServer().getWorld(worldName).orElse(null);
    if (world == null) {
        this.serverNotificationManager.sendPopupNotification(player, notificationTitle, Text.of("Unable to find world, changes not saved!"), 5);
        return null;
    }
    final Location<World> location = new Location<>(world, x, y, z);
    if (location == null) {
        this.serverNotificationManager.sendPopupNotification(player, notificationTitle, Text.of("Invalid location sent to server.  Changes not saved!"), 5);
    } else {
        final Claim claim = GriefDefender.getCore().getClaimManager(player.getWorld().getUniqueId()).getClaimAt(location.getBlockPosition());
        if (claim != null) {
            return claim;
        }
    }
    return null;
}
Also used : World(org.spongepowered.api.world.World) Claim(com.griefdefender.api.claim.Claim) Location(org.spongepowered.api.world.Location)

Example 9 with Claim

use of com.griefdefender.api.claim.Claim 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

Claim (com.griefdefender.api.claim.Claim)9 Player (org.spongepowered.api.entity.living.player.Player)6 MinecraftServer (net.minecraft.server.MinecraftServer)5 PlayerConnection (org.spongepowered.api.network.PlayerConnection)5 ClientboundClaimGuiResponsePacket (com.almuradev.almura.feature.claim.network.ClientboundClaimGuiResponsePacket)2 Location (org.spongepowered.api.world.Location)2 World (org.spongepowered.api.world.World)2 Almura (com.almuradev.almura.Almura)1 ClientboundClaimDataPacket (com.almuradev.almura.feature.claim.network.ClientboundClaimDataPacket)1 ServerNotificationManager (com.almuradev.almura.feature.notification.ServerNotificationManager)1 NetworkConfig (com.almuradev.almura.shared.network.NetworkConfig)1 Witness (com.almuradev.core.event.Witness)1 GriefDefender (com.griefdefender.api.GriefDefender)1 TrustTypes (com.griefdefender.api.claim.TrustTypes)1 PlayerData (com.griefdefender.api.data.PlayerData)1 com.griefdefender.api.event (com.griefdefender.api.event)1 Instant (java.time.Instant)1 List (java.util.List)1 UUID (java.util.UUID)1 Inject (javax.inject.Inject)1