Skip to content
This repository was archived by the owner on Feb 9, 2022. It is now read-only.

Commit fbc7a0a

Browse files
ExplvExplv
authored andcommitted
Updating world selector logic to make sure latest world detail is always used
1 parent 7561857 commit fbc7a0a

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

osbot_manager/src/bot_parameters/configuration/World.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import org.jsoup.select.Elements;
88

99
import java.io.IOException;
10+
import java.io.ObjectInputStream;
11+
import java.io.ObjectOutputStream;
1012
import java.io.Serializable;
1113
import java.util.ArrayList;
1214
import java.util.Comparator;
@@ -27,9 +29,9 @@ public class World implements BotParameter, Serializable {
2729
return Integer.compare(w1.getNumber(), w2.getNumber());
2830
};
2931

30-
private final WorldType type;
31-
private final int number;
32-
private final String detail;
32+
private WorldType type;
33+
private int number;
34+
private String detail;
3335

3436
public World(final WorldType type, final int number, final String detail) {
3537
this.type = type;
@@ -49,6 +51,29 @@ public final String getDetail() {
4951
return detail;
5052
}
5153

54+
private void writeObject(ObjectOutputStream stream) throws IOException {
55+
stream.writeObject(getType());
56+
stream.writeInt(getNumber());
57+
stream.writeObject(getDetail());
58+
}
59+
60+
private void readObject(ObjectInputStream stream) throws ClassNotFoundException, IOException {
61+
type = (WorldType) stream.readObject();
62+
number = stream.readInt();
63+
detail = (String) stream.readObject();
64+
}
65+
66+
@Override
67+
public boolean equals(Object other) {
68+
if (!(other instanceof World)) {
69+
return false;
70+
}
71+
72+
World otherWorld = (World) other;
73+
74+
return getType() == otherWorld.getType() && getNumber() == otherWorld.getNumber();
75+
}
76+
5277
@Override
5378
public String toString() {
5479
String worldStr = getType().toString() + " " + getNumber();

osbot_manager/src/gui/dialogues/world_selector_dialog/WorldSelectorDialog.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import bot_parameters.configuration.World;
44
import bot_parameters.configuration.WorldType;
5+
import gui.dialogues.error_dialog.ExceptionDialog;
56
import javafx.collections.FXCollections;
67
import javafx.collections.ListChangeListener;
78
import javafx.collections.ObservableList;
@@ -110,7 +111,18 @@ public WorldSelectorDialog() {
110111
}
111112

112113
public void setSelectedWorlds(final ObservableList<World> selectedWorlds) {
113-
this.selectedWorlds.setAll(selectedWorlds);
114+
this.selectedWorlds.clear();
115+
116+
for (final World world : selectedWorlds) {
117+
// We get the world from the list of latest worlds, in case the world detail has changed
118+
int latestWorldIndex = allWorlds.indexOf(world);
119+
if (latestWorldIndex == -1) {
120+
continue;
121+
} else {
122+
this.selectedWorlds.add(allWorlds.get(latestWorldIndex));
123+
}
124+
}
125+
114126
this.availableWorlds.setAll(allWorlds);
115127
this.availableWorlds.removeAll(selectedWorlds);
116128
}

osbot_manager/src/main/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class Version {
1010

11-
private final static float currentVersion = 8.1f;
11+
private final static float currentVersion = 8.2f;
1212

1313
public static boolean isLatestVersion() {
1414
try {

0 commit comments

Comments
 (0)