freekin egyptian braces
This commit is contained in:
1 parent
734dc95dab
commit
9bbaaccb3e
12 files changed
+626
-87
No files matched your search
@@ -6,35 +6,44 @@ import net.minecraft.server.command.ServerCommandSource;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public abstract class Validator<T> {
|
||||
public abstract class Validator<T>
|
||||
{
|
||||
/**
|
||||
* Validate the new value of a rule
|
||||
* @return true if valid, false if new rule invalid.
|
||||
*/
|
||||
abstract T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string);
|
||||
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> {
|
||||
public static class POSITIVE_NUMBER<T extends Number> extends Validator<T>
|
||||
{
|
||||
@Override
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string) {
|
||||
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> {
|
||||
public static class _COMMAND<T> extends Validator<T>
|
||||
{
|
||||
@Override
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string) {
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
|
||||
{
|
||||
if (CarpetServer.settingsManager != null)
|
||||
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
|
||||
return newValue;
|
||||
}
|
||||
@Override
|
||||
public String description() { return "It has an accompanying command";}
|
||||
}
|
||||
|
||||
public static class WIP<T> extends Validator<T> {
|
||||
public static class WIP<T> extends Validator<T>
|
||||
{
|
||||
@Override
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string) {
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
|
||||
{
|
||||
if (source != null)
|
||||
try
|
||||
{
|
||||
@@ -43,10 +52,14 @@ public abstract class Validator<T> {
|
||||
catch (NullPointerException ignored) { }
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
public static class _STRICT<T> extends Validator<T> {
|
||||
@Override
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string) {
|
||||
public String description() { return "Its not yet fully implemented - we are working on it";}
|
||||
}
|
||||
public static class _STRICT<T> extends Validator<T>
|
||||
{
|
||||
@Override
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
|
||||
{
|
||||
if (!currentRule.options.contains(string.toLowerCase(Locale.ROOT)))
|
||||
{
|
||||
if (source != null)
|
||||
@@ -63,10 +76,14 @@ public abstract class Validator<T> {
|
||||
}
|
||||
}
|
||||
|
||||
public static class NONNEGATIVE_NUMBER <T extends Number> extends Validator<T> {
|
||||
public static class NONNEGATIVE_NUMBER <T extends Number> extends Validator<T>
|
||||
{
|
||||
@Override
|
||||
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string) {
|
||||
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";}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user