Java Code Examples for org.bukkit.event.player.AsyncPlayerPreLoginEvent#setKickMessage()
The following examples show how to use
org.bukkit.event.player.AsyncPlayerPreLoginEvent#setKickMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerListener.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onAsyncPlayerPreLoginEventLowest(AsyncPlayerPreLoginEvent event) { if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { return; } final String name = event.getName(); // NOTE: getAddress() sometimes returning null, we don't want to handle this race condition if (event.getAddress() == null) { event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, messages.retrieveSingle(name, MessageKey.KICK_UNRESOLVED_HOSTNAME)); return; } if (validationService.isUnrestricted(name)) { return; } // Non-blocking checks try { onJoinVerifier.checkIsValidName(name); } catch (FailedVerificationException e) { event.setKickMessage(messages.retrieveSingle(name, e.getReason(), e.getArgs())); event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); } }
Example 2
Source File: PlayerListener.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onAsyncPlayerPreLoginEventHighest(AsyncPlayerPreLoginEvent event) { if (event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) { return; } final String name = event.getName(); if (validationService.isUnrestricted(name)) { return; } // Slow, blocking checks try { final PlayerAuth auth = dataSource.getAuth(name); final boolean isAuthAvailable = auth != null; onJoinVerifier.checkKickNonRegistered(isAuthAvailable); onJoinVerifier.checkAntibot(name, isAuthAvailable); onJoinVerifier.checkNameCasing(name, auth); final String ip = event.getAddress().getHostAddress(); onJoinVerifier.checkPlayerCountry(name, ip, isAuthAvailable); } catch (FailedVerificationException e) { event.setKickMessage(messages.retrieveSingle(name, e.getReason(), e.getArgs())); event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); } }
Example 3
Source File: ListenerLogin.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority=EventPriority.NORMAL, ignoreCancelled=true) public void beforeLogin(AsyncPlayerPreLoginEvent e) { FileConfiguration config = this.expansion.getConfig("citizens-compatibility.yml"); if(!config.getBoolean("prevent-login", false)) return; UUID uuid = e.getUniqueId(); NPCManager npcManager = this.expansion.getNPCManager(); NPC npc = npcManager.getNPC(uuid); if(npc == null) return; String message = this.expansion.getPlugin().getLanguageMessageColored("citizens-join-deny"); e.setKickMessage(message); e.setLoginResult(Result.KICK_OTHER); }
Example 4
Source File: BungeemodeListener.java From HeavySpleef with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGH) public void onPlayerPreJoin(AsyncPlayerPreLoginEvent event) { BungeemodeConfig config = addon.getConfig(); if (!config.isEnabled()) { return; } if (!addon.getHeavySpleef().isGamesLoaded()) { event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); event.setKickMessage(addon.getI18n().getString(BungeemodeMessages.KICK_MESSAGE_NOT_YET_READY)); return; } String gameName = config.getGame(); GameManager manager = addon.getHeavySpleef().getGameManager(); if (!manager.hasGame(gameName)) { addon.getLogger().log(Level.WARNING, "Cannot handle player pre login for '" + event.getName() + "': Game " + gameName + " does not exist!"); return; } Game game = manager.getGame(gameName); if (!game.getGameState().isGameEnabled()) { event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); event.setKickMessage(addon.getI18n().getString(BungeemodeMessages.KICK_MESSAGE_DISABLED)); return; } boolean joinOnCountdown = game.getPropertyValue(GameProperty.JOIN_ON_COUNTDOWN); if (game.getGameState() == GameState.INGAME || ((game.getGameState() == GameState.STARTING || game.getGameState() == GameState.WARMUP) && !joinOnCountdown)) { if (config.getSpectateWhenIngame()) { if (game.isFlagPresent(FlagSpectate.class)) { return; } else { addon.getLogger().log(Level.WARNING, "Cannot transfer the player " + event.getName() + " into spectate mode: No spectate flag/point has been set"); } } event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); event.setKickMessage(addon.getI18n().getString(BungeemodeMessages.KICK_MESSAGE_INGAME)); return; } }