43 lines
1.4 KiB
Java
43 lines
1.4 KiB
Java
package net.t2code.alias.Spigot.system;
|
|
|
|
import net.t2code.alias.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 BCommandSenderReciver {
|
|
|
|
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.getPlugin(), "t2c:bcmd", stream.toByteArray());
|
|
}else {
|
|
for(Player player : Bukkit.getOnlinePlayers()){
|
|
player.sendPluginMessage(Main.getPlugin(), "t2c:bcmd", stream.toByteArray());
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|