Add Forge ModInfo
This commit is contained in:
parent
7a5219de8e
commit
fbdd2fc9a7
@ -31,11 +31,6 @@ public class MinecraftServer {
|
||||
*/
|
||||
@EqualsAndHashCode.Include private final int port;
|
||||
|
||||
/**
|
||||
* The version information of this server.
|
||||
*/
|
||||
@NonNull private final Version version;
|
||||
|
||||
/**
|
||||
* The player counts of this server.
|
||||
*/
|
||||
@ -51,45 +46,6 @@ public class MinecraftServer {
|
||||
*/
|
||||
private final String icon;
|
||||
|
||||
/**
|
||||
* Version information for a server.
|
||||
*/
|
||||
@AllArgsConstructor @Getter @ToString
|
||||
public static class Version {
|
||||
/**
|
||||
* The version name of the server.
|
||||
*/
|
||||
@NonNull private final String name;
|
||||
|
||||
/**
|
||||
* The identified platform of the server, null if unknown.
|
||||
*/
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* The protocol version of the server.
|
||||
*/
|
||||
private final int protocol;
|
||||
|
||||
/**
|
||||
* Create a more detailed
|
||||
* copy of this object.
|
||||
*
|
||||
* @return the detailed copy
|
||||
*/
|
||||
@NonNull
|
||||
public Version detailedCopy() {
|
||||
String platform = null;
|
||||
if (name.contains(" ")) { // Parse the server platform
|
||||
String[] split = name.split(" ");
|
||||
if (split.length == 2) {
|
||||
platform = split[0];
|
||||
}
|
||||
}
|
||||
return new Version(name, platform, protocol);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Player count data for a server.
|
||||
*/
|
||||
|
@ -9,8 +9,8 @@ import me.braydon.mc.model.MinecraftServer;
|
||||
* @author Braydon
|
||||
*/
|
||||
public final class BedrockMinecraftServer extends MinecraftServer {
|
||||
private BedrockMinecraftServer(@NonNull String hostname, String ip, int port, @NonNull Version version,
|
||||
@NonNull Players players, @NonNull MOTD motd, String icon) {
|
||||
super(hostname, ip, port, version, players, motd, icon);
|
||||
private BedrockMinecraftServer(@NonNull String hostname, String ip, int port, @NonNull Players players,
|
||||
@NonNull MOTD motd, String icon) {
|
||||
super(hostname, ip, port, players, motd, icon);
|
||||
}
|
||||
}
|
@ -1,7 +1,10 @@
|
||||
package me.braydon.mc.model.server;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import me.braydon.mc.RESTfulMC;
|
||||
import me.braydon.mc.model.MinecraftServer;
|
||||
import me.braydon.mc.model.token.JavaServerStatusToken;
|
||||
@ -15,6 +18,16 @@ import net.md_5.bungee.chat.ComponentSerializer;
|
||||
*/
|
||||
@Getter
|
||||
public final class JavaMinecraftServer extends MinecraftServer {
|
||||
/**
|
||||
* The version information of this server.
|
||||
*/
|
||||
@NonNull private final Version version;
|
||||
|
||||
/**
|
||||
* The Forge mod information for this server, null if none.
|
||||
*/
|
||||
private final ModInfo modInfo;
|
||||
|
||||
/**
|
||||
* Does this server enforce secure chat?
|
||||
*/
|
||||
@ -33,10 +46,12 @@ public final class JavaMinecraftServer extends MinecraftServer {
|
||||
*/
|
||||
private final boolean mojangBanned;
|
||||
|
||||
private JavaMinecraftServer(@NonNull String hostname, String ip, int port, @NonNull Version version,
|
||||
@NonNull Players players, @NonNull MOTD motd, String icon, boolean enforcesSecureChat,
|
||||
boolean preventsChatReports, boolean mojangBanned) {
|
||||
super(hostname, ip, port, version, players, motd, icon);
|
||||
private JavaMinecraftServer(@NonNull String hostname, String ip, int port, @NonNull Players players,
|
||||
@NonNull MOTD motd, String icon, @NonNull Version version, ModInfo modInfo,
|
||||
boolean enforcesSecureChat, boolean preventsChatReports, boolean mojangBanned) {
|
||||
super(hostname, ip, port, players, motd, icon);
|
||||
this.version = version;
|
||||
this.modInfo = modInfo;
|
||||
this.enforcesSecureChat = enforcesSecureChat;
|
||||
this.preventsChatReports = preventsChatReports;
|
||||
this.mojangBanned = mojangBanned;
|
||||
@ -57,8 +72,77 @@ public final class JavaMinecraftServer extends MinecraftServer {
|
||||
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().detailedCopy(), token.getPlayers(),
|
||||
MOTD.create(motdString), token.getFavicon(), token.isEnforcesSecureChat(), token.isPreventsChatReports(), false
|
||||
return new JavaMinecraftServer(hostname, ip, port, token.getPlayers(), MOTD.create(motdString),
|
||||
token.getFavicon(), token.getVersion().detailedCopy(), token.getModInfo(),
|
||||
token.isEnforcesSecureChat(), token.isPreventsChatReports(), false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Version information for a server.
|
||||
*/
|
||||
@AllArgsConstructor @Getter @ToString
|
||||
public static class Version {
|
||||
/**
|
||||
* The version name of the server.
|
||||
*/
|
||||
@NonNull private final String name;
|
||||
|
||||
/**
|
||||
* The identified platform of the server, null if unknown.
|
||||
*/
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* The protocol version of the server.
|
||||
*/
|
||||
private final int protocol;
|
||||
|
||||
/**
|
||||
* Create a more detailed
|
||||
* copy of this object.
|
||||
*
|
||||
* @return the detailed copy
|
||||
*/
|
||||
@NonNull
|
||||
public Version detailedCopy() {
|
||||
String platform = null;
|
||||
if (name.contains(" ")) { // Parse the server platform
|
||||
String[] split = name.split(" ");
|
||||
if (split.length == 2) {
|
||||
platform = split[0];
|
||||
}
|
||||
}
|
||||
return new Version(name, platform, protocol);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forge mod information for a server.
|
||||
*/
|
||||
@AllArgsConstructor @Getter @ToString
|
||||
public static class ModInfo {
|
||||
/**
|
||||
* The type of modded server this is.
|
||||
*/
|
||||
@NonNull private final String type;
|
||||
|
||||
/**
|
||||
* The list of mods on this server.
|
||||
*/
|
||||
@NonNull private final ForgeMod[] modList;
|
||||
}
|
||||
|
||||
@AllArgsConstructor @Getter @ToString
|
||||
private static class ForgeMod {
|
||||
/**
|
||||
* The id of this mod.
|
||||
*/
|
||||
@NonNull @SerializedName("modid") private final String id;
|
||||
|
||||
/**
|
||||
* The version of this mod.
|
||||
*/
|
||||
private final String version;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package me.braydon.mc.model.token;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
@ -31,13 +33,18 @@ public final class JavaServerStatusToken {
|
||||
/**
|
||||
* The version information of this server.
|
||||
*/
|
||||
@NonNull private final MinecraftServer.Version version;
|
||||
@NonNull private final JavaMinecraftServer.Version version;
|
||||
|
||||
/**
|
||||
* The player counts of this server.
|
||||
*/
|
||||
@NonNull private final MinecraftServer.Players players;
|
||||
|
||||
/**
|
||||
* The Forge mod information for this server, null if none.
|
||||
*/
|
||||
@SerializedName("modinfo") private final JavaMinecraftServer.ModInfo modInfo;
|
||||
|
||||
/**
|
||||
* Does this server enforce secure chat?
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user