mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +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.Inject;
|
||||||
import com.google.inject.MembersInjector;
|
import com.google.inject.MembersInjector;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -85,8 +86,10 @@ public class JSONUserManager extends CachingUserManager {
|
|||||||
|
|
||||||
if (Files.exists(userFile)) {
|
if (Files.exists(userFile)) {
|
||||||
try {
|
try {
|
||||||
final @Nullable CarbonPlayerCommon player =
|
final @Nullable CarbonPlayerCommon player;
|
||||||
this.serializer.fromJson(Files.newBufferedReader(userFile), CarbonPlayerCommon.class);
|
try (final Reader reader = Files.newBufferedReader(userFile)) {
|
||||||
|
player = this.serializer.fromJson(reader, CarbonPlayerCommon.class);
|
||||||
|
}
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
throw new IllegalStateException("Player file found but was empty.");
|
throw new IllegalStateException("Player file found but was empty.");
|
||||||
|
|||||||
Reference in new issue
Block a user