Skip to content

Commit 7b44209

Browse files
committed
Replaced random hash with random positive integer to prevent pattern issues.
1 parent b102acd commit 7b44209

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/main/java/com/github/ygimenez/method/Pages.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1773,7 +1773,6 @@ public static void modifyButtons(Message msg, @Nullable Page p, Map<String, Func
17731773
}
17741774

17751775
List<LayoutComponent> rows = msg.getComponents();
1776-
17771776
for (LayoutComponent lc : rows) {
17781777
List<ItemComponent> row = lc.getComponents();
17791778
for (int i = 0; i < row.size(); i++) {

src/main/java/com/github/ygimenez/model/InteractPage.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import java.util.EnumMap;
1212
import java.util.Map;
13-
import java.util.Objects;
1413

1514
/**
1615
* Class representing either a {@link String}, {@link MessageEmbed} or {@link EmbedCluster} object.
@@ -97,7 +96,7 @@ public Map<Action, String> getCaptions() {
9796
*/
9897
public Button makeButton(@NotNull Action action) {
9998
ButtonStyle style = styles.getOrDefault(action.getStyle(), ButtonStyle.SECONDARY);
100-
String key = action.name() + "." + Objects.hash(Math.random());
99+
String key = action.name() + "." + (int) (Math.random() * Integer.MAX_VALUE);
101100

102101
if (action == Action.NONE) {
103102
return Button.secondary(key, "\u200B").asDisabled();
@@ -115,7 +114,7 @@ public Button makeButton(@NotNull Action action) {
115114
*/
116115
public Button makeButton(@Nullable ButtonId<?> id) {
117116
if (id != null) {
118-
String key = id.extractId() + "." + Objects.hash(Math.random());
117+
String key = id.extractId() + "." + (int) (Math.random() * Integer.MAX_VALUE);
119118

120119
if (id instanceof TextId) {
121120
return Button.of(id.getStyle(), key, id.getLabel());
@@ -124,6 +123,6 @@ public Button makeButton(@Nullable ButtonId<?> id) {
124123
}
125124
}
126125

127-
return Button.secondary(String.valueOf(Objects.hash(Math.random())), "\u200B").asDisabled();
126+
return Button.secondary(String.valueOf((int) (Math.random() * Integer.MAX_VALUE)), "\u200B").asDisabled();
128127
}
129128
}

0 commit comments

Comments
 (0)