diff --git a/src/com/massivecraft/mcore/cmd/MCommand.java b/src/com/massivecraft/mcore/cmd/MCommand.java index 5e776fd6..9cc27c6b 100644 --- a/src/com/massivecraft/mcore/cmd/MCommand.java +++ b/src/com/massivecraft/mcore/cmd/MCommand.java @@ -467,14 +467,7 @@ public abstract class MCommand // ARGUMENT READERS // -------------------------------------------- // - public String argConcatFrom(int idx) - { - if ( ! this.argIsSet(idx)) return null; - int from = idx; - int to = args.size(); - if (to <= from) return ""; - return Txt.implode(this.args.subList(from, to), " "); - } + // argIsSet public boolean argIsSet(int idx) { @@ -485,6 +478,8 @@ public abstract class MCommand return true; } + // arg + public String arg(int idx) { if ( ! this.argIsSet(idx)) return null; @@ -499,6 +494,35 @@ public abstract class MCommand public T arg(int idx, ArgReader argReader, T defaultNotSet) { String str = this.arg(idx); + return this.arg(str, argReader, defaultNotSet); + } + + // argConcatFrom + + public String argConcatFrom(int idx) + { + if ( ! this.argIsSet(idx)) return null; + int from = idx; + int to = args.size(); + if (to <= from) return ""; + return Txt.implode(this.args.subList(from, to), " "); + } + + public T argConcatFrom(int idx, ArgReader argReader) + { + return this.arg(idx, argReader, null); + } + + public T argConcatFrom(int idx, ArgReader argReader, T defaultNotSet) + { + String str = this.argConcatFrom(idx); + return this.arg(str, argReader, defaultNotSet); + } + + // Core & Other + + public T arg(String str, ArgReader argReader, T defaultNotSet) + { if (str == null) return defaultNotSet; ArgResult result = argReader.read(str, this.sender); if (result.hasErrors()) this.msg(result.getErrors()); @@ -507,8 +531,6 @@ public abstract class MCommand public T arg(ArgReader argReader) { - ArgResult result = argReader.read(this.sender); - if (result.hasErrors()) this.msg(result.getErrors()); - return result.getResult(); + return this.arg(null, argReader, null); } }