use of com.griefdefender.api.GriefDefender 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;
}
}
Aggregations