Add a legacy field to players
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m26s

This commit is contained in:
Braydon 2024-04-11 09:21:16 -04:00
parent a03bac8f1d
commit 5099ad9dfe
4 changed files with 21 additions and 3 deletions

@ -65,4 +65,13 @@ public class Player {
* The profile actions this player has, null if none. * The profile actions this player has, null if none.
*/ */
private final ProfileAction[] profileActions; private final ProfileAction[] profileActions;
/**
* Is this player legacy?
* <p>
* A "Legacy" player is a player that
* has not yet migrated to a Mojang account.
* </p>
*/
private final boolean legacy;
} }

@ -65,8 +65,8 @@ public final class CachedPlayer extends Player implements Serializable {
public CachedPlayer(@NonNull String cacheId, @NonNull UUID uniqueId, @NonNull String username, @NonNull Skin skin, public CachedPlayer(@NonNull String cacheId, @NonNull UUID uniqueId, @NonNull String username, @NonNull Skin skin,
Cape cape, @NonNull MojangProfileToken.ProfileProperty[] properties, ProfileAction[] profileActions, Cape cape, @NonNull MojangProfileToken.ProfileProperty[] properties, ProfileAction[] profileActions,
long cached) { boolean legacy, long cached) {
super(uniqueId, username, skin, cape, properties, profileActions); super(uniqueId, username, skin, cape, properties, profileActions, legacy);
this.cacheId = cacheId; this.cacheId = cacheId;
this.cached = cached; this.cached = cached;
} }

@ -61,6 +61,15 @@ public final class MojangProfileToken {
*/ */
@NonNull private final ProfileAction[] profileActions; @NonNull private final ProfileAction[] profileActions;
/**
* Is this profile legacy?
* <p>
* A "Legacy" profile is a profile that
* has not yet migrated to a Mojang account.
* </p>
*/
private final boolean legacy;
/** /**
* Get the properties of this skin. * Get the properties of this skin.
* *

@ -294,7 +294,7 @@ public final class MojangService {
CachedPlayer player = new CachedPlayer(cacheId, uuid, token.getName(), CachedPlayer player = new CachedPlayer(cacheId, uuid, token.getName(),
skinProperties.getSkin() == null ? Skin.DEFAULT_STEVE : skinProperties.getSkin(), skinProperties.getSkin() == null ? Skin.DEFAULT_STEVE : skinProperties.getSkin(),
skinProperties.getCape(), token.getProperties(), profileActions.length == 0 ? null : profileActions, skinProperties.getCape(), token.getProperties(), profileActions.length == 0 ? null : profileActions,
System.currentTimeMillis() token.isLegacy(), System.currentTimeMillis()
); );
// Store in the cache // Store in the cache
playerCache.save(player); playerCache.save(player);