From f6fbd258052200172ccd39854c5330dd36717db2 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sun, 21 Jan 2024 11:47:14 +0000 Subject: [PATCH] Downgrade severity of handling several incoming user input packet states --- .../client/ClientConfigSessionHandler.java | 2 +- .../client/ClientPlaySessionHandler.java | 22 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java index db1e26988..860ca5830 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientConfigSessionHandler.java @@ -116,7 +116,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler { @Override public boolean handle(PluginMessagePacket packet) { VelocityServerConnection serverConn = player.getConnectionInFlight(); - if (serverConn != null) { + if (serverConn != null) {L if (PluginMessageUtil.isMcBrand(packet)) { String brand = PluginMessageUtil.readBrandMessage(packet.content()); server.getEventManager().fireAndForget(new PlayerClientBrandEvent(player, brand)); 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 121fea721..13c3fed1a 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 @@ -200,7 +200,10 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { @Override public boolean handle(SessionPlayerCommandPacket packet) { - player.ensureAndGetCurrentServer(); + if (player.getCurrentServer().isEmpty()) { + return true; + } + if (!updateTimeKeeper(packet.getTimeStamp())) { return true; @@ -215,7 +218,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { @Override public boolean handle(SessionPlayerChatPacket packet) { - player.ensureAndGetCurrentServer(); + if (player.getCurrentServer().isEmpty()) { + return true; + } if (!updateTimeKeeper(packet.getTimestamp())) { return true; @@ -230,7 +235,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { @Override public boolean handle(KeyedPlayerCommandPacket packet) { - player.ensureAndGetCurrentServer(); + if (player.getCurrentServer().isEmpty()) { + return true; + } if (!updateTimeKeeper(packet.getTimestamp())) { return true; @@ -245,7 +252,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { @Override public boolean handle(KeyedPlayerChatPacket packet) { - player.ensureAndGetCurrentServer(); + if (player.getCurrentServer().isEmpty()) { + return true; + } if (!updateTimeKeeper(packet.getExpiry())) { return true; @@ -260,7 +269,10 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { @Override public boolean handle(LegacyChatPacket packet) { - player.ensureAndGetCurrentServer(); + if (player.getCurrentServer().isEmpty()) { + return true; + } + String msg = packet.getMessage(); if (!validateChat(msg)) { return true;