From 7a5219de8ec5cffece0ada77137bcabc5682b6d2 Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Sat, 6 Apr 2024 21:39:42 -0400 Subject: [PATCH] Add more Java server flags --- .../me/braydon/mc/model/MinecraftServer.java | 11 +------ .../model/server/BedrockMinecraftServer.java | 4 +-- .../mc/model/server/JavaMinecraftServer.java | 32 ++++++++++++++++--- .../mc/model/token/JavaServerStatusToken.java | 10 ++++++ .../impl/JavaMinecraftServerPinger.java | 1 + 5 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/main/java/me/braydon/mc/model/MinecraftServer.java b/src/main/java/me/braydon/mc/model/MinecraftServer.java index de956f9..1c3f180 100644 --- a/src/main/java/me/braydon/mc/model/MinecraftServer.java +++ b/src/main/java/me/braydon/mc/model/MinecraftServer.java @@ -2,7 +2,6 @@ package me.braydon.mc.model; import lombok.*; import me.braydon.mc.common.ColorUtils; -import me.braydon.mc.model.token.JavaServerStatusToken; import me.braydon.mc.service.pinger.MinecraftServerPinger; import me.braydon.mc.service.pinger.impl.BedrockMinecraftServerPinger; import me.braydon.mc.service.pinger.impl.JavaMinecraftServerPinger; @@ -52,14 +51,6 @@ public class MinecraftServer { */ private final String icon; - /** - * Is this server on the list - * of blocked servers by Mojang? - * - * @see Mojang API - */ - private final boolean mojangBanned; - /** * Version information for a server. */ @@ -142,7 +133,7 @@ public class MinecraftServer { @AllArgsConstructor @Getter @ToString public static class MOTD { /** - * The raw MOTD lines, taken directly from the {@link JavaServerStatusToken}. + * The raw MOTD lines. */ @NonNull private final String[] raw; diff --git a/src/main/java/me/braydon/mc/model/server/BedrockMinecraftServer.java b/src/main/java/me/braydon/mc/model/server/BedrockMinecraftServer.java index 6ebcf48..7ca2789 100644 --- a/src/main/java/me/braydon/mc/model/server/BedrockMinecraftServer.java +++ b/src/main/java/me/braydon/mc/model/server/BedrockMinecraftServer.java @@ -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, String icon, boolean mojangBanned) { - super(hostname, ip, port, version, players, motd, icon, mojangBanned); + @NonNull Players players, @NonNull MOTD motd, String icon) { + super(hostname, ip, port, version, players, motd, icon); } } \ No newline at end of file diff --git a/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java b/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java index 67594e1..192b96e 100644 --- a/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java +++ b/src/main/java/me/braydon/mc/model/server/JavaMinecraftServer.java @@ -1,5 +1,6 @@ package me.braydon.mc.model.server; +import lombok.Getter; import lombok.NonNull; import me.braydon.mc.RESTfulMC; import me.braydon.mc.model.MinecraftServer; @@ -12,10 +13,33 @@ import net.md_5.bungee.chat.ComponentSerializer; * * @author Braydon */ +@Getter public final class JavaMinecraftServer extends MinecraftServer { + /** + * Does this server enforce secure chat? + */ + private final boolean enforcesSecureChat; + + /** + * Is this server preventing chat reports? + */ + private final boolean preventsChatReports; + + /** + * Is this server on the list + * of blocked servers by Mojang? + * + * @see Mojang API + */ + 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 mojangBanned) { - super(hostname, ip, port, version, players, motd, icon, mojangBanned); + @NonNull Players players, @NonNull MOTD motd, String icon, boolean enforcesSecureChat, + boolean preventsChatReports, boolean mojangBanned) { + super(hostname, ip, port, version, players, motd, icon); + this.enforcesSecureChat = enforcesSecureChat; + this.preventsChatReports = preventsChatReports; + this.mojangBanned = mojangBanned; } /** @@ -33,8 +57,8 @@ 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(), false + return new JavaMinecraftServer(hostname, ip, port, token.getVersion().detailedCopy(), token.getPlayers(), + MOTD.create(motdString), token.getFavicon(), token.isEnforcesSecureChat(), token.isPreventsChatReports(), false ); } } \ No newline at end of file diff --git a/src/main/java/me/braydon/mc/model/token/JavaServerStatusToken.java b/src/main/java/me/braydon/mc/model/token/JavaServerStatusToken.java index fb397a8..3ea4375 100644 --- a/src/main/java/me/braydon/mc/model/token/JavaServerStatusToken.java +++ b/src/main/java/me/braydon/mc/model/token/JavaServerStatusToken.java @@ -37,4 +37,14 @@ public final class JavaServerStatusToken { * The player counts of this server. */ @NonNull private final MinecraftServer.Players players; + + /** + * Does this server enforce secure chat? + */ + private final boolean enforcesSecureChat; + + /** + * Is this server preventing chat reports? + */ + private final boolean preventsChatReports; } \ No newline at end of file diff --git a/src/main/java/me/braydon/mc/service/pinger/impl/JavaMinecraftServerPinger.java b/src/main/java/me/braydon/mc/service/pinger/impl/JavaMinecraftServerPinger.java index 9ea74bf..c78bb11 100644 --- a/src/main/java/me/braydon/mc/service/pinger/impl/JavaMinecraftServerPinger.java +++ b/src/main/java/me/braydon/mc/service/pinger/impl/JavaMinecraftServerPinger.java @@ -60,6 +60,7 @@ public final class JavaMinecraftServerPinger implements MinecraftServerPinger