2024-04-13 20:53:31 +01:00
|
|
|
package xyz.mcutils.backend.model.player;
|
2024-04-10 07:43:38 +01:00
|
|
|
|
|
|
|
import lombok.AllArgsConstructor;
|
2024-04-19 20:46:30 +01:00
|
|
|
import lombok.EqualsAndHashCode;
|
2024-04-10 07:43:38 +01:00
|
|
|
import lombok.Getter;
|
2024-04-13 17:17:13 +01:00
|
|
|
import lombok.NoArgsConstructor;
|
2024-04-13 20:53:31 +01:00
|
|
|
import xyz.mcutils.backend.common.Tuple;
|
|
|
|
import xyz.mcutils.backend.common.UUIDUtils;
|
|
|
|
import xyz.mcutils.backend.model.skin.Skin;
|
|
|
|
import xyz.mcutils.backend.model.token.MojangProfileToken;
|
2024-04-10 07:43:38 +01:00
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
2024-04-19 20:46:30 +01:00
|
|
|
@AllArgsConstructor @NoArgsConstructor
|
|
|
|
@Getter @EqualsAndHashCode
|
2024-04-10 07:43:38 +01:00
|
|
|
public class Player {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The UUID of the player
|
|
|
|
*/
|
2024-04-13 17:17:13 +01:00
|
|
|
private UUID uniqueId;
|
2024-04-10 07:43:38 +01:00
|
|
|
|
2024-04-11 03:57:46 +01:00
|
|
|
/**
|
|
|
|
* The trimmed UUID of the player
|
|
|
|
*/
|
2024-04-13 17:17:13 +01:00
|
|
|
private String trimmedUniqueId;
|
2024-04-11 03:57:46 +01:00
|
|
|
|
2024-04-10 07:43:38 +01:00
|
|
|
/**
|
|
|
|
* The username of the player
|
|
|
|
*/
|
2024-04-13 17:17:13 +01:00
|
|
|
private String username;
|
2024-04-10 07:43:38 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2024-04-13 17:40:03 +01:00
|
|
|
private MojangProfileToken.ProfileProperty[] rawProperties;
|
2024-04-11 00:15:12 +01:00
|
|
|
|
2024-04-13 17:40:03 +01:00
|
|
|
public Player(MojangProfileToken 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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|