Skip to content

Commit 7704d0d

Browse files
Fix empty categories being checked (SkyblockerMod#851)
1 parent 8288c1b commit 7704d0d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: src/main/java/de/hysky/skyblocker/skyblock/waypoint/WaypointsListWidget.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void updateEntries() {
8585

8686
void updateButtons() {
8787
for (Entry<AbstractWaypointEntry> entry : children()) {
88-
if (entry instanceof WaypointCategoryEntry categoryEntry && categoryEntry.enabled.isChecked() != categoryEntry.category.waypoints().stream().allMatch(screen::isEnabled)) {
88+
if (entry instanceof WaypointCategoryEntry categoryEntry && categoryEntry.enabled.isChecked() != categoryEntry.shouldBeChecked()) {
8989
((CheckboxWidgetAccessor) categoryEntry.enabled).setChecked(!categoryEntry.enabled.isChecked());
9090
} else if (entry instanceof WaypointEntry waypointEntry && waypointEntry.enabled.isChecked() != screen.isEnabled(waypointEntry.waypoint)) {
9191
waypointEntry.enabled.onPress();
@@ -114,7 +114,7 @@ public WaypointCategoryEntry() {
114114

115115
public WaypointCategoryEntry(WaypointCategory category) {
116116
this.category = category;
117-
enabled = CheckboxWidget.builder(Text.literal(""), client.textRenderer).checked(!category.waypoints().isEmpty() && category.waypoints().stream().allMatch(screen::isEnabled)).callback((checkbox, checked) -> category.waypoints().forEach(waypoint -> screen.enabledChanged(waypoint, checked))).build();
117+
enabled = CheckboxWidget.builder(Text.literal(""), client.textRenderer).checked(shouldBeChecked()).callback((checkbox, checked) -> category.waypoints().forEach(waypoint -> screen.enabledChanged(waypoint, checked))).build();
118118
nameField = new TextFieldWidget(client.textRenderer, 70, 20, Text.literal("Name"));
119119
nameField.setText(category.name());
120120
nameField.setChangedListener(this::updateName);
@@ -153,6 +153,10 @@ public List<? extends Element> children() {
153153
return children;
154154
}
155155

156+
private boolean shouldBeChecked() {
157+
return !category.waypoints().isEmpty() && category.waypoints().stream().allMatch(screen::isEnabled);
158+
}
159+
156160
private void updateName(String name) {
157161
int index = waypoints.indexOf(category);
158162
category = category.withName(name);

0 commit comments

Comments
 (0)