use of com.griefdefender.api.claim.Claim in project Almura by AlmuraDev.
the class ServerClaimManager method sendUpdateTo.
public void sendUpdateTo(final Player player, Claim claim, List<UUID> players, final boolean everyone, final String reason) {
if (!Sponge.getPluginManager().isLoaded("griefdefender")) {
// Check here to see if its loaded because in the deobfuscated environment I force load the ClaimManager classes for testing purposes.
return;
}
if ((player == null && players == null && !everyone) || (player == null && (players != null && players.isEmpty()) && !everyone)) {
if (debug) {
System.out.println("Claim sendUpdateTo canceled because no players listed and everyone was false, reason: " + reason);
}
return;
}
if (claim != null && debug)
System.out.println("Claim sendUpdateTo: [" + reason + "] everyone: [" + everyone + "] name: [" + claim.getDisplayName() + "] owner: [" + claim.getOwnerName() + "] wilderness: [" + claim.isWilderness() + "]");
// Lookup claim where player or players is standing
if (claim == null) {
if (player != null) {
claim = GriefDefender.getCore().getClaimManager(player.getWorld().getUniqueId()).getClaimAt(player.getLocation().getPosition().toInt());
}
if (players != null) {
for (UUID playerUUID : players) {
final Player finalPlayer = (Player) FMLServerHandler.instance().getServer().getPlayerList().getPlayerByUUID(playerUUID);
if (finalPlayer != null) {
Task.builder().delayTicks(10).execute(t -> this.sendUpdate(finalPlayer, null)).submit(this.container);
}
}
}
}
// Send to specific player
if (!everyone && player != null && claim != null) {
final Claim finalClaim = claim;
Task.builder().delayTicks(10).execute(t -> this.sendUpdate(player, finalClaim)).submit(this.container);
return;
}
// Send to everyone regardless of implied list from events.
if (everyone && player == null && claim != null) {
final Claim finalClaim = claim;
for (Player onlinePlayer : Sponge.getServer().getOnlinePlayers()) {
Task.builder().delayTicks(10).execute(t -> this.sendUpdate(onlinePlayer, finalClaim)).submit(this.container);
}
return;
}
// Send to the implied list of players when claim is handed into the method.
if (players != null && claim != null) {
final Claim finalClaim = claim;
for (UUID playerUUID : players) {
final Player finalPlayer = (Player) FMLServerHandler.instance().getServer().getPlayerList().getPlayerByUUID(playerUUID);
if (finalPlayer != null) {
Task.builder().delayTicks(10).execute(t -> this.sendUpdate(finalPlayer, finalClaim)).submit(this.container);
}
}
return;
}
// Send update to everyone on server regardless of location or claim
if (player == null && players == null && claim == null && everyone) {
for (final Player onlinePlayer : Sponge.getServer().getOnlinePlayers()) {
if (onlinePlayer != null && onlinePlayer.getWorld() != null) {
claim = GriefDefender.getCore().getClaimManager(onlinePlayer.getWorld().getUniqueId()).getClaimAt(onlinePlayer.getLocation().getPosition().toInt());
if (claim != null) {
final Claim finalClaim = claim;
Task.builder().delayTicks(10).execute(t -> this.sendUpdate(onlinePlayer, finalClaim)).submit(this.container);
}
}
}
return;
}
}
use of com.griefdefender.api.claim.Claim in project Almura by AlmuraDev.
the class ServerClaimManager method saveChanges.
public void saveChanges(final Player player, final String claimName, final String claimGreeting, final String claimFarewell, final double x, final double y, final double z, final String worldName) {
final Claim claim = this.claimLookup(player, x, y, z, worldName);
if (claim != null) {
final boolean isOwner = (claim.getOwnerUniqueId().equals(player.getUniqueId()));
final boolean isAdmin = player.hasPermission(adminPermission);
if (isOwner || isAdmin) {
claim.getData().setDisplayName(Component.text(claimName));
claim.getData().setGreeting(Component.text(claimGreeting));
claim.getData().setFarewell(Component.text(claimFarewell));
claim.getData().save();
this.sendUpdateTo(player, claim, claim.getPlayers(), false, "saveChanges");
this.serverNotificationManager.sendPopupNotification(player, notificationTitle, Text.of("Changed Saved!"), 5);
} else {
this.serverNotificationManager.sendPopupNotification(player, notificationTitle, Text.of("Insufficient Permissions!"), 5);
}
} else {
this.serverNotificationManager.sendPopupNotification(player, notificationTitle, Text.of("Unable to lookup Claim, changed not saved!"), 5);
}
}
use of com.griefdefender.api.claim.Claim in project Almura by AlmuraDev.
the class ServerboundClaimGuiAbandonRequestPacketHandler method handleMessage.
@Override
public void handleMessage(final ServerboundClaimGuiAbandonRequestPacket 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.abandonClaim(claim);
this.notificationManager.sendPopupNotification(player, ServerClaimManager.notificationTitle, Text.of("Claim Abandoned!"), 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 ServerboundClaimGuiForSaleRequestPacketHandler method handleMessage.
@Override
public void handleMessage(final ServerboundClaimGuiForSaleRequestPacket 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.setForSale(claim, message.setForSale, message.salePrice);
this.serverClaimManager.sendUpdateTo(player, claim, claim.getPlayers(), true, "requestClaimForSalePacket");
if (message.setForSale) {
this.notificationManager.sendPopupNotification(player, ServerClaimManager.notificationTitle, Text.of("Claim Listed For Sale!"), 5);
} else {
this.notificationManager.sendPopupNotification(player, ServerClaimManager.notificationTitle, Text.of("Claim Delisted!"), 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 ServerboundClaimGuiToggleDenyMessagesRequestPacketHandler method handleMessage.
@Override
public void handleMessage(final ServerboundClaimGuiToggleDenyMessagesRequestPacket 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.toggleClaimDenyMessages(claim, message.value);
this.serverClaimManager.sendUpdateTo(player, claim, null, true, "claimGuiToggleDenyMessage");
if (message.value) {
this.notificationManager.sendPopupNotification(player, ServerClaimManager.notificationTitle, Text.of("Deny Messages Enabled!"), 5);
} else {
this.notificationManager.sendPopupNotification(player, ServerClaimManager.notificationTitle, Text.of("Deny Messages Disabled!"), 5);
}
} else {
this.notificationManager.sendPopupNotification(player, ServerClaimManager.notificationTitle, Text.of("Insufficient Permissions!"), 5);
}
}
}
}
Aggregations