mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Command changes
Legacy commands still need to be cleaned up (after which economy / confirmation can be centralized) All command names / usage / description is configurable Simplifies creating commands Deeper tab completion / command help
This commit is contained in:
parent
a62b9a334d
commit
8a42eecc11
@ -23,7 +23,6 @@ package com.intellectualcrafters.plot.api;
|
||||
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.commands.SubCommand;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||
@ -40,17 +39,16 @@ import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* PlotSquared API<br>
|
||||
@ -641,17 +639,13 @@ public class PlotAPI {
|
||||
|
||||
/**
|
||||
* Register a subcommand
|
||||
*
|
||||
* @deprecated Command registration is done on object creation
|
||||
* @param c SubCommand, that we want to register
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.commands.SubCommand
|
||||
*/
|
||||
@Deprecated
|
||||
public void registerCommand(SubCommand c) {
|
||||
if (c.getCommand() != null) {
|
||||
MainCommand.getInstance().addCommand(c);
|
||||
} else {
|
||||
MainCommand.getInstance().createCommand(c);
|
||||
}
|
||||
PS.debug("SubCommands are now registered on creation");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,6 @@ package com.plotsquared.bukkit;
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.IPlotMain;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -74,6 +73,12 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -88,13 +93,6 @@ import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
public static BukkitMain THIS;
|
||||
@ -173,7 +171,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
plotCommand.setExecutor(bcmd);
|
||||
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
||||
plotCommand.setTabCompleter(bcmd);
|
||||
MainCommand.getInstance().addCommand(new DebugUUID());
|
||||
new DebugUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -215,7 +213,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
case COMPLEX_PART:
|
||||
case FISHING_HOOK:
|
||||
case ENDER_SIGNAL:
|
||||
case LINGERING_POTION:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case EXPERIENCE_ORB:
|
||||
case LEASH_HITCH:
|
||||
|
@ -65,7 +65,7 @@ import java.util.UUID;
|
||||
public class DebugUUID extends SubCommand {
|
||||
|
||||
public DebugUUID() {
|
||||
this.requiredArguments = new Argument[]{Argument.String};
|
||||
super(Argument.String);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,36 +3,31 @@ package com.plotsquared.bukkit.util;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.plotsquared.bukkit.commands.DebugUUID;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
public BukkitCommand() {
|
||||
MainCommand.getInstance().addCommand(new DebugUUID());
|
||||
new DebugUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender commandSender, org.bukkit.command.Command command, final String commandLabel,
|
||||
String[] args) {
|
||||
if (commandSender instanceof Player) {
|
||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
|
||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
|
||||
}
|
||||
if (commandSender == null || commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
|
||||
return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
|
||||
return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
ConsolePlayer sender = new ConsolePlayer() {
|
||||
@ -55,49 +50,28 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
};
|
||||
sender.teleport(ConsolePlayer.getConsole().getLocationFull());
|
||||
boolean result = MainCommand.onCommand(sender, commandLabel, args);
|
||||
boolean result = MainCommand.onCommand(sender, args);
|
||||
ConsolePlayer.getConsole().teleport(sender.getLocationFull());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, org.bukkit.command.Command command, String s,
|
||||
String[] strings) {
|
||||
public List<String> onTabComplete(CommandSender commandSender, org.bukkit.command.Command command, String s, String[] args) {
|
||||
if (!(commandSender instanceof Player)) {
|
||||
return null;
|
||||
}
|
||||
PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
||||
if (strings.length < 1) {
|
||||
if (strings.length == 0 || "plots".startsWith(s)) {
|
||||
if (args.length == 0) {
|
||||
return Collections.singletonList("plots");
|
||||
}
|
||||
}
|
||||
if (strings.length > 1) {
|
||||
Collection objects = MainCommand.getInstance().tab(player, args, s.endsWith(" "));
|
||||
if (objects == null) {
|
||||
return null;
|
||||
}
|
||||
Set<String> tabOptions = new HashSet<>();
|
||||
String arg = strings[0].toLowerCase();
|
||||
ArrayList<String> labels = new ArrayList<>();
|
||||
for (Command<PlotPlayer> cmd : MainCommand.getInstance().getCommands()) {
|
||||
String label = cmd.getCommand();
|
||||
HashSet<String> aliases = new HashSet<>(cmd.getAliases());
|
||||
aliases.add(label);
|
||||
for (String alias : aliases) {
|
||||
labels.add(alias);
|
||||
if (alias.startsWith(arg)) {
|
||||
if (Permissions.hasPermission(player, cmd.getPermission())) {
|
||||
tabOptions.add(label);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String best = new StringComparison<>(arg, labels).getBestMatch();
|
||||
tabOptions.add(best);
|
||||
if (!tabOptions.isEmpty()) {
|
||||
return new ArrayList<>(tabOptions);
|
||||
}
|
||||
return null;
|
||||
List<String> result = new ArrayList<>();
|
||||
for (Object o : objects) {
|
||||
result.add(o.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.intellectualcrafters.plot;
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.MemorySection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
@ -54,7 +53,6 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.plotsquared.listener.WESubscriber;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -106,10 +104,12 @@ public class PS {
|
||||
// public:
|
||||
public File styleFile;
|
||||
public File configFile;
|
||||
public File commandsFile;
|
||||
public File translationFile;
|
||||
public YamlConfiguration style;
|
||||
public YamlConfiguration config;
|
||||
public YamlConfiguration storage;
|
||||
public YamlConfiguration commands;
|
||||
public IPlotMain IMP = null;
|
||||
public TaskManager TASK;
|
||||
public WorldEdit worldedit;
|
||||
@ -176,7 +176,7 @@ public class PS {
|
||||
if (this.IMP.initWorldEdit()) {
|
||||
this.worldedit = WorldEdit.getInstance();
|
||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
||||
MainCommand.getInstance().createCommand(new WE_Anywhere());
|
||||
new WE_Anywhere();
|
||||
}
|
||||
|
||||
// Events
|
||||
@ -649,7 +649,6 @@ public class PS {
|
||||
plot.setArea(plotarea);
|
||||
}
|
||||
}
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
Set<PlotCluster> clusters = this.clusters_tmp.remove(plotarea.toString());
|
||||
if (clusters == null) {
|
||||
if (plotarea.TYPE == 2) {
|
||||
@ -670,7 +669,6 @@ public class PS {
|
||||
cluster.setArea(plotarea);
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<PlotArea> localAreas = getPlotAreas(plotarea.worldname);
|
||||
Set<PlotArea> globalAreas = getPlotAreas();
|
||||
localAreas.add(plotarea);
|
||||
@ -736,11 +734,9 @@ public class PS {
|
||||
|
||||
public Set<PlotCluster> getClusters(String world) {
|
||||
HashSet<PlotCluster> set = new HashSet<>();
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
for (PlotArea area : getPlotAreas(world)) {
|
||||
set.addAll(area.getClusters());
|
||||
}
|
||||
}
|
||||
return set;
|
||||
|
||||
}
|
||||
@ -991,7 +987,7 @@ public class PS {
|
||||
Collections.sort(list, new Comparator<Plot>() {
|
||||
@Override
|
||||
public int compare(Plot a, Plot b) {
|
||||
return (int) Math.signum(ExpireManager.IMP.getTimestamp(a.owner) - ExpireManager.IMP.getTimestamp(b.owner));
|
||||
return Long.compare(ExpireManager.IMP.getTimestamp(a.owner), ExpireManager.IMP.getTimestamp(b.owner));
|
||||
}
|
||||
});
|
||||
return list;
|
||||
@ -1785,9 +1781,7 @@ public class PS {
|
||||
}
|
||||
DBFunc.dbManager = new SQLManager(this.database, Settings.DB.PREFIX, false);
|
||||
this.plots_tmp = DBFunc.getPlots();
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
this.clusters_tmp = DBFunc.getClusters();
|
||||
}
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
||||
if (Settings.DB.USE_MONGO) {
|
||||
@ -1967,9 +1961,6 @@ public class PS {
|
||||
options.put("protection.redstone.disable-offline", Settings.REDSTONE_DISABLER);
|
||||
options.put("protection.redstone.disable-unoccupied", Settings.REDSTONE_DISABLER_UNOCCUPIED);
|
||||
|
||||
// Clusters
|
||||
options.put("clusters.enabled", Settings.ENABLE_CLUSTERS);
|
||||
|
||||
// PlotMe
|
||||
options.put("plotme-alias", Settings.USE_PLOTME_ALIAS);
|
||||
options.put("plotme-convert.enabled", Settings.CONVERT_PLOTME);
|
||||
@ -2100,9 +2091,6 @@ public class PS {
|
||||
Settings.REDSTONE_DISABLER = this.config.getBoolean("protection.redstone.disable-offline");
|
||||
Settings.REDSTONE_DISABLER_UNOCCUPIED = this.config.getBoolean("protection.redstone.disable-unoccupied");
|
||||
|
||||
// Clusters
|
||||
Settings.ENABLE_CLUSTERS = this.config.getBoolean("clusters.enabled");
|
||||
|
||||
// PlotMe
|
||||
Settings.USE_PLOTME_ALIAS = this.config.getBoolean("plotme-alias");
|
||||
Settings.CONVERT_PLOTME = this.config.getBoolean("plotme-convert.enabled");
|
||||
@ -2265,10 +2253,23 @@ public class PS {
|
||||
log("Failed to save storage.yml");
|
||||
}
|
||||
try {
|
||||
this.style.save(this.styleFile);
|
||||
this.config.save(this.configFile);
|
||||
this.storage.save(this.storageFile);
|
||||
} catch (IOException e) {
|
||||
commandsFile = new File(IMP.getDirectory() + File.separator + "config" + File.separator + "commands.yml");
|
||||
if (!commandsFile.exists()) {
|
||||
if (!commandsFile.createNewFile()) {
|
||||
log("Could not the storage settings file, please create \"commands.yml\" manually.");
|
||||
}
|
||||
}
|
||||
commands = YamlConfiguration.loadConfiguration(commandsFile);
|
||||
setupStorage();
|
||||
} catch (IOException err_trans) {
|
||||
log("Failed to save commands.yml");
|
||||
}
|
||||
try {
|
||||
style.save(styleFile);
|
||||
config.save(configFile);
|
||||
storage.save(storageFile);
|
||||
commands.save(commandsFile);
|
||||
} catch (final IOException e) {
|
||||
log("Configuration file saving failed");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ import java.util.UUID;
|
||||
public class Add extends SubCommand {
|
||||
|
||||
public Add() {
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
super(Argument.PlayerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,13 +8,13 @@ package com.intellectualcrafters.plot.commands;
|
||||
*/
|
||||
public enum CommandCategory {
|
||||
/**
|
||||
* Claiming Commands
|
||||
* Claiming CommandConfig
|
||||
*
|
||||
* Such as: /plot claim
|
||||
*/
|
||||
CLAIMING("Claiming"),
|
||||
/**
|
||||
* Teleportation Commands
|
||||
* Teleportation CommandConfig
|
||||
*
|
||||
* Such as: /plot visit
|
||||
*/
|
||||
@ -36,13 +36,13 @@ public enum CommandCategory {
|
||||
*/
|
||||
APPEARANCE("Cosmetic"),
|
||||
/**
|
||||
* Information Commands
|
||||
* Information CommandConfig
|
||||
*
|
||||
* Such as: /plot info
|
||||
*/
|
||||
INFO("Info"),
|
||||
/**
|
||||
* Debug Commands
|
||||
* Debug CommandConfig
|
||||
*
|
||||
* Such as: /plot debug
|
||||
*/
|
||||
|
@ -37,6 +37,8 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
@ -74,7 +76,7 @@ import javax.script.SimpleScriptContext;
|
||||
@CommandDeclaration(command = "debugexec",
|
||||
permission = "plots.admin",
|
||||
description = "Mutli-purpose debug command",
|
||||
aliases = "exec",
|
||||
aliases = {"exec", "$"},
|
||||
category = CommandCategory.DEBUG)
|
||||
public class DebugExec extends SubCommand {
|
||||
|
||||
@ -310,22 +312,19 @@ public class DebugExec extends SubCommand {
|
||||
.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]),
|
||||
StandardCharsets.UTF_8),
|
||||
System.getProperty("line.separator"));
|
||||
Command<PlotPlayer> subcommand = new Command<PlotPlayer>(args[1].split("\\.")[0]) {
|
||||
new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null, RequiredType.NONE, CommandCategory.DEBUG) {
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
try {
|
||||
DebugExec.this.scope.put("PlotPlayer", plr);
|
||||
DebugExec.this.scope.put("PlotPlayer", player);
|
||||
DebugExec.this.scope.put("args", args);
|
||||
DebugExec.this.engine.eval(cmd, DebugExec.this.scope);
|
||||
return true;
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(player, C.COMMAND_WENT_WRONG);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
MainCommand.getInstance().addCommand(subcommand);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -358,7 +357,7 @@ public class DebugExec extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
Command<PlotPlayer> cmd = MainCommand.getInstance().getCommand(args[3]);
|
||||
Command cmd = MainCommand.getInstance().getCommand(args[3]);
|
||||
String[] params = Arrays.copyOfRange(args, 4, args.length);
|
||||
if ("true".equals(args[1])) {
|
||||
Location loc = player.getMeta("location");
|
||||
@ -366,7 +365,7 @@ public class DebugExec extends SubCommand {
|
||||
for (Plot current : PS.get().getBasePlots()) {
|
||||
player.setMeta("location", current.getBottomAbs());
|
||||
player.setMeta("lastplot", current);
|
||||
cmd.onCommand(player, params);
|
||||
cmd.execute(player, params, null, null);
|
||||
}
|
||||
if (loc == null) {
|
||||
player.deleteMeta("location");
|
||||
|
@ -47,7 +47,7 @@ import java.util.Map.Entry;
|
||||
public class DebugFixFlags extends SubCommand {
|
||||
|
||||
public DebugFixFlags() {
|
||||
this.requiredArguments = new Argument[]{Argument.String};
|
||||
super(Argument.String);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +45,7 @@ import java.util.UUID;
|
||||
public class Deny extends SubCommand {
|
||||
|
||||
public Deny() {
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
super(Argument.PlayerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@ -12,16 +10,14 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class GenerateDocs {
|
||||
|
||||
public static void main(String[] args) {
|
||||
MainCommand.getInstance().addCommand(new WE_Anywhere());
|
||||
MainCommand.getInstance().addCommand(new Cluster());
|
||||
ArrayList<Command<PlotPlayer>> commands = MainCommand.getInstance().getCommands();
|
||||
new WE_Anywhere();
|
||||
List<Command> commands = MainCommand.getInstance().getCommands();
|
||||
log("### Want to document some commands?");
|
||||
log(" - This page is automatically generated");
|
||||
log(" - Fork the project and add a javadoc comment to one of the command classes");
|
||||
@ -30,22 +26,21 @@ public class GenerateDocs {
|
||||
log("# Contents");
|
||||
for (CommandCategory category : CommandCategory.values()) {
|
||||
log("###### " + category.name());
|
||||
for (Command<PlotPlayer> command : MainCommand.getCommands(category, null)) {
|
||||
log(" - [/plot " + command.getCommand() + "](https://github.com/IntellectualSites/PlotSquared/wiki/Commands#" + command.getCommand()
|
||||
+ ") ");
|
||||
for (Command command : MainCommand.getInstance().getCommands(category, null)) {
|
||||
log(" - [/plot " + command.getId() + "](https://github.com/IntellectualSites/PlotSquared/wiki/Commands#" + command.getId() + ") ");
|
||||
}
|
||||
log("");
|
||||
}
|
||||
log("# Commands");
|
||||
for (Command<PlotPlayer> command : commands) {
|
||||
for (Command command : commands) {
|
||||
printCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
public static void printCommand(Command<PlotPlayer> command) {
|
||||
public static void printCommand(Command command) {
|
||||
try {
|
||||
String clazz = command.getClass().getSimpleName();
|
||||
String name = command.getCommand();
|
||||
String name = command.getId();
|
||||
|
||||
// Header
|
||||
String source =
|
||||
@ -88,7 +83,7 @@ public class GenerateDocs {
|
||||
log("`" + command.getRequiredType().name() + "`");
|
||||
}
|
||||
|
||||
Set<String> aliases = command.getAliases();
|
||||
List<String> aliases = command.getAliases();
|
||||
if (!aliases.isEmpty()) {
|
||||
log("#### Aliases");
|
||||
log("`" + StringMan.getString(command.getAliases()) + "`");
|
||||
|
@ -1,16 +1,98 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.helpmenu.HelpMenu;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "help",
|
||||
description = "Get this help menu",
|
||||
aliases = {"he"},
|
||||
category = CommandCategory.INFO)
|
||||
public class Help extends SubCommand {
|
||||
aliases = {"he", "h", "?"},
|
||||
category = CommandCategory.INFO,
|
||||
usage="help [category|#]",
|
||||
permission="plots.use")
|
||||
public class Help extends Command {
|
||||
public Help(Command parent) {
|
||||
super(parent, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
public boolean canExecute(PlotPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
switch (args.length) {
|
||||
case 0: {
|
||||
displayHelp(player, null, 0);
|
||||
return;
|
||||
}
|
||||
case 1: {
|
||||
if (MathMan.isInteger(args[0])) {
|
||||
try {
|
||||
displayHelp(player, null, Integer.parseInt(args[0]));
|
||||
} catch (NumberFormatException e) {
|
||||
displayHelp(player, null, 1);
|
||||
}
|
||||
} else {
|
||||
displayHelp(player, args[0], 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 2: {
|
||||
if (MathMan.isInteger(args[1])) {
|
||||
try {
|
||||
displayHelp(player, args[1], Integer.parseInt(args[1]));
|
||||
} catch (NumberFormatException e) {
|
||||
displayHelp(player, args[1], 1);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void displayHelp(PlotPlayer player, String cat, int page) {
|
||||
CommandCategory catEnum = null;
|
||||
if (cat != null) {
|
||||
if (StringMan.isEqualIgnoreCase(cat, "all")) {
|
||||
catEnum = null;
|
||||
} else {
|
||||
for (CommandCategory c : CommandCategory.values()) {
|
||||
if (StringMan.isEqualIgnoreCaseToAny(cat, c.name(), c.toString())) {
|
||||
catEnum = c;
|
||||
cat = c.name();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (catEnum == null) {
|
||||
cat = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cat == null && page == 0) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_HEADER.s());
|
||||
for (CommandCategory c : CommandCategory.values()) {
|
||||
builder.append(
|
||||
"\n" + StringMan.replaceAll(C.HELP_INFO_ITEM.s(), "%category%", c.toString().toLowerCase(), "%category_desc%", c.toString()));
|
||||
}
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands"));
|
||||
builder.append("\n" + C.HELP_FOOTER.s());
|
||||
MainUtil.sendMessage(player, builder.toString(), false);
|
||||
return;
|
||||
}
|
||||
page--;
|
||||
new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage(page, getParent().toString()).render();
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +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;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "home",
|
||||
aliases = {"h"},
|
||||
description = "Go to your plot",
|
||||
usage = "/plot home [id|alias]",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Home extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
return MainCommand.getInstance().getCommand("visit").onCommand(plr, args);
|
||||
}
|
||||
}
|
@ -56,7 +56,7 @@ import java.util.UUID;
|
||||
permission = "plots.list",
|
||||
category = CommandCategory.INFO,
|
||||
usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done|fuzzy <search...>> [#]")
|
||||
public class List extends SubCommand {
|
||||
public class ListCmd extends SubCommand {
|
||||
|
||||
private String[] getArgumentList(PlotPlayer player) {
|
||||
java.util.List<String> args = new ArrayList<>();
|
@ -20,266 +20,208 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.helpmenu.HelpMenu;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandHandlingOutput;
|
||||
import com.plotsquared.general.commands.CommandManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PlotSquared command class.
|
||||
*/
|
||||
public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
@CommandDeclaration(
|
||||
command = "plot",
|
||||
aliases = {"plots", "p", "plotsquared", "plot2", "p2", "ps", "2", "plotme", "plotz", "ap"})
|
||||
public class MainCommand extends Command {
|
||||
|
||||
private static MainCommand instance;
|
||||
private Help help;
|
||||
|
||||
private MainCommand() {
|
||||
super(null, new ArrayList<Command<PlotPlayer>>());
|
||||
super(null, true);
|
||||
instance = this;
|
||||
createCommand(new Buy());
|
||||
createCommand(new Save());
|
||||
createCommand(new Load());
|
||||
createCommand(new Confirm());
|
||||
createCommand(new Template());
|
||||
createCommand(new Download());
|
||||
createCommand(new Update());
|
||||
createCommand(new Template());
|
||||
createCommand(new Setup());
|
||||
createCommand(new Area());
|
||||
createCommand(new DebugSaveTest());
|
||||
createCommand(new DebugLoadTest());
|
||||
createCommand(new CreateRoadSchematic());
|
||||
createCommand(new DebugAllowUnsafe());
|
||||
createCommand(new RegenAllRoads());
|
||||
createCommand(new Claim());
|
||||
createCommand(new Auto());
|
||||
createCommand(new Visit());
|
||||
createCommand(new Home());
|
||||
createCommand(new Set());
|
||||
createCommand(new Toggle());
|
||||
createCommand(new Clear());
|
||||
createCommand(new Delete());
|
||||
createCommand(new Trust());
|
||||
createCommand(new Add());
|
||||
createCommand(new Deny());
|
||||
createCommand(new Untrust());
|
||||
createCommand(new Remove());
|
||||
createCommand(new Undeny());
|
||||
createCommand(new Info());
|
||||
createCommand(new com.intellectualcrafters.plot.commands.List());
|
||||
createCommand(new Help());
|
||||
createCommand(new Debug());
|
||||
createCommand(new SchematicCmd());
|
||||
createCommand(new Plugin());
|
||||
createCommand(new Purge());
|
||||
createCommand(new Reload());
|
||||
createCommand(new Merge());
|
||||
createCommand(new DebugPaste());
|
||||
createCommand(new Unlink());
|
||||
createCommand(new Kick());
|
||||
createCommand(new Rate());
|
||||
createCommand(new DebugClaimTest());
|
||||
createCommand(new Inbox());
|
||||
createCommand(new Comment());
|
||||
createCommand(new Database());
|
||||
createCommand(new Swap());
|
||||
createCommand(new Music());
|
||||
createCommand(new DebugRoadRegen());
|
||||
createCommand(new Trust());
|
||||
createCommand(new DebugExec());
|
||||
createCommand(new FlagCmd());
|
||||
createCommand(new Target());
|
||||
createCommand(new DebugFixFlags());
|
||||
createCommand(new Move());
|
||||
createCommand(new Condense());
|
||||
createCommand(new Condense());
|
||||
createCommand(new Copy());
|
||||
createCommand(new Chat());
|
||||
createCommand(new Trim());
|
||||
createCommand(new Done());
|
||||
createCommand(new Continue());
|
||||
createCommand(new BO3());
|
||||
createCommand(new Middle());
|
||||
createCommand(new Grant());
|
||||
// set commands
|
||||
createCommand(new Owner());
|
||||
createCommand(new Desc());
|
||||
createCommand(new Biome());
|
||||
createCommand(new Alias());
|
||||
createCommand(new SetHome());
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
MainCommand.getInstance().addCommand(new Cluster());
|
||||
}
|
||||
}
|
||||
|
||||
public static MainCommand getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new MainCommand();
|
||||
new Buy();
|
||||
new Save();
|
||||
new Load();
|
||||
new Confirm();
|
||||
new Template();
|
||||
new Download();
|
||||
new Update();
|
||||
new Template();
|
||||
new Setup();
|
||||
new Area();
|
||||
new DebugSaveTest();
|
||||
new DebugLoadTest();
|
||||
new CreateRoadSchematic();
|
||||
new DebugAllowUnsafe();
|
||||
new RegenAllRoads();
|
||||
new Claim();
|
||||
new Auto();
|
||||
new Visit();
|
||||
new Set();
|
||||
new Toggle();
|
||||
new Clear();
|
||||
new Delete();
|
||||
new Trust();
|
||||
new Add();
|
||||
new Deny();
|
||||
new Untrust();
|
||||
new Remove();
|
||||
new Undeny();
|
||||
new Info();
|
||||
new ListCmd();
|
||||
instance.help = new Help(instance);
|
||||
new Debug();
|
||||
new SchematicCmd();
|
||||
new PluginCmd();
|
||||
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 Music();
|
||||
new DebugRoadRegen();
|
||||
new Trust();
|
||||
new DebugExec();
|
||||
new FlagCmd();
|
||||
new Target();
|
||||
new DebugFixFlags();
|
||||
new Move();
|
||||
new Condense();
|
||||
new Condense();
|
||||
new Copy();
|
||||
new Chat();
|
||||
new Trim();
|
||||
new Done();
|
||||
new Continue();
|
||||
new BO3();
|
||||
new Middle();
|
||||
new Grant();
|
||||
// set commands
|
||||
new Owner();
|
||||
new Desc();
|
||||
new Biome();
|
||||
new Alias();
|
||||
new SetHome();
|
||||
new Cluster();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static boolean no_permission(PlotPlayer player, String permission) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, permission);
|
||||
return false;
|
||||
@Deprecated
|
||||
/**
|
||||
* @Deprecated legacy
|
||||
*/
|
||||
public void addCommand(Command command) {
|
||||
PS.debug("Command registration is now done during instantiation");
|
||||
}
|
||||
|
||||
public static List<Command<PlotPlayer>> getCommandAndAliases(CommandCategory category, PlotPlayer player) {
|
||||
List<Command<PlotPlayer>> commands = new ArrayList<>();
|
||||
for (Command<PlotPlayer> command : getInstance().getCommands()) {
|
||||
if ((category != null) && !command.getCategory().equals(category)) {
|
||||
continue;
|
||||
public static boolean onCommand(final PlotPlayer player, String... args) {
|
||||
if (args.length >= 1 && args[0].contains(":")) {
|
||||
String[] split2 = args[0].split(":");
|
||||
if (split2.length == 2) {
|
||||
// Ref: c:v, this will push value to the last spot in the array
|
||||
// ex. /p h:2 SomeUsername
|
||||
// > /p h SomeUsername 2
|
||||
String[] tmp = new String[args.length + 1];
|
||||
tmp[0] = split2[0];
|
||||
tmp[args.length] = split2[1];
|
||||
if (args.length > 2) {
|
||||
System.arraycopy(args, 1, tmp, 1, args.length - 1);
|
||||
}
|
||||
if ((player != null) && !Permissions.hasPermission(player, command.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
commands.add(command);
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static List<Command<PlotPlayer>> getCommands(CommandCategory category, PlotPlayer player) {
|
||||
List<Command<PlotPlayer>> commands = new ArrayList<>();
|
||||
for (Command<PlotPlayer> command : new HashSet<>(getInstance().getCommands())) {
|
||||
if ((category != null) && !command.getCategory().equals(category)) {
|
||||
continue;
|
||||
}
|
||||
if ((player != null) && !Permissions.hasPermission(player, command.getPermission())) {
|
||||
continue;
|
||||
}
|
||||
commands.add(command);
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static void displayHelp(PlotPlayer player, String cat, int page, String label) {
|
||||
CommandCategory catEnum = null;
|
||||
if (cat != null) {
|
||||
if (StringMan.isEqualIgnoreCase(cat, "all")) {
|
||||
catEnum = null;
|
||||
} else {
|
||||
for (CommandCategory c : CommandCategory.values()) {
|
||||
if (StringMan.isEqualIgnoreCaseToAny(cat, c.name(), c.toString())) {
|
||||
catEnum = c;
|
||||
cat = c.name();
|
||||
break;
|
||||
args = tmp;
|
||||
}
|
||||
}
|
||||
if (catEnum == null) {
|
||||
cat = null;
|
||||
{
|
||||
try {
|
||||
if (args.length == 0 || MathMan.isInteger(args[0]) || CommandCategory.valueOf(args[0].toUpperCase()) != null) {
|
||||
// This will default certain syntax to the help command
|
||||
// e.g. /plot, /plot 1, /plot claiming
|
||||
getInstance().help.execute(player, args, null, null);
|
||||
return true;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {}
|
||||
}
|
||||
}
|
||||
if (cat == null && page == 0) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_HEADER.s());
|
||||
for (CommandCategory c : CommandCategory.values()) {
|
||||
builder.append(
|
||||
"\n" + StringMan.replaceAll(C.HELP_INFO_ITEM.s(), "%category%", c.toString().toLowerCase(), "%category_desc%", c.toString()));
|
||||
}
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands"));
|
||||
builder.append("\n" + C.HELP_FOOTER.s());
|
||||
MainUtil.sendMessage(player, builder.toString(), false);
|
||||
getInstance().execute(player, args, new RunnableVal3<Command, Runnable, Runnable>() {
|
||||
@Override
|
||||
public void run(final Command cmd, final Runnable success, final Runnable failure) {
|
||||
if (cmd.hasConfirmation(player) ) {
|
||||
CmdConfirm.addPending(player, "/plot area create pos2 (Creates world)", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (EconHandler.manager != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Double price = area.PRICES.get(cmd.getId());
|
||||
if (price != null && EconHandler.manager.getMoney(player) < price) {
|
||||
failure.run();
|
||||
return;
|
||||
}
|
||||
page--;
|
||||
new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage(page, label).render();
|
||||
}
|
||||
}
|
||||
success.run();
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (EconHandler.manager != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Double price = area.PRICES.get(cmd.getId());
|
||||
if (price != null && EconHandler.manager.getMoney(player) < price) {
|
||||
failure.run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
success.run();
|
||||
}
|
||||
}, new RunnableVal2<Command, CommandResult>() {
|
||||
@Override
|
||||
public void run(Command cmd, CommandResult result) {
|
||||
// Post command stuff!?
|
||||
}
|
||||
});
|
||||
// Always true
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean onCommand(PlotPlayer player, String cmd, String... args) {
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
// Clear perm caching //
|
||||
player.deleteMeta("perm");
|
||||
////////////////////////
|
||||
int help_index = -1;
|
||||
// Optional command scope //
|
||||
String category = null;
|
||||
Location loc = null;
|
||||
Plot plot = null;
|
||||
boolean tp = false;
|
||||
switch (args.length) {
|
||||
case 0: {
|
||||
help_index = 0;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if (MathMan.isInteger(args[0])) {
|
||||
try {
|
||||
help_index = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
default: {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "he":
|
||||
case "help":
|
||||
case "?": {
|
||||
switch (args.length) {
|
||||
case 1: {
|
||||
help_index = 0;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (MathMan.isInteger(args[1])) {
|
||||
category = null;
|
||||
try {
|
||||
help_index = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
help_index = 1;
|
||||
}
|
||||
} else {
|
||||
help_index = 1;
|
||||
category = args[1];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
category = args[1];
|
||||
if (MathMan.isInteger(args[2])) {
|
||||
try {
|
||||
help_index = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
help_index = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
C.COMMAND_SYNTAX.send(player, "/" + cmd + "? [#|<term>|category [#]]");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
if (args.length >= 2) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
Plot newPlot = Plot.fromString(area, args[0]);
|
||||
if (newPlot == null) {
|
||||
break;
|
||||
}
|
||||
if (!ConsolePlayer.isConsole(player) && (!newPlot.getArea().equals(area) || newPlot.isDenied(player.getUUID()))
|
||||
&& !Permissions.hasPermission(player, C.PERMISSION_ADMIN)) {
|
||||
break;
|
||||
}
|
||||
if (newPlot != null && (ConsolePlayer.isConsole(player) || newPlot.getArea().equals(area) || Permissions.hasPermission(player, C.PERMISSION_ADMIN)) && !newPlot.isDenied(player.getUUID())) {
|
||||
// Save meta
|
||||
loc = player.getMeta("location");
|
||||
plot = player.getMeta("lastplot");
|
||||
@ -291,16 +233,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (help_index != -1) {
|
||||
displayHelp(player, category, help_index, cmd);
|
||||
return true;
|
||||
}
|
||||
String fullCmd = StringMan.join(args, " ");
|
||||
getInstance().handle(player, cmd + " " + fullCmd);
|
||||
// Restore location
|
||||
super.execute(player, args, confirm, whenDone);
|
||||
// Reset command scope //
|
||||
if (tp) {
|
||||
if (loc == null) {
|
||||
player.deleteMeta("location");
|
||||
@ -313,148 +247,10 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
player.setMeta("lastplot", plot);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getMatch(String[] args, Command<PlotPlayer> cmd) {
|
||||
int count = 0;
|
||||
String perm = cmd.getPermission();
|
||||
HashSet<String> desc = new HashSet<>();
|
||||
for (String alias : cmd.getAliases()) {
|
||||
if (alias.startsWith(args[0])) {
|
||||
count += 5;
|
||||
}
|
||||
}
|
||||
Collections.addAll(desc, cmd.getDescription().split(" "));
|
||||
for (String arg : args) {
|
||||
if (perm.startsWith(arg)) {
|
||||
count++;
|
||||
}
|
||||
if (desc.contains(arg)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
String[] usage = cmd.getUsage().split(" ");
|
||||
for (int i = 0; i < Math.min(4, usage.length); i++) {
|
||||
int require;
|
||||
if (usage[i].startsWith("<")) {
|
||||
require = 1;
|
||||
} else {
|
||||
require = 0;
|
||||
}
|
||||
String[] split = usage[i].split("\\|| |\\>|\\<|\\[|\\]|\\{|\\}|\\_|\\/");
|
||||
for (String aSplit : split) {
|
||||
for (String arg : args) {
|
||||
if (StringMan.isEqualIgnoreCase(arg, aSplit)) {
|
||||
count += 5 - i + require;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
count += StringMan.intersection(desc, args);
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handle(PlotPlayer plr, String input) {
|
||||
String[] parts = input.split(" ");
|
||||
String[] args;
|
||||
String label;
|
||||
if (parts.length == 1) {
|
||||
label = null;
|
||||
args = new String[0];
|
||||
} else {
|
||||
label = parts[1];
|
||||
args = new String[parts.length - 2];
|
||||
System.arraycopy(parts, 2, args, 0, args.length);
|
||||
}
|
||||
Command<PlotPlayer> cmd;
|
||||
if (label != null) {
|
||||
if (label.contains(":")) {
|
||||
// Ref: c:v, this will push value to the last spot in the array
|
||||
// ex. /p h:2 SomeUsername
|
||||
// > /p h SomeUsername 2
|
||||
String[] temp = label.split(":");
|
||||
if (temp.length == 2) {
|
||||
label = temp[0];
|
||||
String[] tempArgs = new String[args.length + 1];
|
||||
System.arraycopy(args, 0, tempArgs, 0, args.length);
|
||||
tempArgs[tempArgs.length - 1] = temp[1];
|
||||
args = tempArgs;
|
||||
}
|
||||
}
|
||||
cmd = getInstance().commands.get(label.toLowerCase());
|
||||
} else {
|
||||
cmd = null;
|
||||
}
|
||||
if (cmd == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_SUBCOMMAND);
|
||||
{
|
||||
List<Command<PlotPlayer>> cmds = getCommands(null, plr);
|
||||
if ((label == null) || cmds.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, "/plot help");
|
||||
} else {
|
||||
HashSet<String> setargs = new HashSet<>(args.length + 1);
|
||||
for (String arg : args) {
|
||||
setargs.add(arg.toLowerCase());
|
||||
}
|
||||
setargs.add(label);
|
||||
String[] allargs = setargs.toArray(new String[setargs.size()]);
|
||||
int best = 0;
|
||||
for (Command<PlotPlayer> current : cmds) {
|
||||
int match = getMatch(allargs, current);
|
||||
if (match > best) {
|
||||
cmd = current;
|
||||
}
|
||||
}
|
||||
if (cmd == null) {
|
||||
cmd = new StringComparison<>(label, getCommandAndAliases(null, plr)).getMatchObject();
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, cmd.getUsage().replaceAll("\\{label\\}", parts[0]));
|
||||
}
|
||||
}
|
||||
return CommandHandlingOutput.NOT_FOUND;
|
||||
}
|
||||
if (!cmd.getRequiredType().allows(plr)) {
|
||||
if (ConsolePlayer.isConsole(plr)) {
|
||||
MainUtil.sendMessage(plr, C.IS_CONSOLE);
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.NOT_CONSOLE);
|
||||
}
|
||||
return CommandHandlingOutput.CALLER_OF_WRONG_TYPE;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, cmd.getPermission())) {
|
||||
MainUtil.sendMessage(plr, 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) {
|
||||
C.COMMAND_SYNTAX.send(plr, cmd.getUsage());
|
||||
return CommandHandlingOutput.WRONG_USAGE;
|
||||
}
|
||||
}
|
||||
try {
|
||||
boolean result = cmd.onCommand(plr, args);
|
||||
if (!result) {
|
||||
cmd.getUsage();
|
||||
return CommandHandlingOutput.WRONG_USAGE;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return CommandHandlingOutput.ERROR;
|
||||
}
|
||||
return CommandHandlingOutput.SUCCESS;
|
||||
public boolean canExecute(PlotPlayer player) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
description = "Show plugin information",
|
||||
aliases = "version",
|
||||
category = CommandCategory.INFO)
|
||||
public class Plugin extends SubCommand {
|
||||
public class PluginCmd extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
@ -134,9 +134,9 @@ public class Rate extends SubCommand {
|
||||
}
|
||||
setTitle(Settings.RATING_CATEGORIES.get(index.getValue()));
|
||||
if (Permissions.hasPermission(this.player, "plots.comment")) {
|
||||
Command<PlotPlayer> command = MainCommand.getInstance().getCommand("comment");
|
||||
Command command = MainCommand.getInstance().getCommand("comment");
|
||||
if (command != null) {
|
||||
MainUtil.sendMessage(this.player, C.COMMENT_THIS, command.getUsage().replaceAll("{label}", "plot"));
|
||||
MainUtil.sendMessage(this.player, C.COMMENT_THIS, command.getUsage());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -45,7 +45,7 @@ import java.util.UUID;
|
||||
public class Remove extends SubCommand {
|
||||
|
||||
public Remove() {
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
super(Argument.PlayerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +61,7 @@ public class Set extends SubCommand {
|
||||
this.component = new SetCommand() {
|
||||
|
||||
@Override
|
||||
public String getCommand() {
|
||||
public String getId() {
|
||||
return "set.component";
|
||||
}
|
||||
|
||||
@ -163,9 +163,10 @@ public class Set extends SubCommand {
|
||||
if (args.length == 0) {
|
||||
return noArgs(plr);
|
||||
}
|
||||
Command<PlotPlayer> cmd = MainCommand.getInstance().getCommand("set" + args[0]);
|
||||
Command cmd = MainCommand.getInstance().getCommand("set" + args[0]);
|
||||
if (cmd != null) {
|
||||
return cmd.onCommand(plr, Arrays.copyOfRange(args, 1, args.length));
|
||||
cmd.execute(plr, Arrays.copyOfRange(args, 1, args.length), null, null);
|
||||
return true;
|
||||
}
|
||||
// Additional checks
|
||||
Plot plot = plr.getCurrentPlot();
|
||||
@ -193,7 +194,7 @@ public class Set extends SubCommand {
|
||||
a.append(" ").append(args[x]);
|
||||
}
|
||||
}
|
||||
MainCommand.onCommand(plr, "plot", ("flag set " + args[0] + a.toString()).split(" "));
|
||||
MainCommand.onCommand(plr, ("flag set " + args[0] + a.toString()).split(" "));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -18,15 +18,15 @@ public abstract class SetCommand extends SubCommand {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getCommand())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getCommand());
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getId())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getId());
|
||||
MainUtil.sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!plot.isOwner(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getCommand())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getCommand());
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command." + getId())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command." + getId());
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -21,80 +21,37 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotMessage;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
import java.util.List;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
|
||||
/**
|
||||
* SubCommand class.
|
||||
* SubCommand class
|
||||
* @see com.plotsquared.general.commands.Command(com.plotsquared.general.commands.Command, boolean)
|
||||
* @Deprecated In favor of normal Command class
|
||||
*/
|
||||
public abstract class SubCommand extends com.plotsquared.general.commands.Command<PlotPlayer> {
|
||||
public abstract class SubCommand extends Command {
|
||||
public SubCommand() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* The category.
|
||||
*/
|
||||
public CommandCategory category;
|
||||
public SubCommand(Argument... arguments) {
|
||||
this();
|
||||
setRequiredArguments(arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
* @param plr Player who will receive the message
|
||||
* @param c Caption
|
||||
* @param args Arguments (%s's)
|
||||
*
|
||||
* @see MainUtil#sendMessage(PlotPlayer, C, String...)
|
||||
*/
|
||||
public boolean sendMessage(PlotPlayer plr, C c, String... args) {
|
||||
c.send(plr, args);
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
onCommand(player, args);
|
||||
}
|
||||
|
||||
|
||||
public abstract boolean onCommand(PlotPlayer plr, String[] args);
|
||||
|
||||
public boolean sendMessage(PlotPlayer player, C message, Object... args) {
|
||||
message.send(player, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
public <T> void paginate(PlotPlayer player, List<T> c, int size, int page, RunnableVal3<Integer, T, PlotMessage> add, String baseCommand,
|
||||
String header) {
|
||||
// Calculate pages & index
|
||||
if (page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
int totalPages = (int) Math.ceil(c.size() / size);
|
||||
if (page > totalPages) {
|
||||
page = totalPages;
|
||||
}
|
||||
int max = page * size + size;
|
||||
if (max > c.size()) {
|
||||
max = c.size();
|
||||
}
|
||||
// Send the header
|
||||
header = header.replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", c.size() + "")
|
||||
.replaceAll("%word%", "all");
|
||||
MainUtil.sendMessage(player, header);
|
||||
// Send the page content
|
||||
List<T> subList = c.subList(page * size, max);
|
||||
int i = page * size;
|
||||
for (T obj : subList) {
|
||||
i++;
|
||||
PlotMessage msg = new PlotMessage();
|
||||
add.run(i, obj, msg);
|
||||
msg.send(player);
|
||||
}
|
||||
// Send the footer
|
||||
if (page < totalPages && page > 0) { // Back | Next
|
||||
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ").color("$3").text("->").color("$1")
|
||||
.command(baseCommand + " " + (page + 2))
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
return;
|
||||
}
|
||||
if (page == 0 && totalPages != 0) { // Next
|
||||
new PlotMessage().text("<-").color("$3").text(" | ").color("$3").text("->").color("$1").command(baseCommand + " " + (page + 2))
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
return;
|
||||
}
|
||||
if (page == totalPages && totalPages != 0) { // Back
|
||||
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ").color("$3").text("->").color("$3")
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,20 +20,14 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "toggle",
|
||||
aliases = {"attribute"},
|
||||
@ -42,97 +36,59 @@ import java.util.Map.Entry;
|
||||
usage = "/plot toggle <setting>",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
public class Toggle extends SubCommand {
|
||||
|
||||
private final HashMap<String, Command<PlotPlayer>> toggles;
|
||||
|
||||
public class Toggle extends Command {
|
||||
public Toggle() {
|
||||
this.toggles = new HashMap<>();
|
||||
this.toggles.put("titles",
|
||||
new Command<PlotPlayer>("titles", "/plot toggle titles", "Toggle titles for yourself", C.PERMISSION_PLOT_TOGGLE_TITLES.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (toggle(player, "disabletitles")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, getCommand());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand());
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
this.toggles.put("chatspy", new Command<PlotPlayer>("chatspy", "/plot toggle chatspy", "Toggle chat spying", C.PERMISSION_COMMANDS_CHAT.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@CommandDeclaration(
|
||||
command = "chatspy",
|
||||
aliases = {"spy"},
|
||||
permission = "plots.admin.command.chat",
|
||||
description = "Toggle admin chat spying")
|
||||
public void chatspy(Command command, final PlotPlayer player, String[] args, RunnableVal3<Command,Runnable,Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "chatspy")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand());
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, getCommand());
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
this.toggles.put("chat",
|
||||
new Command<PlotPlayer>("chat", "/plot toggle chat", "Toggle plot chat for yourself", C.PERMISSION_PLOT_TOGGLE_CHAT.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (toggle(player, "chat")) {
|
||||
MainUtil.sendMessage(player, C.PLOT_CHAT_OFF);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.PLOT_CHAT_ON);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (PS.get() != null && PS.get().worldedit != null) {
|
||||
this.toggles.put("worldedit",
|
||||
new Command<PlotPlayer>("worldedit", "/plot toggle worldedit", "Toggle worldedit bypass", C.PERMISSION_WORLDEDIT_BYPASS.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@CommandDeclaration(
|
||||
command = "worldedit",
|
||||
aliases = {"we", "wea"},
|
||||
permission = "plots.worldedit.bypass",
|
||||
description = "Toggle worldedit area restrictions")
|
||||
public void worldedit(Command command, final PlotPlayer player, String[] args, RunnableVal3<Command,Runnable,Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "worldedit")) {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_RESTRICTED);
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_UNMASKED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void noArgs(PlotPlayer plr) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot toggle <setting>");
|
||||
ArrayList<String> options = new ArrayList<>();
|
||||
for (Entry<String, Command<PlotPlayer>> entry : this.toggles.entrySet()) {
|
||||
if (Permissions.hasPermission(plr, entry.getValue().getPermission())) {
|
||||
options.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
if (!options.isEmpty()) {
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(options, ","));
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
noArgs(player);
|
||||
return false;
|
||||
@CommandDeclaration(
|
||||
command = "chat",
|
||||
permission = "plots.toggle.chat",
|
||||
description = "Toggle plot chat")
|
||||
public void chat(Command command, final PlotPlayer player, String[] args, RunnableVal3<Command,Runnable,Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "chat")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
}
|
||||
Command<PlotPlayer> cmd = this.toggles.get(args[0].toLowerCase());
|
||||
if (cmd == null) {
|
||||
noArgs(player);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, cmd.getPermission())) {
|
||||
C.NO_PERMISSION.send(player, cmd.getPermission());
|
||||
return false;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "titles",
|
||||
permission = "plots.toggle.titles",
|
||||
description = "Toggle plot title messages")
|
||||
public void titles(Command command, final PlotPlayer player, String[] args, RunnableVal3<Command,Runnable,Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "titles")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
}
|
||||
return cmd.onCommand(player, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
|
||||
public boolean toggle(PlotPlayer player, String key) {
|
||||
|
@ -44,7 +44,7 @@ import java.util.UUID;
|
||||
public class Trust extends SubCommand {
|
||||
|
||||
public Trust() {
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
super(Argument.PlayerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,7 +43,7 @@ import java.util.UUID;
|
||||
public class Undeny extends SubCommand {
|
||||
|
||||
public Undeny() {
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
super(Argument.PlayerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,7 +46,7 @@ import java.util.UUID;
|
||||
public class Untrust extends SubCommand {
|
||||
|
||||
public Untrust() {
|
||||
this.requiredArguments = new Argument[]{Argument.PlayerName};
|
||||
super(Argument.PlayerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,13 +43,13 @@ import java.util.UUID;
|
||||
permission = "plots.visit",
|
||||
description = "Visit someones plot",
|
||||
usage = "/plot visit [player|alias|world|id] [#]",
|
||||
aliases = {"v", "tp", "teleport", "goto"},
|
||||
aliases = {"v", "tp", "teleport", "goto", "home"},
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.TELEPORT)
|
||||
public class Visit extends SubCommand {
|
||||
|
||||
public Visit() {
|
||||
this.requiredArguments = new Argument[]{Argument.String};
|
||||
super(Argument.String);
|
||||
}
|
||||
|
||||
public List<Plot> getPlots(UUID uuid) {
|
||||
|
@ -369,14 +369,14 @@ public enum C {
|
||||
UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot", "Merge"),
|
||||
UNLINK_SUCCESS("$2Successfully unlinked plots.", "Merge"),
|
||||
/*
|
||||
* Commands
|
||||
* CommandConfig
|
||||
*/
|
||||
NOT_VALID_SUBCOMMAND("$2That is not a valid subcommand", "Commands"),
|
||||
DID_YOU_MEAN("$2Did you mean: $1%s", "Commands"),
|
||||
NAME_LITTLE("$2%s0 name is too short, $1%s1$2<$1%s3", "Commands"),
|
||||
NO_COMMANDS("$2I'm sorry, but you're not permitted to use any subcommands.", "Commands"),
|
||||
SUBCOMMAND_SET_OPTIONS_HEADER("$2Possible Values: ", "Commands"),
|
||||
COMMAND_SYNTAX("$1Usage: $2%s", "Commands"),
|
||||
NOT_VALID_SUBCOMMAND("$2That is not a valid subcommand", "CommandConfig"),
|
||||
DID_YOU_MEAN("$2Did you mean: $1%s", "CommandConfig"),
|
||||
NAME_LITTLE("$2%s0 name is too short, $1%s1$2<$1%s3", "CommandConfig"),
|
||||
NO_COMMANDS("$2I'm sorry, but you're not permitted to use any subcommands.", "CommandConfig"),
|
||||
SUBCOMMAND_SET_OPTIONS_HEADER("$2Possible Values: ", "CommandConfig"),
|
||||
COMMAND_SYNTAX("$1Usage: $2%s", "CommandConfig"),
|
||||
/*
|
||||
* Player not found
|
||||
*/
|
||||
@ -573,7 +573,7 @@ public enum C {
|
||||
FLAG_NOT_ADDED("$2The flag could not be added", "Flag"),
|
||||
FLAG_REMOVED("$4Successfully removed flag", "Flag"),
|
||||
FLAG_ADDED("$4Successfully added flag", "Flag"),
|
||||
FLAG_TUTORIAL_USAGE("$1Have an admin set the flag: $2%s", "Commands"),
|
||||
FLAG_TUTORIAL_USAGE("$1Have an admin set the flag: $2%s", "CommandConfig"),
|
||||
/*
|
||||
* Trusted
|
||||
*/
|
||||
@ -633,16 +633,14 @@ public enum C {
|
||||
*/
|
||||
private final String def;
|
||||
/**
|
||||
* Should the string be prefixed.
|
||||
*/
|
||||
private final boolean prefix; /**
|
||||
* What locale category should this translation fall under.
|
||||
*/
|
||||
private final String category;
|
||||
/**
|
||||
* Translated.
|
||||
*/
|
||||
private String s; /**
|
||||
private String s;
|
||||
/**
|
||||
* Should the string be prefixed.
|
||||
*/
|
||||
private final boolean prefix;
|
||||
|
@ -60,10 +60,6 @@ public class Settings {
|
||||
public static boolean REQUIRE_DONE = false;
|
||||
public static boolean DONE_COUNTS_TOWARDS_LIMIT = false;
|
||||
public static boolean DONE_RESTRICTS_BUILDING = false;
|
||||
/**
|
||||
* Clusters
|
||||
*/
|
||||
public static boolean ENABLE_CLUSTERS = false;
|
||||
/**
|
||||
* PlotMe settings
|
||||
*/
|
||||
|
@ -1044,13 +1044,7 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
@Override
|
||||
public void createTables() throws SQLException {
|
||||
String[] tables;
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
tables = new String[] { "plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings", "cluster", "player_meta" };
|
||||
} else {
|
||||
tables = new String[]{"plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings",
|
||||
"player_meta"};
|
||||
}
|
||||
String[] tables = new String[] { "plot", "plot_denied", "plot_helpers", "plot_comments", "plot_trusted", "plot_rating", "plot_settings", "cluster", "player_meta" };
|
||||
DatabaseMetaData meta = this.connection.getMetaData();
|
||||
int create = 0;
|
||||
for (String s : tables) {
|
||||
|
@ -115,7 +115,7 @@ public class AugmentedUtils {
|
||||
for (int z = bzz; z <= tzz; z++) {
|
||||
int rx = x + bx;
|
||||
int rz = z + bz;
|
||||
boolean can = manager.getPlotIdAbs(area, rx, 0, rz) == null;
|
||||
boolean can = manager.getPlotId(area, rx, 0, rz) == null;
|
||||
if (can) {
|
||||
for (int y = 1; y < 128; y++) {
|
||||
result.setBlock(x, y, z, air);
|
||||
|
@ -20,6 +20,25 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -41,25 +60,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.PathIterator;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* The plot class<br>
|
||||
* [IMPORTANT]
|
||||
@ -1960,14 +1960,12 @@ public class Plot {
|
||||
* @return
|
||||
*/
|
||||
public boolean canClaim(PlotPlayer player) {
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
PlotCluster cluster = this.getCluster();
|
||||
if (cluster != null) {
|
||||
if (!cluster.isAdded(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.claim")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.guessOwner() == null && !isMerged();
|
||||
}
|
||||
|
||||
@ -2650,14 +2648,14 @@ public class Plot {
|
||||
greaterPlot.setMerged(0, true);
|
||||
lesserPlot.mergeData(greaterPlot);
|
||||
if (removeRoads) {
|
||||
if (lesserPlot.getMerged(5)) {
|
||||
lesserPlot.removeRoadSouthEast();
|
||||
}
|
||||
lesserPlot.removeRoadSouth();
|
||||
Plot other = this.getRelative(3);
|
||||
if (other.getMerged(2) && other.getMerged(1)) {
|
||||
other.removeRoadEast();
|
||||
greaterPlot.mergePlot(other, removeRoads);
|
||||
other.removeRoadEast();
|
||||
}
|
||||
if (lesserPlot.getMerged(5)) {
|
||||
lesserPlot.removeRoadSouthEast();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2674,15 +2672,15 @@ public class Plot {
|
||||
greaterPlot.setMerged(3, true);
|
||||
lesserPlot.mergeData(greaterPlot);
|
||||
if (removeRoads) {
|
||||
lesserPlot.removeRoadEast();
|
||||
final Plot other = lesserPlot.getRelative(0);
|
||||
if (other.getMerged(2) && other.getMerged(1)) {
|
||||
greaterPlot.mergePlot(other, removeRoads);
|
||||
other.removeRoadSouthEast();
|
||||
}
|
||||
if (lesserPlot.getMerged(5)) {
|
||||
lesserPlot.removeRoadSouthEast();
|
||||
}
|
||||
Plot other = lesserPlot.getRelative(0);
|
||||
if (other.getMerged(2) && other.getMerged(1)) {
|
||||
other.removeRoadSouthEast();
|
||||
greaterPlot.mergePlot(other, removeRoads);
|
||||
}
|
||||
lesserPlot.removeRoadEast();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -554,9 +554,6 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public PlotCluster getCluster(Location location) {
|
||||
if (!Settings.ENABLE_CLUSTERS) {
|
||||
return null;
|
||||
}
|
||||
Plot plot = getPlot(location);
|
||||
if (plot == null) {
|
||||
return null;
|
||||
@ -565,7 +562,7 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public PlotCluster getFirstIntersectingCluster(PlotId pos1, PlotId pos2) {
|
||||
if (!Settings.ENABLE_CLUSTERS || this.clusters == null) {
|
||||
if (this.clusters == null) {
|
||||
return null;
|
||||
}
|
||||
for (PlotCluster cluster : this.clusters.getAll()) {
|
||||
@ -577,9 +574,6 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public PlotCluster getCluster(PlotId id) {
|
||||
if (!Settings.ENABLE_CLUSTERS) {
|
||||
return null;
|
||||
}
|
||||
return this.clusters != null ? this.clusters.get(id.x, id.y) : null;
|
||||
}
|
||||
|
||||
@ -862,16 +856,13 @@ public abstract class PlotArea {
|
||||
}
|
||||
|
||||
public void removeCluster(PlotCluster plotCluster) {
|
||||
if (!Settings.ENABLE_CLUSTERS || this.clusters == null) {
|
||||
if (this.clusters == null) {
|
||||
throw new IllegalAccessError("Clusters not enabled!");
|
||||
}
|
||||
this.clusters.remove(plotCluster);
|
||||
}
|
||||
|
||||
public void addCluster(PlotCluster plotCluster) {
|
||||
if (!Settings.ENABLE_CLUSTERS) {
|
||||
throw new IllegalAccessError("Clusters not enabled!");
|
||||
}
|
||||
if (this.clusters == null) {
|
||||
this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 64) {
|
||||
@Override
|
||||
|
@ -1,7 +1,13 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
|
||||
/**
|
||||
@ -129,6 +135,39 @@ public abstract class PlotChunk<T> implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a task for each x,z value corresponding to the plot at that location<br>
|
||||
* - Plot: The plot at the x,z (may be null)<br>
|
||||
* - Location: The location in the chunk (y = 0)<br>
|
||||
* - PlotChunk: Reference to this chunk object<br>
|
||||
* @param task
|
||||
*/
|
||||
public void mapByType2D(RunnableVal3<Plot, Integer, Integer> task) {
|
||||
int bx = getX() << 4;
|
||||
int bz = getZ() << 4;
|
||||
String world = getChunkWrapper().world;
|
||||
PlotArea area = PS.get().getPlotArea(world, null);
|
||||
Location loc = new Location(world, bx, 0, bz);
|
||||
if (area != null) {
|
||||
PlotManager manager = area.getPlotManager();
|
||||
for (int x = 0; x < 16; x++) {
|
||||
loc.setX(bx + x);
|
||||
for (int z = 0; z < 16; z++) {
|
||||
loc.setZ(bz + z);
|
||||
task.run(area.getPlotAbs(loc), x, z);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
loc.setX(bx + x);
|
||||
for (int z = 0; z < 16; z++) {
|
||||
loc.setZ(bz + z);
|
||||
task.run(loc.getPlotAbs(), x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill a cuboid in this chunk with a block
|
||||
* @param x1
|
||||
|
@ -15,7 +15,7 @@ public class HelpMenu {
|
||||
private HelpPage _page = new HelpPage(CommandCategory.INFO, 0, 0);
|
||||
private int _maxPage;
|
||||
private CommandCategory _commandCategory;
|
||||
private List<Command<PlotPlayer>> _commands;
|
||||
private List<Command> _commands;
|
||||
|
||||
public HelpMenu(final PlotPlayer player) {
|
||||
_player = player;
|
||||
@ -27,7 +27,7 @@ public class HelpMenu {
|
||||
}
|
||||
|
||||
public HelpMenu getCommands() {
|
||||
_commands = MainCommand.getCommands(_commandCategory, _player);
|
||||
_commands = MainCommand.getInstance().getCommands(_commandCategory, _player);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.commands.CommandCategory;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -21,12 +22,8 @@ public class HelpPage {
|
||||
if (helpObjects.size() < 1) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(0)");
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.HELP_HEADER, false);
|
||||
MainUtil.sendMessage(player, _header, false);
|
||||
for (final HelpObject object : helpObjects) {
|
||||
MainUtil.sendMessage(player, object.toString(), false);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.HELP_FOOTER, false);
|
||||
String message = C.HELP_HEADER.s() + "\n" + _header + "\n" + StringMan.join(helpObjects, "\n") + "\n" + C.HELP_FOOTER.s();
|
||||
MainUtil.sendMessage(player, message, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,156 +1,449 @@
|
||||
package com.plotsquared.general.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.CommandCategory;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotMessage;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class Command<E extends CommandCaller> extends CommandManager {
|
||||
public abstract class Command {
|
||||
|
||||
protected Argument<?>[] requiredArguments;
|
||||
private RequiredType requiredType = RequiredType.NONE;
|
||||
private String command;
|
||||
private String usage = "";
|
||||
private String description = "";
|
||||
private String permission = "";
|
||||
private Set<String> aliases = new HashSet<>();
|
||||
// May be none
|
||||
private ArrayList<Command> allCommands = new ArrayList<>();
|
||||
private ArrayList<Command> dynamicCommands = new ArrayList<>();
|
||||
private HashMap<String, Command> staticCommands = new HashMap<>();
|
||||
|
||||
// Parent command (may be null)
|
||||
private Command parent;
|
||||
|
||||
// The command ID
|
||||
private String id;
|
||||
private List<String> aliases;
|
||||
private RequiredType required;
|
||||
private String usage;
|
||||
private String description;
|
||||
private boolean isStatic;
|
||||
private String perm;
|
||||
private boolean confirmation;
|
||||
private CommandCategory category;
|
||||
private int hash;
|
||||
private Argument[] arguments;
|
||||
|
||||
public Command() {
|
||||
super(null, new ArrayList<Command>());
|
||||
public Command getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public Command(String command) {
|
||||
super(null, new ArrayList<Command>());
|
||||
this.command = command;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Command(String command, String usage) {
|
||||
super(null, new ArrayList<Command>());
|
||||
this.command = command;
|
||||
this.usage = usage;
|
||||
public List<Command> getCommands(PlotPlayer player) {
|
||||
List<Command> commands = new ArrayList<>();
|
||||
for (Command cmd : allCommands) {
|
||||
if (cmd.canExecute(player)) {
|
||||
commands.add(cmd);
|
||||
}
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
|
||||
public Command(String command, String usage, String description) {
|
||||
super(null, new ArrayList<Command>());
|
||||
this.command = command;
|
||||
this.usage = usage;
|
||||
this.description = description;
|
||||
public List<Command> getCommands(CommandCategory cat, PlotPlayer player) {
|
||||
List<Command> cmds = getCommands(player);
|
||||
if (cat != null) {
|
||||
Iterator<Command> iter = cmds.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (iter.next().category != cat) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return cmds;
|
||||
}
|
||||
|
||||
public Command(String command, String usage, String description, String permission) {
|
||||
super(null, new ArrayList<Command>());
|
||||
this.command = command;
|
||||
this.usage = usage;
|
||||
this.description = description;
|
||||
this.permission = permission;
|
||||
public List<Command> getCommands() {
|
||||
return allCommands;
|
||||
}
|
||||
|
||||
public Command(String command, String[] aliases, String usage) {
|
||||
super(null, new ArrayList<Command>());
|
||||
this.command = command;
|
||||
this.aliases = new HashSet<>(Arrays.asList(aliases));
|
||||
this.usage = usage;
|
||||
public boolean hasConfirmation(PlotPlayer player) {
|
||||
return confirmation && !player.hasPermission(getPermission() + ".confirm.bypass");
|
||||
}
|
||||
|
||||
public Command(String command, String[] aliases) {
|
||||
super(null, new ArrayList<Command>());
|
||||
this.command = command;
|
||||
this.aliases = new HashSet<>(Arrays.asList(aliases));
|
||||
public List<String> getAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public Command(String command, String usage, String description, String permission, String[] aliases, RequiredType requiredType) {
|
||||
super(null, new ArrayList<Command>());
|
||||
this.command = command;
|
||||
this.usage = usage;
|
||||
this.description = description;
|
||||
this.permission = permission;
|
||||
this.aliases = new HashSet<>(Arrays.asList(aliases));
|
||||
this.requiredType = requiredType;
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public RequiredType getRequiredType() {
|
||||
return this.requiredType;
|
||||
return required;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
Annotation annotation = getClass().getAnnotation(CommandDeclaration.class);
|
||||
if (annotation == null) {
|
||||
throw new RuntimeException("Command does not have a CommandDeclaration");
|
||||
public Argument[] getRequiredArguments() {
|
||||
return arguments;
|
||||
}
|
||||
CommandDeclaration declaration = (CommandDeclaration) annotation;
|
||||
this.command = declaration.command();
|
||||
this.usage = declaration.usage();
|
||||
this.description = declaration.description();
|
||||
this.usage = declaration.usage();
|
||||
this.permission = declaration.permission();
|
||||
this.aliases = new HashSet<>(Arrays.asList(declaration.aliases()));
|
||||
this.requiredType = declaration.requiredType();
|
||||
|
||||
public void setRequiredArguments(Argument[] arguments) {
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
public Command(Command parent, boolean isStatic, String id, String perm, RequiredType required, CommandCategory cat) {
|
||||
this.parent = parent;
|
||||
this.isStatic = isStatic;
|
||||
this.id = id;
|
||||
this.perm = perm;
|
||||
this.required = required;
|
||||
this.category = cat;
|
||||
this.aliases = Arrays.asList(id);
|
||||
}
|
||||
|
||||
public Command(Command parent, boolean isStatic) {
|
||||
this.parent = parent;
|
||||
this.isStatic = isStatic;
|
||||
final Annotation cdAnnotation = getClass().getAnnotation(CommandDeclaration.class);
|
||||
if (cdAnnotation != null) {
|
||||
final CommandDeclaration declaration = (CommandDeclaration) cdAnnotation;
|
||||
init(declaration);
|
||||
}
|
||||
for (final Method method : getClass().getDeclaredMethods()) {
|
||||
if (method.isAnnotationPresent(CommandDeclaration.class)) {
|
||||
Class<?>[] types = method.getParameterTypes();
|
||||
// final PlotPlayer player, String[] args, RunnableVal3<Command,Runnable,Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone
|
||||
if (types.length == 5 && types[0] == Command.class && types[1] == PlotPlayer.class && types[2] == String[].class && types[3] == RunnableVal3.class && types[4] == RunnableVal2.class) {
|
||||
Command tmp = new Command(this, true) {
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
try {
|
||||
method.invoke(Command.this, this, player, args, confirm, whenDone);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
tmp.init(method.getAnnotation(CommandDeclaration.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void init(CommandDeclaration declaration) {
|
||||
this.id = declaration.command();
|
||||
this.perm = declaration.permission();
|
||||
this.required = declaration.requiredType();
|
||||
this.category = declaration.category();
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
List<String> aliasOptions = new ArrayList<>();
|
||||
aliasOptions.add(id);
|
||||
aliasOptions.addAll(Arrays.asList(declaration.aliases()));
|
||||
options.put("aliases", aliasOptions);
|
||||
options.put("description", declaration.description());
|
||||
options.put("usage", declaration.usage());
|
||||
options.put("confirmation", declaration.confirmation());
|
||||
boolean set = false;
|
||||
for (Map.Entry<String, Object> entry : options.entrySet()) {
|
||||
String key = id + "." + entry.getKey();
|
||||
if (!PS.get().commands.contains(key)) {
|
||||
PS.get().commands.set(key, entry.getValue());
|
||||
set = true;
|
||||
}
|
||||
}
|
||||
if (set) {
|
||||
try {
|
||||
PS.get().commands.save(PS.get().commandsFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
aliases = PS.get().commands.getStringList(id + ".aliases");
|
||||
description = PS.get().commands.getString(id + ".description");
|
||||
usage = PS.get().commands.getString(id + ".usage");
|
||||
confirmation = PS.get().commands.getBoolean(id + ".confirmation");
|
||||
if (parent != null) {
|
||||
parent.register(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void register(Command command) {
|
||||
if (command.isStatic) {
|
||||
for (String alias : command.aliases) {
|
||||
staticCommands.put(alias.toLowerCase(), command);
|
||||
}
|
||||
} else {
|
||||
dynamicCommands.add(command);
|
||||
}
|
||||
allCommands.add(command);
|
||||
}
|
||||
|
||||
public enum CommandResult {
|
||||
FAILURE,
|
||||
SUCCESS
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
if (perm != null && perm.length() != 0) {
|
||||
return perm;
|
||||
}
|
||||
if (parent == null) {
|
||||
return "plots.use";
|
||||
}
|
||||
if (parent.parent == null) {
|
||||
return "plots." + id;
|
||||
}
|
||||
return parent.getPermission() + "." + id;
|
||||
}
|
||||
|
||||
public <T> void paginate(PlotPlayer player, List<T> c, int size, int page, RunnableVal3<Integer, T, PlotMessage> add, String baseCommand, String header) {
|
||||
// Calculate pages & index
|
||||
if (page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
final int totalPages = (int) Math.ceil(c.size() / size);
|
||||
if (page > totalPages) {
|
||||
page = totalPages;
|
||||
}
|
||||
int max = page * size + size;
|
||||
if (max > c.size()) {
|
||||
max = c.size();
|
||||
}
|
||||
// Send the header
|
||||
header = header.replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%amount%", c.size() + "").replaceAll("%word%", "all");
|
||||
MainUtil.sendMessage(player, header);
|
||||
// Send the page content
|
||||
final List<T> subList = c.subList(page * size, max);
|
||||
int i = page * size;
|
||||
for (final T obj : subList) {
|
||||
i++;
|
||||
PlotMessage msg = new PlotMessage();
|
||||
add.run(i, obj, msg);
|
||||
msg.send(player);
|
||||
}
|
||||
// Send the footer
|
||||
if (page < totalPages && page > 0) { // Back | Next
|
||||
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ").color("$3").text("->").color("$1")
|
||||
.command(baseCommand + " " + (page + 2))
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
return;
|
||||
}
|
||||
if (page == 0 && totalPages != 0) { // Next
|
||||
new PlotMessage().text("<-").color("$3").text(" | ").color("$3").text("->").color("$1").command(baseCommand + " " + (page + 2)).text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
return;
|
||||
}
|
||||
if (page == totalPages && totalPages != 0) { // Back
|
||||
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ").color("$3").text("->").color("$3")
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player Caller
|
||||
* @param args Arguments
|
||||
* @param confirm Instance, Success, Failure
|
||||
* @return
|
||||
*/
|
||||
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command,Runnable,Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (args.length == 0 || args[0] == null) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return;
|
||||
}
|
||||
if (allCommands == null || allCommands.size() == 0) {
|
||||
player.sendMessage("Not Implemented: https://github.com/IntellectualSites/PlotSquared/issues/new");
|
||||
return;
|
||||
}
|
||||
Command cmd = getCommand(args[0]);
|
||||
if (cmd == null) {
|
||||
if (parent != null) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return;
|
||||
}
|
||||
// Command recommendation
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
||||
{
|
||||
List<Command> cmds = getCommands(player);
|
||||
if (cmds.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot help");
|
||||
return;
|
||||
}
|
||||
HashSet<String> setargs = new HashSet<>(args.length);
|
||||
for (String arg : args) {
|
||||
setargs.add(arg.toLowerCase());
|
||||
}
|
||||
String[] allargs = setargs.toArray(new String[setargs.size()]);
|
||||
int best = 0;
|
||||
for (Command current : cmds) {
|
||||
int match = getMatch(allargs, current);
|
||||
if (match > best) {
|
||||
cmd = current;
|
||||
}
|
||||
}
|
||||
if (cmd == null) {
|
||||
cmd = new StringComparison<>(args[0], allCommands).getMatchObject();
|
||||
}
|
||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN, cmd.getUsage());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!cmd.canExecute(player)) {
|
||||
Argument<?>[] reqArgs = cmd.getRequiredArguments();
|
||||
if ((reqArgs != null) && (reqArgs.length > 0)) {
|
||||
boolean failed = args.length > reqArgs.length;
|
||||
String[] baseSplit = getCommandString().split(" ");
|
||||
String[] fullSplit = getUsage().split(" ");
|
||||
String base = getCommandString();
|
||||
for (int i = 0; i < reqArgs.length; i++) {
|
||||
fullSplit[i + baseSplit.length] = reqArgs[i].getExample().toString();
|
||||
failed = failed || reqArgs[i].parse(args[i]) == null;
|
||||
}
|
||||
if (failed) {
|
||||
C.COMMAND_SYNTAX.send(player, StringMan.join(fullSplit, " "));
|
||||
return;
|
||||
}
|
||||
}
|
||||
C.NO_PERMISSION.send(player, cmd.getPermission());
|
||||
return;
|
||||
}
|
||||
cmd.execute(player, Arrays.copyOfRange(args, 1, args.length), confirm, whenDone);
|
||||
}
|
||||
|
||||
public int getMatch(String[] args, Command cmd) {
|
||||
int count = 0;
|
||||
String perm = cmd.getPermission();
|
||||
HashSet<String> desc = new HashSet<>();
|
||||
for (String alias : cmd.getAliases()) {
|
||||
if (alias.startsWith(args[0])) {
|
||||
count += 5;
|
||||
}
|
||||
}
|
||||
Collections.addAll(desc, cmd.getDescription().split(" "));
|
||||
for (String arg : args) {
|
||||
if (perm.startsWith(arg)) {
|
||||
count++;
|
||||
}
|
||||
if (desc.contains(arg)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
String[] usage = cmd.getUsage().split(" ");
|
||||
for (int i = 0; i < Math.min(4, usage.length); i++) {
|
||||
int require;
|
||||
if (usage[i].startsWith("<")) {
|
||||
require = 1;
|
||||
} else {
|
||||
require = 0;
|
||||
}
|
||||
String[] split = usage[i].split("\\|| |\\>|\\<|\\[|\\]|\\{|\\}|\\_|\\/");
|
||||
for (String aSplit : split) {
|
||||
for (String arg : args) {
|
||||
if (StringMan.isEqualIgnoreCase(arg, aSplit)) {
|
||||
count += 5 - i + require;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
count += StringMan.intersection(desc, args);
|
||||
return count;
|
||||
}
|
||||
|
||||
public Command getCommand(String arg) {
|
||||
Command cmd = staticCommands.get(arg.toLowerCase());
|
||||
if (cmd == null) {
|
||||
for (Command command : dynamicCommands) {
|
||||
if (command.matches(arg)) {
|
||||
return command;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public boolean canExecute(PlotPlayer player) {
|
||||
return required.allows(player) && Permissions.hasPermission(player, getPermission());
|
||||
}
|
||||
|
||||
public boolean matches(String arg) {
|
||||
arg = arg.toLowerCase();
|
||||
return StringMan.isEqual(arg, id) || aliases.contains(arg);
|
||||
}
|
||||
|
||||
public String getCommandString() {
|
||||
String base;
|
||||
if (parent == null) {
|
||||
return "/" + toString();
|
||||
} else {
|
||||
return parent.getCommandString() + " " + toString();
|
||||
}
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
if (usage != null && usage.length() != 0) {
|
||||
if (usage.startsWith("/")) {
|
||||
return usage;
|
||||
}
|
||||
return getCommandString() + " " + usage;
|
||||
}
|
||||
if (allCommands.size() == 0) {
|
||||
return getCommandString();
|
||||
}
|
||||
StringBuilder args = new StringBuilder("[");
|
||||
String prefix = "";
|
||||
for (Command cmd : allCommands) {
|
||||
args.append(prefix).append(cmd.isStatic ? cmd.toString() : "<" + cmd + ">");
|
||||
prefix = "|";
|
||||
}
|
||||
return getCommandString() + " " + args + "]";
|
||||
}
|
||||
|
||||
public Collection tab(PlotPlayer player, String[] args, boolean space) {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
return allCommands;
|
||||
case 1:
|
||||
String arg = args[0].toLowerCase();
|
||||
if (space) {
|
||||
Command cmd = getCommand(arg);
|
||||
return (cmd != null && cmd.canExecute(player)) ? (cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space)) : null;
|
||||
} else {
|
||||
Set<Command> commands = new HashSet<Command>();
|
||||
for (Map.Entry<String, Command> entry : staticCommands.entrySet()) {
|
||||
if (entry.getKey().startsWith(arg) && entry.getValue().canExecute(player)) {
|
||||
commands.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
default:
|
||||
Command cmd = getCommand(args[0]);
|
||||
return cmd != null ? cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public abstract boolean onCommand(E plr, String[] arguments);
|
||||
|
||||
public int handle(E plr, String[] args) {
|
||||
if (args.length == 0) {
|
||||
return super.handle(plr, "");
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String s : args) {
|
||||
builder.append(s).append(" ");
|
||||
}
|
||||
String s = builder.substring(0, builder.length() - 1);
|
||||
return super.handle(plr, s);
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public String getUsage() {
|
||||
if (this.usage.isEmpty()) {
|
||||
return "/{label} " + this.command;
|
||||
}
|
||||
return this.usage;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
if (this.permission == null || this.permission.isEmpty()) {
|
||||
this.permission = "plots." + this.command.toLowerCase();
|
||||
}
|
||||
return this.permission;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public Set<String> getAliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
public Argument<?>[] getRequiredArguments() {
|
||||
if (this.requiredArguments == null) {
|
||||
return new Argument<?>[0];
|
||||
}
|
||||
return this.requiredArguments;
|
||||
}
|
||||
|
||||
public CommandCategory getCategory() {
|
||||
if (this.category == null) {
|
||||
return CommandCategory.DEBUG;
|
||||
}
|
||||
return this.category;
|
||||
return aliases.size() > 0 ? aliases.get(0) : id;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,18 +454,15 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Command<?> other = (Command<?>) obj;
|
||||
final Command other = (Command) obj;
|
||||
if (this.hashCode() != other.hashCode()) {
|
||||
return false;
|
||||
}
|
||||
return this.command.equals(other.command);
|
||||
return this.id.equals(other.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (this.hash == 0) {
|
||||
this.hash = getCommand().hashCode();
|
||||
}
|
||||
return this.hash;
|
||||
return id.hashCode();
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import java.lang.annotation.Target;
|
||||
import com.intellectualcrafters.plot.commands.CommandCategory;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Target({ElementType.TYPE,ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CommandDeclaration {
|
||||
|
||||
@ -24,5 +24,7 @@ public @interface CommandDeclaration {
|
||||
|
||||
RequiredType requiredType() default RequiredType.NONE;
|
||||
|
||||
CommandCategory category();
|
||||
CommandCategory category() default CommandCategory.INFO;
|
||||
|
||||
boolean confirmation() default false;
|
||||
}
|
||||
|
@ -1,149 +0,0 @@
|
||||
package com.plotsquared.general.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CommandManager<T extends CommandCaller> {
|
||||
|
||||
public final ConcurrentHashMap<String, Command<T>> commands;
|
||||
private final Character initialCharacter;
|
||||
|
||||
public CommandManager(Character initialCharacter, List<Command<T>> commands) {
|
||||
this.commands = new ConcurrentHashMap<>();
|
||||
for (Command<T> command : commands) {
|
||||
addCommand(command);
|
||||
}
|
||||
this.initialCharacter = initialCharacter;
|
||||
}
|
||||
|
||||
public final void addCommand(Command<T> command) {
|
||||
if (command.getCommand() == null) {
|
||||
command.create();
|
||||
}
|
||||
this.commands.put(command.getCommand().toLowerCase(), command);
|
||||
for (String alias : command.getAliases()) {
|
||||
this.commands.put(alias.toLowerCase(), command);
|
||||
}
|
||||
}
|
||||
|
||||
public final Command<T> getCommand(String command) {
|
||||
return this.commands.get(command.toLowerCase());
|
||||
}
|
||||
|
||||
public final boolean createCommand(Command<T> command) {
|
||||
try {
|
||||
command.create();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
if (command.getCommand() != null) {
|
||||
addCommand(command);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public final ArrayList<Command<T>> getCommands() {
|
||||
HashSet<Command<T>> set = new HashSet<>(this.commands.values());
|
||||
ArrayList<Command<T>> result = new ArrayList<>(set);
|
||||
Collections.sort(result, new Comparator<Command<T>>() {
|
||||
@Override
|
||||
public int compare(Command<T> a, Command<T> b) {
|
||||
if (a == b) {
|
||||
return 0;
|
||||
}
|
||||
if (a == null) {
|
||||
return -1;
|
||||
}
|
||||
if (b == null) {
|
||||
return 1;
|
||||
}
|
||||
return a.getCommand().compareTo(b.getCommand());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public final ArrayList<String> getCommandLabels(ArrayList<Command<T>> cmds) {
|
||||
ArrayList<String> labels = new ArrayList<>(cmds.size());
|
||||
for (Command<T> cmd : cmds) {
|
||||
labels.add(cmd.getCommand());
|
||||
}
|
||||
return labels;
|
||||
}
|
||||
|
||||
public int handle(T plr, String input) {
|
||||
if (this.initialCharacter != null && !input.startsWith(this.initialCharacter + "")) {
|
||||
return CommandHandlingOutput.NOT_COMMAND;
|
||||
}
|
||||
if (this.initialCharacter == null) {
|
||||
input = input;
|
||||
} else {
|
||||
input = input.substring(1);
|
||||
}
|
||||
String[] parts = input.split(" ");
|
||||
String[] args;
|
||||
String command = parts[0].toLowerCase();
|
||||
if (parts.length == 1) {
|
||||
args = new String[0];
|
||||
} else {
|
||||
args = new String[parts.length - 1];
|
||||
System.arraycopy(parts, 1, args, 0, args.length);
|
||||
}
|
||||
Command<T> cmd = this.commands.get(command);
|
||||
if (cmd == null) {
|
||||
return CommandHandlingOutput.NOT_FOUND;
|
||||
}
|
||||
if (!cmd.getRequiredType().allows(plr)) {
|
||||
return CommandHandlingOutput.CALLER_OF_WRONG_TYPE;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, 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) {
|
||||
cmd.getUsage().replaceAll("\\{label\\}", parts[0]);
|
||||
C.COMMAND_SYNTAX.send(plr, cmd.getUsage());
|
||||
return CommandHandlingOutput.WRONG_USAGE;
|
||||
}
|
||||
}
|
||||
try {
|
||||
boolean a = cmd.onCommand(plr, args);
|
||||
if (!a) {
|
||||
String usage = cmd.getUsage();
|
||||
if ((usage != null) && !usage.isEmpty()) {
|
||||
plr.sendMessage(usage);
|
||||
}
|
||||
return CommandHandlingOutput.WRONG_USAGE;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return CommandHandlingOutput.ERROR;
|
||||
}
|
||||
return CommandHandlingOutput.SUCCESS;
|
||||
}
|
||||
|
||||
public final char getInitialCharacter() {
|
||||
return this.initialCharacter;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user