package net.t2code.opsecurity.system; import net.t2code.opsecurity.events.Events; import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; import java.io.*; public class BungeeSenderReceiver implements PluginMessageListener { public static void sendToBungee(String information) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); DataOutputStream output = new DataOutputStream(stream); try { output.writeUTF(information.toString()); } catch (IOException e) { e.printStackTrace(); } for (Player player : Bukkit.getOnlinePlayers()) { player.sendPluginMessage(Main.getPlugin(), "t2c:opsec", stream.toByteArray()); return; } } @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message)); T2Csend.debug(Main.getPlugin(), "stream: " + stream.toString()); try { String subChannel = stream.readUTF(); String information = stream.readUTF(); if (subChannel.equals("T2Cconsole")) { Events.notifyPlayer(information); } } catch (IOException e) { e.printStackTrace(); } } }