From 49ea7f908fa443da2453c31b81f5212e6f236fbd Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 12 May 2013 09:15:17 +1000 Subject: [PATCH] Add server switch event --- .../bungee/api/event/ServerSwitchEvent.java | 21 +++++++++++++++++++ .../java/net/md_5/bungee/ServerConnector.java | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 api/src/main/java/net/md_5/bungee/api/event/ServerSwitchEvent.java diff --git a/api/src/main/java/net/md_5/bungee/api/event/ServerSwitchEvent.java b/api/src/main/java/net/md_5/bungee/api/event/ServerSwitchEvent.java new file mode 100644 index 00000000..69b7e69f --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/event/ServerSwitchEvent.java @@ -0,0 +1,21 @@ +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 when a player has changed servers. + */ +@Data +@ToString(callSuper = false) +@EqualsAndHashCode(callSuper = false) +public class ServerSwitchEvent extends Event +{ + + /** + * Player whom the server is for. + */ + private final ProxiedPlayer player; +} diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index 6e339312..c58e0196 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -15,6 +15,7 @@ import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.event.ServerConnectedEvent; import net.md_5.bungee.api.event.ServerKickEvent; +import net.md_5.bungee.api.event.ServerSwitchEvent; import net.md_5.bungee.api.scoreboard.Objective; import net.md_5.bungee.api.scoreboard.Scoreboard; import net.md_5.bungee.api.scoreboard.Team; @@ -189,6 +190,8 @@ public class ServerConnector extends PacketHandler ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new DownstreamBridge( bungee, user, server ) ); } + bungee.getPluginManager().callEvent( new ServerSwitchEvent( user ) ); + thisState = State.FINISHED; throw new CancelSendSignal();