Protection against radius claim attempts which might overload the server
This commit is contained in:
parent
700f244304
commit
b41b3c8d2c
@ -34,6 +34,14 @@ public class CmdClaim extends FCommand
|
||||
{
|
||||
// Read and validate input
|
||||
Faction forFaction = this.argAsFaction(0, myFaction);
|
||||
|
||||
// just to cut the unauthorized off immediately instead of going on to do radius calculations
|
||||
if (! fme.canClaimForFaction(forFaction))
|
||||
{
|
||||
msg("<b>You do not currently have permission to claim land for the faction "+forFaction.describeTo(fme) +"<b>.");
|
||||
return;
|
||||
}
|
||||
|
||||
double radius = this.argAsDouble(1, 1d);
|
||||
radius -= 0.5;
|
||||
if (radius <= 0)
|
||||
@ -41,13 +49,18 @@ public class CmdClaim extends FCommand
|
||||
msg("<b>That radius is to small.");
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
// Get the FLocations
|
||||
Set<FLocation> flocs = new FLocation(me).getCircle(radius);
|
||||
p.log(flocs);
|
||||
for (FLocation floc : flocs)
|
||||
{
|
||||
fme.attemptClaim(forFaction, new Location(floc.getWorld(), floc.getX()*16, 1, floc.getZ()*16), true);
|
||||
fme.attemptClaim(forFaction, new Location(floc.getWorld(), floc.getX() << 4, 1, floc.getZ() << 4), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user