Skip to content

Commit

Permalink
fix msg save crash
Browse files Browse the repository at this point in the history
  • Loading branch information
z64a committed Apr 26, 2024
1 parent 2d338be commit 34ce9f3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/main/java/game/message/editor/MessageGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.FileUtils;

import app.input.IOUtils;
import app.input.InputFileException;
import app.input.Line;
Expand Down Expand Up @@ -133,15 +135,19 @@ public void saveChanges()
}

AssetHandle saveAsset = AssetManager.getTopLevel(asset);
try (PrintWriter pw = IOUtils.getBufferedPrintWriter(saveAsset)) {
for (String line : linesOut) {
pw.println(line);
}
try {
FileUtils.touch(saveAsset);

asset = saveAsset;
hasModified = false;
for (Message msg : messages) {
msg.modified = false;
try (PrintWriter pw = IOUtils.getBufferedPrintWriter(saveAsset)) {
for (String line : linesOut) {
pw.println(line);
}

asset = saveAsset;
hasModified = false;
for (Message msg : messages) {
msg.modified = false;
}
}
}
catch (IOException e) {
Expand Down

0 comments on commit 34ce9f3

Please sign in to comment.