java类org.bukkit.event.player.AsyncPlayerPreLoginEvent的实例源码

EventListener.java 文件源码 项目:AntiBots 阅读 24 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerJoin(AsyncPlayerPreLoginEvent event){
    if(protection){
        DataProvider dp = DataProvider.getInstance();
        ApiDataProvider adp = ApiDataProvider.getInstance();
        try{
            if(dp.getWhitelist().contains(event.getName())) return;
            if(!adp.testFor(event.getName())){
                event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, DataProvider.getInstance().getFormattedMessage());
            }
        } catch(Exception e) {
            Main.instance().getLogger().log(Level.SEVERE, "An exception occured while verifying " + event.getName() + ". Usually it's caused by bad configuration. Check your configuration, or start a new issue on GitHub!");
            event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, DataProvider.getInstance().getFormattedMessage());
        }
    }
}
JoinManagerImplement.java 文件源码 项目:SamaGamesCore 阅读 26 收藏 0 点赞 0 评论 0
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());
}
BukkitConnectionListener.java 文件源码 项目:LuckPerms 阅读 21 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerPreLoginMonitor(AsyncPlayerPreLoginEvent e) {
    /* Listen to see if the event was cancelled after we initially handled the connection
       If the connection was cancelled here, we need to do something to clean up the data that was loaded. */

    // Check to see if this connection was denied at LOW.
    if (this.deniedAsyncLogin.remove(e.getUniqueId())) {
        // their data was never loaded at LOW priority, now check to see if they have been magically allowed since then.

        // This is a problem, as they were denied at low priority, but are now being allowed.
        if (e.getLoginResult() == AsyncPlayerPreLoginEvent.Result.ALLOWED) {
            this.plugin.getLog().severe("Player connection was re-allowed for " + e.getUniqueId());
            e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "");
        }

        return;
    }
}
TransactionAntiBot.java 文件源码 项目:K-Security 阅读 17 收藏 0 点赞 0 评论 0
@EventHandler
public void onAsync(AsyncPlayerPreLoginEvent event) {
    cacher.removeAndGet(event.getAddress()).ifPresent(player -> {
        sendPacket(player, factory.createLoginPacket());
        Bukkit.getScheduler().runTask(plugin, () -> ignore.addIgnore(player, Packets.Server.LOGIN));
        holder.addPlayer(player);

        sendPacket(player, factory.createTransactionPacket(0, Short.MIN_VALUE, false));
        if (latch.await(player)) {
            holder.flush(player);
            players.add(player.getAddress().getAddress().toString());
        } else {
            event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, Lang.BOT_DETECT.withSpacingPrefix());
            counter.incrementAndGet();
        }
        holder.release(player);
        latch.release(player);
        cacher.release(player);
    });
}
TestBukkit.java 文件源码 项目:ExilePearl 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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;
}
BukkitMain.java 文件源码 项目:AdvancedBan 阅读 21 收藏 0 点赞 0 评论 0
public void onEnable() {
    instance = this;
    Universal.get().setup(new BukkitMethods());

    ConnectionListener connListener = new ConnectionListener();
    this.getServer().getPluginManager().registerEvents(connListener, this);
    this.getServer().getPluginManager().registerEvents(new ChatListener(), this);
    this.getServer().getPluginManager().registerEvents(new CommandListener(), this);

    for (Player op : Bukkit.getOnlinePlayers()) {
        AsyncPlayerPreLoginEvent apple = new AsyncPlayerPreLoginEvent(op.getName(), op.getAddress().getAddress(), op.getUniqueId());
        connListener.onConnect(apple);
        if (apple.getLoginResult() == AsyncPlayerPreLoginEvent.Result.KICK_BANNED) {
            op.kickPlayer(apple.getKickMessage());
        }
    }
}
CraftoDatabase.java 文件源码 项目:CraftoPlugin 阅读 21 收藏 0 点赞 0 评论 0
private void checkForNameChange(final CraftoPlayer player, final AsyncPlayerPreLoginEvent event) {
        if (player != null && event != null && player.getUniqueId().equals(event.getUniqueId())) {
            if (!player.getName().equalsIgnoreCase(event.getName())) { // If true, player has changed his name!
//              final String query = "INSERT INTO `cp_history` (`playerid`, `info`, `created_at`) "
//                      + "VALUES ("+player.getId()+", 'Changed name from "+player.getName()+" to "+event.getName()+".', "+new Timestamp(System.currentTimeMillis())
//                      + "); UPDATE `cp_players` SET `name`='"+event.getName()+"' WHERE `uuid`='"+event.getUniqueId()+"' LIMIT 1;";
//              this.executeAsync(Query.of(query));

                player.registerRecord(0, "Changed name from " + player.getName() + " to " + event.getName() + ".", null, null);

                this.plugin.getServer().getPluginManager().callEvent(new CraftoPlayerNameChangeEvent(player, player.getName(), event.getName()));
                ((DatabaseCraftoPlayer) player).setName(event.getName());

                // Reinsert into name map
                if (!this.namePlayerMap.containsKey(player.getName().toLowerCase())) { this.namePlayerMap.put(player.getName().toLowerCase(), new SortedList<>(1)); }
                this.namePlayerMap.get(player.getName().toLowerCase()).add(player);
            }
        }
    }
PlayerListener.java 文件源码 项目:CrazyLogin 阅读 18 收藏 0 点赞 0 评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
@Permission("crazylogin.warnsession")
@Localized({ "CRAZYLOGIN.KICKED.SESSION.DUPLICATE", "CRAZYLOGIN.SESSION.DUPLICATEWARN $Name$ $IP$" })
public void PlayerLoginSessionCheck(final AsyncPlayerPreLoginEvent event) {
    if (plugin.isForceSingleSessionEnabled()) {
        final Player player = Bukkit.getPlayerExact(event.getName());
        if (player != null) {
            if (plugin.isForceSingleSessionSameIPBypassEnabled()) {
                final LoginPlayerData data = plugin.getPlayerData(player);
                if (data != null) {
                    if (event.getAddress().getHostAddress().equals(data.getLatestIP())) {
                        return;
                    }
                }
            }
            event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
            event.setKickMessage(plugin.getLocale().getLocaleMessage(player, "KICKED.SESSION.DUPLICATE"));
            plugin.broadcastLocaleMessage(true, "crazylogin.warnsession", true, "SESSION.DUPLICATEWARN", player.getName(), event.getAddress().getHostAddress());
            plugin.sendLocaleMessage("SESSION.DUPLICATEWARN", player, event.getAddress().getHostAddress(), player.getName());
            plugin.getCrazyLogger().log("AccessDenied", "Denied access for player " + player.getName() + " @ " + event.getAddress().getHostAddress() + " because of a player with this name being already online");
            return;
        }
    }
}
BukkitListener.java 文件源码 项目:CloudNet 阅读 20 收藏 0 点赞 0 评论 0
@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, "§cYou have to connect from a internal proxy server!");
}
JoinManager.java 文件源码 项目:Warzone 阅读 20 收藏 0 点赞 0 评论 0
@EventHandler
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
    if (event.getLoginResult().equals(AsyncPlayerPreLoginEvent.Result.KICK_BANNED)) return;
    UserProfile userProfile = TGM.get().getTeamClient().login(new PlayerLogin(event.getName(), event.getUniqueId().toString(), event.getAddress().getHostAddress()));
    Bukkit.getLogger().info(userProfile.getName() + " " + userProfile.getId().toString());
    queuedJoins.add(new QueuedJoin(event.getUniqueId(), userProfile, System.currentTimeMillis()));
}
DupeLoginPatch.java 文件源码 项目:EscapeLag 阅读 18 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void onLogin(AsyncPlayerPreLoginEvent evt) {
    if (ConfigPatch.fixDupeOnline) {
        if (AzurePlayerList.contains(evt.getName())) {
            evt.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
            evt.setKickMessage(ConfigPatch.messageKickDupeOnline);
        }
    }
}
IdentityProviderImpl.java 文件源码 项目:ProjectAres 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Clear any nickname that collides with the real name of a player logging in.
 * This ensures that usernames + nicknames together contain no duplicates.
 * The user who's nickname was cleared is not notified of this, but this
 * should be an extremely rare situation, so it's not a big problem.
 */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = false)
public void clearConflictingNicks(AsyncPlayerPreLoginEvent event) {
    final String name = event.getName();
    syncExecutor.execute(() -> {
        final Player player = nicknames.get(name);
        if(player != null) {
            changeIdentity(player, null);
        }
    });
}
Punishments.java 文件源码 项目:Kineticraft 阅读 21 收藏 0 点赞 0 评论 0
@EventHandler
public void onJoin(AsyncPlayerPreLoginEvent evt) {
    KCPlayer player = KCPlayer.getWrapper(evt.getUniqueId());
    if (player.isBanned())
        evt.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED,
            ChatColor.RED + "You are banned from Kineticraft!\n"
                    + ChatColor.RED + "Reason: " + ChatColor.YELLOW + player.getPunishments().last().getType().getDisplay() + "\n"
                    + ChatColor.RED + "Expiration: " + ChatColor.YELLOW + Utils.formatTimeFull(player.getPunishExpiry()) + "\n"
                    + ChatColor.RED + "Appeal on discord: http://kineticraft.net");
}
ConnectionListener.java 文件源码 项目:mopm 阅读 25 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
    plugin.getLookupBoss().scheduleLookup(event.getAddress(), optBl -> optBl.ifPresent(proxyBlacklist -> {
        AsyncProxyDetectedEvent detectedEvent = new AsyncProxyDetectedEvent(proxyBlacklist, event.getAddress(), event.getUniqueId());
        plugin.getServer().getPluginManager().callEvent(detectedEvent);
        this.onJoinActions.put(detectedEvent.getUuid(), detectedEvent.getActions());
        this.finders.put(event.getUniqueId(), proxyBlacklist);
    }));
}
AntiDoubleLogin.java 文件源码 项目:NeverLag 阅读 26 收藏 0 点赞 0 评论 0
@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"));
    }
}
UserListener.java 文件源码 项目:VoxelGamesLibv2 阅读 23 收藏 0 点赞 0 评论 0
@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)));
    }
}
JoinQuitHandlers.java 文件源码 项目:UHC 阅读 25 收藏 0 点赞 0 评论 0
@EventHandler
public void prejoin(final AsyncPlayerPreLoginEvent event){
    if (!UserManager.getInstance().getUser(event.getUniqueId()).isPresent() &&
            (GameState.current() != GameState.LOBBY && GameState.current() != GameState.STARTING)
            && UHC.getInstance().getMainConfig().isRoundBanDead()) {
        event.setKickMessage(colour("&cThe round has already started!"));
        event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
    }
}
MessageClientLoginListener.java 文件源码 项目:FlexMC 阅读 24 收藏 0 点赞 0 评论 0
private String tryLogin( ConnectionHandler connectionHandler, MessageC00LoginStart message ) {
    if ( connectionHandler.getVersion() > 338 ) {
        return "Outdated Server. Please use 1.12.1";
    }
    if ( connectionHandler.getVersion() < 338 ) {
        return "Outdated Client. Please use 1.12.1";
    }
    if ( connectionHandler.getVerifySession() != null ) {
        return "Already logging in";
    }
    if ( !Flex.getServer().isRunning() || Flex.getServer().getWorld() == null || !Flex.getServer().getWorld().isGenerated() ) {
        return "Server ist still starting up";
    }
    AsyncPlayerPreLoginEvent event = EventFactory.call( new AsyncPlayerPreLoginEvent( message.getName(), connectionHandler.getSocketAddress().getAddress(), UUID.randomUUID() ) );

    if( event.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED ) {
        return event.getKickMessage() == null ? "null" : event.getKickMessage();
    }

    if ( Flex.getServer().getConfig().isVerifyUsers() ) {
        VerifySession verifySession = new VerifySession( AuthHelper.nextToken(), message.getName() );
        connectionHandler.setVerifySession( verifySession );
        MessageS01EncryptionRequest encryptionRequest = new MessageS01EncryptionRequest( "", Flex.getServer().getKeyPair().getPublic().getEncoded(), verifySession.getToken() );
        connectionHandler.sendMessage( encryptionRequest );
        verifySession.getState().incrementAndGet();
    } else {
        connectionHandler.loginSuccess( message.getName(), UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + message.getName() ).getBytes( Charsets.UTF_8 ) ) );
    }
    return null;
}
PunishmentManager.java 文件源码 项目:ZentrelaCore 阅读 20 收藏 0 点赞 0 评论 0
@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();
    }
}
LoginLogoutManager.java 文件源码 项目:ZentrelaCore 阅读 18 收藏 0 点赞 0 评论 0
@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!");
    }
}
UserListener.java 文件源码 项目:VoxelGamesLib 阅读 25 收藏 0 点赞 0 评论 0
@EventHandler
public void asyncLogin(@Nonnull AsyncPlayerPreLoginEvent event) {
    AsyncUserLoginEvent e = new AsyncUserLoginEvent(event.getUniqueId(), event.getName());
    eventHandler.callEvent(e);
    if (e.isCanceled()) {
        event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
        event.setKickMessage(e.getKickMessage());
    }
}
DOHACheck.java 文件源码 项目:DOHA-Check 阅读 20 收藏 0 点赞 0 评论 0
@Override
public void onEnable() {
    saveDefaultConfig();
    loadComponent(Configuration.class);

    if (Configuration.httpProxy.enabled.get())
        Unirest.setProxy(new HttpHost(Configuration.httpProxy.host.get(), Configuration.httpProxy.port.get()));

    accountTruster = new AccountTruster(new Requester(this));

    ZLib.registerEvents(new Listener() {
        @EventHandler
        public void onLogin(final AsyncPlayerPreLoginEvent event) {
            accountTruster.isHacked(event.getUniqueId(), new Callback<Boolean>() {
                public void call(Boolean hacked) {
                    if (hacked) {
                        Player player = Bukkit.getPlayer(event.getUniqueId());
                        if (player == null)
                            return;

                        player.kickPlayer(Configuration.kickReason.get());

                        for (Player p : Bukkit.getOnlinePlayers())
                            if (p.hasPermission(Configuration.annoucements.permission.get()))
                                p.sendMessage(Configuration.annoucements.message.get()
                                        .replaceAll("%player_name", player.getName())
                                        .replaceAll("%ip_address", event.getAddress().getHostAddress()));
                    }
                }
            });
        }
    });
}
LoginEventHandler.java 文件源码 项目:BeeLogin 阅读 20 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(AsyncPlayerPreLoginEvent event) {
    InetAddress playerAddress = event.getAddress();
    if ((Config.skipOnLoopbackAddress && playerAddress.isLoopbackAddress())
            || (Config.skipOnSiteLocalAddress && playerAddress.isSiteLocalAddress())) {
        return;
    }
    if (Config.usingBeeLoginMod) {
        BeeLogin.loginStatus.put(event.getName().toLowerCase(), false);
        event.allow();
        return;
    }
    String playerName = event.getName();
    String playerIp = playerAddress.getHostAddress().replace("/", "");
    LoginResult result = new LoginResult(Config.checkUrl, Config.queryMode, Config.encodeMode, playerName, playerIp,
            Config.serverIp, Config.serverPassword);
    if (result.getResult()) {
        event.allow();
    } else if (result.isBadIp()) {
        event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
        event.setKickMessage(Config.badIpMessage.replace("%UserIp%", playerIp));
        event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER,
                Config.badIpMessage.replace("%UserIp%", playerIp));
    } else {
        event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
        event.setKickMessage(Config.kickMessage);
        event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, Config.badIpMessage);
    }
}
VanguardListener.java 文件源码 项目:Vanguard 阅读 35 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void preAuth(AsyncPlayerPreLoginEvent ev) {
    PlayerSettings settings = Vanguard.getPlayerSettings(ev.getUniqueId());
    if (settings.getFailedAttempts() >= Configuration.getMaxAttemptFailure()) {
        ev.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_BANNED);
        ev.setKickMessage(Configuration.getString("toomanyfailedattempts"));
    } else if (settings.getBanned() >= System.currentTimeMillis()) {
        ev.setKickMessage(Configuration.getString("vanguardauthfailure")
                .replace("$timeout$",
                        Long.toString(Configuration.getBanTimeOnFail())));

        ev.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_BANNED);
    }
}
BetterShardsListener.java 文件源码 项目:BetterShards 阅读 20 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void playerPreLoginCacheInv(AsyncPlayerPreLoginEvent event) {
    UUID uuid = event.getUniqueId();
    if (uuid != null) {
        plugin.getLogger().log(Level.FINER, "Preparing to pre-load player data: {0}", uuid);
    } else { 
        return;
    }
    if (st == null){ // Small race condition if someone logs on as soon as the server starts.
        event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Please try to log in again in a moment, server is not ready to accept log-ins.");
        plugin.getLogger().log(Level.INFO, "Player {0} logged on before async process was ready, skipping.", uuid);
        return;
    }
    // caching disabled due to fail
    Future<ByteArrayInputStream> soondata = db.loadPlayerDataAsync(uuid, st.getInvIdentifier(uuid), true); // wedon't use the data, but know that it caches behind the scenes.

    try {
        ByteArrayInputStream after = soondata.get(); // I want to _INTENTIONALLY_ delay accepting the user's login until I know for sure I've got the data loaded asynchronously.
        if (after == null) {
            plugin.getLogger().log(Level.INFO, "Pre-load for player data {0} came back empty. New player? Error?", uuid);
        } else {
            plugin.getLogger().log(Level.FINER, "Pre-load for player data {0} complete.", uuid);
        }

    } catch (InterruptedException | ExecutionException e) {
        plugin.getLogger().log(Level.SEVERE, "Failed to pre-load player data: {0}", uuid);
        e.printStackTrace();
    }

    // We do this so it fetches the cache, then when called for real
    // by our CustomWorldNBTStorage class it doesn't have to wait and server won't lock.
}
BetterShardsListener.java 文件源码 项目:BetterShards 阅读 20 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void playerJoinedLobbyServer(AsyncPlayerPreLoginEvent event) {
    if (!config.get("lobby").getBool())
        return;
    UUID uuid = event.getUniqueId();
    if (st == null){ // Small race condition if someone logs on as soon as the server starts.
        plugin.getLogger().log(Level.INFO, "Player logged on before async process was ready, skipping.");
        return;
    }
    st.setInventoryIdentifier(uuid, InventoryIdentifier.IGNORE_INV);
}
RPPlayerListener.java 文件源码 项目:RedProtect 阅读 21 收藏 0 点赞 0 评论 0
@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);
        }
    }
}
PowerfulPermissionManager.java 文件源码 项目:PowerfulPerms 阅读 18 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onAsyncPlayerPreLogin(final AsyncPlayerPreLoginEvent e) {
    debug("AsyncPlayerPreLoginEvent " + e.getName());

    if (e.getLoginResult() == AsyncPlayerPreLoginEvent.Result.ALLOWED) {
        loadPlayer(e.getUniqueId(), e.getName(), true, true);
    }
}
PlayerConnectListener.java 文件源码 项目:Hammer 阅读 19 收藏 0 点赞 0 评论 0
@EventHandler(ignoreCancelled = true)
public void onPlayerConnect(AsyncPlayerPreLoginEvent event) {
    try {
        HammerText text = eventCore.handleEvent(
                new BukkitWrappedPlayer(Bukkit.getOfflinePlayer(event.getUniqueId())),
                event.getAddress().getHostAddress());

        if (text != null) {
            event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, HammerTextConverter.constructMessage(text));
        }
    } catch (HammerException e) {
        plugin.getLogger().severe("Connection to the MySQL database failed. Falling back to the Minecraft ban list.");
        e.printStackTrace();
    }
}
ConnectionListener.java 文件源码 项目:AdvancedBan 阅读 26 收藏 0 点赞 0 评论 0
@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);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号