Search in sources :

Example 56 with PartyPlayerEntity

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());
    });
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity) PartyDeleteTask(com.alessiodp.parties.tasks.PartyDeleteTask)

Example 57 with PartyPlayerEntity

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);
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) UUID(java.util.UUID)

Example 58 with PartyPlayerEntity

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);
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) UUID(java.util.UUID)

Example 59 with PartyPlayerEntity

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;
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity)

Example 60 with PartyPlayerEntity

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);
    }
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) Player(org.bukkit.entity.Player) PartyPlayer(com.alessiodp.partiesapi.objects.PartyPlayer) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity) UUID(java.util.UUID)

Aggregations

PartyPlayerEntity (com.alessiodp.parties.players.objects.PartyPlayerEntity)92 PartyEntity (com.alessiodp.parties.parties.objects.PartyEntity)56 Player (org.bukkit.entity.Player)53 EventHandler (org.bukkit.event.EventHandler)13 PartyPlayer (com.alessiodp.partiesapi.objects.PartyPlayer)9 UUID (java.util.UUID)8 ArrayList (java.util.ArrayList)6 PartiesPartyPostDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPostDeleteEvent)4 PartiesPartyPreDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPreDeleteEvent)4 OfflinePlayer (org.bukkit.OfflinePlayer)4 Status (com.alessiodp.partiesapi.enums.Status)3 PartiesPlayerLeaveEvent (com.alessiodp.partiesapi.events.PartiesPlayerLeaveEvent)3 PartiesPlaceholder (com.alessiodp.parties.addons.internal.PartiesPlaceholder)2 ChatTask (com.alessiodp.parties.tasks.ChatTask)2 PartiesChatEvent (com.alessiodp.partiesapi.events.PartiesChatEvent)2 PartiesFriendlyFireBlockedEvent (com.alessiodp.partiesapi.events.PartiesFriendlyFireBlockedEvent)2 PartiesPlayerJoinEvent (com.alessiodp.partiesapi.events.PartiesPlayerJoinEvent)2 Rank (com.alessiodp.partiesapi.interfaces.Rank)2 Matcher (java.util.regex.Matcher)2 Result (com.alessiodp.parties.addons.external.GriefPreventionHandler.Result)1