2024-04-10 07:43:38 +01:00
|
|
|
package cc.fascinated.model.player;
|
|
|
|
|
|
|
|
import cc.fascinated.common.Tuple;
|
|
|
|
import cc.fascinated.common.UUIDUtils;
|
|
|
|
import cc.fascinated.model.mojang.MojangProfile;
|
2024-04-12 18:46:54 +01:00
|
|
|
import cc.fascinated.model.skin.Skin;
|
2024-04-10 07:43:38 +01:00
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Getter;
|
|
|
|
import org.springframework.data.annotation.Id;
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
@Getter @AllArgsConstructor
|
|
|
|
public class Player {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The UUID of the player
|
|
|
|
*/
|
2024-04-11 00:49:16 +01:00
|
|
|
@Id private final UUID uniqueId;
|
2024-04-10 07:43:38 +01:00
|
|
|
|
2024-04-11 03:57:46 +01:00
|
|
|
/**
|
|
|
|
* The trimmed UUID of the player
|
|
|
|
*/
|
|
|
|
private final String trimmedUniqueId;
|
|
|
|
|
2024-04-10 07:43:38 +01:00
|
|
|
/**
|
|
|
|
* The username of the player
|
|
|
|
*/
|
|
|
|
private final String username;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The skin of the player, null if the
|
|
|
|
* player does not have a skin
|
|
|
|
*/
|
|
|
|
private Skin skin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The cape of the player, null if the
|
|
|
|
* player does not have a cape
|
|
|
|
*/
|
|
|
|
private Cape cape;
|
|
|
|
|
2024-04-11 00:15:12 +01:00
|
|
|
/**
|
|
|
|
* The raw properties of the player
|
|
|
|
*/
|
|
|
|
private MojangProfile.ProfileProperty[] rawProperties;
|
|
|
|
|
2024-04-10 07:43:38 +01:00
|
|
|
public Player(MojangProfile profile) {
|
2024-04-11 00:49:16 +01:00
|
|
|
this.uniqueId = UUIDUtils.addDashes(profile.getId());
|
2024-04-11 03:57:46 +01:00
|
|
|
this.trimmedUniqueId = UUIDUtils.removeDashes(this.uniqueId);
|
2024-04-10 07:43:38 +01:00
|
|
|
this.username = profile.getName();
|
2024-04-11 00:15:12 +01:00
|
|
|
this.rawProperties = profile.getProperties();
|
2024-04-10 07:43:38 +01:00
|
|
|
|
|
|
|
// Get the skin and cape
|
|
|
|
Tuple<Skin, Cape> skinAndCape = profile.getSkinAndCape();
|
|
|
|
if (skinAndCape != null) {
|
|
|
|
this.skin = skinAndCape.getLeft();
|
|
|
|
this.cape = skinAndCape.getRight();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|