Added world-checks in Arena and MASpawnThread

This commit is contained in:
Garbage Mule
2011-07-08 23:56:06 +02:00
parent 8c157af7bc
commit 7fc43e45db
3 changed files with 28 additions and 5 deletions
BIN
View File
Binary file not shown.
@@ -296,6 +296,14 @@ public class MASpawnThread implements Runnable
{ {
for (Player p : arena.livePlayers) for (Player p : arena.livePlayers)
{ {
if (!arena.world.equals(p.getWorld()))
{
System.out.println("[MobArena] MASpawnThread:291: Player '" + p.getName() + "' is not in the right world. Force leaving...");
arena.playerLeave(p);
MAUtils.tellPlayer(p, "You warped out of the arena world.");
continue;
}
if (s.distanceSquared(p.getLocation()) > MIN_DISTANCE) if (s.distanceSquared(p.getLocation()) > MIN_DISTANCE)
continue; continue;
@@ -326,9 +334,16 @@ public class MASpawnThread implements Runnable
* time a squared distance smaller than current is found. */ * time a squared distance smaller than current is found. */
for (Player p : arena.livePlayers) for (Player p : arena.livePlayers)
{ {
dist = p.getLocation().distance(e.getLocation()); if (!arena.world.equals(p.getWorld()))
{
System.out.println("[MobArena] MASpawnThread:326: Player '" + p.getName() + "' is not in the right world. Force leaving...");
arena.playerLeave(p);
MAUtils.tellPlayer(p, "You warped out of the arena world.");
continue;
}
dist = p.getLocation().distanceSquared(e.getLocation());
//double dist = MAUtils.distance(p.getLocation(), e.getLocation()); //double dist = MAUtils.distance(p.getLocation(), e.getLocation());
if (dist < current && dist < 256) if (dist < current && dist < MIN_DISTANCE)
{ {
current = dist; current = dist;
result = p; result = p;
+11 -3
View File
@@ -905,7 +905,15 @@ public class MAUtils
* time a squared distance smaller than current is found. */ * time a squared distance smaller than current is found. */
for (Player p : arena.livePlayers) for (Player p : arena.livePlayers)
{ {
double dist = p.getLocation().distanceSquared(e.getLocation()); //distance(p.getLocation(), e.getLocation()); if (!arena.world.equals(p.getWorld()))
{
System.out.println("[MobArena] MAUtils:908: Player '" + p.getName() + "' is not in the right world. Force leaving...");
arena.playerLeave(p);
tellPlayer(p, "You warped out of the arena world.");
continue;
}
double dist = p.getLocation().distanceSquared(e.getLocation());
if (dist < current && dist < 256) if (dist < current && dist < 256)
{ {
current = dist; current = dist;
@@ -915,14 +923,14 @@ public class MAUtils
return result; return result;
} }
public static double distance(Location loc1, Location loc2) /*public static double distance(Location loc1, Location loc2)
{ {
double x = loc1.getX() - loc2.getX(); double x = loc1.getX() - loc2.getX();
double y = loc1.getY() - loc2.getY(); double y = loc1.getY() - loc2.getY();
double z = loc1.getZ() - loc2.getZ(); double z = loc1.getZ() - loc2.getZ();
return x*x + y*y + z*z; return x*x + y*y + z*z;
} }*/
/** /**
* Convert a proper arena name to a config-file name. * Convert a proper arena name to a config-file name.