I need to figure out the best way to get hold of BungeeCord’s channel, but if we were to create our own channel it’d look something like this:
// Create the channel
RawDataChannel channel = game.getChannelRegistrar().createRawChannel(this, "BungeeCord");
// A one-liner to send a player to a server
channel.sendTo(player, buf -> buf.writeString("Connect").writeString("someServer"));
// Another example
channel.sendTo(player, buf -> {
buf.writeString("PlayerCount");
buf.writeString("someServer");
});
// Add listeners for data
channel.addListener(Platform.Type.SERVER, (buf, con, side) -> {
String subChannel = buf.readString();
if (subChannel.equals("PlayerCount")) {
String server = buf.readString();
int playerCount = buf.readInteger();
System.out.println("Player count on server " + server + " is " + playerCount);
}
});