Factions/src/com/massivecraft/factions/commands/FCommandSafeclaim.java

65 lines
1.6 KiB
Java
Raw Normal View History

2011-07-18 22:06:02 +02:00
package com.massivecraft.factions.commands;
2011-03-23 17:39:56 +01:00
import org.bukkit.command.CommandSender;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.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);
}
@Override
2011-03-23 17:39:56 +01:00
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;
try {
radius = Integer.parseInt(parameters.get(0));
}
catch(NumberFormatException ex) {
sendMessage("Usage: " + getUseageTemplate(false));
sendMessage("The radius value must be an integer.");
return;
}
2011-04-08 21:01:46 +02:00
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-04-08 21:01:46 +02:00
}
2011-03-23 17:39:56 +01:00
}
}