mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Required = !hasDefault && constant
This commit is contained in:
parent
4215bfc6fe
commit
1b941536d0
@ -30,7 +30,7 @@ public class DecIrisStudio implements DecreeExecutor
|
|||||||
{
|
{
|
||||||
@Decree(description = "Open a new studio world", aliases = "o", sync = true)
|
@Decree(description = "Open a new studio world", aliases = "o", sync = true)
|
||||||
public void open(
|
public void open(
|
||||||
@Param(name = "dimension", defaultValue = "overworld", aliases = "dim", required = true)
|
@Param(name = "dimension", defaultValue = "overworld", aliases = "dim")
|
||||||
IrisDimension dimension,
|
IrisDimension dimension,
|
||||||
@Param(name = "seed", defaultValue = "1337", aliases = "s")
|
@Param(name = "seed", defaultValue = "1337", aliases = "s")
|
||||||
long seed)
|
long seed)
|
||||||
|
@ -57,7 +57,7 @@ public class DecreeParameter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRequired() {
|
public boolean isRequired() {
|
||||||
return param.required();
|
return !hasDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> getNames() {
|
public KList<String> getNames() {
|
||||||
@ -80,11 +80,11 @@ public class DecreeParameter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Object getDefaultValue() throws DecreeParsingException, DecreeWhichException {
|
public Object getDefaultValue() throws DecreeParsingException, DecreeWhichException {
|
||||||
return param.defaultValue().isEmpty() ? null : getHandler().parse(param.defaultValue());
|
return param.defaultValue().equals(Param.REQUIRED) ? null : getHandler().parse(param.defaultValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDefault() {
|
public boolean hasDefault() {
|
||||||
return !param.defaultValue().isEmpty();
|
return !param.defaultValue().equals(Param.REQUIRED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String example() {
|
public String example() {
|
||||||
|
@ -28,6 +28,8 @@ import java.lang.annotation.Target;
|
|||||||
public @interface Param {
|
public @interface Param {
|
||||||
String DEFAULT_DESCRIPTION = "No Description Provided";
|
String DEFAULT_DESCRIPTION = "No Description Provided";
|
||||||
|
|
||||||
|
String REQUIRED = "Required";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main name of this command.<br>
|
* The main name of this command.<br>
|
||||||
* Required parameter.<br>
|
* Required parameter.<br>
|
||||||
@ -35,8 +37,6 @@ public @interface Param {
|
|||||||
*/
|
*/
|
||||||
String name();
|
String name();
|
||||||
|
|
||||||
boolean required() default false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The description of this parameter, used in help-popups in game.<br>
|
* The description of this parameter, used in help-popups in game.<br>
|
||||||
* The default value is {@link #DEFAULT_DESCRIPTION}
|
* The default value is {@link #DEFAULT_DESCRIPTION}
|
||||||
@ -49,7 +49,7 @@ public @interface Param {
|
|||||||
* Which indicates the variable MUST be defined by the person running the command.<br>
|
* Which indicates the variable MUST be defined by the person running the command.<br>
|
||||||
* If you define this, the variable automatically becomes non-required, but can still be set.
|
* If you define this, the variable automatically becomes non-required, but can still be set.
|
||||||
*/
|
*/
|
||||||
String defaultValue() default "";
|
String defaultValue() default REQUIRED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))<br>
|
* The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))<br>
|
||||||
|
@ -327,7 +327,7 @@ public class VirtualDecreeCommand {
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(value == null && !i.getParam().defaultValue().trim().isEmpty())
|
if(value == null && i.hasDefault())
|
||||||
{
|
{
|
||||||
value = i.getDefaultValue();
|
value = i.getDefaultValue();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user