From 624dcc0be6eec263248f4ef0b067dfd3739da48d Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 11 Apr 2024 00:15:12 +0100 Subject: [PATCH] add raw profile properties to the player endpoint --- src/main/java/cc.fascinated/model/cache/CachedPlayer.java | 5 +++-- src/main/java/cc.fascinated/model/mojang/MojangProfile.java | 6 +++--- src/main/java/cc.fascinated/model/player/Player.java | 6 ++++++ src/main/java/cc.fascinated/service/PlayerService.java | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/cc.fascinated/model/cache/CachedPlayer.java b/src/main/java/cc.fascinated/model/cache/CachedPlayer.java index 402095f..ae3cd3e 100644 --- a/src/main/java/cc.fascinated/model/cache/CachedPlayer.java +++ b/src/main/java/cc.fascinated/model/cache/CachedPlayer.java @@ -1,5 +1,6 @@ package cc.fascinated.model.cache; +import cc.fascinated.model.mojang.MojangProfile; import cc.fascinated.model.player.Cape; import cc.fascinated.model.player.Player; import cc.fascinated.model.player.Skin; @@ -26,8 +27,8 @@ public final class CachedPlayer extends Player implements Serializable { */ private long cached; - public CachedPlayer(UUID uuid, String username, Skin skin, Cape cape, long cached) { - super(uuid, username, skin, cape); + public CachedPlayer(UUID uuid, String username, Skin skin, Cape cape, MojangProfile.ProfileProperty[] rawProperties, long cached) { + super(uuid, username, skin, cape, rawProperties); this.cached = cached; } } \ No newline at end of file diff --git a/src/main/java/cc.fascinated/model/mojang/MojangProfile.java b/src/main/java/cc.fascinated/model/mojang/MojangProfile.java index 8d92bfb..f147c74 100644 --- a/src/main/java/cc.fascinated/model/mojang/MojangProfile.java +++ b/src/main/java/cc.fascinated/model/mojang/MojangProfile.java @@ -5,14 +5,13 @@ import cc.fascinated.common.Tuple; import cc.fascinated.common.UUIDUtils; import cc.fascinated.model.player.Cape; import cc.fascinated.model.player.Skin; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.google.gson.JsonObject; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.ArrayList; import java.util.Base64; -import java.util.List; @Getter @NoArgsConstructor @AllArgsConstructor public class MojangProfile { @@ -30,7 +29,7 @@ public class MojangProfile { /** * The properties of the player. */ - private final List properties = new ArrayList<>(); + private ProfileProperty[] properties = new ProfileProperty[0]; /** * Get the skin and cape of the player. @@ -95,6 +94,7 @@ public class MojangProfile { * * @return the decoded value */ + @JsonIgnore public String getDecodedValue() { return new String(Base64.getDecoder().decode(this.value)); } diff --git a/src/main/java/cc.fascinated/model/player/Player.java b/src/main/java/cc.fascinated/model/player/Player.java index cc22491..3405178 100644 --- a/src/main/java/cc.fascinated/model/player/Player.java +++ b/src/main/java/cc.fascinated/model/player/Player.java @@ -34,9 +34,15 @@ public class Player { */ private Cape cape; + /** + * The raw properties of the player + */ + private MojangProfile.ProfileProperty[] rawProperties; + public Player(MojangProfile profile) { this.uuid = UUIDUtils.addDashes(profile.getId()); this.username = profile.getName(); + this.rawProperties = profile.getProperties(); // Get the skin and cape Tuple skinAndCape = profile.getSkinAndCape(); diff --git a/src/main/java/cc.fascinated/service/PlayerService.java b/src/main/java/cc.fascinated/service/PlayerService.java index 1f7ae19..6b8ce4e 100644 --- a/src/main/java/cc.fascinated/service/PlayerService.java +++ b/src/main/java/cc.fascinated/service/PlayerService.java @@ -73,6 +73,7 @@ public class PlayerService { mojangProfile.getName(), // Player Name skinAndCape.getLeft(), // Skin skinAndCape.getRight(), // Cape + mojangProfile.getProperties(), // Raw properties System.currentTimeMillis() // Cache time );