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

JoinManagerImplement.java 文件源码 项目:SamaGamesCore 阅读 22 收藏 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());
}
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;
}
AntiDoubleLogin.java 文件源码 项目:NeverLag 阅读 20 收藏 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 阅读 28 收藏 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)));
    }
}
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 阅读 34 收藏 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!");
    }
}
RPPlayerListener.java 文件源码 项目:RedProtect 阅读 31 收藏 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);
        }
    }
}
PaloozaPlugin.java 文件源码 项目:MiniMiniGames 阅读 22 收藏 0 点赞 0 评论 0
@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?");
   }
}
JoinQuitListener.java 文件源码 项目:BetonQuest 阅读 21 收藏 0 点赞 0 评论 0
@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));
}
PlayerLogin.java 文件源码 项目:ProtectPlugin 阅读 22 收藏 0 点赞 0 评论 0
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());
}
BlockerBukkit.java 文件源码 项目:BOHA 阅读 19 收藏 0 点赞 0 评论 0
@EventHandler
public void login(AsyncPlayerPreLoginEvent event) {
    if(Blocker.isBlocked(event.getUniqueId())) {
        event.disallow(Result.KICK_OTHER, Blocker.MESSAGE);
    }
}
ServerShutdown.java 文件源码 项目:SupaCommons 阅读 22 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerLogin(AsyncPlayerPreLoginEvent event) {
  if (isInProgress()) {
    event.disallow(Result.KICK_OTHER, ServerShutdown.this.kickMessage);
  }
}
ModuleLoader.java 文件源码 项目:PV-Star 阅读 26 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGHEST)
private void onPlayerJoin(AsyncPlayerPreLoginEvent event) {

    if (!_isModulesLoaded)
        event.disallow(Result.KICK_OTHER, "PV-Star is still loading.");
}
PlayerLogin.java 文件源码 项目:ProtectPlugin 阅读 25 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void login(AsyncPlayerPreLoginEvent event) {
    if (event.getLoginResult().equals(Result.ALLOWED)) {
        work(event);
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号