Code Optimizations
This commit is contained in:
@@ -26,7 +26,6 @@ public class CmdAutoClaim extends FCommand {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.claim_auto);
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.AUTOCLAIM)
|
||||
@@ -39,13 +38,9 @@ public class CmdAutoClaim extends FCommand {
|
||||
public void perform(CommandContext context) {
|
||||
Faction forFaction = context.argAsFaction(0, context.faction);
|
||||
|
||||
if (forFaction != context.fPlayer.getFaction()) {
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (forFaction != context.fPlayer.getFaction() && !context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (forFaction == null || forFaction == context.fPlayer.getAutoClaimFor()) {
|
||||
|
||||
@@ -41,13 +41,9 @@ public class CmdClaim extends FCommand {
|
||||
int radius = context.argAsInt(0, 1); // Default to 1
|
||||
final Faction forFaction = context.argAsFaction(1, context.faction); // Default to own
|
||||
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (!(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER)) {
|
||||
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!context.fPlayer.isAdminBypassing() && !(context.fPlayer.getFaction().equals(forFaction) && context.fPlayer.getRole() == Role.LEADER) && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,12 +86,11 @@ public class CmdClaim extends FCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
if (FactionsPlugin.cachedRadiusClaim) {
|
||||
if (successfulClaims > 0) {
|
||||
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_RADIUS_CLAIM, context.fPlayer.describeTo(f, true), String.valueOf(successfulClaims), context.fPlayer.getPlayer().getLocation().getChunk().getX(), context.fPlayer.getPlayer().getLocation().getChunk().getZ()));
|
||||
stop();
|
||||
}
|
||||
if (FactionsPlugin.cachedRadiusClaim && successfulClaims > 0) {
|
||||
context.fPlayer.getFaction().getFPlayersWhereOnline(true).forEach(f -> f.msg(TL.CLAIM_RADIUS_CLAIM, context.fPlayer.describeTo(f, true), String.valueOf(successfulClaims), context.fPlayer.getPlayer().getLocation().getChunk().getX(), context.fPlayer.getPlayer().getLocation().getChunk().getZ()));
|
||||
stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,15 +68,10 @@ public class CmdClaimLine extends FCommand {
|
||||
}
|
||||
|
||||
final Faction forFaction = context.argAsFaction(2, context.faction);
|
||||
Faction at = Board.getInstance().getFactionAt(new FLocation(context.fPlayer.getPlayer().getLocation()));
|
||||
|
||||
if (forFaction != context.fPlayer.getFaction()) {
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
if (forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
if (forFaction != context.fPlayer.getFaction() && !context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Location location = context.player.getLocation();
|
||||
@@ -85,13 +80,11 @@ public class CmdClaimLine extends FCommand {
|
||||
int claims = 0;
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
if (FactionsPlugin.cachedRadiusClaim && context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) {
|
||||
claims++;
|
||||
} else {
|
||||
if (!FactionsPlugin.cachedRadiusClaim || !context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), false)) {
|
||||
context.fPlayer.attemptClaim(forFaction, location, true);
|
||||
claims++;
|
||||
}
|
||||
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
|
||||
claims++;
|
||||
location = location.add(blockFace.getModX() * 16D, 0, blockFace.getModZ() * 16D);
|
||||
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(","));
|
||||
}
|
||||
int cachedClaims = claims;
|
||||
|
||||
Reference in New Issue
Block a user