Search in sources :

Example 1 with MotdTask

use of com.alessiodp.parties.common.tasks.MotdTask in project Parties by AlessioDP.

the class JoinLeaveListener method onPlayerJoin.

/**
 * Used by Bukkit, Bungeecord
 */
protected void onPlayerJoin(User player) {
    // Make it async
    plugin.getScheduler().runAsync(() -> {
        PartyPlayerImpl partyPlayer = plugin.getPlayerManager().loadPlayer(player.getUUID());
        // Party checking
        PartyImpl party = plugin.getPartyManager().loadParty(partyPlayer.getPartyId(), true);
        if (party != null) {
            // Party found
            party.addOnlineMember(partyPlayer);
            party.memberJoinTimeout(partyPlayer);
            if (ConfigParties.ADDITIONAL_MOTD_ENABLE && party.getMotd() != null && !plugin.isBungeeCordEnabled()) {
                plugin.getScheduler().scheduleAsyncLater(new MotdTask(plugin, player.getUUID(), partyPlayer.getCreateID()), ConfigParties.ADDITIONAL_MOTD_DELAY, TimeUnit.MILLISECONDS);
            }
            plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_PLAYER_JOIN, player.getName(), party.getName() + "|" + party.getId()), true);
        } else if (ConfigParties.ADDITIONAL_FIXED_DEFAULT_ENABLE && !player.hasPermission(PartiesPermission.ADMIN_JOIN_DEFAULT_BYPASS)) {
            // Party not found - checking for default one
            party = plugin.getPartyManager().loadParty(ConfigParties.ADDITIONAL_FIXED_DEFAULT_PARTY);
            if (party != null) {
                party.addMember(partyPlayer, JoinCause.OTHERS, null);
                if (ConfigParties.ADDITIONAL_MOTD_ENABLE && party.getMotd() != null) {
                    plugin.getScheduler().scheduleAsyncLater(new MotdTask(plugin, player.getUUID(), partyPlayer.getCreateID()), ConfigParties.ADDITIONAL_MOTD_DELAY, TimeUnit.MILLISECONDS);
                }
                partyPlayer.sendMessage(Messages.OTHER_FIXED_DEFAULTJOIN, party);
                plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_PLAYER_JOIN_DEFAULTJOIN, player.getName(), party.getName() + "|" + party.getId()), true);
            } else {
                plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_PLAYER_JOIN_DEFAULTFAIL, ConfigParties.ADDITIONAL_FIXED_DEFAULT_PARTY), true);
            }
        }
        if (ConfigParties.GENERAL_JOIN_LEAVE_MESSAGES && party != null) {
            party.broadcastMessage(Messages.OTHER_JOINLEAVE_SERVERJOIN, partyPlayer);
        }
        plugin.getLoginAlertsManager().sendAlerts(player);
        onJoinComplete(partyPlayer);
    });
}
Also used : PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) MotdTask(com.alessiodp.parties.common.tasks.MotdTask) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Aggregations

PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)1 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)1 MotdTask (com.alessiodp.parties.common.tasks.MotdTask)1