1 // Sending
2ByteArrayDataOutput out = ByteStreams.newDataOutput();
3out.writeUTF("Forward"); // So BungeeCord knows to forward it
4out.writeUTF(recipientServerName);
5out.writeUTF(channelName); // The channel name to check if this your data
6
7ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
8DataOutputStream msgout = new DataOutputStream(msgbytes);
9try {
10 msgout.writeUTF(dataToSend);
11 msgout.writeShort(shortAlsoIntDataToSend);
12} catch (IOException exception){ exception.printStackTrace(); }
13
14out.writeShort(msgbytes.toByteArray().length);
15out.write(msgbytes.toByteArray());
16
17System.out.println("Sending message");
18playerSender.sendPluginMessage(main, "BungeeCord", out.toByteArray());
19
20 //Responce
21String subChannel = in.readUTF();
22short len = in.readShort();
23byte[] msgbytes = new byte[len];
24in.readFully(msgbytes);
25
26DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(msgbytes));
27String somedata = msgin.readUTF(); // Read the data in the same way you wrote it
28short somenumber = msgin.readShort();