validators to creative movement controls

This commit is contained in:
gnembon committed 2020-05-13 10:33:43 -03:00
1 parent a4750f7238
commit 9afd1f3211
3 files changed
+22 -17

No files matched your search

+11 -11
View File
@@ -17,17 +17,6 @@ public abstract class Validator<T>
public abstract T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string);
public String description() {return null;}
public static class POSITIVE_NUMBER<T extends Number> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
{
return newValue.doubleValue() > 0 ? newValue : null;
}
@Override
public String description() { return "Must be a positive number"; }
}
public static class _COMMAND<T> extends Validator<T>
{
@Override
@@ -119,4 +108,15 @@ public abstract class Validator<T>
@Override
public String description() { return "Must be a positive number";}
}
public static class PROBABILITY <T extends Number> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
{
return (newValue.doubleValue() >= 0 && newValue.doubleValue() <= 1 )? newValue : null;
}
@Override
public String description() { return "Must be between 0 and 1";}
}
}