Fix arbitary command argument order.

This commit is contained in:
Magnus Ulf 2015-05-20 18:15:05 +02:00 committed by Olof Larsson
parent 5e2facae8f
commit a1f2e76221

View File

@ -1144,8 +1144,8 @@ 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<T> setting = (ArgSetting<T>) this.getArgSetting(idx);
@ -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> 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> T readArgFrom(AR<T> argReader) throws MassiveException
{
return this.readArgFrom(null, argReader);
}
@Deprecated
public <T> T readArgFrom(String str, AR<T> argReader) throws MassiveException
{
if (argReader == null) throw new IllegalArgumentException("argReader is null");
return argReader.read(str, this.sender);
}
@Deprecated
public <T> T readArgFrom(String str, AR<T> argReader, T defaultNotSet) throws MassiveException
{
if (str == null) return defaultNotSet;