Search in sources :

Example 66 with PartyEntity

use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.

the class PartyManager method deleteTimedParty.

public void deleteTimedParty(String name, boolean leaderLeft) {
    PartyEntity party = getParty(name);
    if (party != null) {
        // Calling Pre API event
        PartiesPartyPreDeleteEvent partiesPreDeleteEvent = new PartiesPartyPreDeleteEvent(party, PartiesPartyPreDeleteEvent.DeleteCause.TIMEOUT, null, null);
        Bukkit.getServer().getPluginManager().callEvent(partiesPreDeleteEvent);
        if (!partiesPreDeleteEvent.isCancelled()) {
            for (UUID u : plugin.getPlayerManager().getListPartyPlayersToDelete()) {
                if (party.getMembers().contains(u))
                    plugin.getPlayerManager().getListPartyPlayers().remove(u);
            }
            String cause = "empty";
            if (leaderLeft) {
                party.sendBroadcast(plugin.getPlayerManager().getPlayer(party.getLeader()), Messages.MAINCMD_LEAVE_DISBANDED);
                cause = "leader left";
            }
            party.removeParty();
            // Calling Post API event
            // Used to avoid ambiguity with PartiesPartyPostDeleteEvent constructors
            PartyPlayer tempPlayer = new PartyPlayer(UUID.fromString(Constants.FIXED_VALUE_UUID), 0);
            PartiesPartyPostDeleteEvent partiesPostDeleteEvent = new PartiesPartyPostDeleteEvent(party.getName(), PartiesPartyPostDeleteEvent.DeleteCause.TIMEOUT, null, tempPlayer);
            Bukkit.getServer().getPluginManager().callEvent(partiesPostDeleteEvent);
            LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_PARTY_DELETE_CAUSE.replace("{party}", party.getName()).replace("{cause}", cause), true);
            if (getListPartiesToDelete().containsKey(name.toLowerCase()))
                getListPartiesToDelete().remove(name.toLowerCase());
        } else {
            LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_API_DELETEEVENT_DENY_GENERIC.replace("{party}", party.getName()), true);
        }
    }
}
Also used : PartiesPartyPostDeleteEvent(com.alessiodp.partiesapi.events.PartiesPartyPostDeleteEvent) PartiesPartyPreDeleteEvent(com.alessiodp.partiesapi.events.PartiesPartyPreDeleteEvent) PartyPlayer(com.alessiodp.partiesapi.objects.PartyPlayer) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity) UUID(java.util.UUID)

Example 67 with PartyEntity

use of com.alessiodp.parties.parties.objects.PartyEntity in project Parties by AlessioDP.

the class PartyManager method existParty.

public boolean existParty(String name) {
    boolean ret = false;
    PartyEntity party = (PartyEntity) getListParties().get(name.toLowerCase());
    if (party != null || plugin.getDatabaseManager().existParty(name).join())
        ret = true;
    return ret;
}
Also used : PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Aggregations

PartyEntity (com.alessiodp.parties.parties.objects.PartyEntity)67 PartyPlayerEntity (com.alessiodp.parties.players.objects.PartyPlayerEntity)56 Player (org.bukkit.entity.Player)31 EventHandler (org.bukkit.event.EventHandler)11 PartyPlayer (com.alessiodp.partiesapi.objects.PartyPlayer)6 Status (com.alessiodp.partiesapi.enums.Status)5 PartiesPartyPostDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPostDeleteEvent)5 PartiesPartyPreDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPreDeleteEvent)5 UUID (java.util.UUID)5 PartiesPlayerLeaveEvent (com.alessiodp.partiesapi.events.PartiesPlayerLeaveEvent)3 Party (com.alessiodp.partiesapi.objects.Party)3 ArrayList (java.util.ArrayList)3 PartiesPlaceholder (com.alessiodp.parties.addons.internal.PartiesPlaceholder)2 ChatTask (com.alessiodp.parties.tasks.ChatTask)2 PartiesChatEvent (com.alessiodp.partiesapi.events.PartiesChatEvent)2 PartiesFriendlyFireBlockedEvent (com.alessiodp.partiesapi.events.PartiesFriendlyFireBlockedEvent)2 Rank (com.alessiodp.partiesapi.interfaces.Rank)2 Matcher (java.util.regex.Matcher)2 OfflinePlayer (org.bukkit.OfflinePlayer)2 Result (com.alessiodp.parties.addons.external.GriefPreventionHandler.Result)1