mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-11-27 20:59:12 +01:00
Add new event for @mbax
This commit is contained in:
parent
30abf975c2
commit
6f005064a1
@ -15,6 +15,7 @@ import net.md_5.bungee.packet.Packet3Chat;
|
|||||||
import net.md_5.bungee.packet.Packet9Respawn;
|
import net.md_5.bungee.packet.Packet9Respawn;
|
||||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
||||||
import net.md_5.bungee.packet.PacketInputStream;
|
import net.md_5.bungee.packet.PacketInputStream;
|
||||||
|
import net.md_5.bungee.plugin.ServerConnectEvent;
|
||||||
|
|
||||||
public class UserConnection extends GenericConnection implements CommandSender
|
public class UserConnection extends GenericConnection implements CommandSender
|
||||||
{
|
{
|
||||||
@ -39,7 +40,10 @@ public class UserConnection extends GenericConnection implements CommandSender
|
|||||||
|
|
||||||
public void connect(String server)
|
public void connect(String server)
|
||||||
{
|
{
|
||||||
InetSocketAddress addr = BungeeCord.instance.config.getServer(server);
|
ServerConnectEvent event = new ServerConnectEvent(this, server);
|
||||||
|
event.setNewServer(server);
|
||||||
|
BungeeCord.instance.pluginManager.onServerConnect(event);
|
||||||
|
InetSocketAddress addr = BungeeCord.instance.config.getServer(event.getNewServer());
|
||||||
connect(server, addr);
|
connect(server, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,13 @@ public abstract class JavaPlugin
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a user is connecting to a new server.
|
||||||
|
*/
|
||||||
|
public void onServerConnect(ServerConnectEvent event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a command for use with the proxy.
|
* Register a command for use with the proxy.
|
||||||
*/
|
*/
|
||||||
|
@ -97,4 +97,13 @@ public class JavaPluginManager extends JavaPlugin
|
|||||||
p.onLogin(event);
|
p.onLogin(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServerConnect(ServerConnectEvent event)
|
||||||
|
{
|
||||||
|
for (JavaPlugin p : plugins)
|
||||||
|
{
|
||||||
|
p.onServerConnect(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
25
src/main/java/net/md_5/bungee/plugin/ServerConnectEvent.java
Normal file
25
src/main/java/net/md_5/bungee/plugin/ServerConnectEvent.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package net.md_5.bungee.plugin;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.md_5.bungee.UserConnection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event called when the decision is made to decide which server to connect to.
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ServerConnectEvent
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User in question.
|
||||||
|
*/
|
||||||
|
private final UserConnection connection;
|
||||||
|
/**
|
||||||
|
* Name of the server they are connecting to.
|
||||||
|
*/
|
||||||
|
private final String server;
|
||||||
|
/**
|
||||||
|
* Name of the server which they will be forwarded to instead.
|
||||||
|
*/
|
||||||
|
private String newServer;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user