Players not in the right world will now get banned for life!

This commit is contained in:
Garbage Mule
2011-10-03 22:03:48 +02:00
parent f808b24464
commit 69ad343e16
7 changed files with 28 additions and 20 deletions
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
name: MobArena name: MobArena
main: com.garbagemule.MobArena.MobArena main: com.garbagemule.MobArena.MobArena
version: 0.94.3.10 version: 0.94.3.11
softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells] softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells]
commands: commands:
ma: ma:
+2 -1
View File
@@ -488,7 +488,8 @@ public class Arena
if (e == null) continue; if (e == null) continue;
Creature c = (Creature) e; Creature c = (Creature) e;
if (c.getTarget() != null && e.getLocation().distanceSquared(c.getTarget().getLocation()) < 8) LivingEntity target = c.getTarget();
if (target != null && target instanceof Player && MAUtils.distanceSquared((Player) target, e.getLocation()) < 8D)
{ {
CraftEntity ce = (CraftEntity) e; CraftEntity ce = (CraftEntity) e;
CraftWorld cw = (CraftWorld) e.getWorld(); CraftWorld cw = (CraftWorld) e.getWorld();
+16 -2
View File
@@ -1087,8 +1087,8 @@ public class MAUtils
continue; continue;
} }
double dist = p.getLocation().distanceSquared(e.getLocation()); double dist = distanceSquared(p, e.getLocation());
if (dist < current && dist < 256) if (dist < current && dist < 256D)
{ {
current = dist; current = dist;
result = p; result = p;
@@ -1097,6 +1097,20 @@ public class MAUtils
return result; return result;
} }
public static double distanceSquared(Player p, Location l)
{
try
{
return p.getLocation().distanceSquared(l);
}
catch(Exception e)
{
p.kickPlayer("Banned for life! No, but stop trying to cheat in MobArena!");
MobArena.warning(p.getName() + " tried to cheat in MobArena and has been kicked.");
return Double.MAX_VALUE;
}
}
/** /**
* Convert a proper arena name to a config-file name. * Convert a proper arena name to a config-file name.
* All spaces are replaced by underscores, and the whole String is * All spaces are replaced by underscores, and the whole String is
+2 -2
View File
@@ -46,8 +46,8 @@ public class MobArena extends JavaPlugin
// Global variables // Global variables
public static PluginDescriptionFile desc; public static PluginDescriptionFile desc;
public static File dir, arenaDir; public static File dir, arenaDir;
public static final double MIN_PLAYER_DISTANCE = 15.0; public static final double MIN_PLAYER_DISTANCE = 15D;
public static final double MIN_PLAYER_DISTANCE_SQUARED = MIN_PLAYER_DISTANCE * MIN_PLAYER_DISTANCE; public static final double MIN_PLAYER_DISTANCE_SQUARED = 225D;
public static final int ECONOMY_MONEY_ID = -29; public static final int ECONOMY_MONEY_ID = -29;
public static Random random = new Random(); public static Random random = new Random();
@@ -30,19 +30,11 @@ public class WaveUtils
{ {
for (Player p : players) for (Player p : players)
{ {
try if (MAUtils.distanceSquared(p, l) >= MobArena.MIN_PLAYER_DISTANCE_SQUARED)
{ continue;
if (l.distanceSquared(p.getLocation()) >= MobArena.MIN_PLAYER_DISTANCE_SQUARED)
continue; result.add(l);
break;
result.add(l);
break;
}
catch (Exception e)
{
p.kickPlayer("Banned for life! No, but stop trying to cheat in MobArena!");
MobArena.warning(p.getName() + " tried to cheat in MobArena and has been kicked.");
}
} }
} }
@@ -16,6 +16,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.garbagemule.MobArena.Arena; import com.garbagemule.MobArena.Arena;
import com.garbagemule.MobArena.MAUtils;
import com.garbagemule.MobArena.MobArena; import com.garbagemule.MobArena.MobArena;
import com.garbagemule.MobArena.util.WaveUtils; import com.garbagemule.MobArena.util.WaveUtils;
@@ -334,7 +335,7 @@ public enum BossAbility
{ {
List<Player> result = new LinkedList<Player>(); List<Player> result = new LinkedList<Player>();
for (Player p : arena.getLivingPlayers()) for (Player p : arena.getLivingPlayers())
if (p.getLocation().distanceSquared(boss.getLocation()) > x*x) if (MAUtils.distanceSquared(p, boss.getLocation()) > (double) (x*x))
result.add(p); result.add(p);
return result; return result;
} }