From 1f45d26f532a0fea6991e4146acd6c47536efb2a Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 8 Apr 2024 05:29:05 +0100 Subject: [PATCH] more cleanup --- .../controller/PlayerController.java | 12 +++++----- .../exception/ExceptionControllerAdvice.java | 2 +- .../player/impl => model/player}/Cape.java | 2 +- .../player/impl => model/player}/Player.java | 23 +++++++++++-------- .../player/impl => model/player}/Skin.java | 2 +- .../impl => model/player}/SkinPart.java | 2 +- .../model/{ => response}/ErrorResponse.java | 2 +- .../service/{player => }/PlayerService.java | 8 +++---- .../service/mojang/MojangAPIService.java | 4 ++-- .../{types => model}/MojangProfile.java | 6 ++--- .../MojangUsernameToUuid.java | 2 +- 11 files changed, 34 insertions(+), 31 deletions(-) rename src/main/java/cc/fascinated/{service/player/impl => model/player}/Cape.java (80%) rename src/main/java/cc/fascinated/{service/player/impl => model/player}/Player.java (63%) rename src/main/java/cc/fascinated/{service/player/impl => model/player}/Skin.java (98%) rename src/main/java/cc/fascinated/{service/player/impl => model/player}/SkinPart.java (97%) rename src/main/java/cc/fascinated/model/{ => response}/ErrorResponse.java (95%) rename src/main/java/cc/fascinated/service/{player => }/PlayerService.java (93%) rename src/main/java/cc/fascinated/service/mojang/{types => model}/MojangProfile.java (95%) rename src/main/java/cc/fascinated/service/mojang/{types => model}/MojangUsernameToUuid.java (91%) diff --git a/src/main/java/cc/fascinated/controller/PlayerController.java b/src/main/java/cc/fascinated/controller/PlayerController.java index 9d38114..ae57fae 100644 --- a/src/main/java/cc/fascinated/controller/PlayerController.java +++ b/src/main/java/cc/fascinated/controller/PlayerController.java @@ -1,9 +1,9 @@ package cc.fascinated.controller; -import cc.fascinated.service.player.PlayerService; -import cc.fascinated.service.player.impl.Player; -import cc.fascinated.service.player.impl.Skin; -import cc.fascinated.service.player.impl.SkinPart; +import cc.fascinated.service.PlayerService; +import cc.fascinated.model.player.Player; +import cc.fascinated.model.player.Skin; +import cc.fascinated.model.player.SkinPart; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.CacheControl; @@ -49,7 +49,7 @@ public class PlayerController { @RequestParam(required = false, defaultValue = "250") int size) { Player player = playerManagerService.getPlayer(id); byte[] headBytes = new byte[0]; - if (player != null) { + if (player != null) { // The player exists Skin skin = player.getSkin(); SkinPart skinPart = skin.getPart(part); if (skinPart != null) { @@ -57,7 +57,7 @@ public class PlayerController { } } - if (headBytes == null) { + if (headBytes == null) { // Fallback to the default head headBytes = defaultHead.getPartData(size); } diff --git a/src/main/java/cc/fascinated/exception/ExceptionControllerAdvice.java b/src/main/java/cc/fascinated/exception/ExceptionControllerAdvice.java index eb74f1a..49e1427 100644 --- a/src/main/java/cc/fascinated/exception/ExceptionControllerAdvice.java +++ b/src/main/java/cc/fascinated/exception/ExceptionControllerAdvice.java @@ -1,6 +1,6 @@ package cc.fascinated.exception; -import cc.fascinated.model.ErrorResponse; +import cc.fascinated.model.response.ErrorResponse; import io.micrometer.common.lang.NonNull; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/cc/fascinated/service/player/impl/Cape.java b/src/main/java/cc/fascinated/model/player/Cape.java similarity index 80% rename from src/main/java/cc/fascinated/service/player/impl/Cape.java rename to src/main/java/cc/fascinated/model/player/Cape.java index 9262eed..6b490be 100644 --- a/src/main/java/cc/fascinated/service/player/impl/Cape.java +++ b/src/main/java/cc/fascinated/model/player/Cape.java @@ -1,4 +1,4 @@ -package cc.fascinated.service.player.impl; +package cc.fascinated.model.player; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/cc/fascinated/service/player/impl/Player.java b/src/main/java/cc/fascinated/model/player/Player.java similarity index 63% rename from src/main/java/cc/fascinated/service/player/impl/Player.java rename to src/main/java/cc/fascinated/model/player/Player.java index 5b88820..4a3d50e 100644 --- a/src/main/java/cc/fascinated/service/player/impl/Player.java +++ b/src/main/java/cc/fascinated/model/player/Player.java @@ -1,10 +1,11 @@ -package cc.fascinated.service.player.impl; +package cc.fascinated.model.player; -import cc.fascinated.service.mojang.types.MojangProfile; +import cc.fascinated.service.mojang.model.MojangProfile; import cc.fascinated.util.Tuple; import cc.fascinated.util.UUIDUtils; import lombok.Getter; +import java.util.List; import java.util.UUID; @Getter @@ -21,24 +22,26 @@ public class Player { private final String name; /** - * The skin of the player - *

- * This will be null if the player does not have a skin. - *

+ * The skin of the player, null if the + * player does not have a skin */ private Skin skin; /** - * The cape of the player - *

- * This will be null if the player does not have a cape. - *

+ * The cape of the player, null if the + * player does not have a cape */ private Cape cape; + /** + * The raw properties of the player + */ + private final List rawProperties; + public Player(MojangProfile profile) { this.uuid = UUID.fromString(UUIDUtils.addUUIDDashes(profile.getId())); this.name = profile.getName(); + this.rawProperties = profile.getProperties(); // Get the skin and cape Tuple skinAndCape = profile.getSkinAndCape(); diff --git a/src/main/java/cc/fascinated/service/player/impl/Skin.java b/src/main/java/cc/fascinated/model/player/Skin.java similarity index 98% rename from src/main/java/cc/fascinated/service/player/impl/Skin.java rename to src/main/java/cc/fascinated/model/player/Skin.java index 8d4a306..1b73873 100644 --- a/src/main/java/cc/fascinated/service/player/impl/Skin.java +++ b/src/main/java/cc/fascinated/model/player/Skin.java @@ -1,4 +1,4 @@ -package cc.fascinated.service.player.impl; +package cc.fascinated.model.player; import cc.fascinated.Main; import cc.fascinated.config.Config; diff --git a/src/main/java/cc/fascinated/service/player/impl/SkinPart.java b/src/main/java/cc/fascinated/model/player/SkinPart.java similarity index 97% rename from src/main/java/cc/fascinated/service/player/impl/SkinPart.java rename to src/main/java/cc/fascinated/model/player/SkinPart.java index e882dc1..6adda60 100644 --- a/src/main/java/cc/fascinated/service/player/impl/SkinPart.java +++ b/src/main/java/cc/fascinated/model/player/SkinPart.java @@ -1,4 +1,4 @@ -package cc.fascinated.service.player.impl; +package cc.fascinated.model.player; import lombok.Getter; import lombok.extern.log4j.Log4j2; diff --git a/src/main/java/cc/fascinated/model/ErrorResponse.java b/src/main/java/cc/fascinated/model/response/ErrorResponse.java similarity index 95% rename from src/main/java/cc/fascinated/model/ErrorResponse.java rename to src/main/java/cc/fascinated/model/response/ErrorResponse.java index 3f83888..1d7aaba 100644 --- a/src/main/java/cc/fascinated/model/ErrorResponse.java +++ b/src/main/java/cc/fascinated/model/response/ErrorResponse.java @@ -1,4 +1,4 @@ -package cc.fascinated.model; +package cc.fascinated.model.response; import com.fasterxml.jackson.annotation.JsonFormat; import io.micrometer.common.lang.NonNull; diff --git a/src/main/java/cc/fascinated/service/player/PlayerService.java b/src/main/java/cc/fascinated/service/PlayerService.java similarity index 93% rename from src/main/java/cc/fascinated/service/player/PlayerService.java rename to src/main/java/cc/fascinated/service/PlayerService.java index fb099e2..c280654 100644 --- a/src/main/java/cc/fascinated/service/player/PlayerService.java +++ b/src/main/java/cc/fascinated/service/PlayerService.java @@ -1,9 +1,9 @@ -package cc.fascinated.service.player; +package cc.fascinated.service; import cc.fascinated.service.mojang.MojangAPIService; -import cc.fascinated.service.mojang.types.MojangProfile; -import cc.fascinated.service.mojang.types.MojangUsernameToUuid; -import cc.fascinated.service.player.impl.Player; +import cc.fascinated.service.mojang.model.MojangProfile; +import cc.fascinated.service.mojang.model.MojangUsernameToUuid; +import cc.fascinated.model.player.Player; import cc.fascinated.util.UUIDUtils; import lombok.extern.log4j.Log4j2; import net.jodah.expiringmap.ExpirationPolicy; diff --git a/src/main/java/cc/fascinated/service/mojang/MojangAPIService.java b/src/main/java/cc/fascinated/service/mojang/MojangAPIService.java index cc27717..6a57883 100644 --- a/src/main/java/cc/fascinated/service/mojang/MojangAPIService.java +++ b/src/main/java/cc/fascinated/service/mojang/MojangAPIService.java @@ -1,7 +1,7 @@ package cc.fascinated.service.mojang; -import cc.fascinated.service.mojang.types.MojangProfile; -import cc.fascinated.service.mojang.types.MojangUsernameToUuid; +import cc.fascinated.service.mojang.model.MojangProfile; +import cc.fascinated.service.mojang.model.MojangUsernameToUuid; import cc.fascinated.util.WebRequest; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Value; diff --git a/src/main/java/cc/fascinated/service/mojang/types/MojangProfile.java b/src/main/java/cc/fascinated/service/mojang/model/MojangProfile.java similarity index 95% rename from src/main/java/cc/fascinated/service/mojang/types/MojangProfile.java rename to src/main/java/cc/fascinated/service/mojang/model/MojangProfile.java index 646b55a..7df3f3d 100644 --- a/src/main/java/cc/fascinated/service/mojang/types/MojangProfile.java +++ b/src/main/java/cc/fascinated/service/mojang/model/MojangProfile.java @@ -1,8 +1,8 @@ -package cc.fascinated.service.mojang.types; +package cc.fascinated.service.mojang.model; import cc.fascinated.Main; -import cc.fascinated.service.player.impl.Cape; -import cc.fascinated.service.player.impl.Skin; +import cc.fascinated.model.player.Cape; +import cc.fascinated.model.player.Skin; import cc.fascinated.util.Tuple; import com.google.gson.JsonObject; import lombok.AllArgsConstructor; diff --git a/src/main/java/cc/fascinated/service/mojang/types/MojangUsernameToUuid.java b/src/main/java/cc/fascinated/service/mojang/model/MojangUsernameToUuid.java similarity index 91% rename from src/main/java/cc/fascinated/service/mojang/types/MojangUsernameToUuid.java rename to src/main/java/cc/fascinated/service/mojang/model/MojangUsernameToUuid.java index 8496e37..45f2278 100644 --- a/src/main/java/cc/fascinated/service/mojang/types/MojangUsernameToUuid.java +++ b/src/main/java/cc/fascinated/service/mojang/model/MojangUsernameToUuid.java @@ -1,4 +1,4 @@ -package cc.fascinated.service.mojang.types; +package cc.fascinated.service.mojang.model; import lombok.Getter; import lombok.NoArgsConstructor;