mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
simplify writing user json
default options are CREATE TRUNCATE_EXISTING and WRITE
This commit is contained in:
1 file changed
+1
-8
@@ -26,7 +26,6 @@ import com.google.inject.MembersInjector;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -128,13 +127,7 @@ public class JSONUserManager extends CachingUserManager {
|
||||
throw new IllegalStateException("No data to save - toJson returned null or blank.");
|
||||
}
|
||||
|
||||
if (!Files.exists(userFile)) {
|
||||
Files.createFile(userFile);
|
||||
}
|
||||
|
||||
Files.writeString(userFile, json,
|
||||
StandardOpenOption.WRITE,
|
||||
StandardOpenOption.TRUNCATE_EXISTING);
|
||||
Files.writeString(userFile, json);
|
||||
} catch (final IOException exception) {
|
||||
throw new RuntimeException("Exception while saving data for player [%s]".formatted(player.username()), exception);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user