Search in sources :

Example 1 with IPartyPreCreateEvent

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;
}
Also used : IPartyPreCreateEvent(com.alessiodp.parties.api.events.common.party.IPartyPreCreateEvent) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Aggregations

IPartyPreCreateEvent (com.alessiodp.parties.api.events.common.party.IPartyPreCreateEvent)1 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)1