add raw profile properties to the player endpoint
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m35s

This commit is contained in:
Lee 2024-04-11 00:15:12 +01:00
parent 0ea69f86f9
commit 624dcc0be6
4 changed files with 13 additions and 5 deletions

@ -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;
}
}

@ -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<ProfileProperty> 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));
}

@ -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<Skin, Cape> skinAndCape = profile.getSkinAndCape();

@ -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
);