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 index 4722517ae..4414ec793 100644 --- 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 @@ -3,6 +3,7 @@ package net.md_5.bungee.api.event; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Event; @@ -19,4 +20,9 @@ public class ServerSwitchEvent extends Event * Player whom the server is for. */ private final ProxiedPlayer player; + /** + * Server the player is switch from. May be null if initial proxy + * connection. + */ + private final ServerInfo from; } 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 65d4b0b12..28b0ac9db 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -292,10 +292,11 @@ public class ServerConnector extends PacketHandler user.setServerJoinQueue( null ); user.setDimensionChange( false ); + ServerInfo from = ( user.getServer() == null ) ? null : user.getServer().getInfo(); user.setServer( server ); ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new DownstreamBridge( bungee, user, server ) ); - bungee.getPluginManager().callEvent( new ServerSwitchEvent( user ) ); + bungee.getPluginManager().callEvent( new ServerSwitchEvent( user, from ) ); thisState = State.FINISHED;