use of me.confuser.banmanager.data.PlayerData in project Parties by AlessioDP.
the class BMHook method onPlayerBan.
@EventHandler(ignoreCancelled = true)
public void onPlayerBan(PlayerBannedEvent event) {
PlayerData pl = event.getBan().getPlayer();
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(pl.getUUID());
// Spy listener
if (pp.isSpy())
plugin.getSpyManager().removeSpy(pp.getPlayerUUID());
// Party checking
if (!pp.getPartyName().isEmpty()) {
PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
if (party != null) {
PartyPlayerEntity kickerPp = plugin.getPlayerManager().getPlayer(event.getBan().getActor().getUUID());
// Calling API event
PartiesPlayerLeaveEvent partiesLeaveEvent = new PartiesPlayerLeaveEvent(pp, party, true, kickerPp);
Bukkit.getServer().getPluginManager().callEvent(partiesLeaveEvent);
if (!partiesLeaveEvent.isCancelled()) {
if (party.getLeader().equals(pl.getUUID())) {
// Calling Pre API event
PartiesPartyPreDeleteEvent partiesPreDeleteEvent = new PartiesPartyPreDeleteEvent(party, PartiesPartyPreDeleteEvent.DeleteCause.BAN, pp, kickerPp);
Bukkit.getServer().getPluginManager().callEvent(partiesPreDeleteEvent);
if (!partiesPreDeleteEvent.isCancelled()) {
party.sendBroadcast(pp, Messages.MAINCMD_LEAVE_DISBANDED);
party.removeParty();
// Calling Post API event
PartiesPartyPostDeleteEvent partiesPostDeleteEvent = new PartiesPartyPostDeleteEvent(party.getName(), PartiesPartyPostDeleteEvent.DeleteCause.BAN, pp, kickerPp);
Bukkit.getServer().getPluginManager().callEvent(partiesPostDeleteEvent);
LoggerManager.log(LogLevel.BASIC, Constants.DEBUG_LIB_BANMANAGER_BAN.replace("{party}", party.getName()).replace("{player}", pl.getName()), true, ConsoleColor.CYAN);
} else {
// Event is cancelled, block ban chain
LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_API_DELETEEVENT_DENY_GENERIC.replace("{party}", party.getName()), true);
return;
}
} else {
party.getMembers().remove(pl.getUUID());
party.getOnlinePlayers().remove(pl.getPlayer());
party.sendBroadcast(pp, Messages.MAINCMD_KICK_BROADCAST);
party.updateParty();
}
} else
LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_API_LEAVEEVENT_DENY.replace("{player}", pl.getName()).replace("{party}", party.getName()), true);
}
pp.cleanupPlayer(true);
}
}
Aggregations