Search in sources :

Example 1 with BungeePartiesConfigurationManager

use of com.alessiodp.parties.bungeecord.configuration.BungeePartiesConfigurationManager in project Parties by AlessioDP.

the class BungeePartiesMessageListener method handleChannelMain.

protected void handleChannelMain(byte[] bytes, String channel) {
    PartiesPacket packet = PartiesPacket.read(plugin, bytes);
    if (packet != null) {
        PartyImpl party;
        PartyPlayerImpl partyPlayer;
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_RECEIVED, packet.getType().name(), channel), true);
        switch(packet.getType()) {
            case UPDATE_PARTY:
                if (((PartiesPlugin) plugin).getPartyManager().reloadParty(packet.getPartyId())) {
                    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_UPDATE_PARTY, packet.getPartyId().toString()), true);
                }
                break;
            case INVITE_PLAYER:
                party = ((PartiesPlugin) plugin).getPartyManager().getParty(packet.getPartyId());
                if (party != null) {
                    try {
                        ByteArrayDataInput input = ByteStreams.newDataInput(packet.getPayloadRaw());
                        PartyPlayerImpl invitedPlayer = ((PartiesPlugin) plugin).getPlayerManager().getPlayer(UUID.fromString(input.readUTF()));
                        String uuidInviter = input.readUTF();
                        PartyPlayerImpl inviter = uuidInviter.isEmpty() ? null : ((PartiesPlugin) plugin).getPlayerManager().getPlayer(UUID.fromString(uuidInviter));
                        party.invitePlayer(invitedPlayer, inviter);
                        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_INVITE_PARTY, invitedPlayer.getPlayerUUID().toString(), party.getId().toString(), inviter != null ? inviter.getPlayerUUID().toString() : "none"), true);
                    } catch (Exception ex) {
                        plugin.getLoggerManager().printError(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_INVITE_PARTY_ERROR, ex.getMessage() != null ? ex.getMessage() : ex.toString()));
                    }
                }
                break;
            case ADD_HOME:
                party = ((PartiesPlugin) plugin).getPartyManager().getParty(packet.getPartyId());
                if (party != null) {
                    String serializedHome = packet.getPayload();
                    CommandSetHome.savePartyHome(party, PartyHomeImpl.deserialize(serializedHome));
                    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_ADD_HOME_BUNGEE, party.getId().toString()), true);
                }
                break;
            case EXPERIENCE:
                if (ConfigMain.ADDITIONAL_EXP_ENABLE) {
                    party = ((PartiesPlugin) plugin).getPartyManager().getParty(packet.getPartyId());
                    partyPlayer = ((PartiesPlugin) plugin).getPlayerManager().getPlayer(packet.getPlayerUuid());
                    if (party != null) {
                        party.giveExperience(packet.getPayloadNumber(), partyPlayer);
                    }
                    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_EXPERIENCE, CommonUtils.formatDouble(packet.getPayloadNumber()), packet.getPartyId().toString(), packet.getPlayerUuid() != null ? packet.getPlayerUuid().toString() : "none"), true);
                }
                break;
            case REQUEST_CONFIGS:
                if (ConfigMain.PARTIES_BUNGEECORD_PACKETS_CONFIG_SYNC) {
                    ((BungeePartiesConfigurationManager) plugin.getConfigurationManager()).makeConfigsSync();
                    plugin.getLoggerManager().logDebug(PartiesConstants.DEBUG_MESSAGING_LISTEN_REQUEST_CONFIGS, true);
                }
                break;
            default:
                // Nothing to do
                break;
        }
    } else {
        plugin.getLoggerManager().printError(String.format(PartiesConstants.DEBUG_MESSAGING_RECEIVED_WRONG, channel));
    }
}
Also used : PartiesPacket(com.alessiodp.parties.common.messaging.PartiesPacket) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartiesPlugin(com.alessiodp.parties.common.PartiesPlugin) BungeePartiesConfigurationManager(com.alessiodp.parties.bungeecord.configuration.BungeePartiesConfigurationManager) ByteArrayDataInput(com.google.common.io.ByteArrayDataInput) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 2 with BungeePartiesConfigurationManager

use of com.alessiodp.parties.bungeecord.configuration.BungeePartiesConfigurationManager in project Parties by AlessioDP.

the class BungeePartiesPlugin method initializeCore.

@Override
protected void initializeCore() {
    scheduler = new ADPBungeeScheduler(this);
    configurationManager = new BungeePartiesConfigurationManager(this);
    messageUtils = new BungeeMessageUtils(this);
    messenger = new BungeePartiesMessenger(this);
    super.initializeCore();
}
Also used : ADPBungeeScheduler(com.alessiodp.core.bungeecord.scheduling.ADPBungeeScheduler) BungeePartiesConfigurationManager(com.alessiodp.parties.bungeecord.configuration.BungeePartiesConfigurationManager) BungeeMessageUtils(com.alessiodp.parties.bungeecord.utils.BungeeMessageUtils) BungeePartiesMessenger(com.alessiodp.parties.bungeecord.messaging.BungeePartiesMessenger)

Example 3 with BungeePartiesConfigurationManager

use of com.alessiodp.parties.bungeecord.configuration.BungeePartiesConfigurationManager in project Parties by AlessioDP.

the class BungeePartiesPlugin method postHandle.

@Override
protected void postHandle() {
    addonManager = new BungeePartiesAddonManager(this);
    economyManager = new BungeeEconomyManager(this);
    eventManager = new BungeeEventManager(this);
    super.postHandle();
    new BungeeMetricsHandler(this);
    ((BungeePartiesConfigurationManager) getConfigurationManager()).makeConfigsSync();
}
Also used : BungeeEventManager(com.alessiodp.parties.bungeecord.events.BungeeEventManager) BungeePartiesConfigurationManager(com.alessiodp.parties.bungeecord.configuration.BungeePartiesConfigurationManager) BungeePartiesAddonManager(com.alessiodp.parties.bungeecord.addons.BungeePartiesAddonManager) BungeeEconomyManager(com.alessiodp.parties.bungeecord.utils.BungeeEconomyManager) BungeeMetricsHandler(com.alessiodp.parties.bungeecord.addons.external.BungeeMetricsHandler)

Aggregations

BungeePartiesConfigurationManager (com.alessiodp.parties.bungeecord.configuration.BungeePartiesConfigurationManager)3 ADPBungeeScheduler (com.alessiodp.core.bungeecord.scheduling.ADPBungeeScheduler)1 BungeePartiesAddonManager (com.alessiodp.parties.bungeecord.addons.BungeePartiesAddonManager)1 BungeeMetricsHandler (com.alessiodp.parties.bungeecord.addons.external.BungeeMetricsHandler)1 BungeeEventManager (com.alessiodp.parties.bungeecord.events.BungeeEventManager)1 BungeePartiesMessenger (com.alessiodp.parties.bungeecord.messaging.BungeePartiesMessenger)1 BungeeEconomyManager (com.alessiodp.parties.bungeecord.utils.BungeeEconomyManager)1 BungeeMessageUtils (com.alessiodp.parties.bungeecord.utils.BungeeMessageUtils)1 PartiesPlugin (com.alessiodp.parties.common.PartiesPlugin)1 PartiesPacket (com.alessiodp.parties.common.messaging.PartiesPacket)1 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)1 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)1 ByteArrayDataInput (com.google.common.io.ByteArrayDataInput)1