use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class ApiHandler method broadcastPartyMessage.
@Override
public Status broadcastPartyMessage(Party paramParty, PartyPlayer paramPartyPlayer, String paramMessage) {
Status ret = Status.NOEXIST;
PartyEntity party = new PartyEntity(paramParty, plugin);
if (party != null) {
party.sendBroadcast(new PartyPlayerEntity(paramPartyPlayer, plugin), paramMessage);
ret = Status.SUCCESS;
}
return ret;
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class ApiHandler method removePlayerFromParty.
@Override
public Status removePlayerFromParty(PartyPlayer paramPartyPlayer) {
Status ret = Status.NOPARTY;
if (!paramPartyPlayer.getPartyName().isEmpty()) {
PartyPlayerEntity player = new PartyPlayerEntity(paramPartyPlayer, plugin);
PartyEntity party = plugin.getPartyManager().getParty(player.getPartyName());
if (party != null) {
if (player.getPlayerUUID().equals(party.getLeader())) {
party.removeParty();
} else {
if (party.getMembers().contains(player.getPlayerUUID())) {
party.getMembers().remove(player.getPlayerUUID());
party.updateParty();
party.callChange();
}
player.cleanupPlayer(true);
}
ret = Status.SUCCESS;
}
}
return ret;
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class ApiHandler method createParty.
@Override
public Status createParty(PartyPlayer paramPartyPlayer, String paramPartyName) {
Status ret = Status.ALREADYINPARTY;
// Get an instance of PartyPlayerEntity, used to save same player
PartyPlayerEntity player = null;
if (paramPartyPlayer instanceof PartyPlayerEntity) {
player = (PartyPlayerEntity) paramPartyPlayer;
} else {
player = (PartyPlayerEntity) getPartyPlayer(paramPartyPlayer.getPlayerUUID());
}
if (player.getPartyName().isEmpty()) {
if (!plugin.getPartyManager().existParty(paramPartyName)) {
PartyEntity party = new PartyEntity(paramPartyName, plugin);
party.getMembers().add(player.getPlayerUUID());
Player p = player.getPlayer();
if (p != null)
party.getOnlinePlayers().add(p);
party.setLeader(player.getPlayerUUID());
plugin.getPartyManager().getListParties().put(party.getName().toLowerCase(), party);
player.setRank(ConfigParties.RANK_SET_HIGHER);
player.setPartyName(party.getName());
party.updateParty();
player.updatePlayer();
party.callChange();
return Status.SUCCESS;
} else
ret = Status.ALREADYEXISTPARTY;
}
return ret;
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity 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);
}
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class PAPIHook method onPlaceholderRequest.
@Override
public String onPlaceholderRequest(Player p, String identifier) {
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(p.getUniqueId());
PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
PartiesPlaceholder ph = PartiesPlaceholder.getPlaceholder(identifier);
return ph != null ? ph.formatPlaceholder(pp, party) : "";
}
Aggregations