package de.jatitv.commandguiv2.Spigot.system; import de.jatitv.commandguiv2.Spigot.Main; import net.t2code.lib.Spigot.Lib.messages.send; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; import java.io.*; public class Bungee_Sender_Reciver implements PluginMessageListener { public static void sendToBungee(Player player,String channel, String information) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); DataOutputStream output = new DataOutputStream(stream); try { output.writeUTF(channel); output.writeUTF(information); } catch (IOException e) { e.printStackTrace(); } player.sendPluginMessage(Main.plugin, "cgui:bungee", stream.toByteArray()); } @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message)); send.debug(Main.plugin,"stream: "+stream.toString()); try { String subChannel = stream.readUTF(); String input = stream.readUTF(); send.debug(Main.plugin,"subChannel: " +subChannel); send.debug(Main.plugin,"input: " +input); switch (subChannel) { case "join": Main.bungeejoinplayers.add(input); break; case "left": Main.bungeejoinplayers.remove(input); break; case "clear": Main.bungeejoinplayers.clear(); break; } } catch (IOException e) { e.printStackTrace(); } } }