Search in sources :

Example 16 with PartiesCommandData

use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.

the class CommandDelete method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    // Command handling
    PartyImpl party = getPlugin().getPartyManager().getParty(commandData.getArgs()[1]);
    if (party == null) {
        sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_PARTYNOTFOUND.replace("%party%", commandData.getArgs()[1]));
        return;
    }
    boolean isSilent = false;
    if (commandData.getArgs().length == 3) {
        if (commandData.havePermission(PartiesPermission.ADMIN_DELETE_SILENT) && commandData.getArgs()[2].equalsIgnoreCase(ConfigMain.COMMANDS_MISC_SILENT)) {
            isSilent = true;
        } else {
            sendMessage(sender, ((PartiesCommandData) commandData).getPartyPlayer(), Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", getSyntaxForUser(sender)));
            return;
        }
    }
    // Command starts
    // Calling Pre API event
    IPartyPreDeleteEvent partiesPreDeleteEvent = getPlugin().getEventManager().preparePartyPreDeleteEvent(party, DeleteCause.DELETE, null, partyPlayer);
    getPlugin().getEventManager().callEvent(partiesPreDeleteEvent);
    if (!partiesPreDeleteEvent.isCancelled()) {
        if (isSilent) {
            sendMessage(sender, partyPlayer, Messages.MAINCMD_DELETE_DELETEDSILENTLY, party);
        } else {
            sendMessage(sender, partyPlayer, Messages.MAINCMD_DELETE_DELETED, party);
            party.broadcastMessage(Messages.MAINCMD_DELETE_BROADCAST, partyPlayer);
        }
        party.delete(DeleteCause.DELETE, null, partyPlayer);
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_DELETE, sender.getName(), party.getName() != null ? party.getName() : "_"), true);
    } else {
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_API_DELETEEVENT_DENY, party.getId(), sender.getName(), sender.getUUID().toString()), true);
    }
}
Also used : User(com.alessiodp.core.common.user.User) IPartyPreDeleteEvent(com.alessiodp.parties.api.events.common.party.IPartyPreDeleteEvent) 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 17 with PartiesCommandData

use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.

the class CommandFollow method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    PartyImpl party = ((PartiesCommandData) commandData).getParty();
    // Command handling
    Boolean follow = plugin.getCommandManager().getCommandUtils().handleOnOffCommand(party.isFollowEnabled(), commandData.getArgs());
    if (follow == null) {
        sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
        return;
    }
    if (follow && getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.FOLLOW, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
        return;
    // Command starts
    party.setFollowEnabled(follow);
    if (follow)
        sendMessage(sender, partyPlayer, Messages.ADDCMD_FOLLOW_ON);
    else
        sendMessage(sender, partyPlayer, Messages.ADDCMD_FOLLOW_OFF);
    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_FOLLOW, partyPlayer.getName(), follow, 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) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 18 with PartiesCommandData

use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.

the class CommandInfo 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.USER_INFO_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;
    }
    // Command starts
    for (String line : Messages.MAINCMD_INFO_CONTENT) {
        line = getPlugin().getMessageUtils().convertPlaceholders(line, partyPlayer, party, Messages.PARTIES_LIST_MISSING);
        sendMessage(sender, partyPlayer, line);
    }
    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_INFO, sender.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) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 19 with PartiesCommandData

use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.

the class CommandChat method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    // Command handling
    Boolean chat = plugin.getCommandManager().getCommandUtils().handleOnOffCommand(partyPlayer.isChatParty(), commandData.getArgs());
    if (chat == null) {
        sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
        return;
    }
    // Command starts
    partyPlayer.setChatParty(chat);
    if (chat) {
        sendMessage(sender, partyPlayer, Messages.MAINCMD_CHAT_ENABLED);
    } else {
        sendMessage(sender, partyPlayer, Messages.MAINCMD_CHAT_DISABLED);
    }
    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CHAT, partyPlayer.getName(), chat), 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)

Example 20 with PartiesCommandData

use of com.alessiodp.parties.common.commands.utils.PartiesCommandData in project Parties by AlessioDP.

the class CommandColor method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    PartyImpl party = ((PartiesCommandData) commandData).getParty();
    // Command handling
    Set<PartyColorImpl> availableColors = getPlugin().getColorManager().getAvailableColors(sender);
    if (commandData.getArgs().length == 1) {
        if (party.getColor() != null)
            sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_INFO, availableColors));
        else
            sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_EMPTY, availableColors));
        return;
    }
    boolean isRemove = false;
    PartyColor color = null;
    if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_MISC_REMOVE)) {
        // Remove command
        isRemove = true;
    } else {
        // Normal command
        for (PartyColorImpl pc : availableColors) {
            if (pc.getCommand().equalsIgnoreCase(commandData.getArgs()[1])) {
                color = pc;
                break;
            }
        }
        if (color == null) {
            // Color doesn't exist
            sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_WRONGCOLOR, availableColors));
            return;
        }
        if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.COLOR, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
            return;
    }
    // Command starts
    party.setColor(color);
    if (isRemove) {
        sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_REMOVED, availableColors));
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_COLOR_REM, partyPlayer.getName(), party.getName() != null ? party.getName() : "_"), true);
    } else {
        sendMessage(sender, partyPlayer, parseWithAvailableColors(Messages.ADDCMD_COLOR_CHANGED, availableColors), party);
        party.broadcastMessage(parseWithAvailableColors(Messages.ADDCMD_COLOR_BROADCAST, availableColors), partyPlayer);
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_COLOR, partyPlayer.getName(), party.getName() != null ? party.getName() : "_", color.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) PartyColor(com.alessiodp.parties.api.interfaces.PartyColor) PartyColorImpl(com.alessiodp.parties.common.parties.objects.PartyColorImpl) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Aggregations

User (com.alessiodp.core.common.user.User)45 PartiesCommandData (com.alessiodp.parties.common.commands.utils.PartiesCommandData)45 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)45 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)31 ADPPlugin (com.alessiodp.core.common.ADPPlugin)6 ADPMainCommand (com.alessiodp.core.common.commands.utils.ADPMainCommand)6 CommandData (com.alessiodp.core.common.commands.utils.CommandData)6 OfflineUser (com.alessiodp.core.common.user.OfflineUser)6 CommonCommands (com.alessiodp.parties.common.commands.list.CommonCommands)6 PartiesSubCommand (com.alessiodp.parties.common.commands.utils.PartiesSubCommand)6 ConfigMain (com.alessiodp.parties.common.configuration.data.ConfigMain)6 ConfigParties (com.alessiodp.parties.common.configuration.data.ConfigParties)6 Messages (com.alessiodp.parties.common.configuration.data.Messages)6 PartiesPermission (com.alessiodp.parties.common.utils.PartiesPermission)6 NotNull (org.jetbrains.annotations.NotNull)6 PartiesConstants (com.alessiodp.parties.common.configuration.PartiesConstants)5 RankPermission (com.alessiodp.parties.common.utils.RankPermission)5 CommonUtils (com.alessiodp.core.common.utils.CommonUtils)4 LinkedList (java.util.LinkedList)4 UUID (java.util.UUID)4