From a6007ec6cfeeafd9c8dd314ae6442a76f5b07633 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 21 Oct 2012 12:46:58 +1100 Subject: [PATCH] Add post auth event --- pom.xml | 6 ------ src/main/java/net/md_5/bungee/InitialHandler.java | 11 +++++++++-- src/main/java/net/md_5/bungee/plugin/JavaPlugin.java | 10 +++++++++- .../net/md_5/bungee/plugin/JavaPluginManager.java | 11 ++++++++++- .../plugin/{HandshakeEvent.java => LoginEvent.java} | 6 ++---- 5 files changed, 30 insertions(+), 14 deletions(-) rename src/main/java/net/md_5/bungee/plugin/{HandshakeEvent.java => LoginEvent.java} (62%) diff --git a/pom.xml b/pom.xml index b8a5d5100..bb8775ac1 100644 --- a/pom.xml +++ b/pom.xml @@ -100,12 +100,6 @@ http://repo.md-5.net/content/groups/public - - - md_5-public - http://repo.md-5.net/content/groups/public - - ${project.name} diff --git a/src/main/java/net/md_5/bungee/InitialHandler.java b/src/main/java/net/md_5/bungee/InitialHandler.java index 0ab0456f1..6db5ebfa3 100644 --- a/src/main/java/net/md_5/bungee/InitialHandler.java +++ b/src/main/java/net/md_5/bungee/InitialHandler.java @@ -9,7 +9,7 @@ import net.md_5.bungee.packet.PacketFCEncryptionResponse; import net.md_5.bungee.packet.PacketFDEncryptionRequest; import net.md_5.bungee.packet.PacketFFKick; import net.md_5.bungee.packet.PacketInputStream; -import net.md_5.bungee.plugin.HandshakeEvent; +import net.md_5.bungee.plugin.LoginEvent; import org.bouncycastle.crypto.io.CipherInputStream; import org.bouncycastle.crypto.io.CipherOutputStream; @@ -39,7 +39,7 @@ public class InitialHandler implements Runnable case 0x02: Packet2Handshake handshake = new Packet2Handshake(packet); // fire connect event - HandshakeEvent event = new HandshakeEvent(handshake.username, socket.getInetAddress()); + LoginEvent event = new LoginEvent(handshake.username, socket.getInetAddress()); BungeeCord.instance.pluginManager.onHandshake(event); if (event.isCancelled()) { @@ -56,6 +56,13 @@ public class InitialHandler implements Runnable throw new KickException("Not authenticated with minecraft.net"); } + // fire post auth event + BungeeCord.instance.pluginManager.onHandshake(event); + if (event.isCancelled()) + { + throw new KickException(event.getCancelReason()); + } + out.write(new PacketFCEncryptionResponse().getPacket()); in = new PacketInputStream(new CipherInputStream(socket.getInputStream(), EncryptionUtil.getCipher(false, shared))); out = new CipherOutputStream(socket.getOutputStream(), EncryptionUtil.getCipher(true, shared)); diff --git a/src/main/java/net/md_5/bungee/plugin/JavaPlugin.java b/src/main/java/net/md_5/bungee/plugin/JavaPlugin.java index 6c1f670a1..16fcf368e 100644 --- a/src/main/java/net/md_5/bungee/plugin/JavaPlugin.java +++ b/src/main/java/net/md_5/bungee/plugin/JavaPlugin.java @@ -32,7 +32,15 @@ public abstract class JavaPlugin * Called when a user connects with their name and address. To keep things * simple this name has not been checked with minecraft.net. */ - public void onHandshake(HandshakeEvent event) + public void onHandshake(LoginEvent event) + { + } + + /** + * Called after a user has been authed with minecraftt.net and is about to + * log into the proxy. + */ + public void onLogin(LoginEvent event) { } diff --git a/src/main/java/net/md_5/bungee/plugin/JavaPluginManager.java b/src/main/java/net/md_5/bungee/plugin/JavaPluginManager.java index e113b513f..a8192405b 100644 --- a/src/main/java/net/md_5/bungee/plugin/JavaPluginManager.java +++ b/src/main/java/net/md_5/bungee/plugin/JavaPluginManager.java @@ -81,11 +81,20 @@ public class JavaPluginManager extends JavaPlugin } @Override - public void onHandshake(HandshakeEvent event) + public void onHandshake(LoginEvent event) { for (JavaPlugin p : plugins) { p.onHandshake(event); } } + + @Override + public void onLogin(LoginEvent event) + { + for (JavaPlugin p : plugins) + { + p.onLogin(event); + } + } } diff --git a/src/main/java/net/md_5/bungee/plugin/HandshakeEvent.java b/src/main/java/net/md_5/bungee/plugin/LoginEvent.java similarity index 62% rename from src/main/java/net/md_5/bungee/plugin/HandshakeEvent.java rename to src/main/java/net/md_5/bungee/plugin/LoginEvent.java index 7a757d09c..518cbfae8 100644 --- a/src/main/java/net/md_5/bungee/plugin/HandshakeEvent.java +++ b/src/main/java/net/md_5/bungee/plugin/LoginEvent.java @@ -4,12 +4,10 @@ import java.net.InetAddress; import lombok.Data; /** - * Event called once a remote connection has begun the login procedure. This - * event is ideal for IP banning, however must be used with care in other places - * such as logging at the username has not yet been verified with Mojang. + * Event called to represent a player logging in. */ @Data -public class HandshakeEvent implements Cancellable +public class LoginEvent implements Cancellable { /**