Search in sources :

Example 11 with PartiesCommandData

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

the class CommandRename method preRequisites.

@Override
public boolean preRequisites(CommandData commandData) {
    User sender = commandData.getSender();
    if (sender.isPlayer()) {
        PartyPlayerImpl partyPlayer = getPlugin().getPlayerManager().getPlayer(sender.getUUID());
        // Checks for command prerequisites
        if (!sender.hasPermission(permission)) {
            sendNoPermissionMessage(partyPlayer, permission);
            return false;
        }
        if (!sender.hasPermission(PartiesPermission.ADMIN_RENAME_OTHERS)) {
            if (!partyPlayer.isInParty()) {
                sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
                return false;
            }
            // Not using handlePreRequesitesFull for this
            if (!getPlugin().getRankManager().checkPlayerRankAlerter(partyPlayer, RankPermission.ADMIN_RENAME))
                return false;
            if (commandData.getArgs().length != 2) {
                sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
                return false;
            }
        }
        if (commandData.getArgs().length < 2 || commandData.getArgs().length > 3) {
            sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
            return false;
        }
        ((PartiesCommandData) commandData).setPartyPlayer(partyPlayer);
        commandData.addPermission(PartiesPermission.ADMIN_RENAME_OTHERS);
        commandData.addPermission(PartiesPermission.ADMIN_COOLDOWN_RENAME_BYPASS);
    } else {
        if (commandData.getArgs().length != 3) {
            sendMessage(sender, null, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
            return false;
        }
    }
    return 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 12 with PartiesCommandData

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

the class CommandVersion method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    // Command starts
    String version = plugin.getVersion();
    String newVersion = plugin.getAdpUpdater().getFoundVersion().isEmpty() ? version : plugin.getAdpUpdater().getFoundVersion();
    String message = version.equals(newVersion) ? Messages.MAINCMD_VERSION_UPDATED : Messages.MAINCMD_VERSION_OUTDATED;
    sendMessage(sender, partyPlayer, message.replace("%version%", version).replace("%newversion%", newVersion).replace("%platform%", plugin.getPlatform().getName()));
}
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 13 with PartiesCommandData

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

the class BukkitCommandClaim method onCommand.

@Override
public void onCommand(CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    PartyImpl party = ((PartiesCommandData) commandData).getParty();
    // Command handling
    Selection selection = Selection.FAILED_GENERAL;
    if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_TRUST))
        selection = Selection.TRUST;
    else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_CONTAINER))
        selection = Selection.CONTAINER;
    else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_ACCESS))
        selection = Selection.ACCESS;
    else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_MANAGER) && ClaimHandler.canChangeManager())
        selection = Selection.MANAGER;
    else if (commandData.getArgs()[1].equalsIgnoreCase(BukkitConfigMain.ADDONS_CLAIM_CMD_REMOVE))
        selection = Selection.REMOVE;
    if (!selection.equals(Selection.FAILED_GENERAL)) {
        Player bukkitSender = Bukkit.getPlayer(sender.getUUID());
        if (bukkitSender == null)
            return;
        ClaimHandler.Result res = ClaimHandler.isManager(bukkitSender);
        switch(res) {
            case NOEXIST:
                selection = Selection.FAILED_NOEXIST;
                break;
            case NOMANAGER:
                selection = Selection.FAILED_NOMANAGER;
                break;
            default:
                // Success, selection it's okay
                break;
        }
    }
    if (getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.CLAIM, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
        return;
    // Command starts
    switch(selection) {
        case FAILED_NOEXIST:
            // Return: No exist claim
            sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_CLAIM_CLAIMNOEXISTS);
            break;
        case FAILED_NOMANAGER:
            // Return: No manager
            sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_CLAIM_NOMANAGER);
            break;
        case FAILED_GENERAL:
            // Return: Wrong command
            sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
            sendMessage(sender, partyPlayer, BukkitMessages.ADDCMD_CLAIM_ALLOWED_PERMISSIONS);
            break;
        default:
            ClaimHandler.addPartyPermission(Bukkit.getPlayer(commandData.getSender().getUUID()), party, selection.getPermission());
            sendMessage(sender, partyPlayer, selection.getPermission().isRemove() ? BukkitMessages.ADDCMD_CLAIM_REMOVED : BukkitMessages.ADDCMD_CLAIM_CLAIMED);
            plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_CMD_CLAIM, partyPlayer.getName(), selection.name()), true);
            break;
    }
}
Also used : Player(org.bukkit.entity.Player) User(com.alessiodp.core.common.user.User) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartiesCommandData(com.alessiodp.parties.common.commands.utils.PartiesCommandData) ClaimHandler(com.alessiodp.parties.bukkit.addons.external.ClaimHandler) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 14 with PartiesCommandData

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

the class CommandCreate method onCommand.

@Override
public void onCommand(@NotNull CommandData commandData) {
    User sender = commandData.getSender();
    PartyPlayerImpl partyPlayer = ((PartiesCommandData) commandData).getPartyPlayer();
    // Command handling
    String partyName;
    if (commandData.getArgs().length > 1) {
        if (!ConfigParties.GENERAL_NAME_DYNAMIC_ENABLE || ConfigParties.GENERAL_NAME_DYNAMIC_ALLOW_IN_CREATE) {
            partyName = commandData.getArgs()[1];
            if (!checkName(this, sender, partyPlayer, partyName))
                return;
        } else {
            sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
            return;
        }
    } else {
        if (!ConfigParties.GENERAL_NAME_DYNAMIC_ENABLE) {
            sendMessage(sender, partyPlayer, Messages.PARTIES_SYNTAX_WRONG_MESSAGE.replace("%syntax%", syntax));
            return;
        }
        partyName = generateDynamicName(getPlugin(), partyPlayer);
    }
    if (getPlugin().getPartyManager().existsParty(partyName)) {
        sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_NAMEEXISTS.replace("%party%", partyName));
        return;
    }
    if (partyPlayer != null && getPlugin().getEconomyManager().payCommand(EconomyManager.PaidCommand.CREATE, partyPlayer, commandData.getCommandLabel(), commandData.getArgs()))
        return;
    // Command starts
    createParty((PartiesPlugin) plugin, this, sender, partyPlayer, partyName, false);
}
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 15 with PartiesCommandData

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

the class CommandCreateFixed 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];
    if (!CommandCreate.checkName(this, sender, partyPlayer, partyName))
        return;
    if (getPlugin().getPartyManager().existsParty(partyName)) {
        sendMessage(sender, partyPlayer, Messages.MAINCMD_CREATE_NAMEEXISTS.replace("%party%", partyName));
        return;
    }
    // Command starts
    CommandCreate.createParty((PartiesPlugin) plugin, this, sender, partyPlayer, partyName, 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)

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