Implement ServerDisconnectEvent. Wow so many server switch events.

This commit is contained in:
md_5 2013-11-25 11:12:49 +11:00
parent d7e78d0945
commit f7851b0436
2 changed files with 33 additions and 0 deletions

View File

@ -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;
}

View File

@ -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