fix username to uuid cache
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Has been cancelled

This commit is contained in:
Lee
2024-04-13 17:29:32 +01:00
parent bda70b19a8
commit a966977d82
2 changed files with 11 additions and 4 deletions

View File

@ -100,7 +100,8 @@ public class PlayerService {
*/
public CachedPlayerName usernameToUuid(String username) {
log.info("Getting UUID from username: {}", username);
Optional<CachedPlayerName> cachedPlayerName = playerNameCacheRepository.findById(username.toUpperCase());
String id = username.toUpperCase();
Optional<CachedPlayerName> cachedPlayerName = playerNameCacheRepository.findById(id);
if (cachedPlayerName.isPresent() && Config.INSTANCE.isProduction()) {
return cachedPlayerName.get();
}
@ -111,7 +112,7 @@ public class PlayerService {
throw new ResourceNotFoundException("Player with username '%s' not found".formatted(username));
}
UUID uuid = UUIDUtils.addDashes(mojangUsernameToUuid.getUuid());
CachedPlayerName player = new CachedPlayerName(username, uuid);
CachedPlayerName player = new CachedPlayerName(id, username, uuid);
playerNameCacheRepository.save(player);
log.info("Got UUID from username: {} -> {}", username, uuid);
player.getCache().setCached(false);