From ffb059ecb88fa60649c0f8e6060be2475ff64e8a Mon Sep 17 00:00:00 2001 From: Draycia Date: Sat, 4 Dec 2021 19:18:32 -0800 Subject: [PATCH] Add timeout to JSONUserManager#carbonPlayer --- .../net/draycia/carbon/common/users/JSONUserManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/net/draycia/carbon/common/users/JSONUserManager.java b/common/src/main/java/net/draycia/carbon/common/users/JSONUserManager.java index 7391d9ee..f501404d 100644 --- a/common/src/main/java/net/draycia/carbon/common/users/JSONUserManager.java +++ b/common/src/main/java/net/draycia/carbon/common/users/JSONUserManager.java @@ -33,6 +33,7 @@ import java.util.Map; import java.util.Objects; import java.util.UUID; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; import net.draycia.carbon.api.CarbonChat; import net.draycia.carbon.api.channels.ChatChannel; import net.draycia.carbon.api.users.ComponentPlayerResult; @@ -97,14 +98,14 @@ public class JSONUserManager implements UserManager { this.serializer.fromJson(Files.newBufferedReader(userFile), CarbonPlayerCommon.class); if (player == null) { - return new ComponentPlayerResult<>(null, text("Player file found but was empty.")); + return new ComponentPlayerResult(null, text("Player file found but was empty.")); } this.userCache.put(uuid, player); return new ComponentPlayerResult<>(player, empty()); } catch (final IOException exception) { - return new ComponentPlayerResult<>(null, text(exception.getMessage())); + return new ComponentPlayerResult(null, text(exception.getMessage())); } } @@ -116,7 +117,7 @@ public class JSONUserManager implements UserManager { this.userCache.put(uuid, player); return new ComponentPlayerResult<>(player, empty()); - }); + }).orTimeout(30, TimeUnit.SECONDS); } @Override