From a1f2e76221c22506613244f0adc0bef0a6370e70 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Wed, 20 May 2015 18:15:05 +0200 Subject: [PATCH] Fix arbitary command argument order. --- .../massivecore/cmd/MassiveCommand.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java index 1a5872b2..775ad075 100644 --- a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java +++ b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java @@ -1143,10 +1143,10 @@ public class MassiveCommand { // Make sure that an ArgSetting is present. if ( ! this.hasArgSettingForIndex(idx)) throw new IllegalArgumentException(idx + " is out of range. ArgSettings size: " + this.getArgSettings().size()); - - // Read the arg here. To ensure counter is incremented. - String arg = this.argAt(idx); - + + // Increment + nextArg = idx + 1; + // Get the setting ArgSetting setting = (ArgSetting) this.getArgSetting(idx); // Return the default in the setting. @@ -1156,30 +1156,42 @@ public class MassiveCommand if ( ! this.argIsSet(idx)) throw new IllegalArgumentException("Trying to access arg: " + idx + " but that is not set."); // Just read the arg normally. + String arg = this.getArgs().get(idx); return setting.getReader().read(arg, sender); } public T readArgAt(int idx, T defaultNotSet) throws MassiveException { // Return the default passed. - if ( ! this.argIsSet(idx)) return defaultNotSet; - + if ( ! this.argIsSet(idx)) + { + // Increment + nextArg = idx + 1; + + // Use default + return defaultNotSet; + } + + // Increment is done in this method return readArgAt(idx); } - // Basic Logic - + // We don't even need this anymore + + @Deprecated public T readArgFrom(AR argReader) throws MassiveException { return this.readArgFrom(null, argReader); } - + + @Deprecated public T readArgFrom(String str, AR argReader) throws MassiveException { if (argReader == null) throw new IllegalArgumentException("argReader is null"); return argReader.read(str, this.sender); } - + + @Deprecated public T readArgFrom(String str, AR argReader, T defaultNotSet) throws MassiveException { if (str == null) return defaultNotSet;