@EventHandler(priority = EventPriority.HIGHEST) public void onConnect(AsyncPlayerPreLoginEvent event) { String result = Universal.get().callConnection(event.getName(), event.getAddress().getHostAddress()); if (result != null) { event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, result); } }
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event) { final String ip = event.getAddress().getHostAddress().trim(); final boolean isAdmin = plugin.al.getEntryByIp(ip) != null; // Check if the player is already online for (Player onlinePlayer : server.getOnlinePlayers()) { if (!onlinePlayer.getName().equalsIgnoreCase(event.getName())) { continue; } if (isAdmin) { event.allow(); FSync.playerKick(onlinePlayer, "An admin just logged in with the username you are using."); return; } event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username is already logged into this server."); return; } }