From 4f26110405ebbdeb74ce6209bf22acce9586d737 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 11 Apr 2024 03:57:46 +0100 Subject: [PATCH] add trimmed uuid to player response --- src/main/java/cc.fascinated/common/UUIDUtils.java | 11 +++++++++++ src/main/java/cc.fascinated/model/player/Player.java | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/cc.fascinated/common/UUIDUtils.java b/src/main/java/cc.fascinated/common/UUIDUtils.java index 3bf486d..a43fa97 100644 --- a/src/main/java/cc.fascinated/common/UUIDUtils.java +++ b/src/main/java/cc.fascinated/common/UUIDUtils.java @@ -22,4 +22,15 @@ public class UUIDUtils { } return UUID.fromString(builder.toString()); } + + /** + * Remove dashes from a UUID. + * + * @param dashed the UUID with dashes + * @return the UUID without dashes + */ + @NonNull + public static String removeDashes(@NonNull UUID dashed) { + return dashed.toString().replace("-", ""); + } } diff --git a/src/main/java/cc.fascinated/model/player/Player.java b/src/main/java/cc.fascinated/model/player/Player.java index 62883bc..06e5906 100644 --- a/src/main/java/cc.fascinated/model/player/Player.java +++ b/src/main/java/cc.fascinated/model/player/Player.java @@ -17,6 +17,11 @@ public class Player { */ @Id private final UUID uniqueId; + /** + * The trimmed UUID of the player + */ + private final String trimmedUniqueId; + /** * The username of the player */ @@ -41,6 +46,7 @@ public class Player { public Player(MojangProfile profile) { this.uniqueId = UUIDUtils.addDashes(profile.getId()); + this.trimmedUniqueId = UUIDUtils.removeDashes(this.uniqueId); this.username = profile.getName(); this.rawProperties = profile.getProperties();