add more to the server response
All checks were successful
ci / deploy (push) Successful in 1m14s

This commit is contained in:
Lee
2024-04-10 09:19:02 +01:00
parent c7fe26ef8f
commit 330c3efc78
12 changed files with 540 additions and 19 deletions

View File

@ -1,5 +1,6 @@
package cc.fascinated.model.server;
import cc.fascinated.common.ColorUtils;
import cc.fascinated.service.pinger.MinecraftServerPinger;
import cc.fascinated.service.pinger.impl.JavaMinecraftServerPinger;
import io.micrometer.common.lang.NonNull;
@ -7,6 +8,8 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import java.util.Arrays;
/**
* @author Braydon
*/
@ -15,7 +18,7 @@ public class MinecraftServer {
private final String hostname;
private final String ip;
private final int port;
private final String motd;
private final MOTD motd;
/**
* A platform a Minecraft
@ -39,4 +42,39 @@ public class MinecraftServer {
*/
private final int defaultPort;
}
@AllArgsConstructor @Getter
public static class MOTD {
/**
* The raw motd lines
*/
private final String[] raw;
/**
* The clean motd lines
*/
private final String[] clean;
/**
* The html motd lines
*/
private final String[] html;
/**
* Create a new MOTD from a raw string.
*
* @param raw the raw motd string
* @return the new motd
*/
@NonNull
public static MOTD create(@NonNull String raw) {
String[] rawLines = raw.split("\n"); // The raw lines
return new MOTD(
rawLines,
Arrays.stream(rawLines).map(ColorUtils::stripColor).toArray(String[]::new),
Arrays.stream(rawLines).map(ColorUtils::toHTML).toArray(String[]::new)
);
}
}
}