From 7d709319c627350072247468cc1f17cf83bf6a3d Mon Sep 17 00:00:00 2001 From: Taah Date: Sun, 8 May 2022 17:59:01 -0700 Subject: [PATCH] oops --- .../main/java/dev/plex/cache/DataUtils.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/server/src/main/java/dev/plex/cache/DataUtils.java b/server/src/main/java/dev/plex/cache/DataUtils.java index 5032a98..e614b45 100644 --- a/server/src/main/java/dev/plex/cache/DataUtils.java +++ b/server/src/main/java/dev/plex/cache/DataUtils.java @@ -3,6 +3,8 @@ package dev.plex.cache; import dev.plex.Plex; import dev.plex.player.PlexPlayer; import dev.plex.storage.StorageType; + +import java.util.Optional; import java.util.UUID; /** @@ -49,19 +51,7 @@ public class DataUtils */ public static PlexPlayer getPlayer(UUID uuid) { - if (PlayerCache.getPlexPlayerMap().containsKey(uuid)) - { - return PlayerCache.getPlexPlayerMap().get(uuid); - } - - if (Plex.get().getStorageType() == StorageType.MONGODB) - { - return Plex.get().getMongoPlayerData().getByUUID(uuid); - } - else - { - return Plex.get().getSqlPlayerData().getByUUID(uuid); - } + return getPlayer(uuid, true); } public static PlexPlayer getPlayer(UUID uuid, boolean loadExtraData) @@ -81,8 +71,19 @@ public class DataUtils } } + public static PlexPlayer getPlayer(String username) + { + return getPlayer(username, true); + } + public static PlexPlayer getPlayer(String username, boolean loadExtraData) { + Optional plexPlayer = PlayerCache.getPlexPlayerMap().values().stream().filter(player -> player.getName().equalsIgnoreCase(username)).findFirst(); + if (plexPlayer.isPresent()) + { + return plexPlayer.get(); + } + if (Plex.get().getStorageType() == StorageType.MONGODB) { return Plex.get().getMongoPlayerData().getByName(username);