Skip to content

Commit 12e6933

Browse files
committed
fix IllegalStateException?
1 parent 988b7ab commit 12e6933

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/main/java/me/voidxwalker/worldpreview/StateOutputHelper.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
public final class StateOutputHelper {
1717
private static final Path OUT_PATH = Paths.get("wpstateout.txt");
18-
private static final ExecutorService EXECUTOR = Executors.newSingleThreadExecutor();
1918
// Storage variable, not necessarily involved or required for using outputState()
2019
public static int loadingProgress = 0;
2120
public static boolean titleHasEverLoaded = false;
@@ -40,11 +39,10 @@ public static void outputState(String string) {
4039
}
4140
lastOutput = string;
4241

43-
// Queue up the file writes as to not interrupt mc itself
44-
EXECUTOR.execute(() -> outputStateInternal(string));
42+
outputStateInternal(string);
4543
}
4644

47-
private static void outputStateInternal(String string) {
45+
private synchronized static void outputStateInternal(String string) {
4846
try {
4947
if(stateFile == null){ // opening file only once is better for performance
5048
stateFile = new RandomAccessFile(OUT_PATH.toString(), "rw");

0 commit comments

Comments
 (0)