From d11ea767d9d56c9a3f7839a5b95867f160f21e1a Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Sat, 6 Apr 2024 14:44:08 -0400 Subject: [PATCH] Mojang response tokens --- .../mc/model/token/MojangProfileToken.java | 63 +++++++++++++++++++ .../token/MojangUsernameToUUIDToken.java | 17 +++++ 2 files changed, 80 insertions(+) create mode 100644 src/main/java/me/braydon/mc/model/token/MojangProfileToken.java create mode 100644 src/main/java/me/braydon/mc/model/token/MojangUsernameToUUIDToken.java diff --git a/src/main/java/me/braydon/mc/model/token/MojangProfileToken.java b/src/main/java/me/braydon/mc/model/token/MojangProfileToken.java new file mode 100644 index 0000000..63ce022 --- /dev/null +++ b/src/main/java/me/braydon/mc/model/token/MojangProfileToken.java @@ -0,0 +1,63 @@ +package me.braydon.mc.model.token; + +import lombok.*; +import me.braydon.mc.model.ModerationAction; + +/** + * A token representing a Mojang user profile. + * + * @author Braydon + * @see Mojang API + */ +@NoArgsConstructor @Setter @Getter @EqualsAndHashCode(onlyExplicitlyIncluded = true) @ToString +public final class MojangProfileToken { + /** + * The id of the profile. + */ + @EqualsAndHashCode.Include @NonNull private String id; + + /** + * The name of the profile. + */ + @NonNull private String name; + + /** + * The properties of the profile. + */ + @NonNull private ProfileProperty[] properties; + + /** + * The actions this profile has. + */ + @NonNull private ModerationAction[] profileActions; + + /** + * A property of a Mojang profile. + */ + @NoArgsConstructor @Setter @Getter @EqualsAndHashCode(onlyExplicitlyIncluded = true) @ToString + public static class ProfileProperty { + /** + * The name of this property. + */ + @EqualsAndHashCode.Include @NonNull private String name; + + /** + * The base64 value of this property. + */ + @NonNull private String value; + + /** + * The base64 signature of this property. + */ + private String signature; + + /** + * Is this property signed? + * + * @return whether this property has a signature + */ + public boolean isSigned() { + return signature != null; + } + } +} \ No newline at end of file diff --git a/src/main/java/me/braydon/mc/model/token/MojangUsernameToUUIDToken.java b/src/main/java/me/braydon/mc/model/token/MojangUsernameToUUIDToken.java new file mode 100644 index 0000000..4765e95 --- /dev/null +++ b/src/main/java/me/braydon/mc/model/token/MojangUsernameToUUIDToken.java @@ -0,0 +1,17 @@ +package me.braydon.mc.model.token; + +import lombok.*; + +/** + * A token representing a Mojang username to UUID response. + * + * @author Braydon + * @see Mojang API + */ +@NoArgsConstructor @Setter @Getter @ToString +public final class MojangUsernameToUUIDToken { + /** + * The id of the username. + */ + private String id; +} \ No newline at end of file