#2376 Add ServerConnectEvent Reason API
This commit is contained in:
@@ -10,6 +10,7 @@ import net.md_5.bungee.api.SkinConfiguration;
|
||||
import net.md_5.bungee.api.Title;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.score.Scoreboard;
|
||||
|
||||
/**
|
||||
@@ -87,6 +88,15 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
||||
*/
|
||||
void connect(ServerInfo target);
|
||||
|
||||
/**
|
||||
* Connects / transfers this user to the specified connection, gracefully
|
||||
* closing the current one. Depending on the implementation, this method
|
||||
* might return before the user has been connected.
|
||||
*
|
||||
* @param reason the reason for connecting to the new server
|
||||
*/
|
||||
void connect(ServerInfo target, ServerConnectEvent.Reason reason);
|
||||
|
||||
/**
|
||||
* Connects / transfers this user to the specified connection, gracefully
|
||||
* closing the current one. Depending on the implementation, this method
|
||||
@@ -99,6 +109,19 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
||||
*/
|
||||
void connect(ServerInfo target, Callback<Boolean> callback);
|
||||
|
||||
/**
|
||||
* Connects / transfers this user to the specified connection, gracefully
|
||||
* closing the current one. Depending on the implementation, this method
|
||||
* might return before the user has been connected.
|
||||
*
|
||||
* @param target the new server to connect to
|
||||
* @param callback the method called when the connection is complete, or
|
||||
* when an exception is encountered. The boolean parameter denotes success
|
||||
* or failure.
|
||||
* @param reason the reason for connecting to the new server
|
||||
*/
|
||||
void connect(ServerInfo target, Callback<Boolean> callback, ServerConnectEvent.Reason reason);
|
||||
|
||||
/**
|
||||
* Gets the server this player is connected to.
|
||||
*
|
||||
|
@@ -34,10 +34,57 @@ public class ServerConnectEvent extends Event implements Cancellable
|
||||
* Cancelled state.
|
||||
*/
|
||||
private boolean cancelled;
|
||||
private final Reason reason;
|
||||
|
||||
@Deprecated
|
||||
public ServerConnectEvent(ProxiedPlayer player, ServerInfo target)
|
||||
{
|
||||
this( player, target, Reason.UNKNOWN );
|
||||
}
|
||||
|
||||
public ServerConnectEvent(ProxiedPlayer player, ServerInfo target, Reason reason)
|
||||
{
|
||||
this.player = player;
|
||||
this.target = target;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public enum Reason
|
||||
{
|
||||
|
||||
/**
|
||||
* Redirection to lobby server due to being unable to connect to
|
||||
* original server
|
||||
*/
|
||||
LOBBY_FALLBACK,
|
||||
/**
|
||||
* Execution of a command
|
||||
*/
|
||||
COMMAND,
|
||||
/**
|
||||
* Redirecting to another server when client loses connection to server
|
||||
* due to an exception.
|
||||
*/
|
||||
SERVER_DOWN_REDIRECT,
|
||||
/**
|
||||
* Redirecting to another server when kicked from original server.
|
||||
*/
|
||||
KICK_REDIRECT,
|
||||
/**
|
||||
* Plugin message request.
|
||||
*/
|
||||
PLUGIN_MESSAGE,
|
||||
/**
|
||||
* Initial proxy connect.
|
||||
*/
|
||||
JOIN_PROXY,
|
||||
/**
|
||||
* Plugin initiated connect.
|
||||
*/
|
||||
PLUGIN,
|
||||
/**
|
||||
* Unknown cause.
|
||||
*/
|
||||
UNKNOWN
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user