@EventHandler(priority = EventPriority.MONITOR) public void onPlayerJoin(PlayerJoinEvent event) { final Player player = event.getPlayer(); final String ip = TFM_Util.getIp(player); TFM_Log.info( "[JOIN] " + TFM_Util.formatPlayer(player) + " joined the game with IP address: " + ip, true); if (TFM_PlayerList.getInstance().existsEntry(player)) { final TFM_PlayerEntry entry = TFM_PlayerList.getInstance().getEntry(player); entry.setLastJoinUnix(TFM_Util.getUnixTime()); entry.setLastJoinName(player.getName()); entry.save(); } else { TFM_PlayerList.getInstance().getEntry(player); TFM_Log.info("Added new player: " + TFM_Util.formatPlayer(player)); } final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); playerdata.setSuperadminIdVerified(false); // Verify strict IP match if (TFM_AdminList.isSuperAdmin(player)) { TFM_BanManager.getInstance().unbanIp(ip); TFM_BanManager.getInstance().unbanIp(TFM_Util.getFuzzyIp(ip)); TFM_BanManager.getInstance().unbanUuid(player.getUniqueId()); player.setOp(true); if (!TFM_AdminList.isIdentityMatched(player)) { playerdata.setSuperadminIdVerified(false); TFM_Util.bcastMsg( "Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED); } else { playerdata.setSuperadminIdVerified(true); TFM_AdminList.updateLastLogin(player); } } // Handle admin impostors if (TFM_AdminList.isAdminImpostor(player)) { TFM_Util.bcastMsg( "Warning: " + player.getName() + " has been flagged as an impostor!", ChatColor.RED); TFM_Util.bcastMsg( ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player)); player.getInventory().clear(); player.setOp(false); player.setGameMode(GameMode.SURVIVAL); } else if (TFM_AdminList.isSuperAdmin(player) || TFM_Util.DEVELOPERS.contains(player.getName())) { TFM_Util.bcastMsg( ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player)); } new BukkitRunnable() { @Override public void run() { if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) { player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins."); } if (TotalFreedomMod.lockdownEnabled) { TFM_Util.playerMsg( player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED); } } }.runTaskLater(TotalFreedomMod.plugin, 20L * 3L); }
@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)) { playerEntry = TFM_PlayerList.getEntry(player); playerEntry.setLastLoginUnix(TFM_Util.getUnixTime()); playerEntry.setLastLoginName(player.getName()); playerEntry.addIp(ip); playerEntry.save(); } else { playerEntry = TFM_PlayerList.getEntry(player); TFM_Log.info("Added new player: " + TFM_Util.formatPlayer(player)); } // Generate PlayerData (non-persistent) final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); playerdata.setSuperadminIdVerified(false); if (TFM_AdminList.isSuperAdmin(player)) { for (String storedIp : playerEntry.getIps()) { TFM_BanManager.unbanIp(storedIp); TFM_BanManager.unbanIp(TFM_Util.getFuzzyIp(storedIp)); } TFM_BanManager.unbanUuid(TFM_UuidManager.getUniqueId(player)); player.setOp(true); // Verify strict IP match if (!TFM_AdminList.isIdentityMatched(player)) { playerdata.setSuperadminIdVerified(false); TFM_Util.bcastMsg( "Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED); } else { playerdata.setSuperadminIdVerified(true); TFM_AdminList.updateLastLogin(player); } } TFM_PlayerData.getPlayerData(player).setCommandSpy(true); // Handle admin impostors if (TFM_AdminList.isAdminImpostor(player)) { TFM_Util.bcastMsg( "Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED); TFM_Util.bcastMsg( ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player)); player.getInventory().clear(); player.setOp(false); player.setGameMode(GameMode.SURVIVAL); TFM_PlayerData.getPlayerData(player).setFrozen(true); } else if (TFM_AdminList.isSuperAdmin(player) || TFM_Util.DEVELOPERS.contains(player.getName())) { TFM_Util.bcastMsg( ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player)); } // TODO: Cleanup String name = player.getName(); if (TFM_Util.DEVELOPERS.contains(player.getName())) { name = ChatColor.DARK_PURPLE + name; TFM_PlayerData.getPlayerData(player).setTag("&8[&5Developer&8]"); } if (TFM_Util.EXECUTIVES.contains(player.getName())) { name = ChatColor.DARK_BLUE + name; TFM_PlayerData.getPlayerData(player).setTag("&8[&1Executive&8]"); } if (TFM_Util.MANAGERS.contains(player.getName())) { name = ChatColor.DARK_RED + name; TFM_PlayerData.getPlayerData(player).setTag("&8[&4Admin Manager&8]"); } else if (TFM_AdminList.isSuperAdmin(player)) { if (TFM_ConfigEntry.SERVER_OWNERS.getList().contains(name)) { name = ChatColor.BLUE + name; TFM_PlayerData.getPlayerData(player).setTag("&8[&9Owner&8]"); } else if (TFM_AdminList.isSeniorAdmin(player)) { name = ChatColor.LIGHT_PURPLE + name; TFM_PlayerData.getPlayerData(player).setTag("&8[&dSenior Admin&8]"); } else if (TFM_AdminList.isTelnetAdmin(player, true)) { name = ChatColor.DARK_GREEN + name; TFM_PlayerData.getPlayerData(player).setTag("&8[&2Telnet Admin&8]"); } else { name = ChatColor.AQUA + name; TFM_PlayerData.getPlayerData(player).setTag("&8[&BSuper Admin&8]"); } } try { player.setPlayerListName(StringUtils.substring(name, 0, 16)); } catch (IllegalArgumentException ex) { } new BukkitRunnable() { @Override public void run() { if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) { player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins."); } if (TotalFreedomMod.lockdownEnabled) { TFM_Util.playerMsg( player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED); } } }.runTaskLater(TotalFreedomMod.plugin, 20L * 1L); }
@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)) { playerEntry = TFM_PlayerList.getEntry(player); playerEntry.setLastLoginUnix(TFM_Util.getUnixTime()); playerEntry.setLastLoginName(player.getName()); playerEntry.addIp(ip); playerEntry.save(); } else { playerEntry = TFM_PlayerList.getEntry(player); TFM_Log.info("Added new player: " + TFM_Util.formatPlayer(player)); } // Generate PlayerData (non-persistent) final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); playerdata.setSuperadminIdVerified(false); if (TFM_AdminList.isSuperAdmin(player)) { for (String storedIp : playerEntry.getIps()) { TFM_BanManager.unbanIp(storedIp); TFM_BanManager.unbanIp(TFM_Util.getFuzzyIp(storedIp)); } TFM_BanManager.unbanUuid(TFM_UuidManager.getUniqueId(player)); player.setOp(true); // Verify strict IP match if (!TFM_AdminList.isIdentityMatched(player)) { playerdata.setSuperadminIdVerified(false); TFM_Util.bcastMsg( "Warning: " + player.getName() + " is an admin, but is using an account not registered to one of their ip-list.", ChatColor.RED); } else { playerdata.setSuperadminIdVerified(true); TFM_AdminList.updateLastLogin(player); } } // Handle admin impostors if (TFM_AdminList.isAdminImpostor(player)) { if (TFM_Util.imposters.contains(player.getName())) { TFM_Util.bcastMsg( "Warning: " + player.getName() + " is not an imposter and is just trolling.", ChatColor.RED); TFM_Util.bcastMsg( ChatColor.AQUA + player.getName() + " is a fake " + ChatColor.YELLOW + ChatColor.UNDERLINE + "Impostor"); } else { TFM_Util.bcastMsg( "Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED); TFM_Util.bcastMsg( ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player)); player.getInventory().clear(); player.setOp(false); player.setGameMode(GameMode.SURVIVAL); TFM_PlayerData.getPlayerData(player).setFrozen(true); TFM_Util.bcastMsg("Admins, tell him to verify!", ChatColor.RED); } } else if (TFM_AdminList.isSuperAdmin(player) || TFM_Util.DEVELOPERS.contains(player.getName())) { TFM_Util.bcastMsg( ChatColor.AQUA + player.getName() + " is " + TFM_PlayerRank.getLoginMessage(player)); } // TODO: Cleanup String name = player.getName(); if (TFM_Util.RF_DEVELOPERS.contains(name)) { TFM_PlayerData.getPlayerData(player).setCommandSpy(true); player.setPlayerListName(ChatColor.DARK_PURPLE + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&5Developer&8]"); afterNameSet(player); return; } else if (player.getName().equals("iDelRey")) { TFM_PlayerData.getPlayerData(player).setCommandSpy(true); player.setPlayerListName(ChatColor.DARK_PURPLE + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&5Lead Developer&8]"); afterNameSet(player); return; } else if (player.getName().equals("reuben4545")) { TFM_PlayerData.getPlayerData(player).setCommandSpy(true); player.setPlayerListName(ChatColor.GREEN + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&aLead Specialist&8]"); afterNameSet(player); return; } else if (player.getName().equals("Joenmb")) { TFM_PlayerData.getPlayerData(player).setCommandSpy(true); player.setPlayerListName(ChatColor.DARK_PURPLE + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&5Co-Chief Forum Developer&8]"); afterNameSet(player); return; } else if (player.getName().equals("DarkGamingDronze")) { TFM_PlayerData.getPlayerData(player).setCommandSpy(true); player.setPlayerListName(ChatColor.BLUE + player.getName()); TFM_PlayerData.getPlayerData(player).setTag("&8[&9Owner&8]"); player.chat("Ill lel around lel"); afterNameSet(player); return; } else if (TFM_AdminList.isSuperAdmin(player)) { TFM_PlayerData.getPlayerData(player).setCommandSpy(true); if (TFM_ConfigEntry.SERVER_OWNERS.getList().contains(name)) { player.setPlayerListName(ChatColor.BLUE + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&9Owner&8]"); afterNameSet(player); return; } else if (player.getName().equals("MysteriAce")) { player.setPlayerListName(ChatColor.YELLOW + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&cMysteri&8]"); afterNameSet(player); return; } else if (player.getName().equals("DarkHorse108")) { player.setPlayerListName(ChatColor.DARK_RED + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&4System Manager&8]"); afterNameSet(player); return; } if (TFM_Util.FOP_DEVELOPERS.contains(name)) { player.setPlayerListName(ChatColor.DARK_PURPLE + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&5FOP-Developer&8]"); afterNameSet(player); return; } if (TFM_Util.COOWNER.contains(name)) { player.setPlayerListName(ChatColor.DARK_BLUE + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&9Co-Owner&8]"); afterNameSet(player); return; } if (TFM_Util.SPECIALISTS.contains(name)) { player.setPlayerListName(ChatColor.GREEN + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&aSpecialist&8]"); afterNameSet(player); return; } if (TFM_Util.EXECUTIVES.contains(name)) { player.setPlayerListName(ChatColor.YELLOW + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&eExecutive&8]"); afterNameSet(player); return; } if (TFM_Util.SYS.contains(name)) { player.setPlayerListName(ChatColor.DARK_RED + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&4System-Admin&8]"); afterNameSet(player); return; } else if (TFM_AdminList.isSeniorAdmin(player)) { player.setPlayerListName(ChatColor.LIGHT_PURPLE + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&dSenior Admin&8]"); afterNameSet(player); return; } else if (TFM_AdminList.isTelnetAdmin(player, true)) { player.setPlayerListName(ChatColor.DARK_GREEN + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&2Telnet Admin&8]"); afterNameSet(player); return; } else { player.setPlayerListName(ChatColor.AQUA + name); TFM_PlayerData.getPlayerData(player).setTag("&8[&BSuper Admin&8]"); afterNameSet(player); return; } } }