use of com.alessiodp.parties.api.events.common.party.IPartyPreCreateEvent in project Parties by AlessioDP.
the class CommandCreate method createParty.
public static PartyImpl createParty(PartiesPlugin plugin, PartiesSubCommand subCommand, User sender, PartyPlayerImpl partyPlayer, String partyName, boolean fixed) {
PartyImpl ret = null;
IPartyPreCreateEvent partiesPreEvent = plugin.getEventManager().preparePartyPreCreateEvent(partyPlayer, partyName, fixed);
plugin.getEventManager().callEvent(partiesPreEvent);
String newPartyName = partiesPreEvent.getPartyName();
boolean isFixed = partiesPreEvent.isFixed();
if (!partiesPreEvent.isCancelled() && (isFixed || partyPlayer != null)) {
PartyImpl party = plugin.getPartyManager().initializeParty();
party.create(newPartyName, isFixed ? null : partyPlayer, partyPlayer);
if (isFixed) {
subCommand.sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_CREATEDFIXED, party);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CREATE_FIXED, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
} else {
subCommand.sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_CREATED, party);
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CREATE, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
}
ret = party;
} else {
plugin.getLoggerManager().log(String.format(PartiesConstants.DEBUG_API_CREATEEVENT_DENY, partyName, sender.getName(), sender.getUUID().toString()), true);
}
return ret;
}
Aggregations