2011-10-09 21:57:43 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-11-27 22:47:40 +01:00
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
|
|
|
|
import com.massivecraft.factions.FLocation;
|
2011-10-22 16:00:24 +02:00
|
|
|
import com.massivecraft.factions.Faction;
|
2011-10-09 14:53:38 +02:00
|
|
|
import com.massivecraft.factions.struct.Permission;
|
|
|
|
|
2011-10-09 20:10:19 +02:00
|
|
|
public class CmdClaim extends FCommand
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
2011-03-22 15:45:41 +01:00
|
|
|
|
2011-10-09 20:10:19 +02:00
|
|
|
public CmdClaim()
|
2011-10-09 14:53:38 +02:00
|
|
|
{
|
|
|
|
super();
|
|
|
|
this.aliases.add("claim");
|
|
|
|
|
|
|
|
//this.requiredArgs.add("");
|
2011-10-22 16:00:24 +02:00
|
|
|
this.optionalArgs.put("faction", "your");
|
2011-11-27 22:47:40 +01:00
|
|
|
this.optionalArgs.put("radius", "1");
|
2011-10-09 14:53:38 +02:00
|
|
|
|
2011-10-09 21:57:43 +02:00
|
|
|
this.permission = Permission.CLAIM.node;
|
|
|
|
this.disableOnLock = true;
|
2011-10-09 14:53:38 +02:00
|
|
|
|
|
|
|
senderMustBePlayer = true;
|
2011-10-22 17:03:49 +02:00
|
|
|
senderMustBeMember = false;
|
2011-10-23 17:55:53 +02:00
|
|
|
senderMustBeOfficer = false;
|
|
|
|
senderMustBeLeader = false;
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
2011-06-21 07:38:31 +02:00
|
|
|
@Override
|
2011-10-09 14:53:38 +02:00
|
|
|
public void perform()
|
|
|
|
{
|
2011-11-27 22:47:40 +01:00
|
|
|
// Read and validate input
|
2011-10-22 16:00:24 +02:00
|
|
|
Faction forFaction = this.argAsFaction(0, myFaction);
|
2012-01-31 17:58:22 +01:00
|
|
|
|
|
|
|
// just to cut the unauthorized off immediately instead of going on to do radius calculations
|
|
|
|
if (! fme.canClaimForFactionAtLocation(forFaction, me.getLocation(), false))
|
|
|
|
{
|
|
|
|
msg("<b>You do not currently have permission to claim land for the faction "+forFaction.describeTo(fme) +"<b>.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-11-27 22:47:40 +01:00
|
|
|
double radius = this.argAsDouble(1, 1d);
|
|
|
|
radius -= 0.5;
|
|
|
|
if (radius <= 0)
|
|
|
|
{
|
|
|
|
msg("<b>That radius is to small.");
|
|
|
|
return;
|
|
|
|
}
|
2012-01-31 17:58:22 +01:00
|
|
|
else if (radius > 100) // huge radius can crash server
|
|
|
|
{
|
|
|
|
msg("<b>That radius is overly large. Remember that the radius is in chunks (16x16 blocks), not individual blocks.");
|
|
|
|
return;
|
|
|
|
}
|
2011-11-27 22:47:40 +01:00
|
|
|
|
|
|
|
// Get the FLocations
|
|
|
|
Set<FLocation> flocs = new FLocation(me).getCircle(radius);
|
|
|
|
for (FLocation floc : flocs)
|
|
|
|
{
|
2012-01-31 17:58:22 +01:00
|
|
|
fme.attemptClaim(forFaction, new Location(floc.getWorld(), floc.getX() << 4, 1, floc.getZ() << 4), true);
|
2011-11-27 22:47:40 +01:00
|
|
|
}
|
2011-03-22 15:45:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|