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);
}
}
}
}
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);
// }
}
}
}
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;
}
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));
}
}
}
}
Aggregations