From b41b3c8d2c870adf097f0c70e0ef970e84bbc231 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Tue, 31 Jan 2012 10:58:25 -0600 Subject: [PATCH] Protection against radius claim attempts which might overload the server --- src/com/massivecraft/factions/cmd/CmdClaim.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/com/massivecraft/factions/cmd/CmdClaim.java b/src/com/massivecraft/factions/cmd/CmdClaim.java index 8020da71..410d9d86 100644 --- a/src/com/massivecraft/factions/cmd/CmdClaim.java +++ b/src/com/massivecraft/factions/cmd/CmdClaim.java @@ -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("You do not currently have permission to claim land for the faction "+forFaction.describeTo(fme) +"."); + return; + } + double radius = this.argAsDouble(1, 1d); radius -= 0.5; if (radius <= 0) @@ -41,13 +49,18 @@ public class CmdClaim extends FCommand msg("That radius is to small."); return; } + else if (radius > 100) // huge radius can crash server + { + msg("That radius is overly large. Remember that the radius is in chunks (16x16 blocks), not individual blocks."); + return; + } // Get the FLocations Set 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); } }