use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class JoinLeaveListener method globalQuit.
private void globalQuit(Player p) {
// Make it async
plugin.getPartiesScheduler().getEventsExecutor().execute(() -> {
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(p.getUniqueId());
boolean removePlFromList = true;
// Spy listener
if (pp.isSpy())
plugin.getSpyManager().removeSpy(pp.getPlayerUUID());
// Party checking
if (!pp.getPartyName().isEmpty()) {
if (pp.getHomeTask() != -1)
plugin.getPlayerManager().remHomeCount();
PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
if (party != null) {
party.getOnlinePlayers().remove(p);
if (ConfigMain.PARTIES_JLMESSAGES) {
party.sendBroadcast(pp, Messages.OTHER_JOINLEAVE_SERVERLEAVE);
}
if (plugin.getDatabaseManager().getDatabaseType().isNone()) {
// Start delete timeout
if (ConfigMain.STORAGE_SETTINGS_NONE_DISBANDONLEADERLEFT && party.getLeader().equals(p.getUniqueId())) {
// Leader left, delete now
plugin.getPartyManager().deleteTimedParty(party.getName(), true);
} else if (party.getOnlinePlayers().size() == 0) {
// All players left, start timer
if (ConfigMain.STORAGE_SETTINGS_NONE_DELAYDELETEPARTY > 0) {
plugin.getPlayerManager().getListPartyPlayersToDelete().add(p.getUniqueId());
PartyDeleteTask task = (PartyDeleteTask) new PartyDeleteTask(party.getName());
task.runTaskLaterAsynchronously(plugin, ConfigMain.STORAGE_SETTINGS_NONE_DELAYDELETEPARTY * 20);
plugin.getPartyManager().getListPartiesToDelete().put(party.getName().toLowerCase(), task.getTaskId());
removePlFromList = false;
LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_TASK_DELETE_START.replace("{party}", party.getName()).replace("{value}", Integer.toString(ConfigMain.STORAGE_SETTINGS_NONE_DELAYDELETEPARTY * 20)), true);
} else
plugin.getPartyManager().deleteTimedParty(party.getName(), false);
}
} else {
if (party.getNumberOnlinePlayers() == 0) {
plugin.getPartyManager().unloadParty(party.getName());
}
}
}
}
if (removePlFromList)
plugin.getPlayerManager().unloadPlayer(p.getUniqueId());
});
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class PartyEntity method denyInvite.
public void denyInvite(UUID to) {
plugin.getServer().getScheduler().cancelTask(invited.get(to));
UUID from = whoInvite.get(to);
PartyPlayerEntity fromTP = plugin.getPlayerManager().getPlayer(from);
PartyPlayerEntity toTP = plugin.getPlayerManager().getPlayer(to);
fromTP.sendMessage(Messages.MAINCMD_DENY_DENYRECEIPT, toTP);
toTP.sendMessage(Messages.MAINCMD_DENY_DENIED, fromTP);
toTP.setLastInvite("");
whoInvite.remove(to);
invited.remove(to);
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class PartyEntity method cancelInvite.
public void cancelInvite(UUID to) {
plugin.getServer().getScheduler().cancelTask(invited.get(to));
UUID from = whoInvite.get(to);
PartyPlayerEntity fromPp = plugin.getPlayerManager().getPlayer(from);
PartyPlayerEntity toPp = plugin.getPlayerManager().getPlayer(to);
fromPp.sendMessage(Messages.MAINCMD_INVITE_TIMEOUT_NORESPONSE, toPp);
toPp.sendMessage(Messages.MAINCMD_INVITE_TIMEOUT_TIMEOUT, fromPp);
toPp.setLastInvite("");
whoInvite.remove(to);
invited.remove(to);
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class PlayerManager method loadPlayer.
public PartyPlayerEntity loadPlayer(UUID uuid) {
PartyPlayerEntity ret = getPlayer(uuid);
getListPartyPlayers().put(uuid, ret);
return ret;
}
use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.
the class PlayerManager method reload.
public void reload() {
listPartyPlayers = new HashMap<UUID, PartyPlayerEntity>();
listPartyPlayersToDelete = new HashSet<UUID>();
homeCounts = 0;
chatCooldown = new HashMap<>();
inviteCooldown = new HashMap<>();
teleportCooldown = new HashMap<>();
plugin.getSpyManager().refreshSpyList();
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
PartyPlayerEntity pp = loadPlayer(p.getUniqueId());
PartyEntity party = plugin.getPartyManager().loadParty(pp.getPartyName());
if (party != null)
party.getOnlinePlayers().add(p);
}
}
Aggregations