mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-06 18:49:34 +01:00
Protection against radius claim attempts which might overload the server
This commit is contained in:
parent
d639a4a93e
commit
ed83711493
@ -34,6 +34,14 @@ public class CmdClaim extends FCommand
|
|||||||
{
|
{
|
||||||
// Read and validate input
|
// Read and validate input
|
||||||
Faction forFaction = this.argAsFaction(0, myFaction);
|
Faction forFaction = this.argAsFaction(0, myFaction);
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
double radius = this.argAsDouble(1, 1d);
|
double radius = this.argAsDouble(1, 1d);
|
||||||
radius -= 0.5;
|
radius -= 0.5;
|
||||||
if (radius <= 0)
|
if (radius <= 0)
|
||||||
@ -41,12 +49,17 @@ public class CmdClaim extends FCommand
|
|||||||
msg("<b>That radius is to small.");
|
msg("<b>That radius is to small.");
|
||||||
return;
|
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
|
// Get the FLocations
|
||||||
Set<FLocation> flocs = new FLocation(me).getCircle(radius);
|
Set<FLocation> flocs = new FLocation(me).getCircle(radius);
|
||||||
for (FLocation floc : 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