From 77b9265cf7f8002f3fc52f876d4e3cd6bd3b9d08 Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 19 Oct 2023 11:27:01 -0500 Subject: [PATCH] Fire PlayerSettingsChangedEvent event when PlayerSettings are provided in the Configuration phase --- .../client/ClientConfigSessionHandler.java | 2 +- .../connection/client/ClientPlaySessionHandler.java | 2 +- .../proxy/connection/client/ConnectedPlayer.java | 12 +++++++----- 3 files changed, 9 insertions(+), 7 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 83d9fe91b1..d0e2cc3b10 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 @@ -84,7 +84,7 @@ public boolean handle(KeepAlive packet) { @Override public boolean handle(ClientSettings packet) { - player.setClientSettingsPacket(packet); + player.setClientSettings(packet); return true; } 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 6004cf8345..87b2a1fdc4 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 @@ -186,7 +186,7 @@ public boolean handle(KeepAlive packet) { @Override public boolean handle(ClientSettings packet) { - player.setPlayerSettings(packet); + player.setClientSettings(packet); VelocityServerConnection serverConnection = player.getConnectedServer(); if (serverConnection == null) { // No server connection yet, probably transitioning. diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index aada98cf54..4c76f2f23c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -282,12 +282,14 @@ public boolean hasSentPlayerSettings() { return settings != null; } - public void setClientSettingsPacket(ClientSettings clientSettingsPacket) { + /** + * Sets player settings. + * + * @param clientSettingsPacket the player settings packet + */ + public void setClientSettings(final ClientSettings clientSettingsPacket) { this.clientSettingsPacket = clientSettingsPacket; - } - - void setPlayerSettings(ClientSettings settings) { - ClientSettingsWrapper cs = new ClientSettingsWrapper(settings); + final ClientSettingsWrapper cs = new ClientSettingsWrapper(clientSettingsPacket); this.settings = cs; server.getEventManager().fireAndForget(new PlayerSettingsChangedEvent(this, cs)); }