43 lines
1.4 KiB
Java
43 lines
1.4 KiB
Java
|
package net.t2code.autoresponse.Spigot.system;
|
||
|
|
||
|
import net.t2code.autoresponse.Spigot.Main;
|
||
|
import org.bukkit.Bukkit;
|
||
|
import org.bukkit.command.CommandSender;
|
||
|
import org.bukkit.entity.Player;
|
||
|
|
||
|
import java.io.ByteArrayOutputStream;
|
||
|
import java.io.DataOutputStream;
|
||
|
import java.io.IOException;
|
||
|
|
||
|
public class BCommand_Sender_Reciver {
|
||
|
|
||
|
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
|
||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||
|
DataOutputStream output = new DataOutputStream(stream);
|
||
|
try {
|
||
|
if (console) {
|
||
|
output.writeUTF("T2Code-Console");
|
||
|
} else {
|
||
|
if (sender instanceof Player) {
|
||
|
output.writeUTF(sender.getName());
|
||
|
} else {
|
||
|
output.writeUTF("T2Code-Console");
|
||
|
}
|
||
|
}
|
||
|
output.writeUTF(information);
|
||
|
} catch (IOException e) {
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
if (sender instanceof Player) {
|
||
|
Player player = (Player) sender;
|
||
|
player.sendPluginMessage(Main.plugin, "t2car:bungee", stream.toByteArray());
|
||
|
}else {
|
||
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||
|
player.sendPluginMessage(Main.plugin, "t2car:bungee", stream.toByteArray());
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|