use of com.google.common.io.ByteArrayDataOutput in project SpaciousLib by anhcraft.
the class BungeeManager method getPlayerAmount.
/**
* Gets the player amount of another server
* @param server the server
* @param response BungeePlayerAmountResponse object
*/
public static void getPlayerAmount(String server, BungeePlayerAmountResponse response) {
if (Bukkit.getServer().getOnlinePlayers().size() == 0) {
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("PlayerCount");
out.writeUTF(server);
Bukkit.getServer().getOnlinePlayers().iterator().next().sendPluginMessage(SpaciousLib.instance, CHANNEL, out.toByteArray());
queue.add(response);
}
use of com.google.common.io.ByteArrayDataOutput in project SpaciousLib by anhcraft.
the class BungeeManager method kickPlayer.
/**
* Sends a kick request
* @param player the player who you want to kick
* @param reason the reason
*/
public static void kickPlayer(String player, String reason) {
if (Bukkit.getServer().getOnlinePlayers().size() == 0) {
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("KickPlayer");
out.writeUTF(player);
out.writeUTF(Strings.color(reason));
Bukkit.getServer().getOnlinePlayers().iterator().next().sendPluginMessage(SpaciousLib.instance, CHANNEL, out.toByteArray());
}
use of com.google.common.io.ByteArrayDataOutput in project SpaciousLib by anhcraft.
the class BungeeManager method sendMessage.
/**
* Sends a message to a specific player who is in another server
* @param player the name of that player
* @param message the message
*/
public static void sendMessage(String player, String message) {
if (Bukkit.getServer().getOnlinePlayers().size() == 0) {
return;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Message");
out.writeUTF(player);
out.writeUTF(Strings.color(message));
Bukkit.getServer().getOnlinePlayers().iterator().next().sendPluginMessage(SpaciousLib.instance, CHANNEL, out.toByteArray());
}
use of com.google.common.io.ByteArrayDataOutput in project Network-depr by Mas281.
the class UtilServer method writeBungee.
/**
* Forwards a message to BungeeCord through the plugin messaging channel
*
* @param args The data to send
* @return Whether the data was sent
*/
public static boolean writeBungee(String... args) {
assert args.length > 0 : "Args length must be at least 1";
Player player = Iterables.getFirst(UtilServer.getPlayers(), null);
if (player == null) {
return false;
}
ByteArrayDataOutput out = ByteStreams.newDataOutput();
for (String arg : args) {
out.writeUTF(arg);
}
player.sendPluginMessage(PLUGIN, "BungeeCord", out.toByteArray());
return true;
}
Aggregations