@Override public boolean run( CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (args.length == 0) { return false; } final Player player = getPlayer(args[0]); if (player == null) { playerMsg(TFM_Command.PLAYER_NOT_FOUND, ChatColor.RED); return true; } String reason = null; if (args.length >= 2) { reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); } TFM_Util.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED); // Undo WorldEdits: try { TFM_WorldEditBridge.undo(player, 15); } catch (NoClassDefFoundError ex) { } // rollback TFM_RollbackManager.rollback(player.getName()); // deop player.setOp(false); // set gamemode to survival: player.setGameMode(GameMode.SURVIVAL); // clear inventory: player.getInventory().clear(); // strike with lightning effect: final Location targetPos = player.getLocation(); for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { final Location strike_pos = new Location( targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z); targetPos.getWorld().strikeLightning(strike_pos); } } // ban IP address: String ip = TFM_Util.getFuzzyIp(player.getAddress().getAddress().getHostAddress()); final StringBuilder bcast = new StringBuilder() .append(ChatColor.RED) .append("Banning: ") .append(player.getName()) .append(", IP: ") .append(ip); if (reason != null) { bcast .append(" - Reason: ") .append(ChatColor.YELLOW) .append(reason) .append(" ") .append(ChatColor.GOLD) .append(sender.getName()); } TFM_Util.bcastMsg(bcast.toString()); TFM_BanManager.addIpBan(new TFM_Ban(ip, player.getName(), sender.getName(), null, reason)); // ban username: TFM_BanManager.addUuidBan( new TFM_Ban( TFM_UuidManager.getUniqueId(player), player.getName(), sender.getName(), null, reason)); // kick Player: player.kickPlayer( ChatColor.RED + "GTFO" + (reason != null ? ("\nReason: " + ChatColor.YELLOW + reason) : "") + ChatColor.GOLD + sender.getName()); return true; }
@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; } } }