diff --git a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java index 97e6d6cd..36e418a5 100644 --- a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java +++ b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java @@ -18,7 +18,6 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import com.massivecraft.massivecore.Lang; -import com.massivecraft.massivecore.MassiveCore; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.cmd.arg.AR; import com.massivecraft.massivecore.cmd.req.Req; @@ -72,12 +71,6 @@ public class MassiveCommand } } - @Deprecated - public void register() - { - this.register(MassiveCore.get()); - } - public Plugin register(Plugin plugin) { return registry.put(this, plugin); @@ -344,29 +337,11 @@ public class MassiveCommand return this.addArg(new ArgSetting(reader, name)); } - // FIELD: requiredArgs - // These args must always be sent - @Deprecated protected List requiredArgs; - @Deprecated public List getRequiredArgs() { return this.requiredArgs; } - @Deprecated public void setRequiredArgs(List requiredArgs) { this.requiredArgs = requiredArgs; } - - @Deprecated public void addRequiredArg(String arg) { this.requiredArgs.add(arg); } - - // FIELD: optionalArgs - // These args are optional - @Deprecated protected Map optionalArgs; - @Deprecated public Map getOptionalArgs() { return this.optionalArgs; } - @Deprecated public void setOptionalArgs(Map optionalArgs) { this.optionalArgs = optionalArgs; } - - @Deprecated public void addOptionalArg(String arg, String def) { this.optionalArgs.put(arg, def); } - // FIELD: errorOnToManyArgs // Should an error be thrown if "too many" args are sent. protected boolean givingErrorOnTooManyArgs; public boolean isGivingErrorOnTooManyArgs() { return this.givingErrorOnTooManyArgs; } public void setGivingErrorOnTooManyArgs(boolean val) { this.givingErrorOnTooManyArgs = val; } - @Deprecated public boolean getErrorOnToManyArgs() { return this.isGivingErrorOnTooManyArgs(); } - @Deprecated public void setErrorOnToManyArgs(boolean val) { this.setGivingErrorOnTooManyArgs(val); } // FIELD concatFrom // From which arg should the be concatenated. @@ -503,19 +478,13 @@ public class MassiveCommand public boolean senderIsConsole; // -------------------------------------------- // - // BACKWARDS COMPAT + // ARG AMOUNTS // -------------------------------------------- // - public boolean isUsingNewArgSystem() - { - return ! this.getArgSettings().isEmpty(); - } - public int getRequiredArgsAmountFor(CommandSender sender) { - if ( ! this.isUsingNewArgSystem()) return this.getRequiredArgs().size(); - int ret = 0; + for (ArgSetting setting : this.getArgSettings()) { if (setting.isRequiredFor(sender)) ret++; @@ -526,9 +495,8 @@ public class MassiveCommand public int getOptionalArgsAmountFor(CommandSender sender) { - if ( ! this.isUsingNewArgSystem()) return this.getOptionalArgs().size(); - int ret = 0; + for (ArgSetting setting : this.getArgSettings()) { if (setting.isOptionalFor(sender)) ret++; @@ -554,9 +522,6 @@ public class MassiveCommand this.argSettings = new ArrayList>(); - this.requiredArgs = new ArrayList(); - this.optionalArgs = new LinkedHashMap(); - this.requirements = new ArrayList(); this.givingErrorOnTooManyArgs = true; @@ -683,8 +648,6 @@ public class MassiveCommand { // So if there is too many, or too few args. We can't do much here. if ( ! this.isArgsValid(args)) return args; - // We can't do anything with the old arg system. - if ( ! this.isUsingNewArgSystem()) return args; String[] ret = new String[this.getArgSettings().size()]; @@ -867,8 +830,9 @@ public class MassiveCommand } // -------------------------------------------- // - // HELP AND USAGE INFORMATION + // USAGE TEMPLATE // -------------------------------------------- // + // TODO: Misspelled "Useage" public static final Mson USAGE_TEMPLATE_CORE = Mson.mson("/").color(ChatColor.AQUA); @@ -942,33 +906,10 @@ public class MassiveCommand protected List getArgUseagesFor(CommandSender sender) { List ret = new MassiveList(); - if (this.isUsingNewArgSystem()) + + for (ArgSetting setting : this.getArgSettings()) { - for (ArgSetting setting : this.getArgSettings()) - { - ret.add(setting.getUseageTemplateDisplayFor(sender)); - } - } - else - { - for (String requiredArg : this.getRequiredArgs()) - { - ret.add(mson("<" + requiredArg + ">")); - } - - for (Entry optionalArg : this.getOptionalArgs().entrySet()) - { - String val = optionalArg.getValue(); - if (val == null) - { - val = ""; - } - else - { - val = "=" + val; - } - ret.add(mson("[" + optionalArg.getKey() + val + "]")); - } + ret.add(setting.getUseageTemplateDisplayFor(sender)); } return ret; @@ -994,6 +935,10 @@ public class MassiveCommand return getUseageTemplate(false); } + // -------------------------------------------- // + // GET COMMAND LINE + // -------------------------------------------- // + public String getCommandLine(String... args) { return getCommandLine(Arrays.asList(args)); @@ -1050,10 +995,6 @@ public class MassiveCommand { return this.getTabCompletionsSub(args, sender); } - else if ( ! this.isUsingNewArgSystem()) - { - return Collections.emptyList(); - } else { return this.getTabCompletionsArg(args, sender); @@ -1270,7 +1211,8 @@ public class MassiveCommand return readArgAt(idx); } - // We don't even need this anymore + // TODO: Some of these are still used by external plugins. + // TODO: Fix those plugins. @Deprecated public T readArgFrom(AR argReader) throws MassiveException @@ -1292,77 +1234,4 @@ public class MassiveCommand return this.readArgFrom(str, argReader); } - // -------------------------------------------- // - // OLD ARGUMENT READERS - // -------------------------------------------- // - - // arg - - @Deprecated - public String arg(int idx) - { - return this.argAt(idx); - } - - @Deprecated - public T arg(int idx, AR argReader) throws MassiveException - { - String str = this.arg(idx); - return this.arg(str, argReader); - } - - @Deprecated - public T arg(int idx, AR argReader, T defaultNotSet) throws MassiveException - { - String str = this.arg(idx); - return this.arg(str, argReader, defaultNotSet); - } - - // argConcatFrom - - @Deprecated - public String argConcatFrom(int idx) - { - if ( ! this.argIsSet(idx)) return null; - int from = idx; - int to = this.getArgs().size(); - if (to <= from) return ""; - return Txt.implode(this.getArgs().subList(from, to), " "); - } - - @Deprecated - public T argConcatFrom(int idx, AR argReader) throws MassiveException - { - String str = this.argConcatFrom(idx); - return this.arg(str, argReader); - } - - @Deprecated - public T argConcatFrom(int idx, AR argReader, T defaultNotSet) throws MassiveException - { - String str = this.argConcatFrom(idx); - return this.arg(str, argReader, defaultNotSet); - } - - // Core & Other - - @Deprecated - public T arg(AR argReader) throws MassiveException - { - return this.arg(null, argReader); - } - - @Deprecated - public T arg(String str, AR argReader) throws MassiveException - { - return argReader.read(str, this.sender); - } - - @Deprecated - public T arg(String str, AR argReader, T defaultNotSet) throws MassiveException - { - if (str == null) return defaultNotSet; - return this.arg(str, argReader); - } - }