use of com.almuradev.almura.feature.claim.network.ClientboundClaimDataPacket in project Almura by AlmuraDev.
the class ServerClaimManager method sendUpdate.
protected void sendUpdate(final Player player, Claim claim) {
if (GriefDefender.getCore() != null) {
boolean isWorldOrilla = false;
boolean isWorldAsgard = false;
if (Sponge.getServer().getWorld("Orilla").isPresent()) {
isWorldOrilla = Sponge.getServer().getWorld("Orilla").get().getUniqueId() == claim.getWorldUniqueId();
}
if (Sponge.getServer().getWorld("Asgard").isPresent()) {
isWorldAsgard = Sponge.getServer().getWorld("Asgard").get().getUniqueId() == claim.getWorldUniqueId();
}
if (GriefDefender.getPermissionManager() != null) {
if (claim == null) {
// This is intended to catch when a delayed task is sent to this method and claim is purposely left null.
claim = GriefDefender.getCore().getClaimManager(player.getWorld().getUniqueId()).getClaimAt(player.getLocation().getPosition().toInt());
}
if (claim != null) {
boolean isClaim = true;
boolean hasWECUI = false;
boolean isForSale = false;
boolean showWarnings = true;
String claimName = "";
String claimGreeting = "";
String claimFarewell = "";
String dateCreated = "";
String claimOwner = "";
String claimType = "";
double claimEconBalance = 0.0;
double claimTaxRate = 0.0;
double claimTaxes = 0.0;
double claimBlockCost = 0.0;
double claimBlockSell = 0.0;
int claimSize = 0;
double claimTaxBalance = 0.0;
double claimSalePrice = 0.0;
final boolean isWilderness = claim.isWilderness();
final boolean isTownClaim = claim.isTown();
final boolean isAdminClaim = claim.isAdminClaim();
final boolean isBasicClaim = claim.isBasicClaim();
final boolean isSubdivision = claim.isSubdivision();
if (claim.getData() != null) {
showWarnings = claim.getData().allowDenyMessages();
}
if (player != null && GriefDefender.getCore().getWorldEditProvider() != null) {
hasWECUI = GriefDefender.getCore().getWorldEditProvider().hasCUISupport(player.getUniqueId());
}
if (claim.getOwnerName() != null) {
claimOwner = claim.getOwnerName();
}
if (claim.getData() != null && claim.getData().getGreeting().isPresent()) {
claimGreeting = ((TextComponent) claim.getData().getGreeting().get()).content();
}
if (claim.getData() != null && claim.getData().getFarewell().isPresent()) {
claimFarewell = ((TextComponent) claim.getData().getFarewell().get()).content();
}
if (claim.getDisplayName() == null) {
claimName = "Name Not Set";
} else {
claimName = claim.getDisplayName();
}
claimType = claim.getType().getName();
dateCreated = claim.getData().getDateCreated().toString();
if (claim.getData() != null) {
final EconomyService service = Sponge.getServiceManager().provide(EconomyService.class).orElse(null);
if (service != null && player != null) {
if (claim.getEconomyData().isForSale()) {
isForSale = true;
claimSalePrice = this.claimSalePrice(claim);
}
// Todo: implement the rest of the econ stuffz.
claimTaxRate = this.claimTaxRate(claim);
claimTaxes = this.claimTaxes(claim);
claimBlockCost = this.claimBlockCost(claim);
claimBlockSell = this.claimBlockSell(claim);
final Currency currency = service.getDefaultCurrency();
if (claim.getEconomyData() != null) {
claimTaxBalance = this.claimTaxBalance(claim);
UUID accountID = claim.getEconomyAccountId();
if (!(accountID == null)) {
final UniqueAccount claimAccount = service.getOrCreateAccount(accountID).orElse(null);
claimEconBalance = claimAccount.getBalance(currency).doubleValue();
}
}
}
}
if (!claim.isWilderness()) {
claimSize = claim.getArea();
}
// Set custom Claim Name for Protected Area's
if (isWorldAsgard || isWorldOrilla) {
claimName = "Server Protected Area";
}
if (player != null) {
if (debug)
System.out.println("Sending Claim packet update to: [" + player.getName() + "] for Claim: [" + claim.getDisplayName() + "] Wilderness: [" + isWilderness + "]");
this.network.sendTo(player, new ClientboundClaimDataPacket(isClaim, claimName, claimOwner, isWilderness, isTownClaim, isAdminClaim, isBasicClaim, isSubdivision, claimEconBalance, claimGreeting, claimFarewell, dateCreated, claimType, claimSize, isForSale, showWarnings, claimTaxRate, claimTaxes, claimBlockCost, claimBlockSell, hasWECUI, claimTaxBalance, claimSalePrice));
}
}
}
}
}
Aggregations