Add ability to block a server change and send a message on change
This commit is contained in:
parent
cd95befbea
commit
71ab7f7c45
@ -40,9 +40,23 @@ public class UserConnection extends GenericConnection implements CommandSender
|
||||
|
||||
public void connect(String server)
|
||||
{
|
||||
ServerConnectEvent event = new ServerConnectEvent(this, server);
|
||||
ServerConnectEvent event = new ServerConnectEvent(this.server == null, this, server);
|
||||
event.setNewServer(server);
|
||||
BungeeCord.instance.pluginManager.onServerConnect(event);
|
||||
if (event.getMessage() != null)
|
||||
{
|
||||
this.sendMessage(event.getMessage());
|
||||
}
|
||||
if (event.getNewServer() == null)
|
||||
{
|
||||
if (event.isFirstTime())
|
||||
{
|
||||
event.setNewServer(BungeeCord.instance.config.defaultServerName);
|
||||
} else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
InetSocketAddress addr = BungeeCord.instance.config.getServer(event.getNewServer());
|
||||
connect(server, addr);
|
||||
}
|
||||
|
@ -10,6 +10,15 @@ import net.md_5.bungee.UserConnection;
|
||||
public class ServerConnectEvent
|
||||
{
|
||||
|
||||
/**
|
||||
* If the player currently has no server, this is true
|
||||
*/
|
||||
private final boolean firstTime;
|
||||
/**
|
||||
* Message to send just before the change.
|
||||
* null for no message
|
||||
*/
|
||||
private String message;
|
||||
/**
|
||||
* User in question.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user