diff options
author | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-06-04 16:08:18 +0300 |
---|---|---|
committer | Juuz <6596629+Juuxel@users.noreply.github.com> | 2021-06-04 16:08:18 +0300 |
commit | 9ab901717e430a48db6e30d5117dd28f15ff8f72 (patch) | |
tree | d255710168ffb0e692919c9f173cad0a1aac9d40 | |
parent | fdaa5276124335b02ce5631197661f2aa90d165f (diff) | |
download | LibGui-9ab901717e430a48db6e30d5117dd28f15ff8f72.tar.gz LibGui-9ab901717e430a48db6e30d5117dd28f15ff8f72.tar.bz2 LibGui-9ab901717e430a48db6e30d5117dd28f15ff8f72.zip |
Make WBar.validate safe to call multiple times
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java | 4 | ||||
-rw-r--r-- | src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java index 1b45a5a..60fb7a9 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java @@ -57,6 +57,7 @@ public class WBar extends WWidget { */ protected int maxValue; protected PropertyDelegate properties; + private boolean manuallySetProperties = false; protected final Direction direction; protected String tooltipLabel; protected Text tooltipTextComponent; @@ -197,7 +198,7 @@ public class WBar extends WWidget { @Override public void validate(GuiDescription host) { super.validate(host); - if (properties==null) properties = host.getPropertyDelegate(); + if (properties==null || !manuallySetProperties) properties = host.getPropertyDelegate(); } /** @@ -221,6 +222,7 @@ public class WBar extends WWidget { */ public WBar setProperties(PropertyDelegate properties) { this.properties = properties; + manuallySetProperties = properties != null; return this; } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java index d94a4b9..1091201 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java @@ -370,7 +370,7 @@ public class WWidget { if (host != null) { this.host = host; } else { - LOGGER.warn("Validating {} with a null host", this); + LOGGER.warn("Validating {} with a null host", this); } } |