Skip to content

Commit

Permalink
Add LAN_SERVER_ID to LAN payload
Browse files Browse the repository at this point in the history
Server side fix for #5
  • Loading branch information
Gunni committed Jan 2, 2024
1 parent 4d7d921 commit 7ceda5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/is/meh/minecraft/lan_announcer/LANAnnouncer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7ceda5d

Please sign in to comment.