public class BungeeChannelApi extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
BungeeChannelApi.ForwardConsumer |
Constructor and Description |
---|
BungeeChannelApi(Plugin plugin) |
Modifier and Type | Method and Description |
---|---|
void |
connect(Player player,
String serverName)
Connects a player to said subserver.
|
void |
connectOther(String playerName,
String server)
Connect a named player to said subserver.
|
void |
forward(String server,
String channelName,
byte[] data)
Send a custom plugin message to said server.
|
void |
forwardToPlayer(String playerName,
String channelName,
byte[] data)
Send a custom plugin message to specific player.
|
CompletableFuture<InetSocketAddress> |
getIp(Player player)
Get the (real) IP of a player.
|
CompletableFuture<Integer> |
getPlayerCount(String serverName)
Get the amount of players on a certain server, or on ALL the servers.
|
CompletableFuture<List<String>> |
getPlayerList(String serverName)
Get a list of players connected on a certain server, or on ALL the servers.
|
CompletableFuture<String> |
getServer()
Get this server's name, as defined in BungeeCord's config.yml
|
CompletableFuture<InetSocketAddress> |
getServerIp(String serverName)
Request the IP of any server on this proxy
|
CompletableFuture<List<String>> |
getServers()
Get a list of server name strings, as defined in BungeeCord's config.yml
|
CompletableFuture<String> |
getUUID(Player player)
Request the UUID of this player
|
void |
kickPlayer(String playerName,
String kickMessage)
Kick any player on this proxy
|
static BungeeChannelApi |
of(Plugin plugin) |
void |
registerForwardListener(BungeeChannelApi.ForwardConsumer globalListener) |
void |
registerForwardListener(String targetChannel,
BungeeChannelApi.ForwardConsumer listener) |
void |
sendMessage(String playerName,
String message)
Send a message (as in, a chat message) to the specified player.
|
void |
unregister()
Unregister message channels.
|
public static BungeeChannelApi of(Plugin plugin)
public void registerForwardListener(BungeeChannelApi.ForwardConsumer globalListener)
public void registerForwardListener(String targetChannel, BungeeChannelApi.ForwardConsumer listener)
public CompletableFuture<Integer> getPlayerCount(String serverName)
serverName
- the server name of the server to get the player count of, or ALL to get the global player countCompletableFuture
that, when completed, will return
the amount of players on a certain server, or on ALL the servers.public CompletableFuture<List<String>> getPlayerList(String serverName)
serverName
- the name of the server to get the list of connected players, or ALL for global online player listCompletableFuture
that, when completed, will return a
list of players connected on a certain server, or on ALL the servers.public CompletableFuture<List<String>> getServers()
CompletableFuture
that, when completed, will return a
list of server name strings, as defined in BungeeCord's config.ymlpublic void connect(Player player, String serverName)
player
- the player you want to teleportserverName
- the name of server to connect to, as defined in BungeeCord config.ymlpublic void connectOther(String playerName, String server)
playerName
- name of the player to teleportserver
- name of server to connect to, as defined in BungeeCord config.ymlpublic CompletableFuture<InetSocketAddress> getIp(Player player)
player
- The player you wish to get the IP of.CompletableFuture
that, when completed, will return the (real) IP of player
.public void sendMessage(String playerName, String message)
playerName
- the name of the player to send the chat messagemessage
- the message to send to the playerpublic CompletableFuture<String> getServer()
CompletableFuture
that, when completed, will return
the server's
name, as defined in BungeeCord's config.ymlpublic CompletableFuture<String> getUUID(Player player)
player
- The player whose UUID you requestedCompletableFuture
that, when completed, will return the UUID of player
public CompletableFuture<InetSocketAddress> getServerIp(String serverName)
serverName
- the name of the serverCompletableFuture
that, when completed, will return the requested ippublic void kickPlayer(String playerName, String kickMessage)
playerName
- the name of the playerkickMessage
- the reason the player is kicked withpublic void forward(String server, String channelName, byte[] data)
server
- the name of the server to send to,
ALL to send to every server (except the one sending the plugin message),
or ONLINE to send to every server that's online (except the one sending the plugin message).channelName
- Subchannel for plugin usage.data
- data to send.public void forwardToPlayer(String playerName, String channelName, byte[] data)
playerName
- the name of the player to send to.channelName
- Subchannel for plugin usage.data
- data to send.public void unregister()