Factions3/src/org/mcteam/factions/commands/FCommandSafeclaim.java

55 lines
1.3 KiB
Java
Raw Normal View History

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);
}
public void perform() {
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);
sendMessage("This land is now a safe zone");
}
2011-03-23 17:39:56 +01:00
}
}