/** * Handles pre-hooks for a player login. * * @param name the name of the player who is logging in * @param address the address of the player who is logging in * @param uuid the UUID of the player who is logging in, provided by Mojang * @return an AsyncPlayerPreLoginEvent */ @SuppressWarnings("deprecation") public AsyncPlayerPreLoginEvent onPlayerPreLogin(String name, InetSocketAddress address, UUID uuid) { // call async event AsyncPlayerPreLoginEvent event = new AsyncPlayerPreLoginEvent(name, address .getAddress(), uuid); callEvent(event); // call sync event only if needed if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length > 0) { // initialize event to match current state from async event PlayerPreLoginEvent syncEvent = new PlayerPreLoginEvent(name, address .getAddress(), uuid); if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { syncEvent.disallow(event.getResult(), event.getKickMessage()); } // call event synchronously and copy data back to original event callEvent(syncEvent); event.disallow(syncEvent.getResult(), syncEvent.getKickMessage()); } return event; }
@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.HIGH) public void onLogin(AsyncPlayerPreLoginEvent e) { if (!cm.isAntiDoubleLogin) { return; } String username = e.getName(); if (username == null) { return; } if (this.checkOnline(username)) { e.disallow(Result.KICK_OTHER, i18n.tr("antiDoubleLoginMessage")); } }
@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; } }
@EventHandler(priority = EventPriority.HIGHEST) public void handle0(AsyncPlayerPreLoginEvent e) { for (Player all : Bukkit.getOnlinePlayers()) if (all.getUniqueId().equals(e.getUniqueId())) { e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("server-kick-proxy-disallow"))); return; } CloudServer.getInstance().getPlayerAndCache(e.getUniqueId()); }
Response response = this.expectedPlayers.remove(e.getUniqueId()); if (response == null || !response.isAllowed()) { e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_WHITELIST, Text.colorize("&cSorry! The server is unable to process your login at this time. (queue error)"));