#2372: Add SettingsChangedEvent for client-side settings

This commit is contained in:
games647 2018-03-05 11:09:55 +01:00 committed by md_5
parent d7eef6ff2e
commit 272258cf5a
2 changed files with 36 additions and 0 deletions

View File

@ -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:
*
* <ul>
* <li>View distance</li>
* <li>Locale</li>
* <li>Displayed skin parts</li>
* <li>Chat visibility</li>
* <li>Chat colors</li>
* <li>Main hand side (left or right)</li>
* </ul>
*/
@Data
@ToString(callSuper = false)
@EqualsAndHashCode(callSuper = false)
public class SettingsChangedEvent extends Event
{
/**
* Player who changed the settings.
*/
private final ProxiedPlayer player;
}

View File

@ -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.ChatEvent;
import net.md_5.bungee.api.event.PlayerDisconnectEvent; import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PluginMessageEvent; 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.api.event.TabCompleteEvent;
import net.md_5.bungee.forge.ForgeConstants; import net.md_5.bungee.forge.ForgeConstants;
import net.md_5.bungee.netty.ChannelWrapper; import net.md_5.bungee.netty.ChannelWrapper;
@ -175,6 +176,9 @@ public class UpstreamBridge extends PacketHandler
public void handle(ClientSettings settings) throws Exception public void handle(ClientSettings settings) throws Exception
{ {
con.setSettings( settings ); con.setSettings( settings );
SettingsChangedEvent settingsEvent = new SettingsChangedEvent( con );
bungee.getPluginManager().callEvent( settingsEvent );
} }
@Override @Override