Prevent players moving to illegal positions. Fixes #651

This commit is contained in:
ChargedCreeper 2015-05-21 11:59:41 -04:00 committed by JeromSar
parent abf52870dd
commit 580ba0a357

View file

@ -63,6 +63,7 @@ public class TFM_PlayerListener implements Listener
public static final List<String> BLOCKED_MUTED_CMDS = Arrays.asList(StringUtils.split("say,me,msg,m,tell,r,reply,mail,email", ","));
public static final int MSG_PER_HEARTBEAT = 10;
public static final int DEFAULT_PORT = 25565;
public static final int MAX_XY_COORD = 30000000;
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event)
@ -386,6 +387,11 @@ public class TFM_PlayerListener implements Listener
{
final Player player = event.getPlayer();
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
// Check absolute value to account for negatives
if(Math.abs(event.getTo().getX()) >= MAX_XY_COORD || Math.abs(event.getTo().getZ()) >= MAX_XY_COORD)
{
event.setCancelled(true); // illegal position, cancel it
}
if (!TFM_AdminList.isSuperAdmin(player) && playerdata.isFrozen())
{
@ -780,13 +786,15 @@ public class TFM_PlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
final Player player = event.getPlayer();
final String ip = TFM_Util.getIp(player);
final TFM_Player playerEntry;
TFM_Log.info("[JOIN] " + TFM_Util.formatPlayer(player) + " joined the game with IP address: " + ip, true);
// Check absolute value to account for negatives
if(Math.abs(player.getLocation().getX()) >= MAX_XY_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XY_COORD)
{
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
}
// Handle PlayerList entry (persistent)
if (TFM_PlayerList.existsEntry(player))
{