Prevent teleporting to invalid coordinates

This commit is contained in:
boy0001 2015-08-28 16:36:26 +10:00
parent 1e8bdb17f8
commit 0dbb1887d5
4 changed files with 6 additions and 0 deletions

View File

@ -122,6 +122,9 @@ public class BukkitPlayer extends PlotPlayer {
@Override @Override
public void teleport(final Location loc) { public void teleport(final Location loc) {
if (Math.abs(loc.getX()) >= 30000000 || Math.abs(loc.getZ()) >= 30000000) {
return;
}
this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5, loc.getYaw(), loc.getPitch())); this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5, loc.getYaw(), loc.getPitch()));
} }

View File

@ -111,6 +111,9 @@ public class SpongePlayer extends PlotPlayer {
@Override @Override
public void teleport(Location loc) { public void teleport(Location loc) {
if (Math.abs(loc.getX()) >= 30000000 || Math.abs(loc.getZ()) >= 30000000) {
return;
}
String world = player.getWorld().getName(); String world = player.getWorld().getName();
if (!world.equals(loc.getWorld())) { if (!world.equals(loc.getWorld())) {
player.transferToWorld(loc.getWorld(), new Vector3d(loc.getX(), loc.getY(), loc.getZ())); player.transferToWorld(loc.getWorld(), new Vector3d(loc.getX(), loc.getY(), loc.getZ()));

Binary file not shown.

Binary file not shown.