diff --git a/api/src/main/java/net/md_5/bungee/api/event/PostLoginEvent.java b/api/src/main/java/net/md_5/bungee/api/event/PostLoginEvent.java new file mode 100644 index 00000000..a2bccf7f --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/event/PostLoginEvent.java @@ -0,0 +1,23 @@ +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; + +/** + * Event called as soon as a connection has an {@link ProxiedPlayer} and is + * ready to be connected to a server. + */ +@Data +@ToString(callSuper = false) +@EqualsAndHashCode(callSuper = false) +public class PostLoginEvent extends Event +{ + + /** + * The player involved with this event. + */ + private final ProxiedPlayer player; +} diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java index 5020e567..c474c15e 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java @@ -28,6 +28,7 @@ import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.LoginEvent; +import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.event.ProxyPingEvent; import net.md_5.bungee.netty.CipherCodec; import net.md_5.bungee.netty.HandlerBoss; @@ -208,6 +209,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" ); UserConnection userCon = new UserConnection( (BungeeCord) bungee, ch, this, handshake, forgeLogin, loginMessages ); + bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) ); + ch.pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) ); ServerInfo server = bungee.getReconnectHandler().getServer( userCon );