46 lines
1.6 KiB
Java
46 lines
1.6 KiB
Java
package net.t2code.t2codelib.BUNGEE.system.pluginMessaging.opSecurity;
|
|
|
|
import net.md_5.bungee.api.ProxyServer;
|
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
|
import net.md_5.bungee.api.plugin.Listener;
|
|
import net.md_5.bungee.event.EventHandler;
|
|
|
|
import java.io.*;
|
|
import java.util.logging.Logger;
|
|
|
|
public class T2CapiOpSecurity implements Listener {
|
|
|
|
@EventHandler
|
|
public void onPluginmessage(PluginMessageEvent event) {
|
|
if (event.getTag().equalsIgnoreCase("t2c:opsec")) {
|
|
event.setCancelled(true);
|
|
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
|
try {
|
|
String channel = stream.readUTF();
|
|
String mode = stream.readUTF();
|
|
String information = stream.readUTF();
|
|
if (channel.equals("T2Cconsole")) {
|
|
sendToSpigotPlayer(channel,mode,information);
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void sendToSpigotPlayer(String channel,String mode,String information) {
|
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
DataOutputStream output = new DataOutputStream(stream);
|
|
try {
|
|
output.writeUTF(channel);
|
|
output.writeUTF(mode);
|
|
output.writeUTF(information);
|
|
} catch (IOException e) {
|
|
Logger.getLogger(e.getMessage());
|
|
}
|
|
ProxyServer.getInstance().getServers().values().stream().forEach((server) -> {
|
|
server.sendData("t2c:opsec", stream.toByteArray());
|
|
});
|
|
}
|
|
}
|