Check System Added and Massive Reformat
This commit is contained in:
@@ -14,172 +14,172 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class CmdUnclaim extends FCommand {
|
||||
|
||||
public CmdUnclaim() {
|
||||
this.aliases.add("unclaim");
|
||||
this.aliases.add("declaim");
|
||||
public CmdUnclaim() {
|
||||
this.aliases.add("unclaim");
|
||||
this.aliases.add("declaim");
|
||||
|
||||
this.optionalArgs.put("radius", "1");
|
||||
this.optionalArgs.put("radius", "1");
|
||||
|
||||
this.permission = Permission.UNCLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
this.permission = Permission.UNCLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
// Read and validate input
|
||||
int radius = this.argAsInt(0, 1); // Default to 1
|
||||
@Override
|
||||
public void perform() {
|
||||
// Read and validate input
|
||||
int radius = this.argAsInt(0, 1); // Default to 1
|
||||
|
||||
if (!fme.isAdminBypassing()) {
|
||||
Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY);
|
||||
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
||||
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage faction territory");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!fme.isAdminBypassing()) {
|
||||
Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY);
|
||||
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
||||
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage faction territory");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (radius < 1) {
|
||||
msg(TL.COMMAND_CLAIM_INVALIDRADIUS);
|
||||
return;
|
||||
}
|
||||
if (radius < 1) {
|
||||
msg(TL.COMMAND_CLAIM_INVALIDRADIUS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (radius < 2) {
|
||||
// single chunk
|
||||
unClaim(new FLocation(me));
|
||||
} else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
|
||||
msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
if (radius < 2) {
|
||||
// single chunk
|
||||
unClaim(new FLocation(me));
|
||||
} else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
|
||||
msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
new SpiralTask(new FLocation(me), radius) {
|
||||
private final int limit = Conf.radiusClaimFailureLimit - 1;
|
||||
private int failCount = 0;
|
||||
new SpiralTask(new FLocation(me), radius) {
|
||||
private final int limit = Conf.radiusClaimFailureLimit - 1;
|
||||
private int failCount = 0;
|
||||
|
||||
@Override
|
||||
public boolean work() {
|
||||
boolean success = unClaim(this.currentFLocation());
|
||||
if (success) {
|
||||
failCount = 0;
|
||||
} else if (failCount++ >= limit) {
|
||||
this.stop();
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean work() {
|
||||
boolean success = unClaim(this.currentFLocation());
|
||||
if (success) {
|
||||
failCount = 0;
|
||||
} else if (failCount++ >= limit) {
|
||||
this.stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private boolean unClaim(FLocation target) {
|
||||
Faction targetFaction = Board.getInstance().getFactionAt(target);
|
||||
if (targetFaction.isSafeZone()) {
|
||||
if (Permission.MANAGE_SAFE_ZONE.has(sender)) {
|
||||
Board.getInstance().removeAt(target);
|
||||
msg(TL.COMMAND_UNCLAIM_SAFEZONE_SUCCESS);
|
||||
private boolean unClaim(FLocation target) {
|
||||
Faction targetFaction = Board.getInstance().getFactionAt(target);
|
||||
if (targetFaction.isSafeZone()) {
|
||||
if (Permission.MANAGE_SAFE_ZONE.has(sender)) {
|
||||
Board.getInstance().removeAt(target);
|
||||
msg(TL.COMMAND_UNCLAIM_SAFEZONE_SUCCESS);
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
msg(TL.COMMAND_UNCLAIM_SAFEZONE_NOPERM);
|
||||
return false;
|
||||
}
|
||||
} else if (targetFaction.isWarZone()) {
|
||||
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
||||
Board.getInstance().removeAt(target);
|
||||
msg(TL.COMMAND_UNCLAIM_WARZONE_SUCCESS);
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
msg(TL.COMMAND_UNCLAIM_SAFEZONE_NOPERM);
|
||||
return false;
|
||||
}
|
||||
} else if (targetFaction.isWarZone()) {
|
||||
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
||||
Board.getInstance().removeAt(target);
|
||||
msg(TL.COMMAND_UNCLAIM_WARZONE_SUCCESS);
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
msg(TL.COMMAND_UNCLAIM_WARZONE_NOPERM);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
msg(TL.COMMAND_UNCLAIM_WARZONE_NOPERM);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (fme.isAdminBypassing()) {
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme);
|
||||
Bukkit.getScheduler().runTask(P.p, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimEvent));
|
||||
if (unclaimEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
if (fme.isAdminBypassing()) {
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme);
|
||||
Bukkit.getScheduler().runTask(P.p, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimEvent));
|
||||
if (unclaimEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Board.getInstance().removeAt(target);
|
||||
Board.getInstance().removeAt(target);
|
||||
|
||||
targetFaction.msg(TL.COMMAND_UNCLAIM_UNCLAIMED, fme.describeTo(targetFaction, true));
|
||||
msg(TL.COMMAND_UNCLAIM_UNCLAIMS);
|
||||
targetFaction.msg(TL.COMMAND_UNCLAIM_UNCLAIMED, fme.describeTo(targetFaction, true));
|
||||
msg(TL.COMMAND_UNCLAIM_UNCLAIMS);
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (targetFaction.getAccess(fme, PermissableAction.TERRITORY) == Access.DENY) {
|
||||
return false;
|
||||
}
|
||||
if (targetFaction.getAccess(fme, PermissableAction.TERRITORY) == Access.DENY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!assertHasFaction()) {
|
||||
return false;
|
||||
}
|
||||
if (!assertHasFaction()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (targetFaction.getAccess(fme, PermissableAction.TERRITORY) != Access.ALLOW && !assertMinRole(Role.MODERATOR)) {
|
||||
return false;
|
||||
}
|
||||
if (targetFaction.getAccess(fme, PermissableAction.TERRITORY) != Access.ALLOW && !assertMinRole(Role.MODERATOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (myFaction != targetFaction) {
|
||||
msg(TL.COMMAND_UNCLAIM_WRONGFACTION);
|
||||
return false;
|
||||
}
|
||||
if (myFaction != targetFaction) {
|
||||
msg(TL.COMMAND_UNCLAIM_WRONGFACTION);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||
if (unclaimEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||
if (unclaimEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Econ.shouldBeUsed()) {
|
||||
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
||||
if (Econ.shouldBeUsed()) {
|
||||
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||
if (!Econ.modifyMoney(myFaction, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Econ.modifyMoney(fme, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||
if (!Econ.modifyMoney(myFaction, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Econ.modifyMoney(fme, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Board.getInstance().removeAt(target);
|
||||
myFaction.msg(TL.COMMAND_UNCLAIM_FACTIONUNCLAIMED, fme.describeTo(myFaction, true));
|
||||
Board.getInstance().removeAt(target);
|
||||
myFaction.msg(TL.COMMAND_UNCLAIM_FACTIONUNCLAIMED, fme.describeTo(myFaction, true));
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_UNCLAIM_DESCRIPTION;
|
||||
}
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_UNCLAIM_DESCRIPTION;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user