Add your command caller back

This commit is contained in:
boy0001 2015-07-27 14:30:50 +10:00
parent 6df9024ff1
commit 56fbeb60e5
75 changed files with 152 additions and 125 deletions

View File

@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;

View File

@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "auto", command = "auto",

View File

@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
@CommandDeclaration( @CommandDeclaration(

View File

@ -5,7 +5,7 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "chat", command = "chat",

View File

@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "claim", command = "claim",

View File

@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
@CommandDeclaration( @CommandDeclaration(

View File

@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.generator.PlotGenerator; import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.generator.AugmentedPopulator; import com.plotsquared.bukkit.generator.AugmentedPopulator;
import com.plotsquared.bukkit.generator.HybridGen; import com.plotsquared.bukkit.generator.HybridGen;
import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.BlockLoc;

View File

@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands;
import java.util.Arrays; import java.util.Arrays;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;

View File

@ -27,7 +27,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;

View File

@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.util.CmdConfirm;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "confirm", command = "confirm",

View File

@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "copy", command = "copy",

View File

@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "createroadschematic", command = "createroadschematic",

View File

@ -15,7 +15,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
@CommandDeclaration( @CommandDeclaration(

View File

@ -27,7 +27,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.Lag; import com.intellectualcrafters.plot.util.Lag;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "debug", command = "debug",

View File

@ -9,7 +9,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "debugallowunsafe", command = "debugallowunsafe",

View File

@ -40,7 +40,7 @@ import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
@CommandDeclaration( @CommandDeclaration(

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
@CommandDeclaration( @CommandDeclaration(

View File

@ -32,7 +32,7 @@ import java.util.UUID;
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SetBlockQueue; import com.intellectualcrafters.plot.util.SetBlockQueue;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "fill", command = "fill",

View File

@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "debugfixflags", command = "debugfixflags",

View File

@ -27,7 +27,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "debugloadtest", command = "debugloadtest",

View File

@ -1,7 +1,7 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.BukkitMain; import com.plotsquared.bukkit.BukkitMain;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;

View File

@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "debugroadregen", command = "debugroadregen",

View File

@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "debugsavetest", command = "debugsavetest",

View File

@ -25,7 +25,7 @@ import java.util.Map.Entry;
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
import com.intellectualcrafters.plot.generator.PlotGenerator; import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;

View File

@ -30,7 +30,7 @@ import java.util.UUID;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
@CommandDeclaration( @CommandDeclaration(

View File

@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;

View File

@ -14,7 +14,7 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "download", command = "download",

View File

@ -25,7 +25,7 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;

View File

@ -8,7 +8,7 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "help", command = "help",

View File

@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "home", command = "home",

View File

@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;

View File

@ -28,7 +28,7 @@ import java.util.regex.Matcher;
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;

View File

@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
@CommandDeclaration( @CommandDeclaration(

View File

@ -17,7 +17,7 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "load", command = "load",

View File

@ -37,7 +37,7 @@ import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.Command; import com.intellectualsites.commands.Command;
import com.intellectualsites.commands.CommandHandlingOutput; import com.intellectualsites.commands.CommandHandlingOutput;
import com.intellectualsites.commands.CommandManager; import com.intellectualsites.commands.CommandManager;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.intellectualsites.commands.util.StringUtil; import com.intellectualsites.commands.util.StringUtil;
/** /**
@ -247,7 +247,7 @@ public class MainCommand extends CommandManager {
public int handle(CommandCaller caller, String input) { public int handle(CommandCaller caller, String input) {
String[] parts = input.split(" "); String[] parts = input.split(" ");
String[] args; String[] args;
String command = parts[0]; String command = parts[0].toLowerCase();
if (parts.length == 1) { if (parts.length == 1) {
args = new String[0]; args = new String[0];
} else { } else {
@ -256,7 +256,7 @@ public class MainCommand extends CommandManager {
} }
Command cmd = null; Command cmd = null;
for (Command c1 : this.commands) { for (Command c1 : this.commands) {
if (c1.getCommand().equalsIgnoreCase(command) || StringUtil.inArray(command, c1.getAliases(), false)) { if (c1.getCommand().equalsIgnoreCase(command) || c1.getAliases().contains(command)) {
cmd = c1; cmd = c1;
break; break;
} }
@ -268,7 +268,7 @@ public class MainCommand extends CommandManager {
for (int i = 0; i < commands.length; i++) { for (int i = 0; i < commands.length; i++) {
commands[i] = this.commands.get(i).getCommand(); commands[i] = this.commands.get(i).getCommand();
} }
final String bestMatch = new StringComparison(args[0], commands).getBestMatch(); final String bestMatch = new StringComparison<String>(args[0], commands).getBestMatch();
caller.message(C.DID_YOU_MEAN, "/plot " + bestMatch); caller.message(C.DID_YOU_MEAN, "/plot " + bestMatch);
} }
return CommandHandlingOutput.NOT_FOUND; return CommandHandlingOutput.NOT_FOUND;

View File

@ -26,7 +26,7 @@ import java.util.UUID;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;

View File

@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "move", command = "move",

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "music", command = "music",

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;

View File

@ -27,7 +27,7 @@ import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.mutable.MutableInt; import org.apache.commons.lang.mutable.MutableInt;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "regenallroads", command = "regenallroads",

View File

@ -25,7 +25,7 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "reload", command = "reload",

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;

View File

@ -17,7 +17,7 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "save", command = "save",

View File

@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
// TODO Add sub-subcommands // TODO Add sub-subcommands

View File

@ -25,7 +25,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;

View File

@ -35,7 +35,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
@CommandDeclaration( @CommandDeclaration(

View File

@ -28,7 +28,7 @@ import java.util.Map.Entry;
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
import com.intellectualcrafters.plot.generator.PlotGenerator; import com.intellectualcrafters.plot.generator.PlotGenerator;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;

View File

@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "swap", command = "swap",

View File

@ -22,7 +22,7 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;

View File

@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "target", command = "target",

View File

@ -42,7 +42,7 @@ import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.SetupUtils; import com.plotsquared.bukkit.util.SetupUtils;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;

View File

@ -24,7 +24,7 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
// TOGGLE("toggle", "attribute"), // TOGGLE("toggle", "attribute"),

View File

@ -40,7 +40,7 @@ import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "trim", command = "trim",

View File

@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;

View File

@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "unclaim", command = "unclaim",

View File

@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;

View File

@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "unlink", command = "unlink",

View File

@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
// UNTRUST("untrust", "ut"), // UNTRUST("untrust", "ut"),

View File

@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "update", command = "update",

View File

@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
@CommandDeclaration( @CommandDeclaration(

View File

@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.listeners.worldedit.WEManager; import com.plotsquared.bukkit.listeners.worldedit.WEManager;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;

View File

@ -6,7 +6,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.Command; import com.intellectualsites.commands.Command;
import com.intellectualsites.commands.CommandManager; import com.intellectualsites.commands.CommandManager;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
public class ConsoleCaller implements CommandCaller<PS> { public class ConsoleCaller implements CommandCaller<PS> {
@Override @Override

View File

@ -5,8 +5,8 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.Command; import com.intellectualsites.commands.Command;
import com.intellectualsites.commands.CommandCaller;
import com.intellectualsites.commands.CommandManager; import com.intellectualsites.commands.CommandManager;
import com.intellectualsites.commands.callers.CommandCaller;
public class PlotPlayerCaller implements CommandCaller<PlotPlayer> { public class PlotPlayerCaller implements CommandCaller<PlotPlayer> {

View File

@ -31,7 +31,7 @@ import java.util.UUID;
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.util.UUIDHandler; import com.plotsquared.bukkit.util.UUIDHandler;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualsites.commands.CommandDeclaration; import com.intellectualsites.commands.CommandDeclaration;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
@CommandDeclaration( @CommandDeclaration(
command = "plugin", command = "plugin",

View File

@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualsites.commands.callers.CommandCaller; import com.intellectualsites.commands.CommandCaller;
import com.plotsquared.bukkit.listeners.PlotListener; import com.plotsquared.bukkit.listeners.PlotListener;
import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.ChunkLoc;

View File

@ -21,6 +21,7 @@
package com.intellectualcrafters.plot.util; package com.intellectualcrafters.plot.util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
/** /**
@ -46,6 +47,10 @@ public class StringComparison<T> {
init(input, objects); init(input, objects);
} }
public StringComparison(String input, final Collection<T> objects) {
init(input, (T[]) objects.toArray());
}
/** /**
* You should call init(...) when you are ready to get a String comparison value * You should call init(...) when you are ready to get a String comparison value
*/ */

View File

@ -26,6 +26,32 @@ public class StringMan {
return sb.toString(); return sb.toString();
} }
public static String replaceFirst(char c, String s) {
if (s == null) {
return "";
}
if (s.isEmpty()) {
return s;
}
char[] chars = s.toCharArray();
char[] newChars = new char[chars.length];
int used = 0;
boolean found = false;
for (char cc : chars) {
if (!found && c == cc) {
found = true;
} else {
newChars[used++] = cc;
}
}
if (found) {
chars = new char[newChars.length - 1];
System.arraycopy(newChars, 0, chars, 0, chars.length);
return String.valueOf(chars);
}
return s;
}
public static String replaceAll(String string, Object... pairs) { public static String replaceAll(String string, Object... pairs) {
StringBuilder sb = new StringBuilder(string); StringBuilder sb = new StringBuilder(string);
for (int i = 0; i < pairs.length; i+=2) { for (int i = 0; i < pairs.length; i+=2) {

View File

@ -1,16 +1,18 @@
package com.intellectualsites.commands; package com.intellectualsites.commands;
import com.intellectualcrafters.plot.commands.CommandCategory;
import com.intellectualsites.commands.callers.CommandCaller;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.intellectualcrafters.plot.commands.CommandCategory;
public abstract class Command extends CommandManager { public abstract class Command extends CommandManager {
private Class requiredType = Object.class; private Class requiredType = Object.class;
private String command, usage = "", description = "", permission = ""; private String command, usage = "", description = "", permission = "";
private String[] aliases = new String[0]; private Set<String> aliases = new HashSet<>();
private CommandCategory category; private CommandCategory category;
protected Argument[] requiredArguments; protected Argument[] requiredArguments;
@ -47,14 +49,14 @@ public abstract class Command extends CommandManager {
public Command(String command, String[] aliases, String usage) { public Command(String command, String[] aliases, String usage) {
super(null, new ArrayList<Command>()); super(null, new ArrayList<Command>());
this.command = command; this.command = command;
this.aliases = aliases; this.aliases = new HashSet<>(Arrays.asList(aliases));
this.usage = usage; this.usage = usage;
} }
public Command(String command, String[] aliases) { public Command(String command, String[] aliases) {
super(null, new ArrayList<Command>()); super(null, new ArrayList<Command>());
this.command = command; this.command = command;
this.aliases = aliases; this.aliases = new HashSet<>(Arrays.asList(aliases));
} }
public Command(String command, String usage, String description, String permission, String[] aliases, Class requiredType) { public Command(String command, String usage, String description, String permission, String[] aliases, Class requiredType) {
@ -63,7 +65,7 @@ public abstract class Command extends CommandManager {
this.usage = usage; this.usage = usage;
this.description = description; this.description = description;
this.permission = permission; this.permission = permission;
this.aliases = aliases; this.aliases = new HashSet<>(Arrays.asList(aliases));
this.requiredType = requiredType; this.requiredType = requiredType;
} }
@ -82,7 +84,7 @@ public abstract class Command extends CommandManager {
this.description = declaration.description(); this.description = declaration.description();
this.usage = declaration.usage(); this.usage = declaration.usage();
this.permission = declaration.permission(); this.permission = declaration.permission();
this.aliases = declaration.aliases(); this.aliases = new HashSet<>(Arrays.asList(declaration.aliases()));
this.requiredType = declaration.requiredType(); this.requiredType = declaration.requiredType();
this.category = declaration.category(); this.category = declaration.category();
} }
@ -126,7 +128,7 @@ public abstract class Command extends CommandManager {
return this.description; return this.description;
} }
final public String[] getAliases() { final public Set<String> getAliases() {
return this.aliases; return this.aliases;
} }

View File

@ -0,0 +1,19 @@
package com.intellectualsites.commands;
import com.intellectualcrafters.plot.config.C;
import com.intellectualsites.commands.Argument;
import com.intellectualsites.commands.Command;
import com.intellectualsites.commands.CommandManager;
public interface CommandCaller<T> {
boolean hasPermission(String permission);
void message(String message);
T getSuperCaller();
void message(C c, String ... args);
void sendRequiredArgumentsList(CommandManager manager, Command cmd, Argument[] required);
}

View File

@ -1,16 +1,16 @@
package com.intellectualsites.commands; package com.intellectualsites.commands;
import com.intellectualsites.commands.callers.CommandCaller;
import com.intellectualsites.commands.util.StringUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import com.intellectualsites.commands.util.StringUtil;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class CommandManager { public class CommandManager {
protected final List<Command> commands; protected final ConcurrentHashMap<String, Command> commands;
protected final Character initialCharacter; protected final Character initialCharacter;
public CommandManager() { public CommandManager() {
@ -18,12 +18,18 @@ public class CommandManager {
} }
public CommandManager(Character initialCharacter, List<Command> commands) { public CommandManager(Character initialCharacter, List<Command> commands) {
this.commands = Collections.synchronizedList(commands); this.commands = new ConcurrentHashMap<>();
for (Command command : commands) {
addCommand(command);
}
this.initialCharacter = initialCharacter; this.initialCharacter = initialCharacter;
} }
final public void addCommand(final Command command) { final public void addCommand(final Command command) {
this.commands.add(command); this.commands.put(command.getCommand().toLowerCase(), command);
for (String alias : command.getAliases()) {
this.commands.put(alias.toLowerCase(), command);
}
} }
final public boolean createCommand(final Command command) { final public boolean createCommand(final Command command) {
@ -34,24 +40,24 @@ public class CommandManager {
return false; return false;
} }
if (command.getCommand() != null) { if (command.getCommand() != null) {
commands.add(command); addCommand(command);
return true; return true;
} }
return false; return false;
} }
final public List<Command> getCommands() { final public Collection<Command> getCommands() {
return this.commands; return this.commands.values();
} }
public int handle(CommandCaller caller, String input) { public int handle(CommandCaller caller, String input) {
if (initialCharacter != null && !StringUtil.startsWith(initialCharacter, input)) { if (initialCharacter != null && !StringUtil.startsWith(initialCharacter, input)) {
return CommandHandlingOutput.NOT_COMMAND; return CommandHandlingOutput.NOT_COMMAND;
} }
input = initialCharacter == null ? input : StringUtil.replaceFirst(initialCharacter, input); input = initialCharacter == null ? input : input.substring(1);
String[] parts = input.split(" "); String[] parts = input.split(" ");
String[] args; String[] args;
String command = parts[0]; String command = parts[0].toLowerCase();
if (parts.length == 1) { if (parts.length == 1) {
args = new String[0]; args = new String[0];
} else { } else {
@ -59,12 +65,7 @@ public class CommandManager {
System.arraycopy(parts, 1, args, 0, args.length); System.arraycopy(parts, 1, args, 0, args.length);
} }
Command cmd = null; Command cmd = null;
for (Command c1 : this.commands) { cmd = commands.get(command);
if (c1.getCommand().equalsIgnoreCase(command) || StringUtil.inArray(command, c1.getAliases(), false)) {
cmd = c1;
break;
}
}
if (cmd == null) { if (cmd == null) {
return CommandHandlingOutput.NOT_FOUND; return CommandHandlingOutput.NOT_FOUND;
} }

View File

@ -8,32 +8,6 @@ public class StringUtil {
return !(s == null || s.isEmpty()) && s.toCharArray()[0] == c; return !(s == null || s.isEmpty()) && s.toCharArray()[0] == c;
} }
public static String replaceFirst(char c, String s) {
if (s == null) {
return "";
}
if (s.isEmpty()) {
return s;
}
char[] chars = s.toCharArray();
char[] newChars = new char[chars.length];
int used = 0;
boolean found = false;
for (char cc : chars) {
if (!found && c == cc) {
found = true;
} else {
newChars[used++] = cc;
}
}
if (found) {
chars = new char[newChars.length - 1];
System.arraycopy(newChars, 0, chars, 0, chars.length);
return String.valueOf(chars);
}
return s;
}
public static boolean inArray(String s, String[] a, boolean matchCase) { public static boolean inArray(String s, String[] a, boolean matchCase) {
for (String aS : a) { for (String aS : a) {
if (matchCase) { if (matchCase) {