mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Prevent players moving to illegal positions. Fixes #651
This commit is contained in:
parent
abf52870dd
commit
580ba0a357
@ -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 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 MSG_PER_HEARTBEAT = 10;
|
||||||
public static final int DEFAULT_PORT = 25565;
|
public static final int DEFAULT_PORT = 25565;
|
||||||
|
public static final int MAX_XY_COORD = 30000000;
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
@ -386,6 +387,11 @@ public class TFM_PlayerListener implements Listener
|
|||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
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())
|
if (!TFM_AdminList.isSuperAdmin(player) && playerdata.isFrozen())
|
||||||
{
|
{
|
||||||
@ -780,13 +786,15 @@ public class TFM_PlayerListener implements Listener
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String ip = TFM_Util.getIp(player);
|
final String ip = TFM_Util.getIp(player);
|
||||||
final TFM_Player playerEntry;
|
final TFM_Player playerEntry;
|
||||||
|
|
||||||
TFM_Log.info("[JOIN] " + TFM_Util.formatPlayer(player) + " joined the game with IP address: " + ip, true);
|
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)
|
// Handle PlayerList entry (persistent)
|
||||||
if (TFM_PlayerList.existsEntry(player))
|
if (TFM_PlayerList.existsEntry(player))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user