Allow ArgReader to handle case where arg is null.
This commit is contained in:
parent
91f9ec7c0c
commit
cf5751333e
@ -514,7 +514,8 @@ public abstract class MCommand
|
|||||||
|
|
||||||
public <T> T arg(int idx, ArgReader<T> argReader)
|
public <T> T arg(int idx, ArgReader<T> argReader)
|
||||||
{
|
{
|
||||||
return this.arg(idx, argReader, null);
|
String str = this.arg(idx);
|
||||||
|
return this.arg(str, argReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T arg(int idx, ArgReader<T> argReader, T defaultNotSet)
|
public <T> T arg(int idx, ArgReader<T> argReader, T defaultNotSet)
|
||||||
@ -536,7 +537,8 @@ public abstract class MCommand
|
|||||||
|
|
||||||
public <T> T argConcatFrom(int idx, ArgReader<T> argReader)
|
public <T> T argConcatFrom(int idx, ArgReader<T> argReader)
|
||||||
{
|
{
|
||||||
return this.argConcatFrom(idx, argReader, null);
|
String str = this.argConcatFrom(idx);
|
||||||
|
return this.arg(str, argReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T argConcatFrom(int idx, ArgReader<T> argReader, T defaultNotSet)
|
public <T> T argConcatFrom(int idx, ArgReader<T> argReader, T defaultNotSet)
|
||||||
@ -547,18 +549,22 @@ public abstract class MCommand
|
|||||||
|
|
||||||
// Core & Other
|
// Core & Other
|
||||||
|
|
||||||
public <T> T arg(String str, ArgReader<T> argReader, T defaultNotSet)
|
public <T> T arg(ArgReader<T> argReader)
|
||||||
|
{
|
||||||
|
return this.arg(null, argReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T arg(String str, ArgReader<T> argReader)
|
||||||
{
|
{
|
||||||
if (str == null) return defaultNotSet;
|
|
||||||
ArgResult<T> result = argReader.read(str, this.sender);
|
ArgResult<T> result = argReader.read(str, this.sender);
|
||||||
if (result.hasErrors()) this.msg(result.getErrors());
|
if (result.hasErrors()) this.msg(result.getErrors());
|
||||||
return result.getResult();
|
return result.getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T arg(ArgReader<T> argReader)
|
public <T> T arg(String str, ArgReader<T> argReader, T defaultNotSet)
|
||||||
{
|
{
|
||||||
ArgResult<T> result = argReader.read(null, this.sender);
|
if (str == null) return defaultNotSet;
|
||||||
if (result.hasErrors()) this.msg(result.getErrors());
|
return this.arg(str, argReader);
|
||||||
return result.getResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import com.massivecraft.mcore.util.Txt;
|
|||||||
import com.massivecraft.mcore.xlib.gson.Gson;
|
import com.massivecraft.mcore.xlib.gson.Gson;
|
||||||
import com.massivecraft.mcore.xlib.gson.JsonElement;
|
import com.massivecraft.mcore.xlib.gson.JsonElement;
|
||||||
import com.massivecraft.mcore.xlib.gson.JsonObject;
|
import com.massivecraft.mcore.xlib.gson.JsonObject;
|
||||||
import com.massivecraft.mcore.xlib.gson.JsonSyntaxException;
|
|
||||||
|
|
||||||
public class Coll<E> implements CollInterface<E>
|
public class Coll<E> implements CollInterface<E>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user