Skip to content

Commit

Permalink
fixed bug where discarding changes would still end up with changes ma…
Browse files Browse the repository at this point in the history
…de, made message for saving or discarding 0 changes different
  • Loading branch information
Nettakrim committed Feb 5, 2023
1 parent ff19c8a commit 73a7e8f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class SpaceDataManager {
public ArrayList<StarData> starDatas;
public ArrayList<OrbitingBodyData> orbitingBodyDatas;

private static int changesMade;
private int changesMade;

public SpaceDataManager(ClientWorld world) {
//https://github.com/Johni0702/bobby/blob/d2024a2d63c63d0bccf2eafcab17dd7bf9d26710/src/main/java/de/johni0702/minecraft/bobby/FakeChunkManager.java#L86
Expand Down Expand Up @@ -281,12 +281,12 @@ public void loadOrbitingBodyDatas() {
}

public static void makeChange() {
changesMade++;
SpyglassAstronomyClient.spaceDataManager.changesMade++;
SpyglassAstronomyClient.updateKnowledge();
}

public static int getChanges() {
return changesMade;
return SpyglassAstronomyClient.spaceDataManager.changesMade;
}

public class StarData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,23 @@ public static int removeConstellation(CommandContext<FabricClientCommandSource>
}

public static int saveChanges(CommandContext<FabricClientCommandSource> context) {
SpyglassAstronomyClient.say("commands.admin.changes.save", Integer.toString(SpaceDataManager.getChanges()));
int changes = SpaceDataManager.getChanges();
if (changes != 0) {
SpyglassAstronomyClient.say("commands.admin.changes.save", Integer.toString(changes));
} else {
SpyglassAstronomyClient.say("commands.admin.changes.save.none");
}
SpyglassAstronomyClient.saveSpace();
return 1;
}

public static int discardUnsavedChanges(CommandContext<FabricClientCommandSource> context) {
SpyglassAstronomyClient.say("commands.admin.changes.discard", Integer.toString(SpaceDataManager.getChanges()));
int changes = SpaceDataManager.getChanges();
if (changes != 0) {
SpyglassAstronomyClient.say("commands.admin.changes.discard", Integer.toString(changes));
} else {
SpyglassAstronomyClient.say("commands.admin.changes.discard.none");
}
SpyglassAstronomyClient.discardUnsavedChanges();
return 1;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/spyglass_astronomy/lang/en_gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"spyglass_astronomy.commands.admin.addconstellation" : "Added new Constellation \"%s\"",
"spyglass_astronomy.commands.admin.addconstellation.fail" : "Cannot add new Constellation \"%s\": collision with \"%s\"",
"spyglass_astronomy.commands.admin.changes.discard" : "Discarded %s unsaved Changes",
"spyglass_astronomy.commands.admin.changes.discard.none" : "No unsaved Changes to Discard",
"spyglass_astronomy.commands.admin.changes.save" : "Saved %s unsaved Changes",
"spyglass_astronomy.commands.admin.changes.save.none" : "No unsaved Changes to Save",
"spyglass_astronomy.commands.admin.changes.query" : "There have been %s Changes since last save",

"spyglass_astronomy.commands.hide.all.hide" : "All hidden, run /sga:hide again to show",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/spyglass_astronomy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"spyglass_astronomy.commands.admin.addconstellation" : "Added new Constellation \"%s\"",
"spyglass_astronomy.commands.admin.addconstellation.fail" : "Cannot add new Constellation \"%s\": collision with \"%s\"",
"spyglass_astronomy.commands.admin.changes.discard" : "Discarded %s unsaved Changes",
"spyglass_astronomy.commands.admin.changes.discard.none" : "No unsaved Changes to Discard",
"spyglass_astronomy.commands.admin.changes.save" : "Saved %s unsaved Changes",
"spyglass_astronomy.commands.admin.changes.save.none" : "No unsaved Changes to Save",
"spyglass_astronomy.commands.admin.changes.query" : "There have been %s Changes since last save",

"spyglass_astronomy.commands.hide.all.hide" : "All hidden, run /sga:hide again to show",
Expand Down

0 comments on commit 73a7e8f

Please sign in to comment.