mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
close player file reader
This commit is contained in:
1 file changed
+5
-2
@@ -24,6 +24,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.MembersInjector;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.UUID;
|
||||
@@ -85,8 +86,10 @@ public class JSONUserManager extends CachingUserManager {
|
||||
|
||||
if (Files.exists(userFile)) {
|
||||
try {
|
||||
final @Nullable CarbonPlayerCommon player =
|
||||
this.serializer.fromJson(Files.newBufferedReader(userFile), CarbonPlayerCommon.class);
|
||||
final @Nullable CarbonPlayerCommon player;
|
||||
try (final Reader reader = Files.newBufferedReader(userFile)) {
|
||||
player = this.serializer.fromJson(reader, CarbonPlayerCommon.class);
|
||||
}
|
||||
|
||||
if (player == null) {
|
||||
throw new IllegalStateException("Player file found but was empty.");
|
||||
|
||||
Reference in new issue
Block a user