From 034f686e0862c9e3d7dabda4c8cbac2190dd6ccb Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 19 Apr 2024 17:25:46 +0100 Subject: [PATCH] use new mojang endpoint status model --- pom.xml | 2 +- src/main/java/xyz/mcutils/McUtilsAPI.java | 4 +-- .../CachedBedrockMinecraftServer.java | 3 +- .../CachedJavaMinecraftServer.java | 3 +- .../cache/CachedMojangEndpointStatus.java | 17 +++++++++++ .../{player => cache}/CachedPlayer.java | 4 ++- .../CachedServerBlockedStatus.java | 2 +- .../CachedUsernameToUuid.java | 2 +- ...ndpointStatus.java => EndpointStatus.java} | 29 ++++++++++++------- src/test/java/xyz/mcutils/MojangTests.java | 2 +- src/test/java/xyz/mcutils/PlayerTests.java | 4 +-- src/test/java/xyz/mcutils/ServerTests.java | 6 ++-- 12 files changed, 52 insertions(+), 26 deletions(-) rename src/main/java/xyz/mcutils/models/{server => cache}/CachedBedrockMinecraftServer.java (94%) rename src/main/java/xyz/mcutils/models/{server => cache}/CachedJavaMinecraftServer.java (97%) create mode 100644 src/main/java/xyz/mcutils/models/cache/CachedMojangEndpointStatus.java rename src/main/java/xyz/mcutils/models/{player => cache}/CachedPlayer.java (91%) rename src/main/java/xyz/mcutils/models/{server => cache}/CachedServerBlockedStatus.java (86%) rename src/main/java/xyz/mcutils/models/{player => cache}/CachedUsernameToUuid.java (90%) rename src/main/java/xyz/mcutils/models/mojang/{CachedMojangEndpointStatus.java => EndpointStatus.java} (59%) diff --git a/pom.xml b/pom.xml index 4a525a3..e1504f1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ xyz.mcutils mcutils-java-library - 1.1 + 1.1.1 17 diff --git a/src/main/java/xyz/mcutils/McUtilsAPI.java b/src/main/java/xyz/mcutils/McUtilsAPI.java index 000a3e9..380d4ea 100644 --- a/src/main/java/xyz/mcutils/McUtilsAPI.java +++ b/src/main/java/xyz/mcutils/McUtilsAPI.java @@ -2,10 +2,8 @@ package xyz.mcutils; import xyz.mcutils.common.WebRequest; import xyz.mcutils.exception.ErrorResponse; -import xyz.mcutils.models.mojang.CachedMojangEndpointStatus; -import xyz.mcutils.models.player.CachedPlayer; +import xyz.mcutils.models.cache.*; import xyz.mcutils.models.player.CachedPlayerSkinPart; -import xyz.mcutils.models.player.CachedUsernameToUuid; import xyz.mcutils.models.player.Skin; import xyz.mcutils.models.server.*; diff --git a/src/main/java/xyz/mcutils/models/server/CachedBedrockMinecraftServer.java b/src/main/java/xyz/mcutils/models/cache/CachedBedrockMinecraftServer.java similarity index 94% rename from src/main/java/xyz/mcutils/models/server/CachedBedrockMinecraftServer.java rename to src/main/java/xyz/mcutils/models/cache/CachedBedrockMinecraftServer.java index 83c3c39..72a1d86 100644 --- a/src/main/java/xyz/mcutils/models/server/CachedBedrockMinecraftServer.java +++ b/src/main/java/xyz/mcutils/models/cache/CachedBedrockMinecraftServer.java @@ -1,7 +1,8 @@ -package xyz.mcutils.models.server; +package xyz.mcutils.models.cache; import lombok.Getter; import lombok.ToString; +import xyz.mcutils.models.server.MinecraftServer; @Getter public class CachedBedrockMinecraftServer extends MinecraftServer { diff --git a/src/main/java/xyz/mcutils/models/server/CachedJavaMinecraftServer.java b/src/main/java/xyz/mcutils/models/cache/CachedJavaMinecraftServer.java similarity index 97% rename from src/main/java/xyz/mcutils/models/server/CachedJavaMinecraftServer.java rename to src/main/java/xyz/mcutils/models/cache/CachedJavaMinecraftServer.java index 4f3cda3..7c356de 100644 --- a/src/main/java/xyz/mcutils/models/server/CachedJavaMinecraftServer.java +++ b/src/main/java/xyz/mcutils/models/cache/CachedJavaMinecraftServer.java @@ -1,7 +1,8 @@ -package xyz.mcutils.models.server; +package xyz.mcutils.models.cache; import lombok.Getter; import lombok.ToString; +import xyz.mcutils.models.server.MinecraftServer; @Getter public class CachedJavaMinecraftServer extends MinecraftServer { diff --git a/src/main/java/xyz/mcutils/models/cache/CachedMojangEndpointStatus.java b/src/main/java/xyz/mcutils/models/cache/CachedMojangEndpointStatus.java new file mode 100644 index 0000000..382fb39 --- /dev/null +++ b/src/main/java/xyz/mcutils/models/cache/CachedMojangEndpointStatus.java @@ -0,0 +1,17 @@ +package xyz.mcutils.models.cache; + +import lombok.Getter; +import lombok.ToString; +import xyz.mcutils.models.CachedResponse; +import xyz.mcutils.models.mojang.EndpointStatus; + +import java.util.List; + +@Getter @ToString +public class CachedMojangEndpointStatus extends CachedResponse { + + /** + * The list of endpoints and their status. + */ + private List endpoints; +} \ No newline at end of file diff --git a/src/main/java/xyz/mcutils/models/player/CachedPlayer.java b/src/main/java/xyz/mcutils/models/cache/CachedPlayer.java similarity index 91% rename from src/main/java/xyz/mcutils/models/player/CachedPlayer.java rename to src/main/java/xyz/mcutils/models/cache/CachedPlayer.java index 93fd358..9073925 100644 --- a/src/main/java/xyz/mcutils/models/player/CachedPlayer.java +++ b/src/main/java/xyz/mcutils/models/cache/CachedPlayer.java @@ -1,8 +1,10 @@ -package xyz.mcutils.models.player; +package xyz.mcutils.models.cache; import lombok.Getter; import lombok.ToString; import xyz.mcutils.models.CachedResponse; +import xyz.mcutils.models.player.Cape; +import xyz.mcutils.models.player.Skin; import java.util.UUID; diff --git a/src/main/java/xyz/mcutils/models/server/CachedServerBlockedStatus.java b/src/main/java/xyz/mcutils/models/cache/CachedServerBlockedStatus.java similarity index 86% rename from src/main/java/xyz/mcutils/models/server/CachedServerBlockedStatus.java rename to src/main/java/xyz/mcutils/models/cache/CachedServerBlockedStatus.java index cb9be57..99de865 100644 --- a/src/main/java/xyz/mcutils/models/server/CachedServerBlockedStatus.java +++ b/src/main/java/xyz/mcutils/models/cache/CachedServerBlockedStatus.java @@ -1,4 +1,4 @@ -package xyz.mcutils.models.server; +package xyz.mcutils.models.cache; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/xyz/mcutils/models/player/CachedUsernameToUuid.java b/src/main/java/xyz/mcutils/models/cache/CachedUsernameToUuid.java similarity index 90% rename from src/main/java/xyz/mcutils/models/player/CachedUsernameToUuid.java rename to src/main/java/xyz/mcutils/models/cache/CachedUsernameToUuid.java index 5a24f97..3db26f9 100644 --- a/src/main/java/xyz/mcutils/models/player/CachedUsernameToUuid.java +++ b/src/main/java/xyz/mcutils/models/cache/CachedUsernameToUuid.java @@ -1,4 +1,4 @@ -package xyz.mcutils.models.player; +package xyz.mcutils.models.cache; import lombok.Getter; import lombok.ToString; diff --git a/src/main/java/xyz/mcutils/models/mojang/CachedMojangEndpointStatus.java b/src/main/java/xyz/mcutils/models/mojang/EndpointStatus.java similarity index 59% rename from src/main/java/xyz/mcutils/models/mojang/CachedMojangEndpointStatus.java rename to src/main/java/xyz/mcutils/models/mojang/EndpointStatus.java index 3737cf8..b18d0b1 100644 --- a/src/main/java/xyz/mcutils/models/mojang/CachedMojangEndpointStatus.java +++ b/src/main/java/xyz/mcutils/models/mojang/EndpointStatus.java @@ -1,21 +1,28 @@ package xyz.mcutils.models.mojang; -import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.ToString; -import xyz.mcutils.models.CachedResponse; -import java.util.Map; - -@AllArgsConstructor -@Getter @ToString -public class CachedMojangEndpointStatus extends CachedResponse { +@Getter +public class EndpointStatus { /** - * The list of endpoints and their status. + * The name of the service. */ - private Map endpoints; + private String name; + /** + * The hostname of the service. + */ + private String hostname; + + /** + * The status of the service. + */ + private Status status; + + /** + * Statuses for the endpoint. + */ public enum Status { /** * The service is online and operational. @@ -33,4 +40,4 @@ public class CachedMojangEndpointStatus extends CachedResponse { */ OFFLINE } -} \ No newline at end of file +} diff --git a/src/test/java/xyz/mcutils/MojangTests.java b/src/test/java/xyz/mcutils/MojangTests.java index d7d500e..6229b26 100644 --- a/src/test/java/xyz/mcutils/MojangTests.java +++ b/src/test/java/xyz/mcutils/MojangTests.java @@ -2,7 +2,7 @@ package xyz.mcutils; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; -import xyz.mcutils.models.mojang.CachedMojangEndpointStatus; +import xyz.mcutils.models.cache.CachedMojangEndpointStatus; public class MojangTests { diff --git a/src/test/java/xyz/mcutils/PlayerTests.java b/src/test/java/xyz/mcutils/PlayerTests.java index 39ade31..501e708 100644 --- a/src/test/java/xyz/mcutils/PlayerTests.java +++ b/src/test/java/xyz/mcutils/PlayerTests.java @@ -3,9 +3,9 @@ package xyz.mcutils; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; import xyz.mcutils.exception.ErrorResponse; -import xyz.mcutils.models.player.CachedPlayer; +import xyz.mcutils.models.cache.CachedPlayer; import xyz.mcutils.models.player.CachedPlayerSkinPart; -import xyz.mcutils.models.player.CachedUsernameToUuid; +import xyz.mcutils.models.cache.CachedUsernameToUuid; import xyz.mcutils.models.player.Skin; public class PlayerTests { diff --git a/src/test/java/xyz/mcutils/ServerTests.java b/src/test/java/xyz/mcutils/ServerTests.java index f53c1c2..973c1a2 100644 --- a/src/test/java/xyz/mcutils/ServerTests.java +++ b/src/test/java/xyz/mcutils/ServerTests.java @@ -3,9 +3,9 @@ package xyz.mcutils; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; import xyz.mcutils.exception.ErrorResponse; -import xyz.mcutils.models.server.CachedBedrockMinecraftServer; -import xyz.mcutils.models.server.CachedJavaMinecraftServer; -import xyz.mcutils.models.server.CachedServerBlockedStatus; +import xyz.mcutils.models.cache.CachedBedrockMinecraftServer; +import xyz.mcutils.models.cache.CachedJavaMinecraftServer; +import xyz.mcutils.models.cache.CachedServerBlockedStatus; import xyz.mcutils.models.server.CachedServerIcon; public class ServerTests {