From 4811e7be4f76e3113f8986cc583766c6e5a380a5 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 14 Mar 2013 21:11:16 +1100 Subject: [PATCH] Implement PostLoginEvent, closes #191 --- .../md_5/bungee/api/event/PostLoginEvent.java | 23 +++++++++++++++++++ .../bungee/connection/InitialHandler.java | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 api/src/main/java/net/md_5/bungee/api/event/PostLoginEvent.java 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 000000000..a2bccf7f6 --- /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 5020e5671..c474c15eb 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 );