public void onLogin(AsyncPlayerPreLoginEvent event) { UUID player = event.getUniqueId(); if (moderatorsExpected.contains(player)) // On traite après return; if(!playersExpected.contains(player)) { JoinResponse response = requestJoin(event.getUniqueId(), true); if (!response.isAllowed()) { event.disallow(Result.KICK_OTHER, ChatColor.RED + response.getReason()); return; } } playersExpected.remove(player); for (IJoinHandler handler : this.joiners.values()) handler.onLogin(player, event.getName()); }
/** * Creates a new player instance and adds it to the server * @param name The player name * @param uid The player UUID * @return The player instance */ public static TestPlayer createOnlinePlayer(String name, UUID uid) { TestPlayer p = TestPlayer.create(name); final InetSocketAddress address = new InetSocketAddress("localhost", 25565); final AsyncPlayerPreLoginEvent preLoginEvent = new AsyncPlayerPreLoginEvent(name, address.getAddress(), uid); getPluginManager().callEvent(preLoginEvent); if (preLoginEvent.getLoginResult() != Result.ALLOWED) { return null; } final PlayerLoginEvent loginEvent = new PlayerLoginEvent(p, "localhost", address.getAddress()); getPluginManager().callEvent(loginEvent); if (loginEvent.getResult() != PlayerLoginEvent.Result.ALLOWED) { return null; } final PlayerJoinEvent joinEvent = new PlayerJoinEvent(p, ""); getPluginManager().callEvent(joinEvent); p.goOnline(); return p; }
@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 public void onAsyncLogin(@Nonnull AsyncPlayerPreLoginEvent event) { if (!handler.login(event.getUniqueId())) { // something went horribly wrong // we don't have a locale here since the data was not loaded :/ event.disallow(Result.KICK_OTHER, Lang.legacyColors(Lang.string(LangKey.DATA_NOT_LOADED))); } }
@EventHandler public void onAsyncPrelogin(AsyncPlayerPreLoginEvent event) { InetAddress address = event.getAddress(); String name = event.getName(); String uuid = event.getUniqueId().toString(); String ip = PunishmentManager.parseIP(address); PunishmentManager.registerIP(event.getUniqueId(), ip); /* * Check if user has a ban in effect matching either UUID or IP */ AutoCloseable[] ac_dub = SQLManager.prepare("SELECT * FROM punishments WHERE uuid = ? OR ip = ?"); try { PreparedStatement request_punishment_status = (PreparedStatement) ac_dub[0]; request_punishment_status.setString(1, uuid); request_punishment_status.setString(2, ip); AutoCloseable[] ac_trip = SQLManager.executeQuery(request_punishment_status); ResultSet rs = (ResultSet) ac_trip[0]; while (rs.next()) { Punishment pun = new Punishment(); pun.load(rs); if (pun.isValid()) { if (pun.type == PunishmentType.BAN || pun.type == PunishmentType.IPBAN) { System.out.println("Kicking " + name + " for active ban."); event.disallow(Result.KICK_OTHER, pun.getReason()); } else if (pun.type == PunishmentType.MUTE) { muted_byUUID.put(uuid, pun); } } } SQLManager.close(ac_dub); SQLManager.close(ac_trip); } catch (Exception e) { e.printStackTrace(); } }
@EventHandler public void onAsyncPrelogin(AsyncPlayerPreLoginEvent event) { if (MaintenanceCommand.maintenanceMode && !MaintenanceCommand.allowed.contains(event.getUniqueId().toString())) { if (MotdManager.getMotd() != null) event.disallow(Result.KICK_OTHER, MotdManager.getMotd()); else event.disallow(Result.KICK_OTHER, ChatColor.RED + "Zentrela is down for maintenance. Please check the MOTD (server list) for details!"); } }
@EventHandler public void PlayerLogin(AsyncPlayerPreLoginEvent e){ if (!RPConfig.getBool("server-protection.nickname-cap-filter.enabled")){ return; } if (RedProtect.get().Ess){ User essp = RedProtect.get().pless.getOfflineUser(e.getName()); if (essp != null && !essp.getConfigUUID().equals(e.getUniqueId())){ e.setKickMessage(RPLang.get("playerlistener.capfilter.kickmessage").replace("{nick}", essp.getName())); e.setLoginResult(Result.KICK_OTHER); } } }
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerJoin(AsyncPlayerPreLoginEvent event) { String ip = event.getAddress().getHostAddress(); if (!ip.equals("127.0.0.1")) { event.disallow(Result.KICK_OTHER, ChatColor.RED + "Eh?"); } }
@EventHandler(priority = EventPriority.HIGHEST) public void playerPreLogin(AsyncPlayerPreLoginEvent event) { // if player was kicked, don't load the data if (event.getLoginResult() != Result.ALLOWED) { return; } String playerID = event.getUniqueId().toString(); BetonQuest plugin = BetonQuest.getInstance(); plugin.putPlayerData(playerID, new PlayerData(playerID)); }
private void work(AsyncPlayerPreLoginEvent event) { InetAddress addr = event.getAddress(); if (this.segment.contains(addr)) { event.setLoginResult(Result.KICK_BANNED); event.setKickMessage("您的IP已被服务器封禁"); } else if (addr.getHostAddress().equals(LOCAL_HOST)) { // DO NOTHING } else if (checkAddr(addr.getHostAddress())) { event.setLoginResult(Result.KICK_OTHER); event.setKickMessage("请稍后尝试登陆服务器"); } this.addrLast.put(addr.getHostAddress(), System.currentTimeMillis()); }
@EventHandler public void login(AsyncPlayerPreLoginEvent event) { if(Blocker.isBlocked(event.getUniqueId())) { event.disallow(Result.KICK_OTHER, Blocker.MESSAGE); } }
@EventHandler public void onPlayerLogin(AsyncPlayerPreLoginEvent event) { if (isInProgress()) { event.disallow(Result.KICK_OTHER, ServerShutdown.this.kickMessage); } }
@EventHandler(priority = EventPriority.HIGHEST) private void onPlayerJoin(AsyncPlayerPreLoginEvent event) { if (!_isModulesLoaded) event.disallow(Result.KICK_OTHER, "PV-Star is still loading."); }
@EventHandler(priority = EventPriority.HIGHEST) public void login(AsyncPlayerPreLoginEvent event) { if (event.getLoginResult().equals(Result.ALLOWED)) { work(event); } }