connect plugin message code example
Example: Send a custom plugin message to said server
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Forward");
out.writeUTF(recipientServerName);
out.writeUTF(channelName);
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
DataOutputStream msgout = new DataOutputStream(msgbytes);
try {
msgout.writeUTF(dataToSend);
msgout.writeShort(shortAlsoIntDataToSend);
} catch (IOException exception){ exception.printStackTrace(); }
out.writeShort(msgbytes.toByteArray().length);
out.write(msgbytes.toByteArray());
System.out.println("Sending message");
playerSender.sendPluginMessage(main, "BungeeCord", out.toByteArray());
String subChannel = in.readUTF();
short len = in.readShort();
byte[] msgbytes = new byte[len];
in.readFully(msgbytes);
DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(msgbytes));
String somedata = msgin.readUTF();
short somenumber = msgin.readShort();