From 8344082b1a43890d5f81520271c8906dc53ec125 Mon Sep 17 00:00:00 2001 From: Rocco Date: Wed, 3 Aug 2022 15:19:30 +0200 Subject: [PATCH] Fix chat decoding for legacy versions (#815) --- .../proxy/connection/client/ClientPlaySessionHandler.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 33c9192ae..afb2158ce 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 @@ -180,13 +180,14 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { return server.getEventManager().fire(event) .thenApply(pme -> { PlayerChatEvent.ChatResult chatResult = pme.getResult(); + IdentifiedKey playerKey = player.getIdentifiedKey(); if (chatResult.isAllowed()) { Optional eventMsg = pme.getResult().getMessage(); if (eventMsg.isPresent()) { String messageNew = eventMsg.get(); - if (player.getIdentifiedKey() != null) { + if (playerKey != null) { if (signedMessage != null && !messageNew.equals(signedMessage.getMessage())) { - if (player.getIdentifiedKey().getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) { + if (playerKey.getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) { // Bad, very bad. logger.fatal("A plugin tried to change a signed chat message. " + "This is no longer possible in 1.19.1 and newer. " @@ -209,7 +210,7 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { return original; } } else { - if (player.getIdentifiedKey().getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) { + if (playerKey != null && playerKey.getKeyRevision().compareTo(IdentifiedKey.Revision.LINKED_V2) >= 0) { logger.fatal("A plugin tried to cancel a signed chat message." + " This is no longer possible in 1.19.1 and newer. " + "Disconnecting player " + player.getUsername());