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));
}
}
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();
}
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();
}
Aggregations