50 lines
1.7 KiB
Java
50 lines
1.7 KiB
Java
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));
|
|
try {
|
|
String subChannel = stream.readUTF();
|
|
String input = stream.readUTF();
|
|
switch (subChannel) {
|
|
case "join":
|
|
Main.bungeeplayers.add(input);
|
|
Main.bungeejoinplayers.add(input);
|
|
break;
|
|
case "left":
|
|
Main.bungeeplayers.remove(input);
|
|
Main.bungeejoinplayers.remove(input);
|
|
break;
|
|
case "clear":
|
|
Main.bungeeplayers.clear();
|
|
Main.bungeejoinplayers.clear();
|
|
break;
|
|
}
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
}
|