diff --git a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java index 83df30b6..599a61e9 100644 --- a/src/com/massivecraft/massivecore/cmd/MassiveCommand.java +++ b/src/com/massivecraft/massivecore/cmd/MassiveCommand.java @@ -1083,23 +1083,26 @@ public class MassiveCommand public T readArgAt(int idx) throws MassiveException { if ( ! this.hasArgSettingForIndex(idx)) throw new IllegalArgumentException(idx + " is out of range. ArgSettings size: " + this.getArgSettings().size()); + if ( ! this.argIsSet(idx)) throw new IllegalArgumentException("Trying to access arg: " + idx + " but that is not set."); + String str = this.argAt(idx); - return this.readArgFrom(str, (AR)this.getArgSettings().get(idx).getReader()); + return this.readArgFrom(str, (AR) this.getArgReader(idx)); } @SuppressWarnings("unchecked") public T readArgAt(int idx, T defaultNotSet) throws MassiveException { if ( ! this.hasArgSettingForIndex(idx)) throw new IllegalArgumentException(idx + " is out of range. ArgSettings size: " + this.getArgSettings().size()); + if ( ! this.argIsSet(idx)) return defaultNotSet; + String str = this.argAt(idx); - return this.readArgFrom(str, (AR)this.getArgSettings().get(idx).getReader(), defaultNotSet); + return this.readArgFrom(str, (AR)this.getArgReader(idx), defaultNotSet); } // Core Logic public T readArgFrom(AR argReader) throws MassiveException { - if (argReader == null) throw new IllegalArgumentException("argReader is null"); return this.readArgFrom(null, argReader); }