Added a radius to safe claim
This commit is contained in:
@ -6,13 +6,14 @@ import org.mcteam.factions.FLocation;
|
||||
import org.mcteam.factions.Faction;
|
||||
import org.mcteam.factions.Factions;
|
||||
|
||||
|
||||
public class FCommandSafeclaim extends FBaseCommand {
|
||||
|
||||
public FCommandSafeclaim() {
|
||||
aliases.add("safeclaim");
|
||||
aliases.add("safe");
|
||||
|
||||
optionalParameters.add("radius");
|
||||
|
||||
helpDescription = "Claim land for the safezone";
|
||||
}
|
||||
|
||||
@ -22,9 +23,26 @@ public class FCommandSafeclaim extends FBaseCommand {
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
FLocation flocation = new FLocation(me);
|
||||
Board.setFactionAt(Faction.getSafeZone(), flocation);
|
||||
sendMessage("This land is now a safe zone");
|
||||
// The current location of the player
|
||||
FLocation playerFlocation = new FLocation(me);
|
||||
|
||||
// Was a radius set?
|
||||
if (parameters.size() > 0) {
|
||||
int radius = Integer.parseInt(parameters.get(0));
|
||||
|
||||
FLocation from = playerFlocation.getRelative(radius, radius);
|
||||
FLocation to = playerFlocation.getRelative(-radius, -radius);
|
||||
|
||||
for (FLocation locToClaim : FLocation.getArea(from, to)) {
|
||||
Board.setFactionAt(Faction.getSafeZone(), locToClaim);
|
||||
}
|
||||
|
||||
sendMessage("You claimed "+(1+radius*2)*(1+radius*2)+" chunks for the safe zone.");
|
||||
|
||||
} else {
|
||||
Board.setFactionAt(Faction.getSafeZone(), playerFlocation);
|
||||
sendMessage("This land is now a safe zone");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user