enabled some client side command interpretation.

This commit is contained in:
gnembon committed 2020-03-30 17:14:16 -03:00
1 parent f3093183ce
commit fe63334509
8 files changed
+74 -7

No files matched your search

+14 -5
View File
@@ -20,6 +20,7 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
public final ImmutableList<String> categories;
public final ImmutableList<String> options;
public boolean isStrict;
public boolean isClient;
public final Class<T> type;
public final List<Validator<T>> validators;
public final T defaultValue;
@@ -46,6 +47,11 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
this.validators.add((Validator<T>) callConstructor(Validator._COMMAND_LEVEL_VALIDATOR.class));
}
}
this.isClient = categories.contains(RuleCategory.CLIENT);
if (this.isClient)
{
this.validators.add(callConstructor(Validator._CLIENT.class));
}
this.defaultValue = get();
this.defaultAsString = convertToString(this.defaultValue);
if (rule.options().length > 0)
@@ -132,16 +138,19 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
value = validator.validate(source, this, value, stringValue);
if (value == null)
{
Messenger.m(source, "r Wrong value for " + name + ": " + stringValue);
if (validator.description()!= null)
Messenger.m(source, "r " + validator.description());
if (source != null)
{
Messenger.m(source, "r Wrong value for " + name + ": " + stringValue);
if (validator.description() != null)
Messenger.m(source, "r " + validator.description());
}
return null;
}
}
if (!value.equals(get()))
if (!value.equals(get()) || source == null)
{
this.field.set(null, value);
CarpetServer.settingsManager.notifyRuleChanged(source, this, stringValue);
if (source != null) CarpetServer.settingsManager.notifyRuleChanged(source, this, stringValue);
}
}
catch (IllegalAccessException e)