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