From 272258cf5a22602fda6b9030fa91524d90511c11 Mon Sep 17 00:00:00 2001 From: games647 Date: Mon, 5 Mar 2018 11:09:55 +0100 Subject: [PATCH] #2372: Add SettingsChangedEvent for client-side settings --- .../api/event/SettingsChangedEvent.java | 32 +++++++++++++++++++ .../bungee/connection/UpstreamBridge.java | 4 +++ 2 files changed, 36 insertions(+) create mode 100644 api/src/main/java/net/md_5/bungee/api/event/SettingsChangedEvent.java diff --git a/api/src/main/java/net/md_5/bungee/api/event/SettingsChangedEvent.java b/api/src/main/java/net/md_5/bungee/api/event/SettingsChangedEvent.java new file mode 100644 index 00000000..dbe4d750 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/event/SettingsChangedEvent.java @@ -0,0 +1,32 @@ +package net.md_5.bungee.api.event; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.plugin.Event; + +/** + * Called after a {@link ProxiedPlayer} changed one or more of the following + * (client-side) settings: + * + * + */ +@Data +@ToString(callSuper = false) +@EqualsAndHashCode(callSuper = false) +public class SettingsChangedEvent extends Event +{ + + /** + * Player who changed the settings. + */ + private final ProxiedPlayer player; +} diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java index bb43810b..19a52458 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java @@ -12,6 +12,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.event.SettingsChangedEvent; import net.md_5.bungee.api.event.TabCompleteEvent; import net.md_5.bungee.forge.ForgeConstants; import net.md_5.bungee.netty.ChannelWrapper; @@ -175,6 +176,9 @@ public class UpstreamBridge extends PacketHandler public void handle(ClientSettings settings) throws Exception { con.setSettings( settings ); + + SettingsChangedEvent settingsEvent = new SettingsChangedEvent( con ); + bungee.getPluginManager().callEvent( settingsEvent ); } @Override