Fix newer API response for server description
This commit is contained in:
parent
29577d8287
commit
d4dc5cb0ba
7
pom.xml
7
pom.xml
@ -88,6 +88,13 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>1.20-R0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
@ -17,13 +17,16 @@ import me.braydon.mc.model.server.JavaMinecraftServer;
|
||||
public final class JavaServerStatusToken {
|
||||
/**
|
||||
* The description (MOTD) of this server.
|
||||
* <p>
|
||||
* Legacy: String, New: JSON Object
|
||||
* </p>
|
||||
*/
|
||||
@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.
|
||||
|
Loading…
Reference in New Issue
Block a user