From be677085ac10205629c9dfe81df9d960f4a4ab15 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Wed, 6 May 2015 17:07:30 +0200 Subject: [PATCH] Some extra checks. --- src/com/massivecraft/massivecore/cmd/MassiveCommand.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); }