Search in sources :

Example 1 with Confirmation

use of com.palmergames.bukkit.towny.confirmations.Confirmation in project Towny by TownyAdvanced.

the class PlotCommand method parsePlotCommand.

public boolean parsePlotCommand(Player player, String[] split) {
    TownyPermissionSource permSource = TownyUniverse.getInstance().getPermissionSource();
    if (split.length == 0 || split[0].equalsIgnoreCase("?")) {
        HelpMenu.PLOT_HELP.send(player);
    } else {
        Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
        if (resident == null) {
            TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_not_registered"));
            return true;
        }
        String world = player.getWorld().getName();
        try {
            TownBlock townBlock = TownyAPI.getInstance().getTownBlock(player);
            if (townBlock == null && !split[0].equalsIgnoreCase("perm") && !split[0].equalsIgnoreCase("claim"))
                throw new TownyException(Translatable.of("msg_not_claimed_1"));
            if (!TownyAPI.getInstance().isWilderness(player.getLocation()) && townBlock.getTownOrNull().isRuined())
                throw new TownyException(Translatable.of("msg_err_cannot_use_command_because_town_ruined"));
            if (split[0].equalsIgnoreCase("claim")) {
                if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_CLAIM.getNode()))
                    throw new TownyException(Translatable.of("msg_err_command_disable"));
                List<WorldCoord> selection = AreaSelectionUtil.selectWorldCoordArea(resident, new WorldCoord(world, Coord.parseCoord(player)), StringMgmt.remFirstArg(split), true);
                // Fast-fail if this is a single plot and it is already claimed.
                if (selection.size() == 1 && selection.get(0).hasTownBlock() && selection.get(0).getTownBlock().hasResident() && !selection.get(0).getTownBlock().isForSale())
                    throw new TownyException(Translatable.of("msg_already_claimed", selection.get(0).getTownBlock().getResidentOrNull()));
                // Filter to just plots that are for sale.
                selection = AreaSelectionUtil.filterPlotsForSale(selection);
                // Filter out plots already owned by the player.
                selection = AreaSelectionUtil.filterUnownedBlocks(resident, selection);
                if (selection.size() > 0) {
                    if (selection.size() + resident.getTownBlocks().size() > TownySettings.getMaxResidentPlots(resident))
                        throw new TownyException(Translatable.of("msg_max_plot_own", TownySettings.getMaxResidentPlots(resident)));
                    /*
						 * If a resident has no town, the Town is open, and the plot is not an Embassy:
						 * Attempt to add the Resident to the town IF the town is not null, the Town is
						 * not going to exceed the maxResidentsWithoutANation value, and the Town will 
						 * not exceed the maxResidentsPerTown value.
						 */
                    if (!resident.hasTown() && townBlock.getTownOrNull().isOpen() && !townBlock.getType().equals(TownBlockType.EMBASSY)) {
                        final Town town = townBlock.getTownOrNull();
                        if (town == null || (TownySettings.getMaxNumResidentsWithoutNation() > 0 && !town.hasNation() && town.getResidents().size() >= TownySettings.getMaxNumResidentsWithoutNation()) || (TownySettings.getMaxResidentsPerTown() > 0 && town.getResidents().size() >= TownySettings.getMaxResidentsForTown(town)) || town.hasOutlaw(resident) || (resident.isOnline() && !resident.getPlayer().hasPermission(PermissionNodes.TOWNY_COMMAND_TOWN_JOIN.getNode()))) {
                        // Town is null (unlikely) or it would have too many residents, we won't be adding
                        // them to the town, continue as per usual (it could be an embassy plot.)
                        } else {
                            final List<WorldCoord> coords = selection;
                            Confirmation.runOnAccept(() -> {
                                try {
                                    resident.setTown(town);
                                } catch (AlreadyRegisteredException ignored) {
                                }
                                try {
                                    continuePlotClaimProcess(coords, resident, player);
                                } catch (TownyException e) {
                                    TownyMessaging.sendErrorMsg(player, e.getMessage(player));
                                }
                            }).setTitle(Translatable.of("msg_you_must_join_this_town_to_claim_this_plot", town.getName())).sendTo(player);
                            return true;
                        }
                    }
                    continuePlotClaimProcess(selection, resident, player);
                } else {
                    TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_empty_area_selection"));
                }
            } else if (split[0].equalsIgnoreCase("evict")) {
                if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_EVICT.getNode()))
                    throw new TownyException(Translatable.of("msg_err_command_disable"));
                if (!townBlock.hasResident()) {
                    TownyMessaging.sendErrorMsg(player, Translatable.of("msg_no_one_to_evict"));
                } else {
                    // Test we are allowed to work on this plot
                    // If this fails it will trigger a TownyException.
                    plotTestOwner(resident, townBlock);
                    if (townBlock.hasPlotObjectGroup()) {
                        townBlock.getPlotObjectGroup().getTownBlocks().stream().forEach(tb -> {
                            // Remove Resident.
                            tb.setResident(null);
                            // Set to NotForSale.
                            tb.setPlotPrice(-1);
                            // Re-set the plot permissions while maintaining plot type.
                            tb.setType(townBlock.getType());
                            // Save townblock.
                            tb.save();
                        });
                        TownyMessaging.sendMsg(player, Translatable.of("msg_plot_evict_group", townBlock.getPlotObjectGroup().getName()));
                        return true;
                    }
                    // Remove Resident.
                    townBlock.setResident(null);
                    // Set to NotForSale.
                    townBlock.setPlotPrice(-1);
                    // Re-set the plot permissions while maintaining plot type.
                    townBlock.setType(townBlock.getType());
                    // Save townblock.
                    townBlock.save();
                    TownyMessaging.sendMsg(player, Translatable.of("msg_plot_evict"));
                }
            } else if (split[0].equalsIgnoreCase("unclaim")) {
                if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_UNCLAIM.getNode()))
                    throw new TownyException(Translatable.of("msg_err_command_disable"));
                if (split.length == 2 && split[1].equalsIgnoreCase("all")) {
                    // Start the unclaim task
                    new PlotClaim(plugin, player, resident, null, false, false, false).start();
                } else {
                    List<WorldCoord> selection = AreaSelectionUtil.selectWorldCoordArea(resident, new WorldCoord(world, Coord.parseCoord(player)), StringMgmt.remFirstArg(split));
                    selection = AreaSelectionUtil.filterOwnedBlocks(resident, selection);
                    if (selection.size() > 0) {
                        for (WorldCoord coord : selection) {
                            TownBlock block = coord.getTownBlock();
                            if (!block.hasPlotObjectGroup()) {
                                // Start the unclaim task
                                new PlotClaim(plugin, player, resident, selection, false, false, false).start();
                                return true;
                            }
                            // Get all the townblocks part of the group.
                            final List<WorldCoord> groupSelection = new ArrayList<>();
                            block.getPlotObjectGroup().getTownBlocks().forEach((tb) -> {
                                groupSelection.add(tb.getWorldCoord());
                            });
                            // Create confirmation.
                            Confirmation.runOnAccept(() -> {
                                new PlotClaim(Towny.getPlugin(), player, resident, groupSelection, false, false, false).start();
                            }).setTitle(Translatable.of("msg_plot_group_unclaim_confirmation", block.getPlotObjectGroup().getTownBlocks().size()).append(" " + Translatable.of("are_you_sure_you_want_to_continue"))).sendTo(player);
                            return true;
                        }
                    } else {
                        TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_empty_area_selection"));
                    }
                }
            } else if (split[0].equalsIgnoreCase("notforsale") || split[0].equalsIgnoreCase("nfs")) {
                if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_NOTFORSALE.getNode()))
                    throw new TownyException(Translatable.of("msg_err_command_disable"));
                List<WorldCoord> selection = AreaSelectionUtil.selectWorldCoordArea(resident, new WorldCoord(world, Coord.parseCoord(player)), StringMgmt.remFirstArg(split));
                selection = AreaSelectionUtil.filterPlotsForSale(selection);
                if (permSource.testPermission(player, PermissionNodes.TOWNY_ADMIN.getNode())) {
                    for (WorldCoord worldCoord : selection) {
                        if (worldCoord.getTownBlock().hasPlotObjectGroup()) {
                            TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_plot_belongs_to_group_plot_nfs", worldCoord));
                            return false;
                        }
                        setPlotForSale(resident, worldCoord, -1);
                    }
                    return true;
                }
                // The follow test will clean up the initial selection fairly well, the plotTestOwner later on in the setPlotForSale will ultimately stop any funny business.
                if (permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_ASMAYOR.getNode()) && (resident.hasTown() && townBlock.hasTown() && resident.getTown() == townBlock.getTownOrNull())) {
                    // Treat it as a mayor able to set their town's plots not for sale.
                    selection = AreaSelectionUtil.filterOwnedBlocks(resident.getTown(), selection);
                } else {
                    // Treat it as a resident making their own plots not for sale.
                    selection = AreaSelectionUtil.filterOwnedBlocks(resident, selection);
                }
                if (selection.isEmpty())
                    throw new TownyException(Translatable.of("msg_err_empty_area_selection"));
                // Set each WorldCoord in selection not for sale.
                for (WorldCoord worldCoord : selection) {
                    // Skip over any plots that are part of a PlotGroup.
                    if (worldCoord.getTownBlock().hasPlotObjectGroup()) {
                        TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_plot_belongs_to_group_plot_nfs", worldCoord));
                        continue;
                    }
                    setPlotForSale(resident, worldCoord, -1);
                }
            } else if (split[0].equalsIgnoreCase("forsale") || split[0].equalsIgnoreCase("fs")) {
                if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_FORSALE.getNode()))
                    throw new TownyException(Translatable.of("msg_err_command_disable"));
                WorldCoord pos = new WorldCoord(world, Coord.parseCoord(player));
                Town town = townBlock.getTownOrNull();
                if (town == null)
                    throw new TownyException(Translatable.of("msg_err_empty_area_selection"));
                double plotPrice = town.getPlotTypePrice(townBlock.getType());
                if (split.length > 1) {
                    /*
						 * This is not a case of '/plot fs' and has a cost and/or an area selection involved.
						 */
                    // areaSelectPivot is how Towny handles the 'within' area selection when setting plots for sale.
                    // Will return -1 if the word 'within' is not found.
                    int areaSelectPivot = AreaSelectionUtil.getAreaSelectPivot(split);
                    List<WorldCoord> selection;
                    if (areaSelectPivot >= 0) {
                        // 'within' has been used in the command, make a selection.
                        selection = AreaSelectionUtil.selectWorldCoordArea(resident, new WorldCoord(world, Coord.parseCoord(player)), StringMgmt.subArray(split, areaSelectPivot + 1, split.length));
                        // The follow test will clean up the initial selection fairly well, the plotTestOwner later on in the setPlotForSale will ultimately stop any funny business.
                        if (permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_ASMAYOR.getNode()) && (resident.hasTown() && resident.getTown() == town)) {
                            // Treat it as a mayor able to put their town's plots for sale.
                            selection = AreaSelectionUtil.filterOwnedBlocks(resident.getTown(), selection);
                            // Filter out any resident-owned plots.
                            selection = AreaSelectionUtil.filterOutResidentBlocks(resident, selection);
                        } else {
                            // Treat it as a resident putting their own plots up for sale.
                            selection = AreaSelectionUtil.filterOwnedBlocks(resident, selection);
                        }
                        if (selection.isEmpty())
                            throw new TownyException(Translatable.of("msg_err_empty_area_selection"));
                    } else {
                        // No 'within' found so this will be a case of /plot fs $, add a single coord to selection.
                        selection = new ArrayList<>();
                        selection.add(pos);
                    }
                    // Check that it's not: /plot forsale within rect 3
                    if (areaSelectPivot != 1) {
                        try {
                            // command was 'plot fs $'
                            plotPrice = Double.parseDouble(split[1]);
                            if (plotPrice < 0) {
                                TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_negative_money"));
                                return true;
                            }
                        } catch (NumberFormatException e) {
                            TownyMessaging.sendErrorMsg(player, Translatable.of("msg_error_must_be_num"));
                            return true;
                        }
                    }
                    // Set each WorldCoord in selection for sale.
                    for (WorldCoord worldCoord : selection) {
                        TownBlock tb = worldCoord.getTownBlock();
                        // Skip over any plots that are part of a PlotGroup.
                        if (tb.hasPlotObjectGroup()) {
                            TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_plot_belongs_to_group_plot_fs2", worldCoord));
                            continue;
                        }
                        // Otherwise continue on normally.
                        setPlotForSale(resident, worldCoord, plotPrice);
                    }
                } else {
                    // Skip over any plots that are part of a PlotGroup.
                    if (pos.getTownBlock().hasPlotObjectGroup()) {
                        TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_plot_belongs_to_group_plot_fs2", pos));
                        return false;
                    }
                    // Otherwise continue on normally.
                    setPlotForSale(resident, pos, plotPrice);
                }
            } else if (split[0].equalsIgnoreCase("perm")) {
                parsePlotPermCommand(player, StringMgmt.remFirstArg(split));
            } else if (split[0].equalsIgnoreCase("info")) {
                if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_PERM_INFO.getNode()))
                    throw new TownyException(Translatable.of("msg_err_command_disable"));
                sendPlotInfo(player, StringMgmt.remFirstArg(split));
            } else if (split[0].equalsIgnoreCase("toggle")) {
                /*
					 * perm test in the plottoggle.
					 */
                // Test we are allowed to work on this plot
                // ignore the return as
                plotTestOwner(resident, townBlock);
                // Make sure that the player is only operating on a single plot and not a plotgroup.
                if (townBlock.hasPlotObjectGroup()) {
                    TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_plot_belongs_to_group_toggle"));
                    return false;
                }
                plotToggle(player, new WorldCoord(world, Coord.parseCoord(player)).getTownBlock(), StringMgmt.remFirstArg(split));
            } else if (split[0].equalsIgnoreCase("set")) {
                split = StringMgmt.remFirstArg(split);
                if (split.length == 0 || split[0].equalsIgnoreCase("?")) {
                    HelpMenu.PLOT_SET.send(player);
                } else if (split.length > 0) {
                    if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_SET.getNode(split[0].toLowerCase())))
                        throw new TownyException(Translatable.of("msg_err_command_disable"));
                    // Make sure that the player is only operating on a plot object group if one exists.
                    if (townBlock.hasPlotObjectGroup()) {
                        TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_plot_belongs_to_group_set"));
                        return false;
                    }
                    if (split[0].equalsIgnoreCase("perm")) {
                        // Set plot level permissions (if the plot owner) or
                        // Mayor/Assistant of the town.
                        // Test we are allowed to work on this plot
                        plotTestOwner(resident, townBlock);
                        setTownBlockPermissions(player, townBlock.getTownBlockOwner(), townBlock, StringMgmt.remFirstArg(split));
                        return true;
                    } else if (split[0].equalsIgnoreCase("name")) {
                        // Test we are allowed to work on this plot
                        plotTestOwner(resident, townBlock);
                        if (split.length == 1) {
                            townBlock.setName("");
                            TownyMessaging.sendMsg(player, Translatable.of("msg_plot_name_removed"));
                            townBlock.save();
                            return true;
                        }
                        String newName = StringMgmt.join(StringMgmt.remFirstArg(split), "_");
                        // Test if the plot name contains invalid characters.
                        if (!NameValidation.isBlacklistName(newName)) {
                            townBlock.setName(newName);
                            // townBlock.setChanged(true);
                            townBlock.save();
                            TownyMessaging.sendMsg(player, Translatable.of("msg_plot_name_set_to", townBlock.getName()));
                        } else {
                            TownyMessaging.sendErrorMsg(player, Translatable.of("msg_invalid_name"));
                        }
                        return true;
                    } else if (split[0].equalsIgnoreCase("outpost")) {
                        if (TownySettings.isAllowingOutposts()) {
                            if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_TOWN_CLAIM_OUTPOST.getNode()))
                                throw new TownyException(Translatable.of("msg_err_command_disable"));
                            // Test we are allowed to work on this plot
                            plotTestOwner(resident, townBlock);
                            Town town = townBlock.getTownOrNull();
                            TownyWorld townyWorld = townBlock.getWorld();
                            boolean isAdmin = permSource.isTownyAdmin(player);
                            Coord key = Coord.parseCoord(plugin.getCache(player).getLastLocation());
                            if (OutpostUtil.OutpostTests(town, resident, townyWorld, key, isAdmin, true)) {
                                // Test if they can pay.
                                if (TownyEconomyHandler.isActive() && !town.getAccount().canPayFromHoldings(TownySettings.getOutpostCost()))
                                    throw new TownyException(Translatable.of("msg_err_cannot_afford_to_set_outpost"));
                                // Create a confirmation for setting outpost.
                                Confirmation.runOnAccept(() -> {
                                    // Make them pay.
                                    if (TownyEconomyHandler.isActive() && TownySettings.getOutpostCost() > 0 && !town.getAccount().withdraw(TownySettings.getOutpostCost(), "Plot Set Outpost")) {
                                        TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_cannot_afford_to_set_outpost"));
                                        return;
                                    }
                                    // Set the outpost spawn and display feedback.
                                    town.addOutpostSpawn(player.getLocation());
                                    TownyMessaging.sendMsg(player, Translatable.of("msg_plot_set_cost", TownyEconomyHandler.getFormattedBalance(TownySettings.getOutpostCost()), Translatable.of("outpost")));
                                }).setTitle(Translatable.of("msg_confirm_purchase", TownyEconomyHandler.getFormattedBalance(TownySettings.getOutpostCost()))).sendTo(player);
                            }
                        }
                        return true;
                    } else if (TownyCommandAddonAPI.hasCommand(CommandType.PLOT_SET, split[0])) {
                        TownyCommandAddonAPI.getAddonCommand(CommandType.PLOT_SET, split[0]).execute(player, "plot", split);
                        return true;
                    }
                    try {
                        String plotTypeName = split[0];
                        // Handle type being reset
                        if (plotTypeName.equalsIgnoreCase("reset"))
                            plotTypeName = "default";
                        TownBlockType townBlockType = TownBlockTypeHandler.getType(plotTypeName);
                        if (townBlockType == null)
                            throw new TownyException(Translatable.of("msg_err_not_block_type"));
                        try {
                            // Test we are allowed to work on this plot
                            // ignore the return as we
                            plotTestOwner(resident, townBlock);
                        // are only checking for an
                        // exception
                        } catch (TownyException e) {
                            TownyMessaging.sendErrorMsg(player, e.getMessage(player));
                            return false;
                        }
                        if (TownBlockType.ARENA.equals(townBlockType) && TownySettings.getOutsidersPreventPVPToggle()) {
                            for (Player target : Bukkit.getOnlinePlayers()) {
                                if (!townBlock.getTownOrNull().hasResident(target) && !player.getName().equals(target.getName()) && townBlock.getWorldCoord().equals(WorldCoord.parseWorldCoord(target)))
                                    throw new TownyException(Translatable.of("msg_cant_toggle_pvp_outsider_in_plot"));
                            }
                        }
                        PlotPreChangeTypeEvent preEvent = new PlotPreChangeTypeEvent(townBlockType, townBlock, resident);
                        BukkitTools.getPluginManager().callEvent(preEvent);
                        if (preEvent.isCancelled()) {
                            TownyMessaging.sendErrorMsg(player, preEvent.getCancelMessage());
                            return false;
                        }
                        double cost = townBlockType.getData().getCost();
                        // Test if we can pay first to throw an exception.
                        if (cost > 0 && TownyEconomyHandler.isActive() && !resident.getAccount().canPayFromHoldings(cost))
                            throw new TownyException(Translatable.of("msg_err_cannot_afford_plot_set_type_cost", townBlockType, TownyEconomyHandler.getFormattedBalance(cost)));
                        // Handle payment via a confirmation to avoid suprise costs.
                        if (cost > 0 && TownyEconomyHandler.isActive()) {
                            Confirmation.runOnAccept(() -> {
                                if (!resident.getAccount().withdraw(cost, String.format("Plot set to %s", townBlockType))) {
                                    TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_cannot_afford_plot_set_type_cost", townBlockType, TownyEconomyHandler.getFormattedBalance(cost)));
                                    return;
                                }
                                TownyMessaging.sendMsg(resident, Translatable.of("msg_plot_set_cost", TownyEconomyHandler.getFormattedBalance(cost), townBlockType));
                                try {
                                    townBlock.setType(townBlockType, resident);
                                } catch (TownyException e) {
                                    TownyMessaging.sendErrorMsg(resident, e.getMessage(player));
                                    return;
                                }
                                TownyMessaging.sendMsg(player, Translatable.of("msg_plot_set_type", townBlockType));
                            }).setTitle(Translatable.of("msg_confirm_purchase", TownyEconomyHandler.getFormattedBalance(cost))).sendTo(BukkitTools.getPlayerExact(resident.getName()));
                        // No cost or economy so no confirmation.
                        } else {
                            townBlock.setType(townBlockType, resident);
                            TownyMessaging.sendMsg(player, Translatable.of("msg_plot_set_type", plotTypeName));
                        }
                    } catch (TownyException te) {
                        TownyMessaging.sendErrorMsg(player, te.getMessage(player));
                    }
                } else {
                    HelpMenu.PLOT_SET.send(player);
                }
            } else if (split[0].equalsIgnoreCase("clear")) {
                if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_CLEAR.getNode()))
                    throw new TownyException(Translatable.of("msg_err_command_disable"));
                if (townBlock != null) {
                    if (!townBlock.getWorld().isUsingPlotManagementMayorDelete())
                        throw new TownyException(Translatable.of("msg_err_plot_clear_disabled_in_this_world"));
                    /*
						 * Only allow mayors or plot owners to use this command.
						 * This will throw an exception if the player isn't a mayor or owner of the plot. 
						 */
                    plotTestOwner(resident, townBlock);
                    PlotPreClearEvent preEvent = new PlotPreClearEvent(townBlock);
                    BukkitTools.getPluginManager().callEvent(preEvent);
                    if (preEvent.isCancelled()) {
                        TownyMessaging.sendErrorMsg(player, preEvent.getCancelMessage());
                        return false;
                    }
                    EnumSet<Material> materialsToDelete = TownyAPI.getInstance().getTownyWorld(world).getPlotManagementMayorDelete();
                    if (!materialsToDelete.isEmpty()) {
                        TownyRegenAPI.deleteMaterialsFromTownBlock(townBlock, materialsToDelete);
                        TownyMessaging.sendMsg(player, Translatable.of("msg_clear_plot_material", StringMgmt.join(materialsToDelete, ", ")));
                    }
                    // Raise an event for the claim
                    BukkitTools.getPluginManager().callEvent(new PlotClearEvent(townBlock));
                } else {
                    // Shouldn't ever reach here as a null townBlock should
                    // be caught already in WorldCoord.
                    TownyMessaging.sendErrorMsg(player, Translatable.of("msg_err_empty_area_selection"));
                }
            } else if (split[0].equalsIgnoreCase("group")) {
                return handlePlotGroupCommand(StringMgmt.remFirstArg(split), player);
            } else if (split[0].equalsIgnoreCase("jailcell")) {
                parsePlotJailCell(player, TownyAPI.getInstance().getTownBlock(player), StringMgmt.remFirstArg(split));
                return true;
            } else if (split[0].equalsIgnoreCase("trust")) {
                if (!permSource.testPermission(player, PermissionNodes.TOWNY_COMMAND_PLOT_TRUST.getNode()))
                    throw new TownyException(Translatable.of("msg_err_command_disable"));
                parsePlotTrustCommand(player, StringMgmt.remFirstArg(split));
                return true;
            } else if (TownyCommandAddonAPI.hasCommand(CommandType.PLOT, split[0])) {
                TownyCommandAddonAPI.getAddonCommand(CommandType.PLOT, split[0]).execute(player, "plot", split);
            } else
                throw new TownyException(Translatable.of("msg_err_invalid_property", split[0]));
        } catch (TownyException x) {
            TownyMessaging.sendErrorMsg(player, x.getMessage(player));
        }
    }
    return true;
}
Also used : Arrays(java.util.Arrays) Resident(com.palmergames.bukkit.towny.object.Resident) TownBlockType(com.palmergames.bukkit.towny.object.TownBlockType) Translatable(com.palmergames.bukkit.towny.object.Translatable) TownBlockTypeHandler(com.palmergames.bukkit.towny.object.TownBlockTypeHandler) Player(org.bukkit.entity.Player) PlotSetForSaleEvent(com.palmergames.bukkit.towny.event.plot.PlotSetForSaleEvent) TownBlockOwner(com.palmergames.bukkit.towny.object.TownBlockOwner) PlotTrustAddEvent(com.palmergames.bukkit.towny.event.plot.PlotTrustAddEvent) CooldownTimerTask(com.palmergames.bukkit.towny.tasks.CooldownTimerTask) TownyFormatter(com.palmergames.bukkit.towny.TownyFormatter) OutpostUtil(com.palmergames.bukkit.towny.utils.OutpostUtil) NameUtil(com.palmergames.bukkit.towny.utils.NameUtil) PlotClaim(com.palmergames.bukkit.towny.tasks.PlotClaim) Material(org.bukkit.Material) EnumSet(java.util.EnumSet) Bukkit(org.bukkit.Bukkit) TownBlockSettingsChangedEvent(com.palmergames.bukkit.towny.event.TownBlockSettingsChangedEvent) TownyRegenAPI(com.palmergames.bukkit.towny.regen.TownyRegenAPI) TownyPermissionSource(com.palmergames.bukkit.towny.permissions.TownyPermissionSource) CommandSender(org.bukkit.command.CommandSender) TownyPermission(com.palmergames.bukkit.towny.object.TownyPermission) NameValidation(com.palmergames.bukkit.util.NameValidation) TownyWorld(com.palmergames.bukkit.towny.object.TownyWorld) SpawnPointLocation(com.palmergames.bukkit.towny.object.SpawnPointLocation) BukkitTools(com.palmergames.bukkit.util.BukkitTools) UUID(java.util.UUID) CombatUtil(com.palmergames.bukkit.towny.utils.CombatUtil) Coord(com.palmergames.bukkit.towny.object.Coord) PlotToggleFireEvent(com.palmergames.bukkit.towny.event.plot.toggle.PlotToggleFireEvent) PlotClearEvent(com.palmergames.bukkit.towny.event.PlotClearEvent) List(java.util.List) Optional(java.util.Optional) Command(org.bukkit.command.Command) Towny(com.palmergames.bukkit.towny.Towny) TownyMessaging(com.palmergames.bukkit.towny.TownyMessaging) PlotNotForSaleEvent(com.palmergames.bukkit.towny.event.plot.PlotNotForSaleEvent) WorldCoord(com.palmergames.bukkit.towny.object.WorldCoord) AreaSelectionUtil(com.palmergames.bukkit.towny.utils.AreaSelectionUtil) PlotPreClearEvent(com.palmergames.bukkit.towny.event.PlotPreClearEvent) PlotToggleExplosionEvent(com.palmergames.bukkit.towny.event.plot.toggle.PlotToggleExplosionEvent) PlotTrustRemoveEvent(com.palmergames.bukkit.towny.event.plot.PlotTrustRemoveEvent) PlotTogglePvpEvent(com.palmergames.bukkit.towny.event.plot.toggle.PlotTogglePvpEvent) TownyUniverse(com.palmergames.bukkit.towny.TownyUniverse) ArrayList(java.util.ArrayList) PlotPreChangeTypeEvent(com.palmergames.bukkit.towny.event.PlotPreChangeTypeEvent) TownyCommandAddonAPI(com.palmergames.bukkit.towny.TownyCommandAddonAPI) HUDManager(com.palmergames.bukkit.towny.huds.HUDManager) PlotGroup(com.palmergames.bukkit.towny.object.PlotGroup) PlotToggleMobsEvent(com.palmergames.bukkit.towny.event.plot.toggle.PlotToggleMobsEvent) CooldownType(com.palmergames.bukkit.towny.tasks.CooldownTimerTask.CooldownType) ChatTools(com.palmergames.bukkit.util.ChatTools) PermissionData(com.palmergames.bukkit.towny.object.PermissionData) Town(com.palmergames.bukkit.towny.object.Town) PermissionGUIUtil(com.palmergames.bukkit.towny.utils.PermissionGUIUtil) StringMgmt(com.palmergames.util.StringMgmt) Colors(com.palmergames.bukkit.util.Colors) TownyPermissionChange(com.palmergames.bukkit.towny.object.TownyPermissionChange) TownyEconomyHandler(com.palmergames.bukkit.towny.TownyEconomyHandler) CommandExecutor(org.bukkit.command.CommandExecutor) TownyAPI(com.palmergames.bukkit.towny.TownyAPI) CommandType(com.palmergames.bukkit.towny.TownyCommandAddonAPI.CommandType) AlreadyRegisteredException(com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException) PermissionNodes(com.palmergames.bukkit.towny.permissions.PermissionNodes) TownBlock(com.palmergames.bukkit.towny.object.TownBlock) Confirmation(com.palmergames.bukkit.towny.confirmations.Confirmation) TownySettings(com.palmergames.bukkit.towny.TownySettings) TownyException(com.palmergames.bukkit.towny.exceptions.TownyException) Collections(java.util.Collections) Jail(com.palmergames.bukkit.towny.object.jail.Jail) TownBlockType(com.palmergames.bukkit.towny.object.TownBlockType) AlreadyRegisteredException(com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException) ArrayList(java.util.ArrayList) PlotPreClearEvent(com.palmergames.bukkit.towny.event.PlotPreClearEvent) Town(com.palmergames.bukkit.towny.object.Town) Resident(com.palmergames.bukkit.towny.object.Resident) List(java.util.List) ArrayList(java.util.ArrayList) PlotClearEvent(com.palmergames.bukkit.towny.event.PlotClearEvent) TownyPermissionSource(com.palmergames.bukkit.towny.permissions.TownyPermissionSource) TownyWorld(com.palmergames.bukkit.towny.object.TownyWorld) PlotPreChangeTypeEvent(com.palmergames.bukkit.towny.event.PlotPreChangeTypeEvent) TownBlock(com.palmergames.bukkit.towny.object.TownBlock) Player(org.bukkit.entity.Player) EnumSet(java.util.EnumSet) TownyException(com.palmergames.bukkit.towny.exceptions.TownyException) PlotClaim(com.palmergames.bukkit.towny.tasks.PlotClaim) Coord(com.palmergames.bukkit.towny.object.Coord) WorldCoord(com.palmergames.bukkit.towny.object.WorldCoord) WorldCoord(com.palmergames.bukkit.towny.object.WorldCoord)

Aggregations

Towny (com.palmergames.bukkit.towny.Towny)1 TownyAPI (com.palmergames.bukkit.towny.TownyAPI)1 TownyCommandAddonAPI (com.palmergames.bukkit.towny.TownyCommandAddonAPI)1 CommandType (com.palmergames.bukkit.towny.TownyCommandAddonAPI.CommandType)1 TownyEconomyHandler (com.palmergames.bukkit.towny.TownyEconomyHandler)1 TownyFormatter (com.palmergames.bukkit.towny.TownyFormatter)1 TownyMessaging (com.palmergames.bukkit.towny.TownyMessaging)1 TownySettings (com.palmergames.bukkit.towny.TownySettings)1 TownyUniverse (com.palmergames.bukkit.towny.TownyUniverse)1 Confirmation (com.palmergames.bukkit.towny.confirmations.Confirmation)1 PlotClearEvent (com.palmergames.bukkit.towny.event.PlotClearEvent)1 PlotPreChangeTypeEvent (com.palmergames.bukkit.towny.event.PlotPreChangeTypeEvent)1 PlotPreClearEvent (com.palmergames.bukkit.towny.event.PlotPreClearEvent)1 TownBlockSettingsChangedEvent (com.palmergames.bukkit.towny.event.TownBlockSettingsChangedEvent)1 PlotNotForSaleEvent (com.palmergames.bukkit.towny.event.plot.PlotNotForSaleEvent)1 PlotSetForSaleEvent (com.palmergames.bukkit.towny.event.plot.PlotSetForSaleEvent)1 PlotTrustAddEvent (com.palmergames.bukkit.towny.event.plot.PlotTrustAddEvent)1 PlotTrustRemoveEvent (com.palmergames.bukkit.towny.event.plot.PlotTrustRemoveEvent)1 PlotToggleExplosionEvent (com.palmergames.bukkit.towny.event.plot.toggle.PlotToggleExplosionEvent)1 PlotToggleFireEvent (com.palmergames.bukkit.towny.event.plot.toggle.PlotToggleFireEvent)1