From 7ceda5d4c74cc661d09603776c75f88775134490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gunnar=20Gu=C3=B0var=C3=B0arson?= Date: Tue, 2 Jan 2024 02:44:54 +0000 Subject: [PATCH] Add `LAN_SERVER_ID` to LAN payload Server side fix for https://github.com/meh-is/LANAnnouncer/issues/5 --- gradle.properties | 2 +- .../is/meh/minecraft/lan_announcer/LANAnnouncer.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index e89ea4b..7d44105 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.20.4+build.3 loader_version=0.15.3 # Mod Properties -mod_version=1.0.2 +mod_version=1.1.0 maven_group=is.meh.minecraft.lan_announcer archives_base_name=lanannouncer diff --git a/src/main/java/is/meh/minecraft/lan_announcer/LANAnnouncer.java b/src/main/java/is/meh/minecraft/lan_announcer/LANAnnouncer.java index 55e0b0d..ec86025 100644 --- a/src/main/java/is/meh/minecraft/lan_announcer/LANAnnouncer.java +++ b/src/main/java/is/meh/minecraft/lan_announcer/LANAnnouncer.java @@ -11,6 +11,7 @@ import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress; +import java.util.UUID; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; @@ -40,10 +41,13 @@ private String sanitizeMOTD(String motd) { } private void onServerStarted(MinecraftServer server) { - String motd = sanitizeMOTD(server.getServerMotd()); - int server_port = server.getServerPort(); + String motd = "[MOTD]" + sanitizeMOTD(server.getServerMotd()) + "[/MOTD]"; + String port = "[AD]" + server.getServerPort() + "[/AD]"; - byte[] message = ("[MOTD]" + motd + "[/MOTD][AD]" + server_port + "[/AD]").getBytes(); + // https://github.com/meh-is/LANAnnouncer/issues/5#issuecomment-1873572736 + String uuid = "[LAN_SERVER_ID]" + UUID.randomUUID() + "[/LAN_SERVER_ID]"; + + byte[] message = (motd + port + uuid).getBytes(); // Initialize and start the IPv4 and IPv6 announcers ipv4Announcer = new ServerAnnouncer("224.0.2.60", message);