From 4ce2a4c1b4a8416db4e9adfee0f337e54dbfb100 Mon Sep 17 00:00:00 2001 From: Josiah Glosson Date: Sun, 30 Jun 2024 16:59:31 -0500 Subject: [PATCH] Add warning message --- .../worldhost/protocol/WorldHostS2CMessage.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java index 3e1edae..8fc9958 100644 --- a/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java +++ b/src/main/java/io/github/gaming32/worldhost/protocol/WorldHostS2CMessage.java @@ -276,6 +276,17 @@ public void handle(ProtocolClient client) { } } + record Warning(String message, boolean important) implements WorldHostS2CMessage { + @Override + public void handle(ProtocolClient client) { + WorldHost.LOGGER.warn("Warning from WH server (important: {}): {}", important, message); + WHToast.builder(Components.translatable("world-host.protocol_warning_occurred")) + .description(Components.literal(message)) + .important(important) + .show(); + } + } + /** * NOTE: This method is called from the RecvThread, so it should be careful to not do anything that could *
    @@ -334,6 +345,7 @@ static WorldHostS2CMessage decode(DataInputStream dis) throws IOException { } yield new NewQueryResponse(friend, serverStatus); } + case 17 -> new Warning(readString(dis), dis.read() != 0); default -> new Error("Received packet with unknown typeId from server (outdated client?): " + typeId); }; }