Skip to content

Commit

Permalink
Add warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jun 30, 2024
1 parent d3d22ca commit 4ce2a4c
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
* <ol>
Expand Down Expand Up @@ -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);
};
}
Expand Down

0 comments on commit 4ce2a4c

Please sign in to comment.