From f7851b04369ec940e39d00462e85bd69a97eb5cf Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 25 Nov 2013 11:12:49 +1100 Subject: [PATCH] Implement ServerDisconnectEvent. Wow so many server switch events. --- .../api/event/ServerDisconnectEvent.java | 29 +++++++++++++++++++ .../bungee/connection/DownstreamBridge.java | 4 +++ 2 files changed, 33 insertions(+) create mode 100644 api/src/main/java/net/md_5/bungee/api/event/ServerDisconnectEvent.java diff --git a/api/src/main/java/net/md_5/bungee/api/event/ServerDisconnectEvent.java b/api/src/main/java/net/md_5/bungee/api/event/ServerDisconnectEvent.java new file mode 100644 index 00000000..2823b716 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/event/ServerDisconnectEvent.java @@ -0,0 +1,29 @@ +package net.md_5.bungee.api.event; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NonNull; +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; + +@Data +@AllArgsConstructor +@ToString(callSuper = false) +@EqualsAndHashCode(callSuper = false) +public class ServerDisconnectEvent extends Event +{ + + /** + * Player disconnecting from a server. + */ + @NonNull + private final ProxiedPlayer player; + /** + * Server the player is disconnecting from. + */ + @NonNull + private ServerInfo target; +} diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index 51ff6bcc..f62515c1 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.EntityMap; import net.md_5.bungee.ServerConnection; +import net.md_5.bungee.api.event.ServerDisconnectEvent; import net.md_5.bungee.UserConnection; import net.md_5.bungee.Util; import net.md_5.bungee.api.ProxyServer; @@ -69,6 +70,9 @@ public class DownstreamBridge extends PacketHandler { con.disconnect( bungee.getTranslation( "lost_connection" ) ); } + + ServerDisconnectEvent serverDisconnectEvent = new ServerDisconnectEvent( con, server.getInfo() ); + bungee.getPluginManager().callEvent( serverDisconnectEvent ); } @Override