2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions.commands;
|
2011-05-29 16:28:29 -05: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;
|
2011-10-08 22:03:44 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2011-05-29 16:28:29 -05:00
|
|
|
|
2011-10-08 23:22:02 +02:00
|
|
|
public class FCommandWarclaim extends FCommand {
|
2011-05-29 16:28:29 -05:00
|
|
|
|
|
|
|
public FCommandWarclaim() {
|
|
|
|
aliases.add("warclaim");
|
|
|
|
aliases.add("war");
|
|
|
|
|
|
|
|
optionalParameters.add("radius");
|
|
|
|
|
|
|
|
helpDescription = "Claim land for the warzone";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasPermission(CommandSender sender) {
|
2011-10-08 22:03:44 +02:00
|
|
|
return P.hasPermManageWarZone(sender);
|
2011-05-29 16:28:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public void perform() {
|
|
|
|
|
|
|
|
if( isLocked() ) {
|
|
|
|
sendLockMessage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The current location of the player
|
2011-10-09 14:53:38 +02:00
|
|
|
FLocation playerFlocation = new FLocation(fme);
|
2011-05-29 16:28:29 -05:00
|
|
|
|
|
|
|
// Was a radius set?
|
|
|
|
if (parameters.size() > 0) {
|
2011-08-03 15:38:54 -05:00
|
|
|
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-05-29 16:28:29 -05:00
|
|
|
|
|
|
|
FLocation from = playerFlocation.getRelative(radius, radius);
|
|
|
|
FLocation to = playerFlocation.getRelative(-radius, -radius);
|
|
|
|
|
|
|
|
for (FLocation locToClaim : FLocation.getArea(from, to)) {
|
|
|
|
Board.setFactionAt(Faction.getWarZone(), locToClaim);
|
|
|
|
}
|
|
|
|
|
|
|
|
sendMessage("You claimed "+(1+radius*2)*(1+radius*2)+" chunks for the war zone.");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
Board.setFactionAt(Faction.getWarZone(), playerFlocation);
|
2011-06-10 14:26:12 -05:00
|
|
|
sendMessage("This land is now a war zone.");
|
2011-05-29 16:28:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|