From 30c679ccd1cf70baa4c2eab73f66af85aa80eea8 Mon Sep 17 00:00:00 2001 From: Adrian <68704415+4drian3d@users.noreply.github.com> Date: Sun, 29 Oct 2023 13:44:04 -0500 Subject: [PATCH] Fire PlayerSettingsChangedEvent event when PlayerSettings are provided in the Configuration phase (#1118) --- .../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 aee90cf80..dd538e127 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 @@ -87,7 +87,7 @@ public class ClientConfigSessionHandler implements MinecraftSessionHandler { @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 a0c786cfc..aa9c0b4ba 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 class ClientPlaySessionHandler implements MinecraftSessionHandler { @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 91ab9e576..d73f6f20a 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 @@ -289,12 +289,14 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player, 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)); }