2022-01-27 08:04:30 +00:00
|
|
|
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 {
|
|
|
|
|
2022-07-25 22:46:29 +00:00
|
|
|
public static void sendToBungee(CommandSender sender, String information, BungeeSend type) {
|
2022-01-27 08:04:30 +00:00
|
|
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
|
|
DataOutputStream output = new DataOutputStream(stream);
|
2022-07-25 22:46:29 +00:00
|
|
|
|
2022-01-27 08:04:30 +00:00
|
|
|
try {
|
2022-07-25 22:46:29 +00:00
|
|
|
switch (type) {
|
|
|
|
case BUNGEECOMMAND:
|
|
|
|
output.writeUTF("ConC");
|
|
|
|
break;
|
|
|
|
case COMMAND:
|
|
|
|
if (sender instanceof Player) {
|
|
|
|
output.writeUTF(sender.getName());
|
|
|
|
} else {
|
|
|
|
output.writeUTF("ConC");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ALLPLAYERMSG:
|
|
|
|
output.writeUTF("ALLPMSG");
|
|
|
|
break;
|
2022-01-27 08:04:30 +00:00
|
|
|
}
|
|
|
|
output.writeUTF(information);
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2022-07-25 22:46:29 +00:00
|
|
|
|
2022-01-27 08:04:30 +00:00
|
|
|
if (sender instanceof Player) {
|
|
|
|
Player player = (Player) sender;
|
2022-07-25 22:46:29 +00:00
|
|
|
player.sendPluginMessage(Main.getPlugin(), "t2car:bungee", stream.toByteArray());
|
|
|
|
} else {
|
|
|
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
|
|
player.sendPluginMessage(Main.getPlugin(), "t2car:bungee", stream.toByteArray());
|
2022-01-27 08:04:30 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|