Skip to content

Commit 7a5e7a7

Browse files
committed
Fixed BooleanElement
1 parent 39902d4 commit 7a5e7a7

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main/java/me/tom/sparse/spigot/chat/menu/element/BooleanElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void setTrueColor(ChatColor trueColor)
104104

105105
public int getWidth()
106106
{
107-
return 8 + (showText ? ChatMenuAPI.getWidth(" " + value) : 0);
107+
return 8 + (showText ? ChatMenuAPI.getWidth(" " + value.current()) : 0);
108108
}
109109

110110
public int getHeight()

src/main/java/me/tom/sparse/spigot/chat/util/State.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,27 @@ public void onChange(Consumer<State<V>> changeCallback)
8383
{
8484
this.changeCallback = changeCallback;
8585
}
86+
87+
public boolean equals(Object o)
88+
{
89+
if(this == o) return true;
90+
if(!(o instanceof State)) return false;
91+
92+
State<?> state = (State<?>) o;
93+
94+
return current != null ? current.equals(state.current) : state.current == null;
95+
}
96+
97+
public int hashCode()
98+
{
99+
return current != null ? current.hashCode() : 0;
100+
}
101+
102+
public String toString()
103+
{
104+
return "State{" +
105+
"current=" + current +
106+
", previous=" + previous +
107+
'}';
108+
}
86109
}

0 commit comments

Comments
 (0)