From 16a42d1af33b80caa055d18c1f827daa7f05a49e Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Thu, 11 Apr 2024 02:20:18 -0400 Subject: [PATCH] Add profile properties to Player --- src/main/java/me/braydon/mc/model/Player.java | 10 +++++++--- .../java/me/braydon/mc/model/cache/CachedPlayer.java | 8 +++++--- .../me/braydon/mc/model/token/MojangProfileToken.java | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/braydon/mc/model/Player.java b/src/main/java/me/braydon/mc/model/Player.java index 6ac8c68..6524ccb 100644 --- a/src/main/java/me/braydon/mc/model/Player.java +++ b/src/main/java/me/braydon/mc/model/Player.java @@ -24,6 +24,7 @@ package me.braydon.mc.model; import lombok.*; +import me.braydon.mc.model.token.MojangProfileToken; import org.springframework.data.annotation.Id; import java.util.UUID; @@ -33,9 +34,7 @@ import java.util.UUID; * * @author Braydon */ -@AllArgsConstructor @Getter -@EqualsAndHashCode(onlyExplicitlyIncluded = true) -@ToString +@AllArgsConstructor @Getter @EqualsAndHashCode(onlyExplicitlyIncluded = true) @ToString public class Player { /** * The unique id of this player. @@ -57,6 +56,11 @@ public class Player { */ private final Cape cape; + /** + * The raw profile properties of this player. + */ + @NonNull private final MojangProfileToken.ProfileProperty[] properties; + /** * The profile actions this player has, null if none. */ diff --git a/src/main/java/me/braydon/mc/model/cache/CachedPlayer.java b/src/main/java/me/braydon/mc/model/cache/CachedPlayer.java index 4978674..784e225 100644 --- a/src/main/java/me/braydon/mc/model/cache/CachedPlayer.java +++ b/src/main/java/me/braydon/mc/model/cache/CachedPlayer.java @@ -31,6 +31,7 @@ import me.braydon.mc.model.Cape; import me.braydon.mc.model.Player; import me.braydon.mc.model.ProfileAction; import me.braydon.mc.model.Skin; +import me.braydon.mc.model.token.MojangProfileToken; import org.springframework.data.redis.core.RedisHash; import java.io.Serializable; @@ -51,9 +52,10 @@ public final class CachedPlayer extends Player implements Serializable { */ private long cached; - public CachedPlayer(@NonNull UUID uniqueId, @NonNull String username, - @NonNull Skin skin, Cape cape, ProfileAction[] profileActions, long cached) { - super(uniqueId, username, skin, cape, profileActions); + public CachedPlayer(@NonNull UUID uniqueId, @NonNull String username, @NonNull Skin skin, Cape cape, + @NonNull MojangProfileToken.ProfileProperty[] properties, ProfileAction[] profileActions, + long cached) { + super(uniqueId, username, skin, cape, properties, profileActions); this.cached = cached; } } \ No newline at end of file diff --git a/src/main/java/me/braydon/mc/model/token/MojangProfileToken.java b/src/main/java/me/braydon/mc/model/token/MojangProfileToken.java index 72b1dd2..d7b3011 100644 --- a/src/main/java/me/braydon/mc/model/token/MojangProfileToken.java +++ b/src/main/java/me/braydon/mc/model/token/MojangProfileToken.java @@ -23,6 +23,7 @@ */ package me.braydon.mc.model.token; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.gson.JsonObject; import lombok.*; import me.braydon.mc.config.AppConfig; @@ -123,7 +124,7 @@ public final class MojangProfileToken { * * @return the decoded value */ - @NonNull + @NonNull @JsonIgnore public String getDecodedValue() { return new String(Base64.getDecoder().decode(value)); }