summaryrefslogtreecommitdiff
path: root/dicore3/command/src/main/java/io/dico/dicore/command/annotation
diff options
context:
space:
mode:
Diffstat (limited to 'dicore3/command/src/main/java/io/dico/dicore/command/annotation')
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/BigRange.java104
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/Cmd.java32
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/CmdParamType.java54
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java70
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/Desc.java54
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/Flag.java32
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/GenerateCommands.java28
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/GroupMatchedCommands.java136
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/NamedArg.java28
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/PreprocessArgs.java34
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/Range.java134
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireConsole.java22
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireParameters.java28
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePermissions.java66
-rw-r--r--dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePlayer.java22
15 files changed, 422 insertions, 422 deletions
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/BigRange.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/BigRange.java
index 467ba4b..b0277c6 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/BigRange.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/BigRange.java
@@ -1,52 +1,52 @@
-package io.dico.dicore.command.annotation;
-
-import io.dico.dicore.command.parameter.type.ParameterConfig;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-public @interface BigRange {
- Class<?> MEMORY_CLASS = Memory.class;
- ParameterConfig<BigRange, Memory> CONFIG = ParameterConfig.getMemoryClassFromField(BigRange.class);
- Memory DEFAULT = new Memory("MIN", "MAX", "0");
-
- String min() default "MIN";
-
- String max() default "MAX";
-
- String defaultValue() default "0";
-
- class Memory {
- private final String min;
- private final String max;
- private final String defaultValue;
-
- public Memory(BigRange range) {
- this(range.min(), range.max(), range.defaultValue());
- }
-
- public Memory(String min, String max, String defaultValue) {
- this.min = min;
- this.max = max;
- this.defaultValue = defaultValue;
- }
-
- public String min() {
- return min;
- }
-
- public String max() {
- return max;
- }
-
- public String defaultValue() {
- return defaultValue;
- }
-
- }
-
-}
+package io.dico.dicore.command.annotation;
+
+import io.dico.dicore.command.parameter.type.ParameterConfig;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+public @interface BigRange {
+ Class<?> MEMORY_CLASS = Memory.class;
+ ParameterConfig<BigRange, Memory> CONFIG = ParameterConfig.getMemoryClassFromField(BigRange.class);
+ Memory DEFAULT = new Memory("MIN", "MAX", "0");
+
+ String min() default "MIN";
+
+ String max() default "MAX";
+
+ String defaultValue() default "0";
+
+ class Memory {
+ private final String min;
+ private final String max;
+ private final String defaultValue;
+
+ public Memory(BigRange range) {
+ this(range.min(), range.max(), range.defaultValue());
+ }
+
+ public Memory(String min, String max, String defaultValue) {
+ this.min = min;
+ this.max = max;
+ this.defaultValue = defaultValue;
+ }
+
+ public String min() {
+ return min;
+ }
+
+ public String max() {
+ return max;
+ }
+
+ public String defaultValue() {
+ return defaultValue;
+ }
+
+ }
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Cmd.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Cmd.java
index 109490a..dfad0bb 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Cmd.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Cmd.java
@@ -1,16 +1,16 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface Cmd {
-
- String value();
-
- String[] aliases() default {};
-
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Cmd {
+
+ String value();
+
+ String[] aliases() default {};
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CmdParamType.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CmdParamType.java
index ea51e44..3eb2d53 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CmdParamType.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CmdParamType.java
@@ -1,27 +1,27 @@
-package io.dico.dicore.command.annotation;
-
-import io.dico.dicore.command.parameter.type.IParameterTypeSelector;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to mark methods that register a parameter type to the localized selector for use in reflective commands.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface CmdParamType {
-
- /**
- * If this flag is set, the type is registered without its annotation type.
- * As a result, the {@link IParameterTypeSelector} is more likely to select it (faster).
- * This is irrelevant if there is no annotation type or param config.
- *
- * @return true if this parameter type should be registered without its annotation type too
- */
- boolean infolessAlias() default false;
-
-}
-
+package io.dico.dicore.command.annotation;
+
+import io.dico.dicore.command.parameter.type.IParameterTypeSelector;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to mark methods that register a parameter type to the localized selector for use in reflective commands.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface CmdParamType {
+
+ /**
+ * If this flag is set, the type is registered without its annotation type.
+ * As a result, the {@link IParameterTypeSelector} is more likely to select it (faster).
+ * This is irrelevant if there is no annotation type or param config.
+ *
+ * @return true if this parameter type should be registered without its annotation type too
+ */
+ boolean infolessAlias() default false;
+
+}
+
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java
index 868884c..7983997 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/CommandAnnotationUtils.java
@@ -1,35 +1,35 @@
-package io.dico.dicore.command.annotation;
-
-public class CommandAnnotationUtils {
-
- /**
- * Get the short description from a {@link Desc} annotation.
- * If {@link Desc#shortVersion()} is given, returns that.
- * Otherwise, returns the first element of {@link Desc#value()}
- * If neither is available, returns null.
- *
- * @param desc the annotation
- * @return the short description
- */
- public static String getShortDescription(Desc desc) {
- String descString;
- if (desc == null) {
- descString = null;
- } else if (!desc.shortVersion().isEmpty()) {
- descString = desc.shortVersion();
- } else if (desc.value().length > 0) {
- descString = desc.value()[0];
- if (desc.value().length > 1) {
- //System.out.println("[Command Warning] Multiline descriptions not supported here. Keep it short for: " + targetIdentifier);
- }
- if (descString != null && descString.isEmpty()) {
- descString = null;
- }
- } else {
- descString = null;
- }
-
- return descString;
- }
-
-}
+package io.dico.dicore.command.annotation;
+
+public class CommandAnnotationUtils {
+
+ /**
+ * Get the short description from a {@link Desc} annotation.
+ * If {@link Desc#shortVersion()} is given, returns that.
+ * Otherwise, returns the first element of {@link Desc#value()}
+ * If neither is available, returns null.
+ *
+ * @param desc the annotation
+ * @return the short description
+ */
+ public static String getShortDescription(Desc desc) {
+ String descString;
+ if (desc == null) {
+ descString = null;
+ } else if (!desc.shortVersion().isEmpty()) {
+ descString = desc.shortVersion();
+ } else if (desc.value().length > 0) {
+ descString = desc.value()[0];
+ if (desc.value().length > 1) {
+ //System.out.println("[Command Warning] Multiline descriptions not supported here. Keep it short for: " + targetIdentifier);
+ }
+ if (descString != null && descString.isEmpty()) {
+ descString = null;
+ }
+ } else {
+ descString = null;
+ }
+
+ return descString;
+ }
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Desc.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Desc.java
index 0011fb8..ab3e555 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Desc.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Desc.java
@@ -1,27 +1,27 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Desc {
-
- /**
- * Multiline description if {@link #shortVersion} is set.
- * Otherwise, this should be an array with one element (aka, you don't have to add array brackets).
- *
- * @return the multiline description.
- * @see CommandAnnotationUtils#getShortDescription(Desc)
- */
- String[] value();
-
- /**
- * Short description, use if {@link #value} is multi-line.
- * To get a short description from a {@link Desc}, you should use {@link CommandAnnotationUtils#getShortDescription(Desc)}
- *
- * @return short description
- * @see CommandAnnotationUtils#getShortDescription(Desc)
- */
- String shortVersion() default "";
-
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Desc {
+
+ /**
+ * Multiline description if {@link #shortVersion} is set.
+ * Otherwise, this should be an array with one element (aka, you don't have to add array brackets).
+ *
+ * @return the multiline description.
+ * @see CommandAnnotationUtils#getShortDescription(Desc)
+ */
+ String[] value();
+
+ /**
+ * Short description, use if {@link #value} is multi-line.
+ * To get a short description from a {@link Desc}, you should use {@link CommandAnnotationUtils#getShortDescription(Desc)}
+ *
+ * @return short description
+ * @see CommandAnnotationUtils#getShortDescription(Desc)
+ */
+ String shortVersion() default "";
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Flag.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Flag.java
index 31a47dd..edc50ef 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Flag.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Flag.java
@@ -1,16 +1,16 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-public @interface Flag {
-
- String value() default "";
-
- String permission() default "";
-
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+public @interface Flag {
+
+ String value() default "";
+
+ String permission() default "";
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/GenerateCommands.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/GenerateCommands.java
index 9b7164d..eeff351 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/GenerateCommands.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/GenerateCommands.java
@@ -1,14 +1,14 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface GenerateCommands {
-
- String[] value() default {"help"};
-
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface GenerateCommands {
+
+ String[] value() default {"help"};
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/GroupMatchedCommands.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/GroupMatchedCommands.java
index 53e3e9e..de89e00 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/GroupMatchedCommands.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/GroupMatchedCommands.java
@@ -1,68 +1,68 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to define sub-groups of the group registered reflectively from all methods in a class.
- * <p>
- * Commands are selected for grouping by matching their method's names to a regular expression.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface GroupMatchedCommands {
-
- @Retention(RetentionPolicy.RUNTIME)
- @interface GroupEntry {
-
- /**
- * Regular expression to match method names for this group
- * Must be non-empty
- *
- * @return the regular expression
- */
- String regex();
-
- /**
- * The name or main key of the sub-group or address
- * Must be non-empty
- *
- * @return the group name
- */
- String group();
-
- /**
- * The aliases for the sub-group
- *
- * @return the group aliases
- */
- String[] groupAliases() default {};
-
- /**
- * Generated (predefined) commands for the sub-group
- */
- String[] generatedCommands() default {};
-
- /**
- * @see Desc
- */
- String[] description() default {};
-
- /**
- * @see Desc
- */
- String shortDescription() default "";
- }
-
- /**
- * The defined groups.
- * If a method name matches the regex of multiple groups,
- * groups are prioritized by the order in which they appear in this array.
- *
- * @return the defined groups
- */
- GroupEntry[] value();
-
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation to define sub-groups of the group registered reflectively from all methods in a class.
+ * <p>
+ * Commands are selected for grouping by matching their method's names to a regular expression.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface GroupMatchedCommands {
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @interface GroupEntry {
+
+ /**
+ * Regular expression to match method names for this group
+ * Must be non-empty
+ *
+ * @return the regular expression
+ */
+ String regex();
+
+ /**
+ * The name or main key of the sub-group or address
+ * Must be non-empty
+ *
+ * @return the group name
+ */
+ String group();
+
+ /**
+ * The aliases for the sub-group
+ *
+ * @return the group aliases
+ */
+ String[] groupAliases() default {};
+
+ /**
+ * Generated (predefined) commands for the sub-group
+ */
+ String[] generatedCommands() default {};
+
+ /**
+ * @see Desc
+ */
+ String[] description() default {};
+
+ /**
+ * @see Desc
+ */
+ String shortDescription() default "";
+ }
+
+ /**
+ * The defined groups.
+ * If a method name matches the regex of multiple groups,
+ * groups are prioritized by the order in which they appear in this array.
+ *
+ * @return the defined groups
+ */
+ GroupEntry[] value();
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/NamedArg.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/NamedArg.java
index fa42e6b..d84358b 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/NamedArg.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/NamedArg.java
@@ -1,14 +1,14 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-public @interface NamedArg {
-
- String value();
-
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+public @interface NamedArg {
+
+ String value();
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/PreprocessArgs.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/PreprocessArgs.java
index 57f53bd..32b0723 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/PreprocessArgs.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/PreprocessArgs.java
@@ -1,17 +1,17 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-@Deprecated
-public @interface PreprocessArgs {
-
- String tokens() default "\"\"";
-
- char escapeChar() default '\\';
-
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@Deprecated
+public @interface PreprocessArgs {
+
+ String tokens() default "\"\"";
+
+ char escapeChar() default '\\';
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Range.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Range.java
index 3fd4160..98aec22 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Range.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/Range.java
@@ -1,67 +1,67 @@
-package io.dico.dicore.command.annotation;
-
-import io.dico.dicore.command.CommandException;
-import io.dico.dicore.command.Validate;
-import io.dico.dicore.command.parameter.type.ParameterConfig;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-public @interface Range {
- Class<?> MEMORY_CLASS = Memory.class;
- ParameterConfig<Range, Memory> CONFIG = ParameterConfig.getMemoryClassFromField(Range.class);
- Memory DEFAULT = new Memory(-Double.MAX_VALUE, Double.MAX_VALUE, 0);
-
- double min() default -Double.MAX_VALUE;
-
- double max() default Double.MAX_VALUE;
-
- double defaultValue() default 0;
-
- class Memory {
- private final double min;
- private final double max;
- private final double defaultValue;
-
- public Memory(Range range) {
- this(range.min(), range.max(), range.defaultValue());
- }
-
- public Memory(double min, double max, double defaultValue) {
- this.min = min;
- this.max = max;
- this.defaultValue = defaultValue;
- }
-
- public double min() {
- return min;
- }
-
- public double max() {
- return max;
- }
-
- public double defaultValue() {
- return defaultValue;
- }
-
- public void validate(Number x, String failMessage) throws CommandException {
- Validate.isTrue(valid(x), failMessage);
- }
-
- public boolean valid(Number x) {
- double d = x.doubleValue();
- return min <= d && d <= max;
- }
-
- public boolean isDefault() {
- return this == DEFAULT || (min == DEFAULT.min && max == DEFAULT.max && defaultValue == DEFAULT.defaultValue);
- }
-
- }
-
-}
+package io.dico.dicore.command.annotation;
+
+import io.dico.dicore.command.CommandException;
+import io.dico.dicore.command.Validate;
+import io.dico.dicore.command.parameter.type.ParameterConfig;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+public @interface Range {
+ Class<?> MEMORY_CLASS = Memory.class;
+ ParameterConfig<Range, Memory> CONFIG = ParameterConfig.getMemoryClassFromField(Range.class);
+ Memory DEFAULT = new Memory(-Double.MAX_VALUE, Double.MAX_VALUE, 0);
+
+ double min() default -Double.MAX_VALUE;
+
+ double max() default Double.MAX_VALUE;
+
+ double defaultValue() default 0;
+
+ class Memory {
+ private final double min;
+ private final double max;
+ private final double defaultValue;
+
+ public Memory(Range range) {
+ this(range.min(), range.max(), range.defaultValue());
+ }
+
+ public Memory(double min, double max, double defaultValue) {
+ this.min = min;
+ this.max = max;
+ this.defaultValue = defaultValue;
+ }
+
+ public double min() {
+ return min;
+ }
+
+ public double max() {
+ return max;
+ }
+
+ public double defaultValue() {
+ return defaultValue;
+ }
+
+ public void validate(Number x, String failMessage) throws CommandException {
+ Validate.isTrue(valid(x), failMessage);
+ }
+
+ public boolean valid(Number x) {
+ double d = x.doubleValue();
+ return min <= d && d <= max;
+ }
+
+ public boolean isDefault() {
+ return this == DEFAULT || (min == DEFAULT.min && max == DEFAULT.max && defaultValue == DEFAULT.defaultValue);
+ }
+
+ }
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireConsole.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireConsole.java
index 362f05c..3510ca8 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireConsole.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireConsole.java
@@ -1,11 +1,11 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface RequireConsole {
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface RequireConsole {
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireParameters.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireParameters.java
index 02f5548..68d5706 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireParameters.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequireParameters.java
@@ -1,14 +1,14 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface RequireParameters {
-
- int value();
-
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface RequireParameters {
+
+ int value();
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePermissions.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePermissions.java
index d2ba782..13d7167 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePermissions.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePermissions.java
@@ -1,33 +1,33 @@
-package io.dico.dicore.command.annotation;
-
-import io.dico.dicore.command.IContextFilter;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * If this annotation is not present, inheriting permissions is default.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface RequirePermissions {
-
- /**
- * Any permissions that must be present on the sender
- *
- * @return an array of permission nodes
- */
- String[] value();
-
- /**
- * Whether permissions should (also) be inherited from the parent.
- * This uses {@link IContextFilter#INHERIT_PERMISSIONS}
- * This is true by default.
- *
- * @return true if permissions should be inherited.
- */
- boolean inherit() default true;
-
-}
+package io.dico.dicore.command.annotation;
+
+import io.dico.dicore.command.IContextFilter;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * If this annotation is not present, inheriting permissions is default.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface RequirePermissions {
+
+ /**
+ * Any permissions that must be present on the sender
+ *
+ * @return an array of permission nodes
+ */
+ String[] value();
+
+ /**
+ * Whether permissions should (also) be inherited from the parent.
+ * This uses {@link IContextFilter#INHERIT_PERMISSIONS}
+ * This is true by default.
+ *
+ * @return true if permissions should be inherited.
+ */
+ boolean inherit() default true;
+
+}
diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePlayer.java b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePlayer.java
index 2165e05..3f447f9 100644
--- a/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePlayer.java
+++ b/dicore3/command/src/main/java/io/dico/dicore/command/annotation/RequirePlayer.java
@@ -1,11 +1,11 @@
-package io.dico.dicore.command.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface RequirePlayer {
-}
+package io.dico.dicore.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface RequirePlayer {
+}