@NonnullByDefault public final class BungeeMessaging extends Object implements PluginMessageListener
See: https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel and https://github.com/SpigotMC/BungeeCord/blob/master/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java#L223
| Modifier and Type | Field and Description |
|---|---|
static String |
ALL_SERVERS
Server name to represent all servers on the proxy
|
static String |
ONLINE_SERVERS
Server name to represent only the online servers on the proxy
|
| Modifier and Type | Method and Description |
|---|---|
static void |
connect(Player player,
String serverName)
Connects a player to said subserver
|
static void |
connectOther(String playerName,
String serverName)
Connects a named player to said subserver
|
static void |
forward(String serverName,
String channelName,
byte[] data)
Sends a custom plugin message to a given server.
|
static void |
forward(String serverName,
String channelName,
ByteArrayDataOutput data)
Sends a custom plugin message to a given server.
|
static void |
forwardToPlayer(String playerName,
String channelName,
byte[] data)
Sends a custom plugin message to a given server.
|
static void |
forwardToPlayer(String playerName,
String channelName,
ByteArrayDataOutput data)
Sends a custom plugin message to a given server.
|
static void |
getServer(Consumer<String> callback)
Gets this servers name, as defined in the BungeeCord config
|
static void |
getServers(Consumer<List<String>> callback)
Get a list of server name strings, as defined in the BungeeCord config
|
static void |
ip(Player player,
Consumer<Map.Entry<String,Integer>> callback)
Get the real IP of a player
|
static void |
kickPlayer(String playerName,
String reason)
Kick a player from the proxy
|
static void |
message(String playerName,
String message)
Send a message (as in chat message) to the specified player
|
void |
onPluginMessageReceived(String channel,
Player player,
byte[] data) |
static void |
playerCount(String serverName,
Consumer<Integer> callback)
Gets the amount of players on a certain server, or all servers
|
static void |
playerList(String serverName,
Consumer<List<String>> callback)
Gets a list of players connected on a certain server, or all servers.
|
static void |
registerForwardCallback(String channelName,
Predicate<ByteArrayDataInput> callback)
Registers a callback to listen for messages sent on forwarded subchannels.
|
static void |
registerForwardCallbackRaw(String channelName,
Predicate<byte[]> callback)
Registers a callback to listen for messages sent on forwarded subchannels.
|
static void |
serverIp(String serverName,
Consumer<Map.Entry<String,Integer>> callback)
Get the IP of any server connected to the proxy
|
static void |
uuid(Player player,
Consumer<UUID> callback)
Get the UUID of a player
|
static void |
uuidOther(String playerName,
Consumer<UUID> callback)
Get the UUID of any player connected to the proxy
|
public static final String ALL_SERVERS
public static final String ONLINE_SERVERS
public static void connect(Player player, String serverName)
player - the player to connectserverName - the name of the server to connect topublic static void connectOther(String playerName, String serverName)
playerName - the username of the player to connectserverName - the name of the server to connect topublic static void ip(Player player, Consumer<Map.Entry<String,Integer>> callback)
player - the player to get the IP ofcallback - a callback to consume the ip and portpublic static void playerCount(String serverName, Consumer<Integer> callback)
serverName - the name of the server to get the player count for. Use ALL_SERVERS to get the global countcallback - a callback to consume the countpublic static void playerList(String serverName, Consumer<List<String>> callback)
serverName - the name of the server to get the player list for. Use ALL_SERVERS to get the global listcallback - a callback to consume the player listpublic static void getServers(Consumer<List<String>> callback)
callback - a callback to consume the list of server namespublic static void message(String playerName, String message)
playerName - the username of the player to send the message tomessage - the message to sendpublic static void getServer(Consumer<String> callback)
callback - a callback to consume the namepublic static void uuid(Player player, Consumer<UUID> callback)
player - the player to get the uuid ofcallback - a callback to consume the uuidpublic static void uuidOther(String playerName, Consumer<UUID> callback)
playerName - the username of the player to get the uuid ofcallback - a callback to consume the uuidpublic static void serverIp(String serverName, Consumer<Map.Entry<String,Integer>> callback)
serverName - the name of the server to get the ip ofcallback - a callback to consume the ip and portpublic static void kickPlayer(String playerName, String reason)
playerName - the username of the player to kickreason - the reason to display to the player when they are kickedpublic static void forward(String serverName, String channelName, byte[] data)
You can use registerForwardCallbackRaw(String, Predicate) to register listeners on a given subchannel.
serverName - the name of the server to send to. use ALL_SERVERS to send to all servers, or ONLINE_SERVERS to only send to servers which are online.channelName - the name of the subchanneldata - the data to sendpublic static void forward(String serverName, String channelName, ByteArrayDataOutput data)
You can use registerForwardCallback(String, Predicate) to register listeners on a given subchannel.
serverName - the name of the server to send to. use ALL_SERVERS to send to all servers, or ONLINE_SERVERS to only send to servers which are online.channelName - the name of the subchanneldata - the data to sendpublic static void forwardToPlayer(String playerName, String channelName, byte[] data)
You can use registerForwardCallbackRaw(String, Predicate) to register listeners on a given subchannel.
playerName - the username of a player. BungeeCord will send the forward message to their server.channelName - the name of the subchanneldata - the data to sendpublic static void forwardToPlayer(String playerName, String channelName, ByteArrayDataOutput data)
You can use registerForwardCallback(String, Predicate) to register listeners on a given subchannel.
playerName - the username of a player. BungeeCord will send the forward message to their server.channelName - the name of the subchanneldata - the data to sendpublic static void registerForwardCallbackRaw(String channelName, Predicate<byte[]> callback)
Use forward(String, String, byte[]) to dispatch messages.
channelName - the name of the channel to listen oncallback - the callback. the predicate should return true when the callback should be unregistered.public static void registerForwardCallback(String channelName, Predicate<ByteArrayDataInput> callback)
Use forward(String, String, ByteArrayDataOutput) to dispatch messages.
channelName - the name of the channel to listen oncallback - the callback. the predicate should return true when the callback should be unregistered.public void onPluginMessageReceived(String channel, Player player, byte[] data)
onPluginMessageReceived in interface PluginMessageListenerCopyright © 2017. All rights reserved.