Fix Doubles not being editable in the game-rule menu (#3397)

* Fix double gamerules rules not being editable in menu

* Updated `validate`'s javadoc
This commit is contained in:
Estecka 2023-11-02 11:28:47 +01:00 committed by GitHub
parent 3f30150281
commit a44e16a6dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -113,7 +113,12 @@ public final class DoubleRule extends GameRules.Rule<DoubleRule> implements Vali
try { try {
final double d = Double.parseDouble(value); final double d = Double.parseDouble(value);
return this.inBounds(d); if (!this.inBounds(d)) {
return false;
}
this.value = d;
return true;
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
return false; return false;
} }

View file

@ -23,9 +23,10 @@ package net.fabricmc.fabric.api.gamerule.v1.rule;
public interface ValidateableRule { public interface ValidateableRule {
/** /**
* Validates if a rule can accept the input. * Validates if a rule can accept the input.
* If valid, the input will be set as the rule's value.
* *
* @param value the value to validate * @param value the value to validate
* @return true if the value can be accepted. * @return true if the value was accepted.
*/ */
boolean validate(String value); boolean validate(String value);
} }