From fcac93fd258d91f769b9b99cb5dde488a5be29f0 Mon Sep 17 00:00:00 2001 From: Timongcraft Date: Sat, 22 Jun 2024 17:52:39 +0200 Subject: [PATCH] Refactor command suggestion tooltip handling to support non-Velocity messages --- .../connection/client/ClientPlaySessionHandler.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index a76f054e72..f01796e1c3 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -676,10 +676,14 @@ private boolean handleCommandTabComplete(TabCompleteRequestPacket packet) { for (Suggestion suggestion : suggestions.getList()) { String offer = suggestion.getText(); ComponentHolder tooltip = null; - if (suggestion.getTooltip() != null - && suggestion.getTooltip() instanceof VelocityBrigadierMessage) { - tooltip = new ComponentHolder(player.getProtocolVersion(), - ((VelocityBrigadierMessage) suggestion.getTooltip()).asComponent()); + if (suggestion.getTooltip() != null) { + if (suggestion.getTooltip() instanceof VelocityBrigadierMessage velocityMessage) { + tooltip = new ComponentHolder(player.getProtocolVersion(), + velocityMessage.asComponent()); + } else { + tooltip = new ComponentHolder(player.getProtocolVersion(), + Component.text(suggestion.getTooltip().getString())); + } } offers.add(new Offer(offer, tooltip)); }