org.springframework.boot
diff --git a/src/main/java/me/braydon/mc/model/MinecraftServer.java b/src/main/java/me/braydon/mc/model/MinecraftServer.java
index 5aba99b..74f879e 100644
--- a/src/main/java/me/braydon/mc/model/MinecraftServer.java
+++ b/src/main/java/me/braydon/mc/model/MinecraftServer.java
@@ -47,9 +47,9 @@ public class MinecraftServer {
@NonNull private final MOTD motd;
/**
- * The Base64 encoded icon of this server.
+ * The Base64 encoded icon of this server, null if no icon.
*/
- @NonNull private final String icon;
+ private final String icon;
/**
* Is this server on the list
@@ -137,16 +137,21 @@ public class MinecraftServer {
/**
* The Java edition of Minecraft.
*/
- JAVA(new JavaMinecraftServerPinger()),
+ JAVA(new JavaMinecraftServerPinger(), 25565),
/**
* The Bedrock edition of Minecraft.
*/
- BEDROCK(new BedrockMinecraftServerPinger());
+ BEDROCK(new BedrockMinecraftServerPinger(), 19132);
/**
* The server pinger for this platform.
*/
@NonNull private final MinecraftServerPinger> pinger;
+
+ /**
+ * The default server port for this platform.
+ */
+ private final int defaultPort;
}
}
\ No newline at end of file
diff --git a/src/main/java/me/braydon/mc/model/server/BedrockMinecraftServer.java b/src/main/java/me/braydon/mc/model/server/BedrockMinecraftServer.java
index 84c3484..6ebcf48 100644
--- a/src/main/java/me/braydon/mc/model/server/BedrockMinecraftServer.java
+++ b/src/main/java/me/braydon/mc/model/server/BedrockMinecraftServer.java
@@ -10,7 +10,7 @@ import me.braydon.mc.model.MinecraftServer;
*/
public final class BedrockMinecraftServer extends MinecraftServer {
private BedrockMinecraftServer(@NonNull String hostname, String ip, int port, @NonNull Version version,
- @NonNull Players players, @NonNull MOTD motd, @NonNull String icon, boolean mojangBanned) {
+ @NonNull Players players, @NonNull MOTD motd, String icon, boolean mojangBanned) {
super(hostname, ip, port, version, players, motd, icon, mojangBanned);
}
}
\ No newline at end of file
diff --git a/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java b/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java
index 56717f9..d626e1b 100644
--- a/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java
+++ b/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java
@@ -1,8 +1,14 @@
package me.braydon.mc.model.server;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.internal.LinkedTreeMap;
import lombok.NonNull;
+import me.braydon.mc.RESTfulMC;
import me.braydon.mc.model.MinecraftServer;
import me.braydon.mc.model.token.JavaServerStatusToken;
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.chat.ComponentSerializer;
/**
* A Java edition {@link MinecraftServer}.
@@ -11,7 +17,7 @@ import me.braydon.mc.model.token.JavaServerStatusToken;
*/
public final class JavaMinecraftServer extends MinecraftServer {
private JavaMinecraftServer(@NonNull String hostname, String ip, int port, @NonNull Version version,
- @NonNull Players players, @NonNull MOTD motd, @NonNull String icon, boolean mojangBanned) {
+ @NonNull Players players, @NonNull MOTD motd, String icon, boolean mojangBanned) {
super(hostname, ip, port, version, players, motd, icon, mojangBanned);
}
@@ -26,8 +32,12 @@ public final class JavaMinecraftServer extends MinecraftServer {
*/
@NonNull
public static JavaMinecraftServer create(@NonNull String hostname, String ip, int port, @NonNull JavaServerStatusToken token) {
+ String motdString = token.getDescription() instanceof String ? (String) token.getDescription() : null;
+ if (motdString == null) { // Not a string motd, convert from Json
+ motdString = new TextComponent(ComponentSerializer.parse(RESTfulMC.GSON.toJson(token.getDescription()))).toLegacyText();
+ }
return new JavaMinecraftServer(hostname, ip, port, token.getVersion(), token.getPlayers(),
- MOTD.create(token.getDescription()), token.getFavicon(), false
+ MOTD.create(motdString), token.getFavicon(), false
);
}
}
\ No newline at end of file
diff --git a/src/main/java/me/braydon/mc/model/token/JavaServerStatusToken.java b/src/main/java/me/braydon/mc/model/token/JavaServerStatusToken.java
index cc784a1..fb397a8 100644
--- a/src/main/java/me/braydon/mc/model/token/JavaServerStatusToken.java
+++ b/src/main/java/me/braydon/mc/model/token/JavaServerStatusToken.java
@@ -17,13 +17,16 @@ import me.braydon.mc.model.server.JavaMinecraftServer;
public final class JavaServerStatusToken {
/**
* The description (MOTD) of this server.
+ *
+ * Legacy: String, New: JSON Object
+ *
*/
- @NonNull private final String description;
+ @NonNull private final Object description;
/**
- * The base64 encoded favicon of this server.
+ * The base64 encoded favicon of this server, null if no favicon.
*/
- @NonNull private final String favicon;
+ private final String favicon;
/**
* The version information of this server.