MC server models
This commit is contained in:
parent
b9125a2016
commit
617c19bf3c
90
src/main/java/me/braydon/mc/model/MinecraftServer.java
Normal file
90
src/main/java/me/braydon/mc/model/MinecraftServer.java
Normal file
@ -0,0 +1,90 @@
|
||||
package me.braydon.mc.model;
|
||||
|
||||
import lombok.*;
|
||||
import me.braydon.mc.service.pinger.MinecraftServerPinger;
|
||||
import me.braydon.mc.service.pinger.impl.BedrockMinecraftServerPinger;
|
||||
import me.braydon.mc.service.pinger.impl.JavaMinecraftServerPinger;
|
||||
|
||||
import java.beans.JavaBean;
|
||||
|
||||
/**
|
||||
* A model representing a Minecraft server.
|
||||
*
|
||||
* @author Braydon
|
||||
*/
|
||||
@AllArgsConstructor @Getter @EqualsAndHashCode(onlyExplicitlyIncluded = true) @ToString
|
||||
public class MinecraftServer {
|
||||
/**
|
||||
* The IP address of this server.
|
||||
*/
|
||||
@EqualsAndHashCode.Include @NonNull private final String ip;
|
||||
|
||||
/**
|
||||
* The port of this server.
|
||||
*/
|
||||
@EqualsAndHashCode.Include private final int port;
|
||||
|
||||
/**
|
||||
* The version information of this server.
|
||||
*/
|
||||
@NonNull private final Version version;
|
||||
|
||||
/**
|
||||
* The player counts of this server.
|
||||
*/
|
||||
@NonNull private final Players players;
|
||||
|
||||
/**
|
||||
* Version information for a server.
|
||||
*/
|
||||
@AllArgsConstructor @Getter @ToString
|
||||
public static class Version {
|
||||
/**
|
||||
* The version name of the server.
|
||||
*/
|
||||
@NonNull private final String name;
|
||||
|
||||
/**
|
||||
* The protocol version of the server.
|
||||
*/
|
||||
private final int protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 platform a Minecraft
|
||||
* server can operate on.
|
||||
*/
|
||||
@AllArgsConstructor @Getter
|
||||
public enum Platform {
|
||||
/**
|
||||
* The Java edition of Minecraft.
|
||||
*/
|
||||
JAVA(new JavaMinecraftServerPinger()),
|
||||
|
||||
/**
|
||||
* The Bedrock edition of Minecraft.
|
||||
*/
|
||||
BEDROCK(new BedrockMinecraftServerPinger());
|
||||
|
||||
/**
|
||||
* The server pinger for this platform.
|
||||
*/
|
||||
@NonNull private final MinecraftServerPinger<?> pinger;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package me.braydon.mc.model.server;
|
||||
|
||||
import lombok.NonNull;
|
||||
import me.braydon.mc.model.MinecraftServer;
|
||||
import me.braydon.mc.model.token.JavaServerStatusToken;
|
||||
|
||||
/**
|
||||
* A Bedrock edition {@link MinecraftServer}.
|
||||
*
|
||||
* @author Braydon
|
||||
*/
|
||||
public final class BedrockMinecraftServer extends MinecraftServer {
|
||||
private BedrockMinecraftServer(@NonNull String ip, int port, @NonNull Version version, @NonNull Players players) {
|
||||
super(ip, port, version, players);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package me.braydon.mc.model.server;
|
||||
|
||||
import lombok.NonNull;
|
||||
import me.braydon.mc.model.MinecraftServer;
|
||||
import me.braydon.mc.model.token.JavaServerStatusToken;
|
||||
|
||||
/**
|
||||
* A Java edition {@link MinecraftServer}.
|
||||
*
|
||||
* @author Braydon
|
||||
*/
|
||||
public final class JavaMinecraftServer extends MinecraftServer {
|
||||
private JavaMinecraftServer(@NonNull String ip, int port, @NonNull Version version, @NonNull Players players) {
|
||||
super(ip, port, version, players);
|
||||
}
|
||||
|
||||
public static JavaMinecraftServer create(@NonNull String ip, int port, @NonNull JavaServerStatusToken token) {
|
||||
return new JavaMinecraftServer(ip, port, token.getVersion(), token.getPlayers());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user