-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Waypoints #968
Comments
Simple fix by applying the following diff public static void loadWaypoints() {
- waypoints.clear();
try (BufferedReader reader = Files.newBufferedReader(waypointsFile)) {
List<WaypointCategory> waypoints = CODEC.parse(JsonOps.INSTANCE, SkyblockerMod.GSON.fromJson(reader, JsonArray.class)).resultOrPartial(LOGGER::error).orElseThrow();
+ Waypoints.waypoints.clear();
waypoints.forEach(waypointCategory -> Waypoints.waypoints.put(waypointCategory.island(), waypointCategory));
} catch (Exception e) {
LOGGER.error("[Skyblocker Waypoints] Encountered exception while loading waypoints", e);
}
} to Skyblocker/src/main/java/de/hysky/skyblocker/skyblock/waypoint/Waypoints.java Lines 62 to 70 in 3b344cd
|
I completely misunderstood your problem. Please ignore the above fix. The best solution for this is to probably backup the old waypoints file when saving a new one. |
It was also on me, I was not exactly paying attention when applying the diff, oops. eg. public static void saveWaypoints(MinecraftClient client) {
+ if (waypoints.isEmpty()) return;
try (BufferedWriter writer = Files.newBufferedWriter(waypointsFile)) {
JsonElement waypointsJson = CODEC.encodeStart(JsonOps.INSTANCE, List.copyOf(waypoints.values())).resultOrPartial(LOGGER::error).orElseThrow();
SkyblockerMod.GSON.toJson(waypointsJson, writer);
LOGGER.info("[Skyblocker Waypoints] Saved waypoints");
} catch (Exception e) {
LOGGER.error("[Skyblocker Waypoints] Encountered exception while saving waypoints", e);
}
} Sorry if this sounds ridiculous I don't often work in public groups |
Then you can't delete all the waypoints. |
Well based on what I understand of the Waypoint class, it would only delete it from the the MultiMap, which should not effect the actual waypoint file in any way. I probably am just be overthinking this and, yeah honestly keeping a copy is probably the best idea. |
If someone delets all the waypoints, under your proposal, then the file won't get saved. On the next launch, the old waypoints will be loaded again, even though the user has deleted all of them. |
You're absolutely right. Sorry didn't see that far ahead, but based off this it is all the solutions I had in mind. In the end I will just stick to keeping a copy of my stuff, if that is all, feel free to close this issue |
What happened?
Okay this was kind of on me, but at the same time I thought this might be something to address
When loading Waypoints, if it errors, the next time the game is loaded, the entire file is cleared of all waypoints due to overwriting it with the empty Waypoint List that is saved in memory
Screenshots
No response
Log output
No response
Minecraft Version
1.21.0/1.21.1
Skyblocker Version
skyblocker-1.20.6+1.21.2
Additional context
No response
The text was updated successfully, but these errors were encountered: