add bedrock server support
Some checks failed
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Failing after 20s

This commit is contained in:
Lee
2024-04-10 11:55:58 +01:00
parent 5ad2f438d1
commit 2ba9651161
12 changed files with 381 additions and 41 deletions

View File

@ -2,6 +2,7 @@ package cc.fascinated.model.server;
import cc.fascinated.common.ColorUtils;
import cc.fascinated.service.pinger.MinecraftServerPinger;
import cc.fascinated.service.pinger.impl.BedrockMinecraftServerPinger;
import cc.fascinated.service.pinger.impl.JavaMinecraftServerPinger;
import io.micrometer.common.lang.NonNull;
import lombok.AllArgsConstructor;
@ -9,17 +10,38 @@ import lombok.Getter;
import lombok.ToString;
import java.util.Arrays;
import java.util.UUID;
/**
* @author Braydon
*/
@AllArgsConstructor @Getter @ToString
public class MinecraftServer {
/**
* The hostname of the server.
*/
private final String hostname;
/**
* The IP address of the server.
*/
private final String ip;
/**
* The port of the server.
*/
private final int port;
/**
* The motd for the server.
*/
private final MOTD motd;
/**
* The players on the server.
*/
private Players players;
/**
* A platform a Minecraft
* server can operate on.
@ -29,7 +51,12 @@ public class MinecraftServer {
/**
* The Java edition of Minecraft.
*/
JAVA(new JavaMinecraftServerPinger(), 25565);
JAVA(new JavaMinecraftServerPinger(), 25565),
/**
* The Bedrock edition of Minecraft.
*/
BEDROCK(new BedrockMinecraftServerPinger(), 19132);
/**
* The server pinger for this platform.
@ -77,4 +104,41 @@ public class MinecraftServer {
);
}
}
/**
* Player count data for a server.
*/
@AllArgsConstructor @Getter @ToString
public static class Players {
/**
* The online players on this server.
*/
private final int online;
/**
* The maximum allowed players on this server.
*/
private final int max;
/**
* A sample of players on this server, null or empty if no sample.
*/
private final Sample[] sample;
/**
* A sample player.
*/
@AllArgsConstructor @Getter @ToString
public static class Sample {
/**
* The unique id of this player.
*/
@NonNull private final UUID id;
/**
* The name of this player.
*/
@NonNull private final String name;
}
}
}