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

下面列出了怎么用org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ChangeSkin   文件: LoginListener.java
@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());
}
 
源代码2 项目: VoxelGamesLibv2   文件: UserListener.java
@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)));
    }
}
 
源代码3 项目: CombatLogX   文件: ListenerLogin.java
@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);
}
 
源代码4 项目: ChangeSkin   文件: LoginListener.java
@EventHandler(priority = EventPriority.HIGHEST)
public void onPreLogin(AsyncPlayerPreLoginEvent preLoginEvent) {
    if (preLoginEvent.getLoginResult() != Result.ALLOWED) {
        //in this event isCancelled option in the annotation doesn't work
        return;
    }

    UUID playerUuid = preLoginEvent.getUniqueId();
    String playerName = preLoginEvent.getName();

    UserPreference preferences = core.getStorage().getPreferences(playerUuid);
    if (preferences == null) {
        return;
    }

    plugin.startSession(playerUuid, preferences);

    Optional<SkinModel> optSkin = preferences.getTargetSkin();
    if (optSkin.isPresent()) {
        SkinModel targetSkin = optSkin.get();
        if (!preferences.isKeepSkin()) {
            targetSkin = core.checkAutoUpdate(targetSkin);
        }

        preferences.setTargetSkin(targetSkin);
        save(preferences);
    } else if (core.getConfig().getBoolean("restoreSkins")) {
        refetchSkin(playerName, preferences);
    }

    if (!preferences.getTargetSkin().isPresent()) {
        getRandomSkin().ifPresent(preferences::setTargetSkin);
    }
}
 
源代码5 项目: BetonQuest   文件: JoinQuitListener.java
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
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));
}
 
 类所在包
 类方法
 同包方法