Search in sources :

Example 16 with PartyPlayer

use of com.alessiodp.partiesapi.objects.PartyPlayer 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)

Aggregations

PartyPlayer (com.alessiodp.partiesapi.objects.PartyPlayer)16 UUID (java.util.UUID)6 PartyEntity (com.alessiodp.parties.parties.objects.PartyEntity)5 PartyPlayerEntity (com.alessiodp.parties.players.objects.PartyPlayerEntity)5 Party (com.alessiodp.partiesapi.objects.Party)5 Player (org.bukkit.entity.Player)4 DatabaseData (com.alessiodp.parties.storage.DatabaseData)2 PartiesPartyPostDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPostDeleteEvent)2 PartiesPartyPreDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPreDeleteEvent)2 Rank (com.alessiodp.partiesapi.interfaces.Rank)2 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 OfflinePlayer (org.bukkit.OfflinePlayer)2 Status (com.alessiodp.partiesapi.enums.Status)1 PartiesPlayerLeaveEvent (com.alessiodp.partiesapi.events.PartiesPlayerLeaveEvent)1 Connection (java.sql.Connection)1 Date (java.sql.Date)1 Time (java.sql.Time)1 Matcher (java.util.regex.Matcher)1