mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
No more errors made my me, they're all yours :)
This commit is contained in:
parent
a41925117f
commit
6df9024ff1
@ -609,11 +609,14 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
|||||||
*
|
*
|
||||||
* @param c SubCommand, that we want to register
|
* @param c SubCommand, that we want to register
|
||||||
*
|
*
|
||||||
* @see com.intellectualcrafters.plot.commands.MainCommand#subCommands
|
|
||||||
* @see com.intellectualcrafters.plot.commands.SubCommand
|
* @see com.intellectualcrafters.plot.commands.SubCommand
|
||||||
*/
|
*/
|
||||||
public void registerCommand(final SubCommand c) {
|
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.Argument;
|
||||||
import com.intellectualsites.commands.CommandDeclaration;
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
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;
|
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
|
@ -27,6 +27,7 @@ import java.util.UUID;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
import com.intellectualsites.commands.CommandDeclaration;
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
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 java.util.Arrays;
|
||||||
|
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
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.object.comment.PlotComment;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
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 class Comment extends SubCommand {
|
||||||
public Comment() {
|
|
||||||
super(Command.COMMENT, "Comment on a plot", "comment", CommandCategory.ACTIONS, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (args.length < 2) {
|
||||||
sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|"));
|
sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|"));
|
||||||
return false;
|
return false;
|
||||||
|
@ -26,6 +26,8 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
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.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
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 class Condense extends SubCommand {
|
||||||
public static boolean TASK = false;
|
|
||||||
|
|
||||||
public Condense() {
|
public static boolean TASK = false;
|
||||||
super("condense", "plots.admin", "Condense a plotworld", "condense", "", CommandCategory.DEBUG, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendMessage(final String message) {
|
public static void sendMessage(final String message) {
|
||||||
PS.log("&3PlotSquared -> Plot condense&8: &7" + message);
|
PS.log("&3PlotSquared -> Plot condense&8: &7" + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean onCommand(final CommandCaller caller, String ... args) {
|
||||||
if (plr != null) {
|
final PlotPlayer plr = null;
|
||||||
MainUtil.sendMessage(plr, (C.NOT_CONSOLE));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ((args.length != 2) && (args.length != 3)) {
|
if ((args.length != 2) && (args.length != 3)) {
|
||||||
MainUtil.sendMessage(plr, "/plot condense <world> <start|stop|info> [radius]");
|
MainUtil.sendMessage(plr, "/plot condense <world> <start|stop|info> [radius]");
|
||||||
return false;
|
return false;
|
||||||
|
@ -20,23 +20,27 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.CmdInstance;
|
import com.intellectualcrafters.plot.object.CmdInstance;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.CmdConfirm;
|
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
|
|
||||||
/**
|
@CommandDeclaration(
|
||||||
* @author Citymonstret
|
command = "confirm",
|
||||||
*/
|
permission = "plots.use",
|
||||||
|
description = "Confirm an action",
|
||||||
|
category = CommandCategory.ACTIONS
|
||||||
|
)
|
||||||
public class Confirm extends SubCommand {
|
public class Confirm extends SubCommand {
|
||||||
public Confirm() {
|
|
||||||
super("confirm", "plots.use", "Confirm an action", "confirm", "confirm", CommandCategory.ACTIONS, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||||
|
final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||||
CmdInstance command = CmdConfirm.getPending(plr);
|
CmdInstance command = CmdConfirm.getPending(plr);
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
MainUtil.sendMessage(plr, C.FAILED_CONFIRM);
|
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.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
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 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
|
@Override
|
||||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||||
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||||
import com.intellectualcrafters.plot.database.MySQL;
|
import com.intellectualcrafters.plot.database.MySQL;
|
||||||
import com.intellectualcrafters.plot.database.SQLManager;
|
import com.intellectualcrafters.plot.database.SQLManager;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
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.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
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;
|
||||||
|
|
||||||
/**
|
@CommandDeclaration(
|
||||||
* Created 2014-11-15 for PlotSquared
|
command = "database",
|
||||||
*
|
aliases = {"convert"},
|
||||||
* @author Citymonstret
|
category = CommandCategory.DEBUG,
|
||||||
*/
|
permission = "plots.database",
|
||||||
|
description = "Convert/Backup Storage",
|
||||||
|
usage = "/plots database <type> [details...]"
|
||||||
|
)
|
||||||
public class Database extends SubCommand {
|
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) {
|
private static boolean sendMessageU(final UUID uuid, final String msg) {
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
@ -70,7 +73,8 @@ public class Database extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (args.length < 1) {
|
||||||
return sendMessage(plr, "/plot database [sqlite/mysql]");
|
return sendMessage(plr, "/plot database [sqlite/mysql]");
|
||||||
}
|
}
|
||||||
|
@ -21,18 +21,26 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.Lag;
|
import com.intellectualcrafters.plot.util.Lag;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
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 class Debug extends SubCommand {
|
||||||
public Debug() {
|
|
||||||
super(Command.DEBUG, "Show debug information", "debug [msg]", CommandCategory.DEBUG, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@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")) {
|
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
|
||||||
final StringBuilder msg = new StringBuilder();
|
final StringBuilder msg = new StringBuilder();
|
||||||
for (final C c : C.values()) {
|
for (final C c : C.values()) {
|
||||||
|
@ -5,18 +5,24 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
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 class DebugAllowUnsafe extends SubCommand {
|
||||||
|
|
||||||
public static final List<UUID> unsafeAllowed = new ArrayList<>();
|
public static final List<UUID> unsafeAllowed = new ArrayList<>();
|
||||||
|
|
||||||
public DebugAllowUnsafe() {
|
|
||||||
super(Command.ALLOWUNSAFE, "Allow unsafe actions until toggled off", "allowunsafe", CommandCategory.DEBUG, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
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.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
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;
|
||||||
|
|
||||||
/**
|
@CommandDeclaration(
|
||||||
* @author Citymonstret
|
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 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) {
|
public static boolean claimPlot(final PlotPlayer player, final Plot plot, final boolean teleport) {
|
||||||
return claimPlot(player, plot, teleport, "");
|
return claimPlot(player, plot, teleport, "");
|
||||||
@ -67,87 +70,83 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||||
if (plr == null) {
|
if (args.length < 3) {
|
||||||
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}");
|
||||||
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];
|
final Location loc = manager.getSignLoc(plotworld, plot);
|
||||||
if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) {
|
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||||
return !MainUtil.sendMessage(null, "&cInvalid plot world!");
|
final boolean result = ChunkManager.manager.loadChunk(world, chunk);
|
||||||
|
if (!result) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
PlotId min, max;
|
final String[] lines = BlockManager.manager.getSign(loc);
|
||||||
try {
|
if (lines != null) {
|
||||||
final String[] split1 = args[1].split(";");
|
String line = lines[2];
|
||||||
final String[] split2 = args[2].split(";");
|
if ((line != null) && (line.length() > 2)) {
|
||||||
min = new PlotId(Integer.parseInt(split1[0]), Integer.parseInt(split1[1]));
|
line = line.substring(2);
|
||||||
max = new PlotId(Integer.parseInt(split2[0]), Integer.parseInt(split2[1]));
|
final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
||||||
} catch (final Exception e) {
|
UUID uuid = (map.get(new StringWrapper(line)));
|
||||||
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.");
|
if (uuid == null) {
|
||||||
}
|
for (final StringWrapper string : map.keySet()) {
|
||||||
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
|
if (string.value.toLowerCase().startsWith(line.toLowerCase())) {
|
||||||
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
|
uuid = map.get(string);
|
||||||
final PlotManager manager = PS.get().getPlotManager(world);
|
break;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (uuid == null) {
|
}
|
||||||
uuid = UUIDHandler.getUUID(line);
|
if (uuid == null) {
|
||||||
}
|
uuid = UUIDHandler.getUUID(line);
|
||||||
if (uuid != null) {
|
}
|
||||||
MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line);
|
if (uuid != null) {
|
||||||
plot.owner = uuid;
|
MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line);
|
||||||
plots.add(plot);
|
plot.owner = uuid;
|
||||||
} else {
|
plots.add(plot);
|
||||||
MainUtil.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line);
|
} 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!");
|
if (plots.size() > 0) {
|
||||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
|
||||||
@Override
|
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||||
public void run() {
|
@Override
|
||||||
MainUtil.sendMessage(null, "&6Database update finished!");
|
public void run() {
|
||||||
}
|
MainUtil.sendMessage(null, "&6Database update finished!");
|
||||||
});
|
|
||||||
for (final Plot plot : plots) {
|
|
||||||
PS.get().updatePlot(plot);
|
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
});
|
||||||
} else {
|
for (final Plot plot : plots) {
|
||||||
MainUtil.sendMessage(null, "No plots were found for the given search.");
|
PS.get().updatePlot(plot);
|
||||||
}
|
}
|
||||||
|
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
||||||
} else {
|
} 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
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.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
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 class DebugClear extends SubCommand {
|
||||||
public DebugClear() {
|
|
||||||
super(Command.DEBUGCLEAR, "Clear a plot using a fast experimental algorithm", "debugclear", CommandCategory.DEBUG, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@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) {
|
if (plr == null) {
|
||||||
// Is console
|
// Is console
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
@ -85,10 +92,9 @@ public class DebugClear extends SubCommand {
|
|||||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||||
return sendMessage(plr, C.UNLINK_REQUIRED);
|
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);
|
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 pos1 = MainUtil.getPlotBottomLoc(loc.getWorld(), plot.id).add(1, 0, 1);
|
||||||
final Location pos2 = MainUtil.getPlotTopLoc(loc.getWorld(), plot.id);
|
final Location pos2 = MainUtil.getPlotTopLoc(loc.getWorld(), plot.id);
|
||||||
if (MainUtil.runners.containsKey(plot)) {
|
if (MainUtil.runners.containsKey(plot)) {
|
||||||
|
@ -30,6 +30,10 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
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.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
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.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
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 class DebugExec extends SubCommand {
|
||||||
public DebugExec() {
|
|
||||||
super("debugexec", "plots.admin", "Multi-purpose debug command", "debugexec", "exec", CommandCategory.DEBUG, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@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");
|
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) {
|
if (args.length > 0) {
|
||||||
final String arg = args[0].toLowerCase();
|
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.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
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 class DebugFill extends SubCommand {
|
||||||
public DebugFill() {
|
|
||||||
super("fill", "plots.fill", "Fill or surround a plot in bedrock", "fill", "debugfill", CommandCategory.DEBUG, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||||
@ -48,7 +55,7 @@ public class DebugFill extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
if ((plot == null) || !plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -33,22 +33,29 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
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 class DebugFixFlags extends SubCommand {
|
||||||
|
|
||||||
public DebugFixFlags() {
|
public DebugFixFlags() {
|
||||||
super(Command.DEBUGFIXFLAGS, "Attempt to fix all flags for a world", "debugclear", CommandCategory.DEBUG, false);
|
requiredArguments = new Argument[] {
|
||||||
|
Argument.String
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||||
if (plr != null) {
|
final PlotPlayer 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;
|
|
||||||
}
|
|
||||||
final String world = args[0];
|
final String world = args[0];
|
||||||
if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) {
|
if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]);
|
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.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
|
|
||||||
/**
|
@CommandDeclaration(
|
||||||
* @author Citymonstret
|
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 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
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||||
if (plr == null) {
|
try {
|
||||||
try {
|
final Field fPlots = PS.class.getDeclaredField("plots");
|
||||||
final Field fPlots = PS.class.getDeclaredField("plots");
|
fPlots.setAccessible(true);
|
||||||
fPlots.setAccessible(true);
|
fPlots.set(null, DBFunc.getPlots());
|
||||||
fPlots.set(null, DBFunc.getPlots());
|
} catch (final Exception e) {
|
||||||
} catch (final Exception e) {
|
PS.log("&3===FAILED&3===");
|
||||||
PS.log("&3===FAILED&3===");
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
PS.log("&3===END OF STACKTRACE===");
|
||||||
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..");
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
import com.plotsquared.bukkit.BukkitMain;
|
import com.plotsquared.bukkit.BukkitMain;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
@ -13,14 +15,18 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
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 class DebugPaste extends SubCommand {
|
||||||
|
|
||||||
public DebugPaste() {
|
|
||||||
super(Command.DEBUG_PASTE, "Upload settings.yml & latest.log to hastebin", "", CommandCategory.DEBUG, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, String... args) {
|
public boolean onCommand(final CommandCaller caller, String[] args) {
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -30,7 +36,7 @@ public class DebugPaste extends SubCommand {
|
|||||||
try {
|
try {
|
||||||
latestLOG = HastebinUtility.upload(new File(BukkitMain.THIS.getDirectory(), "../../logs/latest.log"));
|
latestLOG = HastebinUtility.upload(new File(BukkitMain.THIS.getDirectory(), "../../logs/latest.log"));
|
||||||
} catch(final Exception e) {
|
} 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 :(";
|
latestLOG = "too big :(";
|
||||||
}
|
}
|
||||||
StringBuilder b = new StringBuilder();
|
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");
|
b.append("\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues");
|
||||||
|
|
||||||
String link = HastebinUtility.upload(b.toString());
|
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) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,18 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
|
|||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
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 class DebugRoadRegen extends SubCommand {
|
||||||
public DebugRoadRegen() {
|
|
||||||
super(Command.DEBUGROADREGEN, "Regenerate all road schematic in your current chunk", "debugroadregen", CommandCategory.DEBUG, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
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.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
|
|
||||||
/**
|
@CommandDeclaration(
|
||||||
* @author Citymonstret
|
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 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
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||||
if (plr == null) {
|
final ArrayList<Plot> plots = new ArrayList<Plot>();
|
||||||
final ArrayList<Plot> plots = new ArrayList<Plot>();
|
plots.addAll(PS.get().getPlots());
|
||||||
plots.addAll(PS.get().getPlots());
|
MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`");
|
||||||
MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`");
|
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
MainUtil.sendMessage(null, "&6Database sync finished!");
|
||||||
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");
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||||
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
import com.intellectualsites.commands.CommandDeclaration;
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
@ -22,13 +22,23 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
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.C;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
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.CommandManager;
|
||||||
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
|
import com.intellectualsites.commands.util.StringUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotSquared command class
|
* PlotSquared command class
|
||||||
@ -37,17 +47,55 @@ import com.intellectualsites.commands.CommandManager;
|
|||||||
*/
|
*/
|
||||||
public class MainCommand extends 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) {
|
public static boolean no_permission(final PlotPlayer player, final String permission) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION, permission);
|
MainUtil.sendMessage(player, C.NO_PERMISSION, permission);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SubCommand> getCommands(final CommandCategory category, final PlotPlayer player) {
|
public static List<Command> getCommands(final CommandCategory category, final PlotPlayer player) {
|
||||||
final List<SubCommand> cmds = new ArrayList<>();
|
final List<Command> cmds = new ArrayList<>();
|
||||||
for (final Command c : commands) {
|
for (final Command c : instance.commands) {
|
||||||
if (!c.requiredType )
|
if (!c.getRequiredType().equals(PlotPlayer.class)) {
|
||||||
if (!c.isPlayer || (player != null)) {
|
if ((c.getCategory().equals(category)) && player.hasPermission(c.getPermission())) {
|
||||||
if ((c.category.equals(category)) && c.permission.hasPermission(player)) {
|
|
||||||
cmds.add(c);
|
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) {
|
public static List<String> helpMenu(final PlotPlayer player, final CommandCategory category, int page) {
|
||||||
List<SubCommand> commands;
|
List<Command> commands;
|
||||||
if (category != null) {
|
if (category != null) {
|
||||||
commands = getCommands(category, player);
|
commands = getCommands(category, player);
|
||||||
} else {
|
} else {
|
||||||
commands = subCommands;
|
commands = instance.commands;
|
||||||
}
|
}
|
||||||
// final int totalPages = ((int) Math.ceil(12 * (commands.size()) /
|
// final int totalPages = ((int) Math.ceil(12 * (commands.size()) /
|
||||||
// 100));
|
// 100));
|
||||||
@ -77,18 +125,18 @@ public class MainCommand extends CommandManager {
|
|||||||
help.add(C.HELP_HEADER.s());
|
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_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()));
|
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;
|
final int start = page * perPage;
|
||||||
for (int x = start; x < max; x++) {
|
for (int x = start; x < max; x++) {
|
||||||
cmd = commands.get(x);
|
cmd = commands.get(x);
|
||||||
String s = C.HELP_ITEM.s();
|
String s = C.HELP_ITEM.s();
|
||||||
if (cmd.alias.size() > 0) {
|
if (cmd.getAliases().length > 0) {
|
||||||
s = s.replace("%alias%", cmd.alias.get(0));
|
s = s.replace("%alias%", cmd.getAliases()[0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s = s.replace("%alias%", "");
|
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);
|
help.add(s);
|
||||||
}
|
}
|
||||||
if (help.size() < 2) {
|
if (help.size() < 2) {
|
||||||
@ -151,32 +199,123 @@ public class MainCommand extends CommandManager {
|
|||||||
MainUtil.sendMessage(player, help.toString());
|
MainUtil.sendMessage(player, help.toString());
|
||||||
// return PlayerFunctions.sendMessage(player, help.toString());
|
// return PlayerFunctions.sendMessage(player, help.toString());
|
||||||
} else {
|
} else {
|
||||||
for (final SubCommand command : subCommands) {
|
CommandCaller caller;
|
||||||
if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.contains(args[0].toLowerCase())) {
|
if (player != null) {
|
||||||
final String[] arguments = new String[args.length - 1];
|
caller = new PlotPlayerCaller(player);
|
||||||
System.arraycopy(args, 1, arguments, 0, args.length - 1);
|
} else {
|
||||||
if (command.permission.hasPermission(player)) {
|
caller = new ConsoleCaller();
|
||||||
if ((player != null) || !command.isPlayer) {
|
}
|
||||||
return command.execute(player, arguments);
|
StringBuilder builder = new StringBuilder(cmd).append(" ");
|
||||||
} else {
|
Iterator<String> iterator = Arrays.asList(args).iterator();
|
||||||
return !MainUtil.sendMessage(null, C.IS_CONSOLE);
|
while (iterator.hasNext()) {
|
||||||
}
|
builder.append(iterator.next());
|
||||||
} else {
|
if (iterator.hasNext()) {
|
||||||
return no_permission(player, command.permission.permission.toLowerCase());
|
builder.append(" ");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
instance.handle(caller, builder.toString());
|
||||||
final String[] commands = new String[subCommands.size()];
|
// for (final SubCommand command : subCommands) {
|
||||||
for (int x = 0; x < subCommands.size(); x++) {
|
// if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.contains(args[0].toLowerCase())) {
|
||||||
commands[x] = subCommands.get(x).cmd;
|
// final String[] arguments = new String[args.length - 1];
|
||||||
}
|
// System.arraycopy(args, 1, arguments, 0, args.length - 1);
|
||||||
/* Let's try to get a proper usage string */
|
// if (command.permission.hasPermissipon(player)) {
|
||||||
final String command = new StringComparison(args[0], commands).getBestMatch();
|
// if ((player != null) || !command.isPlayer) {
|
||||||
return MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command);
|
// 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
|
// PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new
|
||||||
// StringComparsion(args[0], commands).getBestMatch());
|
// StringComparsion(args[0], commands).getBestMatch());
|
||||||
}
|
}
|
||||||
return true;
|
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.Argument;
|
||||||
import com.intellectualsites.commands.CommandDeclaration;
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
|
import com.plotsquared.bukkit.util.UUIDHandler;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
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.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.plotsquared.bukkit.util.bukkit.UUIDHandler;
|
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "merge",
|
command = "merge",
|
||||||
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||||
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
import com.intellectualsites.commands.CommandDeclaration;
|
import com.intellectualsites.commands.CommandDeclaration;
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
import com.intellectualsites.commands.callers.CommandCaller;
|
||||||
import org.apache.commons.lang.StringUtils;
|
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.ConfigurationNode;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
import com.plotsquared.bukkit.generator.HybridGen;
|
||||||
import com.plotsquared.bukkit.object.PlotGenerator;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
public class CommandManager {
|
public class CommandManager {
|
||||||
|
|
||||||
protected final List<Command> commands;
|
protected final List<Command> commands;
|
||||||
private final Character initialCharacter;
|
protected final Character initialCharacter;
|
||||||
|
|
||||||
public CommandManager() {
|
public CommandManager() {
|
||||||
this('/', new ArrayList<Command>());
|
this('/', new ArrayList<Command>());
|
||||||
@ -44,7 +44,7 @@ public class CommandManager {
|
|||||||
return this.commands;
|
return this.commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public int handle(CommandCaller caller, String input) {
|
public int handle(CommandCaller caller, String input) {
|
||||||
if (initialCharacter != null && !StringUtil.startsWith(initialCharacter, input)) {
|
if (initialCharacter != null && !StringUtil.startsWith(initialCharacter, input)) {
|
||||||
return CommandHandlingOutput.NOT_COMMAND;
|
return CommandHandlingOutput.NOT_COMMAND;
|
||||||
}
|
}
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package com.intellectualsites.commands.callers;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
|
||||||
import com.intellectualsites.commands.Argument;
|
|
||||||
import com.intellectualsites.commands.Command;
|
|
||||||
import com.intellectualsites.commands.CommandManager;
|
|
||||||
|
|
||||||
public interface CommandCaller<T> {
|
|
||||||
|
|
||||||
boolean hasPermission(String permission);
|
|
||||||
|
|
||||||
void message(String message);
|
|
||||||
|
|
||||||
T getSuperCaller();
|
|
||||||
|
|
||||||
void message(C c, String ... args);
|
|
||||||
|
|
||||||
void sendRequiredArgumentsList(CommandManager manager, Command cmd, Argument[] required);
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package com.intellectualsites.commands.callers;
|
|
||||||
|
|
||||||
import com.intellectualsites.commands.Argument;
|
|
||||||
import com.intellectualsites.commands.Command;
|
|
||||||
import com.intellectualsites.commands.CommandManager;
|
|
||||||
|
|
||||||
public class SystemCaller implements CommandCaller {
|
|
||||||
|
|
||||||
public boolean hasPermission(String permission) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void message(String message) {
|
|
||||||
System.out.println(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getSuperCaller() {
|
|
||||||
return new Object();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendRequiredArgumentsList(CommandManager manager, Command cmd, Argument[] required) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append(manager.getInitialCharacter()).append(cmd.getCommand()).append(" requires ");
|
|
||||||
for (Argument argument : required) {
|
|
||||||
builder.append(argument.getName()).append(" (").append(argument.getExample()).append("), ");
|
|
||||||
}
|
|
||||||
message(builder.substring(0, builder.length() - 2));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package com.intellectualsites.commands.test;
|
|
||||||
|
|
||||||
import com.intellectualsites.commands.*;
|
|
||||||
import com.intellectualsites.commands.callers.CommandCaller;
|
|
||||||
import com.intellectualsites.commands.callers.SystemCaller;
|
|
||||||
|
|
||||||
public class CommandTest {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
CommandCaller caller = new SystemCaller();
|
|
||||||
CommandManager manager = new CommandManager();
|
|
||||||
if(!manager.createCommand(new TestCommand())) {
|
|
||||||
System.out.println("Failed to create command :(");
|
|
||||||
}
|
|
||||||
manager.handle(caller, "/test banana cow grass");
|
|
||||||
}
|
|
||||||
|
|
||||||
@CommandDeclaration(command = "test", usage = "/test [word]")
|
|
||||||
public static class TestCommand extends Command {
|
|
||||||
TestCommand() {
|
|
||||||
requiredArguments = new Argument[] {
|
|
||||||
Argument.String, Argument.String, Argument.String
|
|
||||||
};
|
|
||||||
addCommand(new Command("banana", new String[0]) {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandCaller caller, String[] arguments) {
|
|
||||||
if (getCommands().isEmpty()) {
|
|
||||||
addCommand(new Command("cow") {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandCaller caller, String[] arguments) {
|
|
||||||
caller.message("I eat " + arguments[0]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
handle(caller, arguments);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandCaller caller, String[] arguments) {
|
|
||||||
handle(caller, arguments);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,14 +5,13 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.commands.*;
|
import com.intellectualcrafters.plot.commands.*;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
|
import com.plotsquared.bukkit.commands.BukkitCommand;
|
||||||
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
|
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
|
||||||
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
||||||
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
||||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
|
||||||
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
import com.plotsquared.bukkit.generator.HybridGen;
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.plotsquared.bukkit.listeners.*;
|
import com.plotsquared.bukkit.listeners.*;
|
||||||
@ -153,74 +152,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
new MainCommand();
|
|
||||||
MainCommand.subCommands.add(new Buy());
|
|
||||||
MainCommand.subCommands.add(new Save());
|
|
||||||
MainCommand.subCommands.add(new Load());
|
|
||||||
MainCommand.subCommands.add(new Download());
|
|
||||||
MainCommand.subCommands.add(new Disable());
|
|
||||||
MainCommand.subCommands.add(new Update());
|
|
||||||
MainCommand.subCommands.add(new Template());
|
|
||||||
MainCommand.subCommands.add(new Setup());
|
|
||||||
MainCommand.subCommands.add(new DebugUUID());
|
|
||||||
MainCommand.subCommands.add(new DebugFill());
|
|
||||||
MainCommand.subCommands.add(new DebugSaveTest());
|
|
||||||
MainCommand.subCommands.add(new DebugLoadTest());
|
|
||||||
MainCommand.subCommands.add(new CreateRoadSchematic());
|
|
||||||
MainCommand.subCommands.add(new DebugAllowUnsafe());
|
|
||||||
MainCommand.subCommands.add(new RegenAllRoads());
|
|
||||||
MainCommand.subCommands.add(new DebugClear());
|
|
||||||
MainCommand.subCommands.add(new Claim());
|
|
||||||
MainCommand.subCommands.add(new Auto());
|
|
||||||
MainCommand.subCommands.add(new Home());
|
|
||||||
MainCommand.subCommands.add(new Visit());
|
|
||||||
MainCommand.subCommands.add(new TP());
|
|
||||||
MainCommand.subCommands.add(new Set());
|
|
||||||
MainCommand.subCommands.add(new Toggle());
|
|
||||||
MainCommand.subCommands.add(new Clear());
|
|
||||||
MainCommand.subCommands.add(new Delete());
|
|
||||||
MainCommand.subCommands.add(new SetOwner());
|
|
||||||
if (Settings.ENABLE_CLUSTERS) {
|
|
||||||
MainCommand.subCommands.add(new Cluster());
|
|
||||||
}
|
|
||||||
MainCommand.subCommands.add(new Trust());
|
|
||||||
MainCommand.subCommands.add(new Add());
|
|
||||||
MainCommand.subCommands.add(new Deny());
|
|
||||||
MainCommand.subCommands.add(new Untrust());
|
|
||||||
MainCommand.subCommands.add(new Remove());
|
|
||||||
MainCommand.subCommands.add(new Undeny());
|
|
||||||
MainCommand.subCommands.add(new Info());
|
|
||||||
MainCommand.subCommands.add(new list());
|
|
||||||
MainCommand.subCommands.add(new Help());
|
|
||||||
MainCommand.subCommands.add(new Debug());
|
|
||||||
MainCommand.subCommands.add(new SchematicCmd());
|
|
||||||
MainCommand.subCommands.add(new plugin());
|
|
||||||
MainCommand.subCommands.add(new Inventory());
|
|
||||||
MainCommand.subCommands.add(new Purge());
|
|
||||||
MainCommand.subCommands.add(new Reload());
|
|
||||||
MainCommand.subCommands.add(new Merge());
|
|
||||||
MainCommand.subCommands.add(new DebugPaste());
|
|
||||||
MainCommand.subCommands.add(new Unlink());
|
|
||||||
MainCommand.subCommands.add(new Kick());
|
|
||||||
MainCommand.subCommands.add(new Rate());
|
|
||||||
MainCommand.subCommands.add(new DebugClaimTest());
|
|
||||||
MainCommand.subCommands.add(new Inbox());
|
|
||||||
MainCommand.subCommands.add(new Comment());
|
|
||||||
MainCommand.subCommands.add(new Database());
|
|
||||||
MainCommand.subCommands.add(new Unclaim());
|
|
||||||
MainCommand.subCommands.add(new Swap());
|
|
||||||
MainCommand.subCommands.add(new MusicSubcommand());
|
|
||||||
MainCommand.subCommands.add(new DebugRoadRegen());
|
|
||||||
MainCommand.subCommands.add(new Trim());
|
|
||||||
MainCommand.subCommands.add(new DebugExec());
|
|
||||||
MainCommand.subCommands.add(new FlagCmd());
|
|
||||||
MainCommand.subCommands.add(new Target());
|
|
||||||
MainCommand.subCommands.add(new DebugFixFlags());
|
|
||||||
MainCommand.subCommands.add(new Move());
|
|
||||||
MainCommand.subCommands.add(new Condense());
|
|
||||||
MainCommand.subCommands.add(new Confirm());
|
|
||||||
MainCommand.subCommands.add(new Copy());
|
|
||||||
MainCommand.subCommands.add(new Chat());
|
|
||||||
final BukkitCommand bcmd = new BukkitCommand();
|
final BukkitCommand bcmd = new BukkitCommand();
|
||||||
final PluginCommand plotCommand = getCommand("plots");
|
final PluginCommand plotCommand = getCommand("plots");
|
||||||
plotCommand.setExecutor(bcmd);
|
plotCommand.setExecutor(bcmd);
|
||||||
@ -417,7 +348,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
} else {
|
} else {
|
||||||
getServer().getPluginManager().registerEvents(new WEListener(), this);
|
getServer().getPluginManager().registerEvents(new WEListener(), this);
|
||||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
||||||
MainCommand.subCommands.add(new WE_Anywhere());
|
MainCommand.instance.createCommand(new WE_Anywhere());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.plotsquared.bukkit.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
|
import com.intellectualsites.commands.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
@ -22,7 +24,7 @@ import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
|||||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender commandSender, final Command command, final String commandLabel, final String[] args) {
|
public boolean onCommand(final CommandSender commandSender, final org.bukkit.command.Command command, final String commandLabel, final String[] args) {
|
||||||
if (commandSender instanceof Player) {
|
if (commandSender instanceof Player) {
|
||||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
|
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
|
||||||
}
|
}
|
||||||
@ -30,14 +32,14 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(final CommandSender commandSender, final Command command, final String s, final String[] strings) {
|
public List<String> onTabComplete(final CommandSender commandSender, final org.bukkit.command.Command command, final String s, final String[] strings) {
|
||||||
if (!(commandSender instanceof Player)) {
|
if (!(commandSender instanceof Player)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
||||||
if (strings.length < 1) {
|
if (strings.length < 1) {
|
||||||
if ((strings.length == 0) || "plots".startsWith(s)) {
|
if ((strings.length == 0) || "plots".startsWith(s)) {
|
||||||
return Arrays.asList("plots");
|
return Collections.singletonList("plots");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strings.length > 1) {
|
if (strings.length > 1) {
|
||||||
@ -47,20 +49,20 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final List<String> tabOptions = new ArrayList<>();
|
final List<String> tabOptions = new ArrayList<>();
|
||||||
final String[] commands = new String[MainCommand.subCommands.size()];
|
final String[] commands = new String[MainCommand.instance.getCommands().size()];
|
||||||
for (int x = 0; x < MainCommand.subCommands.size(); x++) {
|
for (int x = 0; x < MainCommand.instance.getCommands().size(); x++) {
|
||||||
commands[x] = MainCommand.subCommands.get(x).cmd;
|
commands[x] = MainCommand.instance.getCommands().get(x).getCommand();
|
||||||
}
|
}
|
||||||
String best = new StringComparison(strings[0], commands).getBestMatch();
|
String best = new StringComparison(strings[0], commands).getBestMatch();
|
||||||
tabOptions.add(best);
|
tabOptions.add(best);
|
||||||
final String arg = strings[0].toLowerCase();
|
final String arg = strings[0].toLowerCase();
|
||||||
for (final SubCommand cmd : MainCommand.subCommands) {
|
for (final Command cmd : MainCommand.instance.getCommands()) {
|
||||||
if (!cmd.cmd.equalsIgnoreCase(best)) {
|
if (!cmd.getCommand().equalsIgnoreCase(best)) {
|
||||||
if (cmd.permission.hasPermission(player)) {
|
if (player.hasPermission(cmd.getPermission())) {
|
||||||
if (cmd.cmd.startsWith(arg)) {
|
if (cmd.getCommand().startsWith(arg)) {
|
||||||
tabOptions.add(cmd.cmd);
|
tabOptions.add(cmd.getCommand());
|
||||||
} else if (cmd.alias.size() > 0 && cmd.alias.get(0).startsWith(arg)) {
|
} else if (cmd.getAliases().length > 0 && cmd.getAliases()[0].startsWith(arg)) {
|
||||||
tabOptions.add(cmd.alias.get(0));
|
tabOptions.add(cmd.getAliases()[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user