#2379: Add ServerSwitchEvent getFrom API

This commit is contained in:
Mystiflow 2020-03-25 18:19:55 +11:00 committed by md_5
parent cb3f87bb27
commit f1c32f84f4
2 changed files with 8 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package net.md_5.bungee.api.event;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; 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.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Event; import net.md_5.bungee.api.plugin.Event;
@ -19,4 +20,9 @@ public class ServerSwitchEvent extends Event
* Player whom the server is for. * Player whom the server is for.
*/ */
private final ProxiedPlayer player; private final ProxiedPlayer player;
/**
* Server the player is switch from. May be null if initial proxy
* connection.
*/
private final ServerInfo from;
} }

View File

@ -292,10 +292,11 @@ public class ServerConnector extends PacketHandler
user.setServerJoinQueue( null ); user.setServerJoinQueue( null );
user.setDimensionChange( false ); user.setDimensionChange( false );
ServerInfo from = ( user.getServer() == null ) ? null : user.getServer().getInfo();
user.setServer( server ); user.setServer( server );
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new DownstreamBridge( bungee, user, 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; thisState = State.FINISHED;