Search in sources :

Example 96 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class CommandAsk method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    // Command handling
    String partyName = commandData.getArgs()[1];
    PartyImpl party = getPlugin().getPartyManager().getParty(partyName);
    if (party == null) {
        sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", partyName));
        return;
    }
    if (party.isFull()) {
        sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYFULL);
        return;
    }
    boolean mustStartCooldown = false;
    if (ConfigParties.ADDITIONAL_ASK_COOLDOWN_ENABLE && !commandData.havePermission(PartiesPermission.ADMIN_COOLDOWN_ASK_BYPASS)) {
        // Check invite cooldown
        mustStartCooldown = true;
        RequestCooldown askCooldown = getPlugin().getCooldownManager().canMultiAction(CooldownManager.MultiAction.ASK, partyPlayer.getPlayerUUID(), party.getId());
        if (askCooldown != null) {
            sendMessage(sender, partyPlayer, (askCooldown.isGlobal() ? Messages.ADDCMD_ASK_COOLDOWN_GLOBAL : Messages.ADDCMD_ASK_COOLDOWN_INDIVIDUAL).replace("%seconds%", String.valueOf(askCooldown.getWaitTime())));
        }
    }
    if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.ASK, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
        return;
    // Command starts
    partyPlayer.askToJoin(party);
    if (mustStartCooldown) {
        getPlugin().getCooldownManager().startMultiAction(CooldownManager.MultiAction.ASK, partyPlayer.getPlayerUUID(), null, ConfigParties.ADDITIONAL_ASK_COOLDOWN_GLOBAL);
        getPlugin().getCooldownManager().startMultiAction(CooldownManager.MultiAction.ASK, partyPlayer.getPlayerUUID(), party.getId(), ConfigParties.ADDITIONAL_ASK_COOLDOWN_INDIVIDUAL);
    }
    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_ASK, partyPlayer.getName(), party.getName() != null ? party.getName() : "_"), true);
}
Also used : User(com.alessiodp.core.common.user.User) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartiesCommandData(com.alessiodp.parties.common.commands.utils.PartiesCommandData) RequestCooldown(com.alessiodp.parties.common.players.objects.RequestCooldown) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 97 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class CommandClose method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    PartyImpl party;
    // Command handling
    if (commandData.getArgs().length == 1 && sender.isPlayer()) {
        party = getPlugin().getPartyManager().getPartyOfPlayer(partyPlayer);
    } else if (commandData.getArgs().length == 2 && commandData.havePermission(PartiesPermission.ADMIN_CLOSE_OTHERS)) {
        party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
    } else {
        sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", getSyntaxForUser(sender)));
        return;
    }
    if (party == null) {
        if (commandData.getArgs().length > 1)
            sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", commandData.getArgs()[1]));
        else
            sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
        return;
    }
    if (!party.isOpen()) {
        sendMessage(sender, partyPlayer, Messages.ADDCMD_JOIN_OPENCLOSE_ALREADY_CLOSED);
        return;
    }
    boolean mustStartCooldown = false;
    if (ConfigParties.ADDITIONAL_JOIN_OPENCLOSE_COOLDOWN_CLOSE > 0 && !commandData.havePermission(PartiesPermission.ADMIN_COOLDOWN_CLOSE_BYPASS)) {
        mustStartCooldown = true;
        long remainingCooldown = getPlugin().getCooldownManager().canAction(CooldownManager.Action.CLOSE, sender.getUUID(), ConfigParties.ADDITIONAL_JOIN_OPENCLOSE_COOLDOWN_CLOSE);
        if (remainingCooldown > 0) {
            sendMessage(sender, partyPlayer, Messages.ADDCMD_JOIN_OPENCLOSE_COOLDOWN.replace("%seconds%", String.valueOf(remainingCooldown)));
            return;
        }
    }
    if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.CLOSE, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
        return;
    if (mustStartCooldown)
        getPlugin().getCooldownManager().startAction(CooldownManager.Action.CLOSE, sender.getUUID(), ConfigParties.ADDITIONAL_JOIN_OPENCLOSE_COOLDOWN_CLOSE);
    // Command starts
    party.setOpen(false);
    sendMessage(sender, partyPlayer, Messages.ADDCMD_JOIN_OPENCLOSE_CLOSED);
    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_OPENCLOSE, partyPlayer.getName(), party.getName() != null ? party.getName() : "_", false), true);
}
Also used : User(com.alessiodp.core.common.user.User) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartiesCommandData(com.alessiodp.parties.common.commands.utils.PartiesCommandData) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 98 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class BungeeCommandTeleport method teleportSinglePlayer.

public static void teleportSinglePlayer(PartiesPlugin plugin, PartyPlayerImpl player, PartyPlayerImpl targetPlayer, ServerInfo serverInfo) {
    ProxiedPlayer bungeePlayer = ((BungeePartiesBootstrap) plugin.getBootstrap()).getProxy().getPlayer(player.getPlayerUUID());
    if (bungeePlayer != null) {
        boolean serverChange = false;
        PartyImpl party = plugin.getPartyManager().getParty(player.getPartyId());
        IPlayerPreTeleportEvent partiesPreTeleportEvent = plugin.getEventManager().preparePlayerPreTeleportEvent(player, party, serverInfo);
        plugin.getEventManager().callEvent(partiesPreTeleportEvent);
        if (!partiesPreTeleportEvent.isCancelled()) {
            if (!bungeePlayer.getServer().getInfo().equals(serverInfo)) {
                serverChange = true;
                bungeePlayer.connect(serverInfo);
            }
            User bungeeUser = plugin.getPlayer(player.getPlayerUUID());
            if (bungeeUser != null) {
                if (serverChange) {
                    plugin.getScheduler().scheduleAsyncLater(() -> ((BungeePartiesMessageDispatcher) plugin.getMessenger().getMessageDispatcher()).sendTeleport(bungeeUser, targetPlayer, serverInfo), BungeeConfigParties.ADDITIONAL_TELEPORT_EXACT_LOCATION_DELAY, TimeUnit.MILLISECONDS);
                } else {
                    ((BungeePartiesMessageDispatcher) plugin.getMessenger().getMessageDispatcher()).sendTeleport(bungeeUser, targetPlayer, serverInfo);
                }
                player.sendMessage(Messages.ADDCMD_TELEPORT_PLAYER_TELEPORTED, targetPlayer);
                IPlayerPostTeleportEvent partiesPostTeleportEvent = plugin.getEventManager().preparePlayerPostTeleportEvent(player, party, serverInfo);
                plugin.getEventManager().callEvent(partiesPostTeleportEvent);
            }
        } else
            plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_API_TELEPORTEVENT_DENY, player.getName(), party.getName() != null ? party.getName() : "_"), true);
    }
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) IPlayerPreTeleportEvent(com.alessiodp.parties.api.events.common.player.IPlayerPreTeleportEvent) BungeePartiesMessageDispatcher(com.alessiodp.parties.bungeecord.messaging.BungeePartiesMessageDispatcher) User(com.alessiodp.core.common.user.User) IPlayerPostTeleportEvent(com.alessiodp.parties.api.events.common.player.IPlayerPostTeleportEvent) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 99 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class ApiHandler method createParty.

@Override
public boolean createParty(@Nullable String name, @Nullable PartyPlayer leader) {
    if (name == null || !plugin.getDatabaseManager().existsParty(name) || leader == null || !leader.isInParty()) {
        PartyImpl partyImpl = plugin.getPartyManager().initializeParty(UUID.randomUUID());
        partyImpl.create(name, leader != null ? (PartyPlayerImpl) leader : null, null);
        return true;
    }
    return false;
}
Also used : PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 100 with PartyImpl

use of com.alessiodp.parties.common.parties.objects.PartyImpl in project Parties by AlessioDP.

the class BukkitPartiesBungeecordListener method handleUnloadParty.

public void handleUnloadParty(PartiesPacket packet) {
    PartyImpl party = ((PartiesPlugin) plugin).getPartyManager().getCacheParties().get(packet.getParty());
    if (party != null) {
        ((PartiesPlugin) plugin).getPartyManager().unloadParty(party);
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_UNLOAD_PARTY, packet.getParty().toString()), true);
    }
}
Also used : PartiesPlugin(com.alessiodp.parties.common.PartiesPlugin) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Aggregations

PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)106 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)75 User (com.alessiodp.core.common.user.User)39 PartiesCommandData (com.alessiodp.parties.common.commands.utils.PartiesCommandData)31 ADPPlugin (com.alessiodp.core.common.ADPPlugin)11 UUID (java.util.UUID)11 ConfigMain (com.alessiodp.parties.common.configuration.data.ConfigMain)10 ConfigParties (com.alessiodp.parties.common.configuration.data.ConfigParties)10 PartiesPlugin (com.alessiodp.parties.common.PartiesPlugin)9 PartiesConstants (com.alessiodp.parties.common.configuration.PartiesConstants)9 PartyHomeImpl (com.alessiodp.parties.common.parties.objects.PartyHomeImpl)8 LinkedList (java.util.LinkedList)8 LinkedHashSet (java.util.LinkedHashSet)7 List (java.util.List)7 HashMap (java.util.HashMap)6 ADPMainCommand (com.alessiodp.core.common.commands.utils.ADPMainCommand)5 CommandData (com.alessiodp.core.common.commands.utils.CommandData)5 OfflineUser (com.alessiodp.core.common.user.OfflineUser)5 CommonCommands (com.alessiodp.parties.common.commands.list.CommonCommands)5 PartiesSubCommand (com.alessiodp.parties.common.commands.utils.PartiesSubCommand)5