if (event.getResult() != Result.ALLOWED) { disconnect(event.getKickMessage(), true); return;
@Override public String getResult() { return event.getResult().toString(); }
@EventHandler(priority = EventPriority.MONITOR) @RegisterMethodWithOrder(tag = "system.nocheatplus.datamanager", beforeTag = ".*") @Override public void onEvent(final PlayerLoginEvent event) { // TODO: Maintain a flag for precondition (e.g. ProtocolLib present). if (event.getResult() == PlayerLoginEvent.Result.ALLOWED) { onPlayerLogin(event); } else { onPlayerLoginDenied(event); } } },
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerLogin(PlayerLoginEvent event) { if (event.getResult() == Result.ALLOWED) { // Temporarily set the max player count to the one as specified here if (hasChangedMaxPlayers()) { maxPlayersField.set(CommonNMS.getPlayerList(), customListCount); } } }
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerLoginFirst(PlayerLoginEvent event) { if (event.getResult() == Result.ALLOWED) { // Register a PlayerTabInfo instance getInfo(event.getPlayer()); // Ensure the listeners are registered in the right order CommonUtil.queueListenerLast(this, PlayerLoginEvent.class); CommonUtil.queueListenerFirst(this, PlayerJoinEvent.class); } }
if(GriefPrevention.instance.config_spam_loginCooldownSeconds > 0 && event.getResult() == Result.ALLOWED && !player.hasPermission("griefprevention.spam")) event.disallow(event.getResult(), event.getKickMessage()); return; if(GriefPrevention.instance.config_smartBan && event.getResult() == Result.KICK_BANNED)
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerLogin(PlayerLoginEvent event) { try { PlayerLoginEvent.Result result = event.getResult(); UUID uuid = event.getPlayer().getUniqueId(); boolean op = event.getPlayer().isOp(); boolean banned = result == PlayerLoginEvent.Result.KICK_BANNED; processing.submit(processors.player().banAndOpProcessor(uuid, () -> banned, op)); } catch (Exception e) { errorHandler.log(L.ERROR, this.getClass(), e); } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerLogin(PlayerLoginEvent loginEvent) { if (loginEvent.getResult() != PlayerLoginEvent.Result.ALLOWED) { //in this event isCancelled option in the annotation doesn't work return; } Player player = loginEvent.getPlayer(); //updates to the chosen one UserPreference preferences = plugin.getLoginSession(player.getUniqueId()); if (preferences != null) { preferences.getTargetSkin().ifPresent(skin -> plugin.getApi().applySkin(player, skin)); } plugin.endSession(player.getUniqueId()); }
@Override public void setup(@Nonnull TerminableConsumer consumer) { try (Connection c = this.sql.getConnection()) { try (Statement s = c.createStatement()) { s.execute(replaceTableName(CREATE)); } } catch (SQLException e) { e.printStackTrace(); } // preload data if (this.preloadAmount > 0) { Log.info("[helper-profiles] Preloading the most recent " + this.preloadAmount + " entries..."); long start = System.currentTimeMillis(); int found = preload(this.preloadAmount); long time = System.currentTimeMillis() - start; Log.info("[helper-profiles] Preloaded " + found + " profiles into the cache! - took " + time + "ms"); } // observe logins Events.subscribe(PlayerLoginEvent.class, EventPriority.MONITOR) .filter(e -> e.getResult() == PlayerLoginEvent.Result.ALLOWED) .handler(e -> { ImmutableProfile profile = new ImmutableProfile(e.getPlayer().getUniqueId(), e.getPlayer().getName()); updateCache(profile); Schedulers.async().run(() -> saveProfile(profile)); }) .bindWith(consumer); }
checkBans(bukkitevent, joindata.data); Bukkit.getPluginManager().callEvent(bukkitevent); if (bukkitevent.getResult() != PlayerLoginEvent.Result.ALLOWED) { disconnect(bukkitevent.getKickMessage()); joindata.close();
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerLogin(final PlayerLoginEvent event) { // (NORMAL to have chat checks come after this.) if (event.getResult() != Result.ALLOWED) { return; } final Player player = event.getPlayer(); // Check if login is denied (plus expiration check). // TODO: Store by id + HashMapLOW + AsyncPlayerPreLogin. if (checkDenyLoginsNames(player.getName())) { if (DataManager.getPlayerData(player).hasPermission(Permissions.BYPASS_DENY_LOGIN, player)) { return; } // TODO: Consider using the vanilla temporary ban feature instead (for an alternative?). // TODO: Display time for which the player is banned. event.setResult(Result.KICK_OTHER); // TODO: Some basic/language configuration object, possibly independent of checks. event.setKickMessage(ColorUtil.replaceColors(ConfigManager.getConfigFile(player.getWorld().getName()).getString(ConfPaths.STRINGS + ".msgtempdenylogin"))); } }
/** * We listen to this type of events to prevent spambots from login to the server. * * @param event * the event */ @EventHandler( priority = EventPriority.NORMAL) public void onPlayerLogin(final PlayerLoginEvent event) { if (event.getResult() != Result.ALLOWED) return; final Player player = event.getPlayer(); final IPlayerData pData = DataManager.getPlayerData(player); final ChatConfig cc = pData.getGenericInstance(ChatConfig.class); final ChatData data = pData.getGenericInstance(ChatData.class); // (No forced permission update, because the associated permissions are treated as hints rather.) // Reset captcha of player if needed. synchronized(data) { captcha.resetCaptcha(player, cc, data, pData); } // Fast relog check. if (relog.isEnabled(player, pData) && relog.unsafeLoginCheck(player, cc, data,pData)) { event.disallow(Result.KICK_OTHER, cc.relogKickMessage); } else if (logins.isEnabled(player, pData) && logins.check(player, cc, data)) { event.disallow(Result.KICK_OTHER, cc.loginsKickMessage); } }