Merging branches 1 new mission type
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdAutoClaim extends FCommand {
|
||||
@@ -15,39 +19,45 @@ public class CmdAutoClaim extends FCommand {
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.permission = Permission.AUTOCLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.AUTOCLAIM)
|
||||
.playerOnly()
|
||||
.withAction(PermissableAction.TERRITORY)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
Faction forFaction = this.argAsFaction(0, myFaction);
|
||||
if (forFaction == null || forFaction == fme.getAutoClaimFor()) {
|
||||
fme.setAutoClaimFor(null);
|
||||
msg(TL.COMMAND_AUTOCLAIM_DISABLED);
|
||||
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 == null || forFaction == context.fPlayer.getAutoClaimFor()) {
|
||||
context.fPlayer.setAutoClaimFor(null);
|
||||
context.msg(TL.COMMAND_AUTOCLAIM_DISABLED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!fme.canClaimForFaction(forFaction)) {
|
||||
if (myFaction == forFaction) {
|
||||
msg(TL.COMMAND_AUTOCLAIM_REQUIREDRANK, Role.MODERATOR.getTranslation());
|
||||
if (!context.fPlayer.canClaimForFaction(forFaction)) {
|
||||
if (context.faction == forFaction) {
|
||||
context.msg(TL.COMMAND_AUTOCLAIM_REQUIREDRANK, Role.MODERATOR.getTranslation());
|
||||
} else {
|
||||
msg(TL.COMMAND_AUTOCLAIM_OTHERFACTION, forFaction.describeTo(fme));
|
||||
context.msg(TL.COMMAND_AUTOCLAIM_OTHERFACTION, forFaction.describeTo(context.fPlayer));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fme.setAutoClaimFor(forFaction);
|
||||
context.fPlayer.setAutoClaimFor(forFaction);
|
||||
|
||||
msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(fme));
|
||||
fme.attemptClaim(forFaction, me.getLocation(), true);
|
||||
context.msg(TL.COMMAND_AUTOCLAIM_ENABLED, forFaction.describeTo(context.fPlayer));
|
||||
context.fPlayer.attemptClaim(forFaction, context.fPlayer.getPlayer().getLocation(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.massivecraft.factions.cmd.claim;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
@@ -22,59 +24,56 @@ public class CmdClaim extends FCommand {
|
||||
this.optionalArgs.put("radius", "1");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.permission = Permission.CLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CLAIM)
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
// Read and validate input
|
||||
int radius = this.argAsInt(0, 1); // Default to 1
|
||||
final Faction forFaction = this.argAsFaction(1, myFaction); // Default to own
|
||||
public void perform(CommandContext context) {
|
||||
|
||||
if (!fme.isAdminBypassing()) {
|
||||
Access access = myFaction.getAccess(fme, PermissableAction.TERRITORY);
|
||||
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
||||
fme.msg(TL.GENERIC_NOPERMISSION, "change faction territory");
|
||||
return;
|
||||
// Read and validate input
|
||||
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 (radius < 1) {
|
||||
msg(TL.COMMAND_CLAIM_INVALIDRADIUS);
|
||||
context.msg(TL.COMMAND_CLAIM_INVALIDRADIUS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (radius < 2) {
|
||||
// single chunk
|
||||
fme.attemptClaim(forFaction, me.getLocation(), true);
|
||||
context.fPlayer.attemptClaim(forFaction, context.player.getLocation(), true);
|
||||
} else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
|
||||
msg(TL.COMMAND_CLAIM_DENIED);
|
||||
if (!Permission.CLAIM_RADIUS.has(context.sender, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
new SpiralTask(new FLocation(me), radius) {
|
||||
new SpiralTask(new FLocation(context.player), radius) {
|
||||
private final int limit = Conf.radiusClaimFailureLimit - 1;
|
||||
private int failCount = 0;
|
||||
|
||||
@Override
|
||||
public boolean work() {
|
||||
boolean success = fme.attemptClaim(forFaction, this.currentLocation(), true);
|
||||
boolean success = context.fPlayer.attemptClaim(forFaction, this.currentLocation(), true);
|
||||
if (success) {
|
||||
failCount = 0;
|
||||
} else if (failCount++ >= limit) {
|
||||
this.stop();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,8 +2,11 @@ package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdClaimAt extends FCommand {
|
||||
@@ -16,28 +19,26 @@ public class CmdClaimAt extends FCommand {
|
||||
this.requiredArgs.add("x");
|
||||
this.requiredArgs.add("z");
|
||||
|
||||
this.permission = Permission.CLAIMAT.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CLAIMAT)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.TERRITORY)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
int x = argAsInt(1);
|
||||
int z = argAsInt(2);
|
||||
FLocation location = new FLocation(argAsString(0), x, z);
|
||||
if (!((fme.getPlayer().getLocation().getX() + (x * 16)) > (fme.getPlayer().getLocation().getX() + (Conf.mapWidth * 16))) &&
|
||||
!((fme.getPlayer().getLocation().getZ() + (z * 16)) > (fme.getPlayer().getLocation().getZ() + (Conf.mapHeight * 16)))) {
|
||||
fme.attemptClaim(myFaction, location, true);
|
||||
} else fme.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
public void perform(CommandContext context) {
|
||||
int x = context.argAsInt(1);
|
||||
int z = context.argAsInt(2);
|
||||
FLocation location = new FLocation(context.argAsString(0), x, z);
|
||||
if (!((context.player.getLocation().getX() + (x * 16)) > (context.player.getLocation().getX() + (Conf.mapWidth * 16))) &&
|
||||
!((context.player.getLocation().getZ() + (z * 16)) > (context.player.getLocation().getZ() + (Conf.mapHeight * 16))) &&
|
||||
!context.argAsString(0).equals(context.player.getLocation().getWorld().getName())) {
|
||||
context.fPlayer.attemptClaim(context.faction, location, true);
|
||||
} else context.fPlayer.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return null;
|
||||
|
||||
@@ -2,8 +2,12 @@ package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -23,32 +27,28 @@ public class CmdClaimLine extends FCommand {
|
||||
this.optionalArgs.put("direction", "facing");
|
||||
this.optionalArgs.put("faction", "you");
|
||||
|
||||
this.permission = Permission.CLAIM_LINE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CLAIM_LINE)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.TERRITORY)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
public void perform(CommandContext context) {
|
||||
// Args
|
||||
Integer amount = this.argAsInt(0, 1); // Default to 1
|
||||
Integer amount = context.argAsInt(0, 1); // Default to 1
|
||||
|
||||
if (amount > Conf.lineClaimLimit) {
|
||||
fme.msg(TL.COMMAND_CLAIMLINE_ABOVEMAX, Conf.lineClaimLimit);
|
||||
context.fPlayer.msg(TL.COMMAND_CLAIMLINE_ABOVEMAX, Conf.lineClaimLimit);
|
||||
return;
|
||||
}
|
||||
|
||||
String direction = this.argAsString(1);
|
||||
String direction = context.argAsString(1);
|
||||
BlockFace blockFace;
|
||||
|
||||
if (direction == null) {
|
||||
blockFace = axis[Math.round(me.getLocation().getYaw() / 90f) & 0x3];
|
||||
blockFace = axis[Math.round(context.player.getLocation().getYaw() / 90f) & 0x3];
|
||||
} else if (direction.equalsIgnoreCase("north")) {
|
||||
blockFace = BlockFace.NORTH;
|
||||
} else if (direction.equalsIgnoreCase("east")) {
|
||||
@@ -58,16 +58,26 @@ public class CmdClaimLine extends FCommand {
|
||||
} else if (direction.equalsIgnoreCase("west")) {
|
||||
blockFace = BlockFace.WEST;
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_CLAIMLINE_NOTVALID, direction);
|
||||
context.msg(TL.COMMAND_CLAIMLINE_NOTVALID, direction);
|
||||
return;
|
||||
}
|
||||
|
||||
final Faction forFaction = this.argAsFaction(2, myFaction);
|
||||
Location location = me.getLocation();
|
||||
final Faction forFaction = context.argAsFaction(2, 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Location location = context.player.getLocation();
|
||||
|
||||
// TODO: make this a task like claiming a radius?
|
||||
for (int i = 0; i < amount; i++) {
|
||||
fme.attemptClaim(forFaction, location, true);
|
||||
context.fPlayer.attemptClaim(forFaction, location, true);
|
||||
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.CornerTask;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -16,29 +19,29 @@ public class CmdCorner extends FCommand {
|
||||
public CmdCorner() {
|
||||
this.aliases.add("corner");
|
||||
|
||||
this.permission = Permission.CLAIM_RADIUS.node;
|
||||
|
||||
this.senderMustBePlayer = true;
|
||||
this.senderMustBeMember = true;
|
||||
this.senderMustBeModerator = false;
|
||||
this.senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CORNER)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.TERRITORY)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
FLocation to = new FLocation(me.getLocation());
|
||||
if (P.p.getFactionsPlayerListener().getCorners().contains(to)) {
|
||||
public void perform(CommandContext context) {
|
||||
FLocation to = new FLocation(context.player.getLocation());
|
||||
if (FactionsPlugin.getInstance().getFactionsPlayerListener().getCorners().contains(to)) {
|
||||
Faction cornerAt = Board.getInstance().getFactionAt(to);
|
||||
if (cornerAt != null && cornerAt.isNormal() && !cornerAt.equals(fme.getFaction())) {
|
||||
msg(TL.COMMAND_CORNER_CANT_CLAIM);
|
||||
if (cornerAt != null && cornerAt.isNormal() && !cornerAt.equals(context.fPlayer.getFaction())) {
|
||||
context.msg(TL.COMMAND_CORNER_CANT_CLAIM);
|
||||
} else {
|
||||
msg(TL.COMMAND_CORNER_ATTEMPTING_CLAIM);
|
||||
context.msg(TL.COMMAND_CORNER_ATTEMPTING_CLAIM);
|
||||
List<FLocation> surrounding = new ArrayList<>(400);
|
||||
for (int x = 0; x < Conf.factionBufferSize; ++x) {
|
||||
for (int z = 0; z < Conf.factionBufferSize; ++z) {
|
||||
int newX = (int) ((to.getX() > 0L) ? (to.getX() - x) : (to.getX() + x));
|
||||
int newZ = (int) ((to.getZ() > 0L) ? (to.getZ() - z) : (to.getZ() + z));
|
||||
FLocation location = new FLocation(me.getWorld().getName(), newX, newZ);
|
||||
FLocation location = new FLocation(context.player.getWorld().getName(), newX, newZ);
|
||||
Faction at = Board.getInstance().getFactionAt(location);
|
||||
if (at == null || !at.isNormal()) {
|
||||
surrounding.add(location);
|
||||
@@ -47,13 +50,13 @@ public class CmdCorner extends FCommand {
|
||||
}
|
||||
surrounding.sort(Comparator.comparingInt(fLocation -> (int) fLocation.getDistanceTo(to)));
|
||||
if (surrounding.isEmpty()) {
|
||||
msg(TL.COMMAND_CORNER_CANT_CLAIM);
|
||||
context.msg(TL.COMMAND_CORNER_CANT_CLAIM);
|
||||
} else {
|
||||
new CornerTask(fme, surrounding).runTaskTimer(P.p, 1L, 1L);
|
||||
new CornerTask(context.fPlayer, surrounding).runTaskTimer(FactionsPlugin.getInstance(), 1L, 1L);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
msg(TL.COMMAND_CORNER_NOT_CORNER);
|
||||
context.msg(TL.COMMAND_CORNER_NOT_CORNER);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.massivecraft.factions.cmd.claim;
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
@@ -15,25 +17,15 @@ public class CmdSafeunclaimall extends FCommand {
|
||||
public CmdSafeunclaimall() {
|
||||
this.aliases.add("safeunclaimall");
|
||||
this.aliases.add("safedeclaimall");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("world", "all");
|
||||
|
||||
this.permission = Permission.MANAGE_SAFE_ZONE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeColeader = false;
|
||||
senderMustBeAdmin = false;
|
||||
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.MANAGE_SAFE_ZONE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
String worldName = argAsString(0);
|
||||
public void perform(CommandContext context) {
|
||||
String worldName = context.argAsString(0);
|
||||
World world = null;
|
||||
|
||||
if (worldName != null) {
|
||||
@@ -48,10 +40,10 @@ public class CmdSafeunclaimall extends FCommand {
|
||||
Board.getInstance().unclaimAllInWorld(id, world);
|
||||
}
|
||||
|
||||
msg(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMED);
|
||||
context.msg(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMED);
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMEDLOG.format(sender.getName()));
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_SAFEUNCLAIMALL_UNCLAIMEDLOG.format(context.sender.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.event.LandUnclaimEvent;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
@@ -19,51 +21,54 @@ public class CmdUnclaim extends FCommand {
|
||||
this.aliases.add("declaim");
|
||||
|
||||
this.optionalArgs.put("radius", "1");
|
||||
this.optionalArgs.put("faction", "yours");
|
||||
|
||||
this.permission = Permission.UNCLAIM.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
this.requirements = new CommandRequirements.Builder(Permission.UNCLAIM)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.TERRITORY)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
// Read and validate input
|
||||
int radius = this.argAsInt(0, 1); // Default to 1
|
||||
public void perform(CommandContext context) {
|
||||
|
||||
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");
|
||||
if (context.args.size() == 2) {
|
||||
Faction target = context.argAsFaction(1);
|
||||
// Dont have to say anything since the argsAsFaction method will tell the player for me.
|
||||
if (target == null) return;
|
||||
context.faction = target;
|
||||
if (context.faction != context.fPlayer.getFaction() && !context.fPlayer.isAdminBypassing()) {
|
||||
context.msg(TL.COMMAND_UNCLAIM_WRONGFACTION);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Read and validate input
|
||||
int radius = context.argAsInt(0, 1); // Default to 1
|
||||
|
||||
if (radius < 1) {
|
||||
msg(TL.COMMAND_CLAIM_INVALIDRADIUS);
|
||||
context.msg(TL.COMMAND_CLAIM_INVALIDRADIUS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (radius < 2) {
|
||||
if (radius == 1) {
|
||||
// single chunk
|
||||
unClaim(new FLocation(me));
|
||||
unClaim(new FLocation(context.player), context);
|
||||
} else {
|
||||
// radius claim
|
||||
if (!Permission.CLAIM_RADIUS.has(sender, false)) {
|
||||
msg(TL.COMMAND_CLAIM_DENIED);
|
||||
if (!Permission.CLAIM_RADIUS.has(context.sender, false)) {
|
||||
context.msg(TL.COMMAND_CLAIM_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
new SpiralTask(new FLocation(me), radius) {
|
||||
new SpiralTask(new FLocation(context.player), radius) {
|
||||
private final int limit = Conf.radiusClaimFailureLimit - 1;
|
||||
private int failCount = 0;
|
||||
|
||||
@Override
|
||||
public boolean work() {
|
||||
boolean success = unClaim(this.currentFLocation());
|
||||
boolean success = unClaim(currentFLocation(), context);
|
||||
if (success) {
|
||||
failCount = 0;
|
||||
} else if (failCount++ >= limit) {
|
||||
@@ -77,101 +82,101 @@ public class CmdUnclaim extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean unClaim(FLocation target) {
|
||||
private boolean unClaim(FLocation target, CommandContext context) {
|
||||
Faction targetFaction = Board.getInstance().getFactionAt(target);
|
||||
if (targetFaction.isSafeZone()) {
|
||||
if (Permission.MANAGE_SAFE_ZONE.has(sender)) {
|
||||
if (Permission.MANAGE_SAFE_ZONE.has(context.sender)) {
|
||||
Board.getInstance().removeAt(target);
|
||||
msg(TL.COMMAND_UNCLAIM_SAFEZONE_SUCCESS);
|
||||
context.msg(TL.COMMAND_UNCLAIM_SAFEZONE_SUCCESS);
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_UNCLAIM_LOG.format(context.fPlayer.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
msg(TL.COMMAND_UNCLAIM_SAFEZONE_NOPERM);
|
||||
context.msg(TL.COMMAND_UNCLAIM_SAFEZONE_NOPERM);
|
||||
return false;
|
||||
}
|
||||
} else if (targetFaction.isWarZone()) {
|
||||
if (Permission.MANAGE_WAR_ZONE.has(sender)) {
|
||||
if (Permission.MANAGE_WAR_ZONE.has(context.sender)) {
|
||||
Board.getInstance().removeAt(target);
|
||||
msg(TL.COMMAND_UNCLAIM_WARZONE_SUCCESS);
|
||||
context.msg(TL.COMMAND_UNCLAIM_WARZONE_SUCCESS);
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_UNCLAIM_LOG.format(context.fPlayer.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
msg(TL.COMMAND_UNCLAIM_WARZONE_NOPERM);
|
||||
context.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 (context.fPlayer.isAdminBypassing()) {
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, context.fPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||
if (unclaimEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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, context.fPlayer.describeTo(targetFaction, true));
|
||||
context.msg(TL.COMMAND_UNCLAIM_UNCLAIMS);
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_UNCLAIM_LOG.format(context.fPlayer.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (targetFaction.getClaimOwnership().containsKey(target) && !targetFaction.isPlayerInOwnerList(context.fPlayer, target)) {
|
||||
context.msg(TL.GENERIC_FPERM_OWNER_NOPERMISSION, "unclaim");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (targetFaction.getAccess(fme, PermissableAction.TERRITORY) == Access.DENY) {
|
||||
if (targetFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) == Access.DENY && context.fPlayer.getRole() != Role.LEADER) {
|
||||
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "unclaim");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!context.assertHasFaction()) {
|
||||
context.msg(TL.ACTIONS_NOFACTION);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.faction != targetFaction) {
|
||||
context.msg(TL.COMMAND_UNCLAIM_WRONGFACTION);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!assertHasFaction()) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, fme);
|
||||
Bukkit.getServer().getPluginManager().callEvent(unclaimEvent);
|
||||
LandUnclaimEvent unclaimEvent = new LandUnclaimEvent(target, targetFaction, context.fPlayer);
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> Bukkit.getServer().getPluginManager().callEvent(unclaimEvent));
|
||||
if (unclaimEvent.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Econ.shouldBeUsed()) {
|
||||
double refund = Econ.calculateClaimRefund(myFaction.getLandRounded());
|
||||
double refund = Econ.calculateClaimRefund(context.faction.getLandRounded());
|
||||
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||
if (!Econ.modifyMoney(myFaction, refund, TL.COMMAND_UNCLAIM_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIM_FORUNCLAIM.toString())) {
|
||||
if (!Econ.modifyMoney(context.faction, 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())) {
|
||||
if (!Econ.modifyMoney(context.fPlayer, 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));
|
||||
context.faction.msg(TL.COMMAND_UNCLAIM_FACTIONUNCLAIMED, context.fPlayer.describeTo(context.faction, true));
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIM_LOG.format(fme.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_UNCLAIM_LOG.format(context.fPlayer.getName(), target.getCoordString(), targetFaction.getTag()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -2,11 +2,15 @@ package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.event.LandUnclaimAllEvent;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -16,45 +20,61 @@ public class CmdUnclaimall extends FCommand {
|
||||
this.aliases.add("unclaimall");
|
||||
this.aliases.add("declaimall");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.UNCLAIM_ALL.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = true;
|
||||
senderMustBeAdmin = false;
|
||||
this.optionalArgs.put("faction", "yours");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.UNCLAIM_ALL)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.TERRITORY) //TODO: Add Unclaimall PermissableAction
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
public void perform(CommandContext context) {
|
||||
Faction target = context.faction;
|
||||
if (context.args.size() == 1) {
|
||||
target = context.argAsFaction(0);
|
||||
if (target == null) {
|
||||
context.msg(TL.GENERIC_NOFACTION_FOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
context.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag()).replace("{action}", "unclaimall land"));
|
||||
return;
|
||||
}
|
||||
|
||||
Board.getInstance().unclaimAll(target.getId());
|
||||
context.faction.msg(TL.COMMAND_UNCLAIMALL_LOG, context.fPlayer.describeTo(target, true), target.getTag());
|
||||
if (Conf.logLandUnclaims)
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_UNCLAIMALL_LOG.format(context.fPlayer.getName(), context.faction.getTag()));
|
||||
return;
|
||||
|
||||
}
|
||||
if (Econ.shouldBeUsed()) {
|
||||
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
|
||||
double refund = Econ.calculateTotalLandRefund(target.getLandRounded());
|
||||
if (Conf.bankEnabled && Conf.bankFactionPaysLandCosts) {
|
||||
if (!Econ.modifyMoney(myFaction, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
||||
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!Econ.modifyMoney(fme, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
||||
if (!Econ.modifyMoney(target, refund, TL.COMMAND_UNCLAIMALL_TOUNCLAIM.toString(), TL.COMMAND_UNCLAIMALL_FORUNCLAIM.toString())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme);
|
||||
Bukkit.getScheduler().runTask(P.p, () -> Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent));
|
||||
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(target, context.fPlayer);
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent));
|
||||
if (unclaimAllEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Board.getInstance().unclaimAll(myFaction.getId());
|
||||
myFaction.msg(TL.COMMAND_UNCLAIMALL_UNCLAIMED, fme.describeTo(myFaction, true));
|
||||
Board.getInstance().unclaimAll(target.getId());
|
||||
context.faction.msg(TL.COMMAND_UNCLAIMALL_UNCLAIMED, context.fPlayer.describeTo(context.faction, true));
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_UNCLAIMALL_LOG.format(fme.getName(), myFaction.getTag()));
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_UNCLAIMALL_LOG.format(context.fPlayer.getName(), context.faction.getTag()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,3 +84,4 @@ public class CmdUnclaimall extends FCommand {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.massivecraft.factions.cmd.claim;
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
@@ -15,28 +17,18 @@ public class CmdWarunclaimall extends FCommand {
|
||||
public CmdWarunclaimall() {
|
||||
this.aliases.add("warunclaimall");
|
||||
this.aliases.add("wardeclaimall");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("world", "all");
|
||||
|
||||
this.permission = Permission.MANAGE_WAR_ZONE.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeModerator = false;
|
||||
senderMustBeAdmin = false;
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.MANAGE_WAR_ZONE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
String worldName = argAsString(0);
|
||||
public void perform(CommandContext context) {
|
||||
String worldName = context.argAsString(0);
|
||||
World world = null;
|
||||
|
||||
if (worldName != null) {
|
||||
world = Bukkit.getWorld(worldName);
|
||||
}
|
||||
if (worldName != null) world = Bukkit.getWorld(worldName);
|
||||
|
||||
String id = Factions.getInstance().getWarZone().getId();
|
||||
|
||||
@@ -46,12 +38,9 @@ public class CmdWarunclaimall extends FCommand {
|
||||
Board.getInstance().unclaimAllInWorld(id, world);
|
||||
}
|
||||
|
||||
fme.msg(TL.COMMAND_WARUNCLAIMALL_SUCCESS);
|
||||
|
||||
|
||||
if (Conf.logLandUnclaims) {
|
||||
P.p.log(TL.COMMAND_WARUNCLAIMALL_LOG.format(fme.getName()));
|
||||
}
|
||||
context.msg(TL.COMMAND_WARUNCLAIMALL_SUCCESS);
|
||||
if (Conf.logLandUnclaims)
|
||||
FactionsPlugin.getInstance().log(TL.COMMAND_WARUNCLAIMALL_LOG.format(context.fPlayer.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,3 +49,4 @@ public class CmdWarunclaimall extends FCommand {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user