From a44e16a6dc3795db133aee1806ef5455a79ed35a Mon Sep 17 00:00:00 2001 From: Estecka Date: Thu, 2 Nov 2023 11:28:47 +0100 Subject: [PATCH] Fix Doubles not being editable in the game-rule menu (#3397) * Fix double gamerules rules not being editable in menu * Updated `validate`'s javadoc --- .../fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java | 7 ++++++- .../fabric/api/gamerule/v1/rule/ValidateableRule.java | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java index aee650bf49..ce3f6b9b61 100644 --- a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java +++ b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/DoubleRule.java @@ -113,7 +113,12 @@ public boolean validate(String value) { try { final double d = Double.parseDouble(value); - return this.inBounds(d); + if (!this.inBounds(d)) { + return false; + } + + this.value = d; + return true; } catch (NumberFormatException ignored) { return false; } diff --git a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/ValidateableRule.java b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/ValidateableRule.java index bf2fda2f73..6f7284de99 100644 --- a/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/ValidateableRule.java +++ b/fabric-game-rule-api-v1/src/main/java/net/fabricmc/fabric/api/gamerule/v1/rule/ValidateableRule.java @@ -23,9 +23,10 @@ public interface ValidateableRule { /** * 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 - * @return true if the value can be accepted. + * @return true if the value was accepted. */ boolean validate(String value); }