2011-04-08 15:51:07 +02:00
|
|
|
package org.mcteam.factions.commands;
|
2011-03-23 17:39:56 +01:00
|
|
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
2011-04-08 15:51:07 +02:00
|
|
|
import org.mcteam.factions.Board;
|
|
|
|
import org.mcteam.factions.FLocation;
|
|
|
|
import org.mcteam.factions.Faction;
|
|
|
|
import org.mcteam.factions.Factions;
|
2011-03-23 17:39:56 +01:00
|
|
|
|
|
|
|
public class FCommandSafeclaim extends FBaseCommand {
|
|
|
|
|
|
|
|
public FCommandSafeclaim() {
|
|
|
|
aliases.add("safeclaim");
|
|
|
|
aliases.add("safe");
|
|
|
|
|
2011-04-08 21:01:46 +02:00
|
|
|
optionalParameters.add("radius");
|
|
|
|
|
2011-03-23 17:39:56 +01:00
|
|
|
helpDescription = "Claim land for the safezone";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasPermission(CommandSender sender) {
|
|
|
|
return Factions.hasPermManageSafeZone(sender);
|
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-03-23 17:39:56 +01:00
|
|
|
public void perform() {
|
2011-05-08 17:16:43 +02:00
|
|
|
|
|
|
|
if( isLocked() ) {
|
|
|
|
sendLockMessage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-08 21:01:46 +02:00
|
|
|
// 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);
|
2011-06-10 21:26:12 +02:00
|
|
|
sendMessage("This land is now a safe zone.");
|
2011-04-08 21:01:46 +02:00
|
|
|
}
|
2011-03-23 17:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|