mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-04 03:03:43 +01:00 
			
		
		
		
	No more errors made my me, they're all yours :)
This commit is contained in:
		@@ -609,11 +609,14 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
 | 
			
		||||
     *
 | 
			
		||||
     * @param c SubCommand, that we want to register
 | 
			
		||||
     *
 | 
			
		||||
     * @see com.intellectualcrafters.plot.commands.MainCommand#subCommands
 | 
			
		||||
     * @see com.intellectualcrafters.plot.commands.SubCommand
 | 
			
		||||
     */
 | 
			
		||||
    public void registerCommand(final SubCommand c) {
 | 
			
		||||
        MainCommand.subCommands.add(c);
 | 
			
		||||
        if (c.getCommand() != null) {
 | 
			
		||||
            MainCommand.instance.addCommand(c);
 | 
			
		||||
        } else {
 | 
			
		||||
            MainCommand.instance.createCommand(c);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,8 @@ import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
import com.intellectualsites.commands.Argument;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import com.plotsquared.bukkit.util.bukkit.UUIDHandler;
 | 
			
		||||
 | 
			
		||||
import com.plotsquared.bukkit.util.UUIDHandler;
 | 
			
		||||
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
 
 | 
			
		||||
@@ -1,73 +0,0 @@
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.command.Command;
 | 
			
		||||
import org.bukkit.command.CommandExecutor;
 | 
			
		||||
import org.bukkit.command.CommandSender;
 | 
			
		||||
import org.bukkit.command.TabCompleter;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.StringComparison;
 | 
			
		||||
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created 2015-02-20 for PlotSquared
 | 
			
		||||
 *
 | 
			
		||||
 * @author Citymonstret
 | 
			
		||||
 */
 | 
			
		||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
 | 
			
		||||
    
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final CommandSender commandSender, final Command command, final String commandLabel, final String[] args) {
 | 
			
		||||
        if (commandSender instanceof Player) {
 | 
			
		||||
            return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
 | 
			
		||||
        }
 | 
			
		||||
        return MainCommand.onCommand(null, commandLabel, args);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<String> onTabComplete(final CommandSender commandSender, final Command command, final String s, final String[] strings) {
 | 
			
		||||
        if (!(commandSender instanceof Player)) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
 | 
			
		||||
        if (strings.length < 1) {
 | 
			
		||||
            if ((strings.length == 0) || "plots".startsWith(s)) {
 | 
			
		||||
                return Arrays.asList("plots");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (strings.length > 1) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        if (!command.getLabel().equalsIgnoreCase("plots")) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        final List<String> tabOptions = new ArrayList<>();
 | 
			
		||||
        final String[] commands = new String[MainCommand.subCommands.size()];
 | 
			
		||||
        for (int x = 0; x < MainCommand.subCommands.size(); x++) {
 | 
			
		||||
            commands[x] = MainCommand.subCommands.get(x).cmd;
 | 
			
		||||
        }
 | 
			
		||||
        String best = new StringComparison(strings[0], commands).getBestMatch();
 | 
			
		||||
        tabOptions.add(best);
 | 
			
		||||
        final String arg = strings[0].toLowerCase();
 | 
			
		||||
        for (final SubCommand cmd : MainCommand.subCommands) {
 | 
			
		||||
            if (!cmd.cmd.equalsIgnoreCase(best)) {
 | 
			
		||||
                if (cmd.permission.hasPermission(player)) {
 | 
			
		||||
                    if (cmd.cmd.startsWith(arg)) {
 | 
			
		||||
                        tabOptions.add(cmd.cmd);
 | 
			
		||||
                    } else if (cmd.alias.size() > 0 && cmd.alias.get(0).startsWith(arg)) {
 | 
			
		||||
                        tabOptions.add(cmd.alias.get(0));
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (tabOptions.size() > 0) {
 | 
			
		||||
            return tabOptions;
 | 
			
		||||
        }
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -27,6 +27,7 @@ import java.util.UUID;
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.database.DBFunc;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,162 +0,0 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// PlotSquared - A plot manager and world generator for the Bukkit API                             /
 | 
			
		||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters                                       /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// This program is free software; you can redistribute it and/or modify                            /
 | 
			
		||||
// it under the terms of the GNU General Public License as published by                            /
 | 
			
		||||
// the Free Software Foundation; either version 3 of the License, or                               /
 | 
			
		||||
// (at your option) any later version.                                                             /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// This program is distributed in the hope that it will be useful,                                 /
 | 
			
		||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                  /
 | 
			
		||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                   /
 | 
			
		||||
// GNU General Public License for more details.                                                    /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// You should have received a copy of the GNU General Public License                               /
 | 
			
		||||
// along with this program; if not, write to the Free Software Foundation,                         /
 | 
			
		||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA                               /
 | 
			
		||||
//                                                                                                 /
 | 
			
		||||
// You can contact us via: support@intellectualsites.com                                           /
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by Citymonstret on 2014-08-03.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Citymonstret
 | 
			
		||||
 * @author Empire92
 | 
			
		||||
 */
 | 
			
		||||
public enum Command {
 | 
			
		||||
    // TODO new commands
 | 
			
		||||
    // (economy)
 | 
			
		||||
    // - /plot buy
 | 
			
		||||
    // - /plot sell <value>
 | 
			
		||||
    // (Rating system) (ratings can be stored as the average, and number of
 | 
			
		||||
    // ratings)
 | 
			
		||||
    // - /plot rate <number out of 10>
 | 
			
		||||
    
 | 
			
		||||
    ADD("add","a"),
 | 
			
		||||
    TRUST("trust", "t"),
 | 
			
		||||
    DENY("deny", "d"),
 | 
			
		||||
    REMOVE("remove", "r"),
 | 
			
		||||
    UNTRUST("untrust", "ut"),
 | 
			
		||||
    UNDENY("undeny", "ud"),
 | 
			
		||||
    TOGGLE("toggle", "attribute"),
 | 
			
		||||
    DOWNLOAD("download", "dl"),
 | 
			
		||||
    SAVE("save", "backup"),
 | 
			
		||||
    LOAD("load", "restore"),
 | 
			
		||||
    MOVE("move"),
 | 
			
		||||
    FLAG("flag", "f"),
 | 
			
		||||
    TARGET("target"),
 | 
			
		||||
    CLUSTER("cluster", "clusters"),
 | 
			
		||||
    BUY("buy", "b"),
 | 
			
		||||
    CREATEROADSCHEMATIC("createroadschematic", "crs"),
 | 
			
		||||
    DEBUGROADREGEN("debugroadregen"),
 | 
			
		||||
    DEBUGFIXFLAGS("debugfixflags"),
 | 
			
		||||
    REGENALLROADS("regenallroads"),
 | 
			
		||||
    ALLOWUNSAFE("debugallowunsafe"),
 | 
			
		||||
    DEBUGLOADTEST("debugloadtest"),
 | 
			
		||||
    DEBUGSAVETEST("debugsavetest"),
 | 
			
		||||
    DEBUG_PASTE("debugpaste", "dp"),
 | 
			
		||||
    UNCLAIM("unclaim"),
 | 
			
		||||
    DEBUGCLEAR("debugclear", "fastclear"),
 | 
			
		||||
    SWAP("swap"),
 | 
			
		||||
    INBOX("inbox"),
 | 
			
		||||
    DEBUGCLAIMTEST("debugclaimtest"),
 | 
			
		||||
    COMMENT("comment", "msg"),
 | 
			
		||||
    PASTE("paste"),
 | 
			
		||||
    CLIPBOARD("clipboard", "cboard"),
 | 
			
		||||
    COPY("copy"),
 | 
			
		||||
    KICK("kick", "k"),
 | 
			
		||||
    CLAIM("claim", "c"),
 | 
			
		||||
    MERGE("merge", "m"),
 | 
			
		||||
    UNLINK("unlink", "u"),
 | 
			
		||||
    CLEAR("clear", "", new CommandPermission("plots.clear")),
 | 
			
		||||
    DELETE("delete", "", new CommandPermission("plots.delete")),
 | 
			
		||||
    DEBUG("debug", "", new CommandPermission("plots.admin")),
 | 
			
		||||
    INTERFACE("interface", "int", new CommandPermission("plots.interface")),
 | 
			
		||||
    HOME("home", "h"),
 | 
			
		||||
    INFO("info", "i"),
 | 
			
		||||
    LIST("list", "l"),
 | 
			
		||||
    SET("set", "s"),
 | 
			
		||||
    PURGE("purge"),
 | 
			
		||||
    DATABASE("database", "convert"),
 | 
			
		||||
    CONFIRM("confirm"),
 | 
			
		||||
    TP("tp", "tp"),
 | 
			
		||||
    CHAT("chat", "on|off", new CommandPermission("plots.chat"));
 | 
			
		||||
    /**
 | 
			
		||||
     * Command
 | 
			
		||||
     */
 | 
			
		||||
    private final String command;
 | 
			
		||||
    /**
 | 
			
		||||
     * Alias
 | 
			
		||||
     */
 | 
			
		||||
    private final String alias;
 | 
			
		||||
    /**
 | 
			
		||||
     * Permission Node
 | 
			
		||||
     */
 | 
			
		||||
    private final CommandPermission permission;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param command Command "name" (/plot [cmd])
 | 
			
		||||
     */
 | 
			
		||||
    Command(final String command) {
 | 
			
		||||
        this.command = command;
 | 
			
		||||
        this.alias = command;
 | 
			
		||||
        this.permission = new CommandPermission("plots." + command);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param command    Command "name" (/plot [cmd])
 | 
			
		||||
     * @param permission Command Permission Node
 | 
			
		||||
     */
 | 
			
		||||
    Command(final String command, final CommandPermission permission) {
 | 
			
		||||
        this.command = command;
 | 
			
		||||
        this.permission = permission;
 | 
			
		||||
        this.alias = command;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param command Command "name" (/plot [cmd])
 | 
			
		||||
     * @param alias   Command Alias
 | 
			
		||||
     */
 | 
			
		||||
    Command(final String command, final String alias) {
 | 
			
		||||
        this.command = command;
 | 
			
		||||
        this.alias = alias;
 | 
			
		||||
        this.permission = new CommandPermission("plots." + command);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param command    Command "name" (/plot [cmd])
 | 
			
		||||
     * @param alias      Command Alias
 | 
			
		||||
     * @param permission Required Permission Node
 | 
			
		||||
     */
 | 
			
		||||
    Command(final String command, final String alias, final CommandPermission permission) {
 | 
			
		||||
        this.command = command;
 | 
			
		||||
        this.alias = alias;
 | 
			
		||||
        this.permission = permission;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return command
 | 
			
		||||
     */
 | 
			
		||||
    public String getCommand() {
 | 
			
		||||
        return this.command;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return alias
 | 
			
		||||
     */
 | 
			
		||||
    public String getAlias() {
 | 
			
		||||
        return this.alias;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return permission object
 | 
			
		||||
     *
 | 
			
		||||
     * @see com.intellectualcrafters.plot.commands.CommandPermission
 | 
			
		||||
     */
 | 
			
		||||
    public CommandPermission getPermission() {
 | 
			
		||||
        return this.permission;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -22,6 +22,8 @@ package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
@@ -34,13 +36,19 @@ import com.plotsquared.bukkit.object.comment.CommentManager;
 | 
			
		||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "comment",
 | 
			
		||||
        aliases = {"msg"},
 | 
			
		||||
        description = "Comment on a plot",
 | 
			
		||||
        category = CommandCategory.ACTIONS,
 | 
			
		||||
        requiredType = PlotPlayer.class,
 | 
			
		||||
        permission = "plot.comment"
 | 
			
		||||
)
 | 
			
		||||
public class Comment extends SubCommand {
 | 
			
		||||
    public Comment() {
 | 
			
		||||
        super(Command.COMMENT, "Comment on a plot", "comment", CommandCategory.ACTIONS, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer player, final String... args) {
 | 
			
		||||
    public boolean onCommand(CommandCaller caller, String[] args) {
 | 
			
		||||
        final PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
 | 
			
		||||
        if (args.length < 2) {
 | 
			
		||||
            sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|"));
 | 
			
		||||
            return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,8 @@ import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
@@ -36,23 +38,24 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "condense",
 | 
			
		||||
        permission = "plots.admin",
 | 
			
		||||
        description = "Condense a plotworld",
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        requiredType = PS.class
 | 
			
		||||
)
 | 
			
		||||
public class Condense extends SubCommand {
 | 
			
		||||
    public static boolean TASK = false;
 | 
			
		||||
 | 
			
		||||
    public Condense() {
 | 
			
		||||
        super("condense", "plots.admin", "Condense a plotworld", "condense", "", CommandCategory.DEBUG, false);
 | 
			
		||||
    }
 | 
			
		||||
    public static boolean TASK = false;
 | 
			
		||||
 | 
			
		||||
    public static void sendMessage(final String message) {
 | 
			
		||||
        PS.log("&3PlotSquared -> Plot condense&8: &7" + message);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, final String... args) {
 | 
			
		||||
        if (plr != null) {
 | 
			
		||||
            MainUtil.sendMessage(plr, (C.NOT_CONSOLE));
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    public boolean onCommand(final CommandCaller caller, String ... args) {
 | 
			
		||||
        final PlotPlayer plr = null;
 | 
			
		||||
        if ((args.length != 2) && (args.length != 3)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, "/plot condense <world> <start|stop|info> [radius]");
 | 
			
		||||
            return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -20,23 +20,27 @@
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.object.CmdInstance;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.CmdConfirm;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Citymonstret
 | 
			
		||||
 */
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
		command = "confirm",
 | 
			
		||||
		permission = "plots.use",
 | 
			
		||||
		description = "Confirm an action",
 | 
			
		||||
		category = CommandCategory.ACTIONS
 | 
			
		||||
)
 | 
			
		||||
public class Confirm extends SubCommand {
 | 
			
		||||
    public Confirm() {
 | 
			
		||||
        super("confirm", "plots.use", "Confirm an action", "confirm", "confirm", CommandCategory.ACTIONS, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, final String... args) {
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean onCommand(final CommandCaller caller, final String ... args) {
 | 
			
		||||
		final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
 | 
			
		||||
    	CmdInstance command = CmdConfirm.getPending(plr);
 | 
			
		||||
    	if (command == null) {
 | 
			
		||||
    		MainUtil.sendMessage(plr, C.FAILED_CONFIRM);
 | 
			
		||||
 
 | 
			
		||||
@@ -28,12 +28,19 @@ import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "createroadschematic",
 | 
			
		||||
        aliases = {"crs"},
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        requiredType = PlotPlayer.class,
 | 
			
		||||
        permission = "plots.createroadschematic",
 | 
			
		||||
        description = "Add a road schematic to your world using the roads around your current plot",
 | 
			
		||||
        usage = "/plot createroadschematic"
 | 
			
		||||
)
 | 
			
		||||
public class CreateRoadSchematic extends SubCommand {
 | 
			
		||||
    public CreateRoadSchematic() {
 | 
			
		||||
        super(Command.CREATEROADSCHEMATIC, "Add a road schematic to your world using the road around your current plot", "crs", CommandCategory.DEBUG, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final CommandCaller caller, final String ... args) {
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,7 @@ import java.util.ArrayList;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
 | 
			
		||||
import com.intellectualcrafters.plot.database.MySQL;
 | 
			
		||||
import com.intellectualcrafters.plot.database.SQLManager;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
@@ -13,17 +14,19 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.StringComparison;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.plotsquared.bukkit.util.bukkit.UUIDHandler;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import com.plotsquared.bukkit.util.UUIDHandler;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created 2014-11-15 for PlotSquared
 | 
			
		||||
 *
 | 
			
		||||
 * @author Citymonstret
 | 
			
		||||
 */
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "database",
 | 
			
		||||
        aliases = {"convert"},
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        permission = "plots.database",
 | 
			
		||||
        description = "Convert/Backup Storage",
 | 
			
		||||
        usage = "/plots database <type> [details...]"
 | 
			
		||||
)
 | 
			
		||||
public class Database extends SubCommand {
 | 
			
		||||
    public Database() {
 | 
			
		||||
        super(Command.DATABASE, "Convert/Backup Storage", "database [type] [...details]", CommandCategory.DEBUG, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static boolean sendMessageU(final UUID uuid, final String msg) {
 | 
			
		||||
        if (uuid == null) {
 | 
			
		||||
@@ -70,7 +73,8 @@ public class Database extends SubCommand {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, final String... args) {
 | 
			
		||||
    public boolean onCommand(CommandCaller caller, String[] args) {
 | 
			
		||||
        final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
 | 
			
		||||
        if (args.length < 1) {
 | 
			
		||||
            return sendMessage(plr, "/plot database [sqlite/mysql]");
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -21,18 +21,26 @@
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.Lag;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debug",
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        description = "Show debug information",
 | 
			
		||||
        usage = "/plot debug [msg]",
 | 
			
		||||
        permission = "plots.admin"
 | 
			
		||||
)
 | 
			
		||||
public class Debug extends SubCommand {
 | 
			
		||||
    public Debug() {
 | 
			
		||||
        super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.DEBUG, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, final String... args) {
 | 
			
		||||
    public boolean onCommand(CommandCaller caller, String[] args) {
 | 
			
		||||
        final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
 | 
			
		||||
        if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
 | 
			
		||||
            final StringBuilder msg = new StringBuilder();
 | 
			
		||||
            for (final C c : C.values()) {
 | 
			
		||||
 
 | 
			
		||||
@@ -5,18 +5,24 @@ import java.util.List;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debugallowunsafe",
 | 
			
		||||
        description = "Allow unsafe actions until toggled off",
 | 
			
		||||
        usage = "/plot debugallowunsafe",
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        requiredType = PlotPlayer.class,
 | 
			
		||||
        permission = "plots.debugallowunsafe"
 | 
			
		||||
)
 | 
			
		||||
public class DebugAllowUnsafe extends SubCommand {
 | 
			
		||||
 | 
			
		||||
    public static final List<UUID> unsafeAllowed = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
    public DebugAllowUnsafe() {
 | 
			
		||||
        super(Command.ALLOWUNSAFE, "Allow unsafe actions until toggled off", "allowunsafe", CommandCategory.DEBUG, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final CommandCaller caller, final String ... args) {
 | 
			
		||||
        final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
 | 
			
		||||
 
 | 
			
		||||
@@ -39,15 +39,18 @@ import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChunkManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.EventUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.plotsquared.bukkit.util.bukkit.UUIDHandler;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import com.plotsquared.bukkit.util.UUIDHandler;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Citymonstret
 | 
			
		||||
 */
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debugclaimtest",
 | 
			
		||||
        description = "If you accidentally delete your database, this command will attempt to restore all plots based on the data from plot sighs. Execution time may vary",
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        requiredType = PS.class,
 | 
			
		||||
        permission = "plots.debugclaimtest"
 | 
			
		||||
)
 | 
			
		||||
public class DebugClaimTest extends SubCommand {
 | 
			
		||||
    public DebugClaimTest() {
 | 
			
		||||
        super(Command.DEBUGCLAIMTEST, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. Execution time may vary", "debugclaimtest", CommandCategory.DEBUG, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport) {
 | 
			
		||||
        return claimPlot(player, plot, teleport, "");
 | 
			
		||||
@@ -67,87 +70,83 @@ public class DebugClaimTest extends SubCommand {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, final String... args) {
 | 
			
		||||
        if (plr == null) {
 | 
			
		||||
            if (args.length < 3) {
 | 
			
		||||
                return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
 | 
			
		||||
    public boolean onCommand(CommandCaller caller, String[] args) {
 | 
			
		||||
        if (args.length < 3) {
 | 
			
		||||
            return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
 | 
			
		||||
        }
 | 
			
		||||
        final String world = args[0];
 | 
			
		||||
        if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) {
 | 
			
		||||
            return !MainUtil.sendMessage(null, "&cInvalid plot world!");
 | 
			
		||||
        }
 | 
			
		||||
        PlotId min, max;
 | 
			
		||||
        try {
 | 
			
		||||
            final String[] split1 = args[1].split(";");
 | 
			
		||||
            final String[] split2 = args[2].split(";");
 | 
			
		||||
            min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1]));
 | 
			
		||||
            max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1]));
 | 
			
		||||
        } catch (final Exception e) {
 | 
			
		||||
            return !MainUtil.sendMessage(null, "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X,Y are the plot coords\nThe conversion will only check the plots in the selected area.");
 | 
			
		||||
        }
 | 
			
		||||
        MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
 | 
			
		||||
        MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
 | 
			
		||||
        final PlotManager manager = PS.get().getPlotManager(world);
 | 
			
		||||
        final PlotWorld plotworld = PS.get().getPlotWorld(world);
 | 
			
		||||
        final ArrayList<Plot> plots = new ArrayList<>();
 | 
			
		||||
        for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
 | 
			
		||||
            final Plot plot = MainUtil.getPlot(world, id);
 | 
			
		||||
            final boolean contains = PS.get().getPlots(world).containsKey(plot.id);
 | 
			
		||||
            if (contains) {
 | 
			
		||||
                MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final String world = args[0];
 | 
			
		||||
            if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) {
 | 
			
		||||
                return !MainUtil.sendMessage(null, "&cInvalid plot world!");
 | 
			
		||||
            final Location loc = manager.getSignLoc(plotworld, plot);
 | 
			
		||||
            final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
 | 
			
		||||
            final boolean result = ChunkManager.manager.loadChunk(world, chunk);
 | 
			
		||||
            if (!result) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            PlotId min, max;
 | 
			
		||||
            try {
 | 
			
		||||
                final String[] split1 = args[1].split(";");
 | 
			
		||||
                final String[] split2 = args[2].split(";");
 | 
			
		||||
                min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1]));
 | 
			
		||||
                max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1]));
 | 
			
		||||
            } catch (final Exception e) {
 | 
			
		||||
                return !MainUtil.sendMessage(null, "&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X,Y are the plot coords\nThe conversion will only check the plots in the selected area.");
 | 
			
		||||
            }
 | 
			
		||||
            MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
 | 
			
		||||
            MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
 | 
			
		||||
            final PlotManager manager = PS.get().getPlotManager(world);
 | 
			
		||||
            final PlotWorld plotworld = PS.get().getPlotWorld(world);
 | 
			
		||||
            final ArrayList<Plot> plots = new ArrayList<>();
 | 
			
		||||
            for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
 | 
			
		||||
                final Plot plot = MainUtil.getPlot(world, id);
 | 
			
		||||
                final boolean contains = PS.get().getPlots(world).containsKey(plot.id);
 | 
			
		||||
                if (contains) {
 | 
			
		||||
                    MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                final Location loc = manager.getSignLoc(plotworld, plot);
 | 
			
		||||
                final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
 | 
			
		||||
                final boolean result = ChunkManager.manager.loadChunk(world, chunk);
 | 
			
		||||
                if (!result) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                final String[] lines = BlockManager.manager.getSign(loc);
 | 
			
		||||
                if (lines != null) {
 | 
			
		||||
                    String line = lines[2];
 | 
			
		||||
                    if ((line != null) && (line.length() > 2)) {
 | 
			
		||||
                        line = line.substring(2);
 | 
			
		||||
                        final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
 | 
			
		||||
                        UUID uuid = (map.get(new StringWrapper(line)));
 | 
			
		||||
                        if (uuid == null) {
 | 
			
		||||
                            for (final StringWrapper string : map.keySet()) {
 | 
			
		||||
                                if (string.value.toLowerCase().startsWith(line.toLowerCase())) {
 | 
			
		||||
                                    uuid = map.get(string);
 | 
			
		||||
                                    break;
 | 
			
		||||
                                }
 | 
			
		||||
            final String[] lines = BlockManager.manager.getSign(loc);
 | 
			
		||||
            if (lines != null) {
 | 
			
		||||
                String line = lines[2];
 | 
			
		||||
                if ((line != null) && (line.length() > 2)) {
 | 
			
		||||
                    line = line.substring(2);
 | 
			
		||||
                    final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
 | 
			
		||||
                    UUID uuid = (map.get(new StringWrapper(line)));
 | 
			
		||||
                    if (uuid == null) {
 | 
			
		||||
                        for (final StringWrapper string : map.keySet()) {
 | 
			
		||||
                            if (string.value.toLowerCase().startsWith(line.toLowerCase())) {
 | 
			
		||||
                                uuid = map.get(string);
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        if (uuid == null) {
 | 
			
		||||
                            uuid = UUIDHandler.getUUID(line);
 | 
			
		||||
                        }
 | 
			
		||||
                        if (uuid != null) {
 | 
			
		||||
                            MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line);
 | 
			
		||||
                            plot.owner = uuid;
 | 
			
		||||
                            plots.add(plot);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            MainUtil.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    if (uuid == null) {
 | 
			
		||||
                        uuid = UUIDHandler.getUUID(line);
 | 
			
		||||
                    }
 | 
			
		||||
                    if (uuid != null) {
 | 
			
		||||
                        MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line);
 | 
			
		||||
                        plot.owner = uuid;
 | 
			
		||||
                        plots.add(plot);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        MainUtil.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (plots.size() > 0) {
 | 
			
		||||
                MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
 | 
			
		||||
                DBFunc.createPlotsAndData(plots, new Runnable() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        MainUtil.sendMessage(null, "&6Database update finished!");
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
                for (final Plot plot : plots) {
 | 
			
		||||
                    PS.get().updatePlot(plot);
 | 
			
		||||
        }
 | 
			
		||||
        if (plots.size() > 0) {
 | 
			
		||||
            MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
 | 
			
		||||
            DBFunc.createPlotsAndData(plots, new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    MainUtil.sendMessage(null, "&6Database update finished!");
 | 
			
		||||
                }
 | 
			
		||||
                MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
 | 
			
		||||
            } else {
 | 
			
		||||
                MainUtil.sendMessage(null, "No plots were found for the given search.");
 | 
			
		||||
            });
 | 
			
		||||
            for (final Plot plot : plots) {
 | 
			
		||||
                PS.get().updatePlot(plot);
 | 
			
		||||
            }
 | 
			
		||||
            MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
 | 
			
		||||
        } else {
 | 
			
		||||
            MainUtil.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused.");
 | 
			
		||||
            MainUtil.sendMessage(null, "No plots were found for the given search.");
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
@@ -30,15 +31,21 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChunkManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
import com.plotsquared.bukkit.util.bukkit.UUIDHandler;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import com.plotsquared.bukkit.util.UUIDHandler;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debugclear",
 | 
			
		||||
        aliases = {"fastclear"},
 | 
			
		||||
        description = "Clear a plot using a fast experiment algorithm",
 | 
			
		||||
        category = CommandCategory.DEBUG
 | 
			
		||||
)
 | 
			
		||||
public class DebugClear extends SubCommand {
 | 
			
		||||
    public DebugClear() {
 | 
			
		||||
        super(Command.DEBUGCLEAR, "Clear a plot using a fast experimental algorithm", "debugclear", CommandCategory.DEBUG, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, final String... args) {
 | 
			
		||||
    public boolean onCommand(CommandCaller caller, String[] args) {
 | 
			
		||||
        final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
 | 
			
		||||
        if (plr == null) {
 | 
			
		||||
            // Is console
 | 
			
		||||
            if (args.length < 2) {
 | 
			
		||||
@@ -85,10 +92,9 @@ public class DebugClear extends SubCommand {
 | 
			
		||||
        if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
 | 
			
		||||
            return sendMessage(plr, C.UNLINK_REQUIRED);
 | 
			
		||||
        }
 | 
			
		||||
        if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) {
 | 
			
		||||
        if ((!plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) {
 | 
			
		||||
            return sendMessage(plr, C.NO_PLOT_PERMS);
 | 
			
		||||
        }
 | 
			
		||||
        assert plot != null;
 | 
			
		||||
        final Location pos1 = MainUtil.getPlotBottomLoc(loc.getWorld(), plot.id).add(1, 0, 1);
 | 
			
		||||
        final Location pos2 = MainUtil.getPlotTopLoc(loc.getWorld(), plot.id);
 | 
			
		||||
        if (MainUtil.runners.containsKey(plot)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,10 @@ import java.util.Date;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import com.plotsquared.bukkit.util.UUIDHandler;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
 | 
			
		||||
@@ -48,15 +52,19 @@ import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ChunkManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.ExpireManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.plotsquared.bukkit.util.bukkit.UUIDHandler;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debugexec",
 | 
			
		||||
        permission = "plots.admin",
 | 
			
		||||
        description = "Mutli-purpose debug command",
 | 
			
		||||
        aliases = {"exec"},
 | 
			
		||||
        category = CommandCategory.DEBUG
 | 
			
		||||
)
 | 
			
		||||
public class DebugExec extends SubCommand {
 | 
			
		||||
    public DebugExec() {
 | 
			
		||||
        super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer player, final String... args) {
 | 
			
		||||
    public boolean onCommand(CommandCaller caller, String[] args) {
 | 
			
		||||
        final PlotPlayer player = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
 | 
			
		||||
        final List<String> allowed_params = Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check");
 | 
			
		||||
        if (args.length > 0) {
 | 
			
		||||
            final String arg = args[0].toLowerCase();
 | 
			
		||||
 
 | 
			
		||||
@@ -29,12 +29,19 @@ import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
 | 
			
		||||
import com.intellectualcrafters.plot.util.TaskManager;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "fill",
 | 
			
		||||
        permission = "plots.fill",
 | 
			
		||||
        description = "Fill or surround a plot in bedrock",
 | 
			
		||||
        usage = "/plot fill",
 | 
			
		||||
        aliases = {"debugfill"},
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        requiredType = PlotPlayer.class
 | 
			
		||||
)
 | 
			
		||||
public class DebugFill extends SubCommand {
 | 
			
		||||
    public DebugFill() {
 | 
			
		||||
        super("fill", "plots.fill", "Fill or surround a plot in bedrock", "fill", "debugfill", CommandCategory.DEBUG, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final CommandCaller caller, final String ... args) {
 | 
			
		||||
@@ -48,7 +55,7 @@ public class DebugFill extends SubCommand {
 | 
			
		||||
        if (plot == null) {
 | 
			
		||||
            return !sendMessage(player, C.NOT_IN_PLOT);
 | 
			
		||||
        }
 | 
			
		||||
        if ((plot == null) || !plot.hasOwner()) {
 | 
			
		||||
        if (!plot.hasOwner()) {
 | 
			
		||||
            MainUtil.sendMessage(player, C.PLOT_UNOWNED);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -33,22 +33,29 @@ import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualsites.commands.Argument;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debugfixflags",
 | 
			
		||||
        usage = "/plot debugfixflags <world>",
 | 
			
		||||
        permission = "plots.debugfixflags",
 | 
			
		||||
        description = "Attempt to fix all flags for a world",
 | 
			
		||||
        requiredType = PS.class,
 | 
			
		||||
        category = CommandCategory.DEBUG
 | 
			
		||||
)
 | 
			
		||||
public class DebugFixFlags extends SubCommand {
 | 
			
		||||
 | 
			
		||||
    public DebugFixFlags() {
 | 
			
		||||
        super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false);
 | 
			
		||||
        requiredArguments = new Argument[] {
 | 
			
		||||
                Argument.String
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, final String... args) {
 | 
			
		||||
        if (plr != null) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_CONSOLE);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        if (args.length != 1) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot debugfixflags <world>");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    public boolean onCommand(CommandCaller caller, String[] args) {
 | 
			
		||||
        final PlotPlayer plr = null;
 | 
			
		||||
        final String world = args[0];
 | 
			
		||||
        if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) {
 | 
			
		||||
            MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]);
 | 
			
		||||
 
 | 
			
		||||
@@ -26,29 +26,29 @@ import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.database.DBFunc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Citymonstret
 | 
			
		||||
 */
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debugloadtest",
 | 
			
		||||
        permission = "plots.debugloadtest",
 | 
			
		||||
        description = "This debug command will force the reload of all plots in the DB",
 | 
			
		||||
        usage = "/plot debugloadtest",
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        requiredType = PS.class
 | 
			
		||||
)
 | 
			
		||||
public class DebugLoadTest extends SubCommand {
 | 
			
		||||
    public DebugLoadTest() {
 | 
			
		||||
        super(Command.DEBUGLOADTEST, "This debug command will force the reload of all plots in the DB", "debugloadtest", CommandCategory.DEBUG, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, final String... args) {
 | 
			
		||||
        if (plr == null) {
 | 
			
		||||
            try {
 | 
			
		||||
                final Field fPlots = PS.class.getDeclaredField("plots");
 | 
			
		||||
                fPlots.setAccessible(true);
 | 
			
		||||
                fPlots.set(null, DBFunc.getPlots());
 | 
			
		||||
            } catch (final Exception e) {
 | 
			
		||||
                PS.log("&3===FAILED&3===");
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                PS.log("&3===END OF STACKTRACE===");
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            MainUtil.sendMessage(plr, "&6This command can only be executed by console as it has been deemed unsafe if abused..");
 | 
			
		||||
    public boolean onCommand(CommandCaller caller, String[] args) {
 | 
			
		||||
        try {
 | 
			
		||||
            final Field fPlots = PS.class.getDeclaredField("plots");
 | 
			
		||||
            fPlots.setAccessible(true);
 | 
			
		||||
            fPlots.set(null, DBFunc.getPlots());
 | 
			
		||||
        } catch (final Exception e) {
 | 
			
		||||
            PS.log("&3===FAILED&3===");
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            PS.log("&3===END OF STACKTRACE===");
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,7 @@
 | 
			
		||||
package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import com.plotsquared.bukkit.BukkitMain;
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
@@ -13,14 +15,18 @@ import org.bukkit.plugin.Plugin;
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debugpaste",
 | 
			
		||||
        aliases = {"dp"},
 | 
			
		||||
        usage = "/plot debugpaste",
 | 
			
		||||
        description = "Upload settings.yml & latest.log to hastebin",
 | 
			
		||||
        permission = "plots.debugpaste",
 | 
			
		||||
        category = CommandCategory.DEBUG
 | 
			
		||||
)
 | 
			
		||||
public class DebugPaste extends SubCommand {
 | 
			
		||||
 | 
			
		||||
    public DebugPaste() {
 | 
			
		||||
        super(Command.DEBUG_PASTE, "Upload settings.yml & latest.log to hastebin", "", CommandCategory.DEBUG, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, String... args) {
 | 
			
		||||
    public boolean onCommand(final CommandCaller caller, String[] args) {
 | 
			
		||||
        TaskManager.runTaskAsync(new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
@@ -30,7 +36,7 @@ public class DebugPaste extends SubCommand {
 | 
			
		||||
                    try {
 | 
			
		||||
                        latestLOG = HastebinUtility.upload(new File(BukkitMain.THIS.getDirectory(), "../../logs/latest.log"));
 | 
			
		||||
                    } catch(final Exception e) {
 | 
			
		||||
                        plr.sendMessage("&clatest.log is too big to be pasted, will ignore");
 | 
			
		||||
                        caller.message("&clatest.log is too big to be pasted, will ignore");
 | 
			
		||||
                        latestLOG = "too big :(";
 | 
			
		||||
                    }
 | 
			
		||||
                    StringBuilder b = new StringBuilder();
 | 
			
		||||
@@ -59,7 +65,7 @@ public class DebugPaste extends SubCommand {
 | 
			
		||||
                    b.append("\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues");
 | 
			
		||||
 | 
			
		||||
                    String link = HastebinUtility.upload(b.toString());
 | 
			
		||||
                    MainUtil.sendMessage(plr, C.DEBUG_REPORT_CREATED.s().replace("%url%", link));
 | 
			
		||||
                    caller.message(C.DEBUG_REPORT_CREATED.s().replace("%url%", link));
 | 
			
		||||
                } catch (IOException e) {
 | 
			
		||||
                    e.printStackTrace();
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -28,12 +28,18 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Location;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debugroadregen",
 | 
			
		||||
        usage = "/plot debugroadregen",
 | 
			
		||||
        requiredType = PlotPlayer.class,
 | 
			
		||||
        description = "Regenerate all roads based on the road schematic",
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        permission = "plots.debugroadregen"
 | 
			
		||||
)
 | 
			
		||||
public class DebugRoadRegen extends SubCommand {
 | 
			
		||||
    public DebugRoadRegen() {
 | 
			
		||||
        super(Command.DEBUGROADREGEN, "Regenerate all road schematic in your current chunk", "debugroadregen", CommandCategory.DEBUG, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCommand(final CommandCaller caller, final String ... args) {
 | 
			
		||||
 
 | 
			
		||||
@@ -27,30 +27,30 @@ import com.intellectualcrafters.plot.database.DBFunc;
 | 
			
		||||
import com.intellectualcrafters.plot.object.Plot;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Citymonstret
 | 
			
		||||
 */
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "debugsavetest",
 | 
			
		||||
        permission = "plots.debugsavetest",
 | 
			
		||||
        category = CommandCategory.DEBUG,
 | 
			
		||||
        requiredType = PS.class,
 | 
			
		||||
        usage = "/plot debugsavetest",
 | 
			
		||||
        description = "This command will force the recreation of all plots in the DB"
 | 
			
		||||
)
 | 
			
		||||
public class DebugSaveTest extends SubCommand {
 | 
			
		||||
    public DebugSaveTest() {
 | 
			
		||||
        super(Command.DEBUGSAVETEST, "This debug command will force the recreation of all plots in the DB", "debugsavetest", CommandCategory.DEBUG, false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean execute(final PlotPlayer plr, final String... args) {
 | 
			
		||||
        if (plr == null) {
 | 
			
		||||
            final ArrayList<Plot> plots = new ArrayList<Plot>();
 | 
			
		||||
            plots.addAll(PS.get().getPlots());
 | 
			
		||||
            MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`");
 | 
			
		||||
            DBFunc.createPlotsAndData(plots, new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    MainUtil.sendMessage(null, "&6Database sync finished!");
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        } else {
 | 
			
		||||
            MainUtil.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused");
 | 
			
		||||
        }
 | 
			
		||||
    public boolean onCommand(CommandCaller caller, String[] args) {
 | 
			
		||||
        final ArrayList<Plot> plots = new ArrayList<Plot>();
 | 
			
		||||
        plots.addAll(PS.get().getPlots());
 | 
			
		||||
        MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`");
 | 
			
		||||
        DBFunc.createPlotsAndData(plots, new Runnable() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void run() {
 | 
			
		||||
                MainUtil.sendMessage(null, "&6Database sync finished!");
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.commands;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import org.bukkit.generator.ChunkGenerator;
 | 
			
		||||
 
 | 
			
		||||
@@ -22,13 +22,23 @@ package com.intellectualcrafters.plot.commands;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
import com.intellectualcrafters.plot.commands.callers.ConsoleCaller;
 | 
			
		||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
 | 
			
		||||
import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.StringComparison;
 | 
			
		||||
import com.intellectualsites.commands.Argument;
 | 
			
		||||
import com.intellectualsites.commands.Command;
 | 
			
		||||
import com.intellectualsites.commands.CommandHandlingOutput;
 | 
			
		||||
import com.intellectualsites.commands.CommandManager;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import com.intellectualsites.commands.util.StringUtil;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * PlotSquared command class
 | 
			
		||||
@@ -37,17 +47,55 @@ import com.intellectualsites.commands.CommandManager;
 | 
			
		||||
 */
 | 
			
		||||
public class MainCommand extends CommandManager {
 | 
			
		||||
 | 
			
		||||
    public static MainCommand instance = new MainCommand();
 | 
			
		||||
 | 
			
		||||
    private MainCommand() {
 | 
			
		||||
        super(null, new ArrayList<Command>());
 | 
			
		||||
        List<SubCommand> toAdd = Arrays.asList(
 | 
			
		||||
                new Buy(), new Save(), new Load(),
 | 
			
		||||
                new Template(), new Download(),
 | 
			
		||||
                new Update(), new Template(),
 | 
			
		||||
                new Setup(), new DebugUUID(),
 | 
			
		||||
                new DebugFill(), new DebugSaveTest(),
 | 
			
		||||
                new DebugLoadTest(), new CreateRoadSchematic(),
 | 
			
		||||
                new DebugAllowUnsafe(), new RegenAllRoads(),
 | 
			
		||||
                new DebugClear(), new Claim(),
 | 
			
		||||
                new Auto(), new Home(), new Visit(),
 | 
			
		||||
                new TP(), new Set(), new Toggle(),
 | 
			
		||||
                new Clear(), new Delete(), new SetOwner(),
 | 
			
		||||
                new Trust(), new Add(), new Deny(),
 | 
			
		||||
                new Untrust(), new Remove(), new Undeny(),
 | 
			
		||||
                new Info(), new list(), new Help(),
 | 
			
		||||
                new Debug(), new SchematicCmd(), new plugin(),
 | 
			
		||||
                new Purge(), new Reload(), new Merge(),
 | 
			
		||||
                new DebugPaste(), new Unlink(), new Kick(),
 | 
			
		||||
                new Rate(), new DebugClaimTest(), new Inbox(),
 | 
			
		||||
                new Comment(), new Database(), new Swap(),
 | 
			
		||||
                new MusicSubcommand(), new DebugRoadRegen(),
 | 
			
		||||
                new Trust(), new DebugExec(), new FlagCmd(),
 | 
			
		||||
                new Target(), new DebugFixFlags(), new Move(),
 | 
			
		||||
                new Condense(), new Condense(), new Copy(),
 | 
			
		||||
                new Chat());
 | 
			
		||||
        if (Settings.ENABLE_CLUSTERS) {
 | 
			
		||||
            toAdd.add(new Cluster());
 | 
			
		||||
        }
 | 
			
		||||
        for (final SubCommand cmd : toAdd) {
 | 
			
		||||
            if (!createCommand(cmd)) {
 | 
			
		||||
                PS.log("Failed to create command: " + cmd.getClass());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean no_permission(final PlotPlayer player, final String permission) {
 | 
			
		||||
        MainUtil.sendMessage(player, C.NO_PERMISSION, permission);
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static List<SubCommand> getCommands(final CommandCategory category, final PlotPlayer player) {
 | 
			
		||||
        final List<SubCommand> cmds = new ArrayList<>();
 | 
			
		||||
        for (final Command c : commands) {
 | 
			
		||||
            if (!c.requiredType )
 | 
			
		||||
            if (!c.isPlayer || (player != null)) {
 | 
			
		||||
                if ((c.category.equals(category)) && c.permission.hasPermission(player)) {
 | 
			
		||||
    public static List<Command> getCommands(final CommandCategory category, final PlotPlayer player) {
 | 
			
		||||
        final List<Command> cmds = new ArrayList<>();
 | 
			
		||||
        for (final Command c : instance.commands) {
 | 
			
		||||
            if (!c.getRequiredType().equals(PlotPlayer.class)) {
 | 
			
		||||
                if ((c.getCategory().equals(category)) && player.hasPermission(c.getPermission())) {
 | 
			
		||||
                    cmds.add(c);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -56,11 +104,11 @@ public class MainCommand extends CommandManager {
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static List<String> helpMenu(final PlotPlayer player, final CommandCategory category, int page) {
 | 
			
		||||
        List<SubCommand> commands;
 | 
			
		||||
        List<Command> commands;
 | 
			
		||||
        if (category != null) {
 | 
			
		||||
            commands = getCommands(category, player);
 | 
			
		||||
        } else {
 | 
			
		||||
            commands = subCommands;
 | 
			
		||||
            commands = instance.commands;
 | 
			
		||||
        }
 | 
			
		||||
        // final int totalPages = ((int) Math.ceil(12 * (commands.size()) /
 | 
			
		||||
        // 100));
 | 
			
		||||
@@ -77,18 +125,18 @@ public class MainCommand extends CommandManager {
 | 
			
		||||
        help.add(C.HELP_HEADER.s());
 | 
			
		||||
        // HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"),
 | 
			
		||||
        help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages)).replace("%dis%", "" + perPage).replace("%total%", "" + commands.size()));
 | 
			
		||||
        SubCommand cmd;
 | 
			
		||||
        Command cmd;
 | 
			
		||||
        final int start = page * perPage;
 | 
			
		||||
        for (int x = start; x < max; x++) {
 | 
			
		||||
            cmd = commands.get(x);
 | 
			
		||||
            String s = C.HELP_ITEM.s();
 | 
			
		||||
            if (cmd.alias.size() > 0) {
 | 
			
		||||
                s = s.replace("%alias%", cmd.alias.get(0));
 | 
			
		||||
            if (cmd.getAliases().length > 0) {
 | 
			
		||||
                s = s.replace("%alias%", cmd.getAliases()[0]);
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                s = s.replace("%alias%", "");
 | 
			
		||||
            }
 | 
			
		||||
            s = s.replace("%usage%", cmd.usage.contains("plot") ? cmd.usage : "/plot " + cmd.usage).replace("%cmd%", cmd.cmd).replace("%desc%", cmd.description).replace("[]", "");
 | 
			
		||||
            s = s.replace("%usage%", cmd.getUsage().contains("plot") ? cmd.getUsage() : "/plot " + cmd.getUsage()).replace("%cmd%", cmd.getCommand()).replace("%desc%", cmd.getDescription()).replace("[]", "");
 | 
			
		||||
            help.add(s);
 | 
			
		||||
        }
 | 
			
		||||
        if (help.size() < 2) {
 | 
			
		||||
@@ -151,32 +199,123 @@ public class MainCommand extends CommandManager {
 | 
			
		||||
            MainUtil.sendMessage(player, help.toString());
 | 
			
		||||
            // return PlayerFunctions.sendMessage(player, help.toString());
 | 
			
		||||
        } else {
 | 
			
		||||
            for (final SubCommand command : subCommands) {
 | 
			
		||||
                if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.contains(args[0].toLowerCase())) {
 | 
			
		||||
                    final String[] arguments = new String[args.length - 1];
 | 
			
		||||
                    System.arraycopy(args, 1, arguments, 0, args.length - 1);
 | 
			
		||||
                    if (command.permission.hasPermission(player)) {
 | 
			
		||||
                        if ((player != null) || !command.isPlayer) {
 | 
			
		||||
                            return command.execute(player, arguments);
 | 
			
		||||
                        } else {
 | 
			
		||||
                            return !MainUtil.sendMessage(null, C.IS_CONSOLE);
 | 
			
		||||
                        }
 | 
			
		||||
                    } else {
 | 
			
		||||
                        return no_permission(player, command.permission.permission.toLowerCase());
 | 
			
		||||
                    }
 | 
			
		||||
            CommandCaller caller;
 | 
			
		||||
            if (player != null) {
 | 
			
		||||
                caller = new PlotPlayerCaller(player);
 | 
			
		||||
            } else {
 | 
			
		||||
                caller = new ConsoleCaller();
 | 
			
		||||
            }
 | 
			
		||||
            StringBuilder builder = new StringBuilder(cmd).append(" ");
 | 
			
		||||
            Iterator<String> iterator = Arrays.asList(args).iterator();
 | 
			
		||||
            while (iterator.hasNext()) {
 | 
			
		||||
                builder.append(iterator.next());
 | 
			
		||||
                if (iterator.hasNext()) {
 | 
			
		||||
                    builder.append(" ");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
 | 
			
		||||
            final String[] commands = new String[subCommands.size()];
 | 
			
		||||
            for (int x = 0; x < subCommands.size(); x++) {
 | 
			
		||||
                commands[x] = subCommands.get(x).cmd;
 | 
			
		||||
            }
 | 
			
		||||
            /* Let's try to get a proper usage string */
 | 
			
		||||
            final String command = new StringComparison(args[0], commands).getBestMatch();
 | 
			
		||||
            return MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command);
 | 
			
		||||
            instance.handle(caller, builder.toString());
 | 
			
		||||
            // for (final SubCommand command : subCommands) {
 | 
			
		||||
            //    if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.contains(args[0].toLowerCase())) {
 | 
			
		||||
            //        final String[] arguments = new String[args.length - 1];
 | 
			
		||||
            //        System.arraycopy(args, 1, arguments, 0, args.length - 1);
 | 
			
		||||
            //        if (command.permission.hasPermissipon(player)) {
 | 
			
		||||
            //            if ((player != null) || !command.isPlayer) {
 | 
			
		||||
            //                return command.execute(player, arguments);
 | 
			
		||||
            //            } else {
 | 
			
		||||
            //                return !MainUtil.sendMessage(null, C.IS_CONSOLE);
 | 
			
		||||
            //            }
 | 
			
		||||
            //        } else {
 | 
			
		||||
            //            return no_permission(player, command.permission.permission.toLowerCase());
 | 
			
		||||
            //        }
 | 
			
		||||
            //    }
 | 
			
		||||
            // }
 | 
			
		||||
            // MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
 | 
			
		||||
            // final String[] commands = new String[subCommands.size()];
 | 
			
		||||
            // for (int x = 0; x < subCommands.size(); x++) {
 | 
			
		||||
            //    commands[x] = subCommands.get(x).cmd;
 | 
			
		||||
            // }
 | 
			
		||||
            // /* Let's try to get a proper usage string */
 | 
			
		||||
            // final String command = new StringComparison(args[0], commands).getBestMatch();
 | 
			
		||||
            // return MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command);
 | 
			
		||||
            // PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new
 | 
			
		||||
            // StringComparsion(args[0], commands).getBestMatch());
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int handle(CommandCaller caller, String input) {
 | 
			
		||||
        String[] parts = input.split(" ");
 | 
			
		||||
        String[] args;
 | 
			
		||||
        String command = parts[0];
 | 
			
		||||
        if (parts.length == 1) {
 | 
			
		||||
            args = new String[0];
 | 
			
		||||
        } else {
 | 
			
		||||
            args = new String[parts.length - 1];
 | 
			
		||||
            System.arraycopy(parts, 1, args, 0, args.length);
 | 
			
		||||
        }
 | 
			
		||||
        Command cmd = null;
 | 
			
		||||
        for (Command c1 : this.commands) {
 | 
			
		||||
            if (c1.getCommand().equalsIgnoreCase(command) || StringUtil.inArray(command, c1.getAliases(), false)) {
 | 
			
		||||
                cmd = c1;
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (cmd == null) {
 | 
			
		||||
            caller.message(C.NOT_VALID_SUBCOMMAND);
 | 
			
		||||
            {
 | 
			
		||||
                final String[] commands = new String[this.commands.size()];
 | 
			
		||||
                for (int i = 0; i < commands.length; i++) {
 | 
			
		||||
                    commands[i] = this.commands.get(i).getCommand();
 | 
			
		||||
                }
 | 
			
		||||
                final String bestMatch = new StringComparison(args[0], commands).getBestMatch();
 | 
			
		||||
                caller.message(C.DID_YOU_MEAN, "/plot " + bestMatch);
 | 
			
		||||
            }
 | 
			
		||||
            return CommandHandlingOutput.NOT_FOUND;
 | 
			
		||||
        }
 | 
			
		||||
        if (!cmd.getRequiredType().isInstance(caller.getSuperCaller())) {
 | 
			
		||||
            if (caller instanceof PlotPlayerCaller) {
 | 
			
		||||
                caller.message(C.NOT_CONSOLE);
 | 
			
		||||
            } else {
 | 
			
		||||
                caller.message(C.IS_CONSOLE);
 | 
			
		||||
                return CommandHandlingOutput.CALLER_OF_WRONG_TYPE;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if (!caller.hasPermission(cmd.getPermission())) {
 | 
			
		||||
            caller.message(C.NO_PERMISSION, cmd.getPermission());
 | 
			
		||||
            return CommandHandlingOutput.NOT_PERMITTED;
 | 
			
		||||
        }
 | 
			
		||||
        Argument[] requiredArguments = cmd.getRequiredArguments();
 | 
			
		||||
        if (requiredArguments != null && requiredArguments.length > 0) {
 | 
			
		||||
            boolean success = true;
 | 
			
		||||
            if (args.length < requiredArguments.length) {
 | 
			
		||||
                success = false;
 | 
			
		||||
            } else {
 | 
			
		||||
                for (int i = 0; i < requiredArguments.length; i++) {
 | 
			
		||||
                    if (requiredArguments[i].parse(args[i]) == null) {
 | 
			
		||||
                        success = false;
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if (!success) {
 | 
			
		||||
                caller.sendRequiredArgumentsList(this, cmd, requiredArguments);
 | 
			
		||||
                return CommandHandlingOutput.WRONG_USAGE;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        try {
 | 
			
		||||
            boolean a = cmd.onCommand(caller, args);
 | 
			
		||||
            if (!a) {
 | 
			
		||||
                String usage = cmd.getUsage();
 | 
			
		||||
                if (usage != null && !usage.isEmpty()) {
 | 
			
		||||
                    caller.message(usage);
 | 
			
		||||
                }
 | 
			
		||||
                return CommandHandlingOutput.WRONG_USAGE;
 | 
			
		||||
            }
 | 
			
		||||
        } catch (final Throwable t) {
 | 
			
		||||
            t.printStackTrace();
 | 
			
		||||
            return CommandHandlingOutput.ERROR;
 | 
			
		||||
        }
 | 
			
		||||
        return CommandHandlingOutput.SUCCESS;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ import java.util.UUID;
 | 
			
		||||
import com.intellectualsites.commands.Argument;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import com.plotsquared.bukkit.util.UUIDHandler;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.PS;
 | 
			
		||||
@@ -41,7 +42,6 @@ import com.intellectualcrafters.plot.util.EconHandler;
 | 
			
		||||
import com.intellectualcrafters.plot.util.EventUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.MainUtil;
 | 
			
		||||
import com.intellectualcrafters.plot.util.Permissions;
 | 
			
		||||
import com.plotsquared.bukkit.util.bukkit.UUIDHandler;
 | 
			
		||||
 | 
			
		||||
@CommandDeclaration(
 | 
			
		||||
        command = "merge",
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ import java.util.List;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
 | 
			
		||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
 | 
			
		||||
import com.intellectualsites.commands.CommandDeclaration;
 | 
			
		||||
import com.intellectualsites.commands.callers.CommandCaller;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
@@ -35,7 +36,7 @@ import com.intellectualcrafters.plot.config.C;
 | 
			
		||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
 | 
			
		||||
import com.intellectualcrafters.plot.config.Settings;
 | 
			
		||||
import com.plotsquared.bukkit.generator.HybridGen;
 | 
			
		||||
import com.plotsquared.bukkit.object.PlotGenerator;
 | 
			
		||||
 | 
			
		||||
import com.intellectualcrafters.plot.object.PlotPlayer;
 | 
			
		||||
import com.intellectualcrafters.plot.object.SetupObject;
 | 
			
		||||
import com.intellectualcrafters.plot.util.BlockManager;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user