Java Code Examples for org.bukkit.entity.Player#sendPluginMessage()
The following examples show how to use
org.bukkit.entity.Player#sendPluginMessage() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BukkitNotifier.java From BungeePerms with GNU General Public License v3.0 | 6 votes |
private void sendPM(UUID player, String msg, String origin) { //if standalone don't notify bungee if (config.isStandalone()) { return; } Player p = Bukkit.getPlayer(player); if (p != null) { p.sendPluginMessage(BukkitPlugin.getInstance(), BungeePerms.CHANNEL, msg.getBytes()); //send config for match checking sendConfig(p); } else { sendPMAll(msg, origin); } }
Example 2
Source File: BukkitNotifier.java From BungeePerms with GNU General Public License v3.0 | 6 votes |
private void sendPM(String player, String msg, String origin) { //if standalone don't notify bungee if (config.isStandalone()) { return; } Player p = Bukkit.getPlayer(player); if (p != null) { p.sendPluginMessage(BukkitPlugin.getInstance(), BungeePerms.CHANNEL, msg.getBytes()); //send config for match checking sendConfig(p); } else { sendPMAll(msg, origin); } }
Example 3
Source File: PlayerListener.java From BedWars with GNU Lesser General Public License v3.0 | 6 votes |
@EventHandler public void onJoin(PlayerJoinEvent event) { final Player player = event.getPlayer(); final Game game = Main.getApi().getFirstWaitingGame(); if (game != null) { game.joinToGame(event.getPlayer()); } else if (!player.hasPermission("misat11.bw.admin")) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Connect"); out.writeUTF(Main.getApi().getHubServerName()); player.sendPluginMessage(Main.getInstance(), "BungeeCord", out.toByteArray()); } }
Example 4
Source File: BukkitNotifier.java From BungeePerms with GNU General Public License v3.0 | 6 votes |
private void sendPMAll(String msg, String origin) { //if standalone don't notify bungee if (config.isStandalone()) { return; } List<Player> players = BukkitPlugin.getBukkitPlayers(); Player p = players.iterator().hasNext() ? players.iterator().next() : null; if (p != null) { p.sendPluginMessage(BukkitPlugin.getInstance(), BungeePerms.CHANNEL, msg.getBytes());//todo use utf8 encoding //send config for match checking sendConfig(p); } }
Example 5
Source File: PluginMessenger.java From TAB with Apache License 2.0 | 6 votes |
public void onPluginMessageReceived(String channel, Player player, byte[] bytes){ if (!channel.equalsIgnoreCase(Shared.CHANNEL_NAME)) return; ByteArrayDataInput in = ByteStreams.newDataInput(bytes); String subChannel = in.readUTF(); if (subChannel.equalsIgnoreCase("Placeholder")){ String placeholder = in.readUTF(); long start = System.nanoTime(); String output = PluginHooks.PlaceholderAPI_setPlaceholders(player, placeholder); long time = System.nanoTime() - start; ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Placeholder"); out.writeUTF(placeholder); out.writeUTF(output); out.writeLong(time); player.sendPluginMessage(plugin, Shared.CHANNEL_NAME, out.toByteArray()); } }
Example 6
Source File: BukkitPluginMessageSender.java From BungeePerms with GNU General Public License v3.0 | 6 votes |
@Override public void sendPluginMessage(String target, String channel, String msg) { if (!target.equalsIgnoreCase("bungee")) { return; } List<Player> players = BukkitPlugin.getBukkitPlayers(); Player p = players.iterator().hasNext() ? players.iterator().next() : null; if (p == null) { BungeePerms.getLogger().info("No server found for " + target); return; } p.sendPluginMessage(BukkitPlugin.getInstance(), BungeePerms.CHANNEL, msg.getBytes()); }
Example 7
Source File: BungeeUtils.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
private static void internalMove(Player player) { String server = Main.getConfigurator().config.getString("bungee.server"); ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Connect"); out.writeUTF(server); player.sendPluginMessage(Main.getInstance(), "BungeeCord", out.toByteArray()); }
Example 8
Source File: NickNamerPlugin.java From NickNamer with MIT License | 5 votes |
@Override public void sendPluginMessage(Player player, String action, String... values) { if (!bungeecord) { return; } if (player == null || !player.isOnline()) { return; } ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(action); out.writeUTF(player.getUniqueId().toString()); for (String s : values) { out.writeUTF(s); } player.sendPluginMessage(instance, channelIdentifier, out.toByteArray()); }
Example 9
Source File: BukkitNotifier.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
public void sendWorldUpdate(Player p) { //if standalone don't notify bungee if (config.isStandalone()) { return; } String world = p.getWorld() == null ? "" : p.getWorld().getName(); p.sendPluginMessage(BukkitPlugin.getInstance(), BungeePerms.CHANNEL, ("playerworldupdate;" + p.getName() + ";" + world).getBytes()); //send config for match checking sendConfig(p); }
Example 10
Source File: ModListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
private void denyBSM(Player player, String channel) { if (channel.equalsIgnoreCase(BSM) && !player.hasPermission("redprotect.mods.bettersprinting.bypass")) { player.sendPluginMessage(plugin, channel, new byte[] {1}); executeAction(player, "bettersprinting"); } }
Example 11
Source File: EventExecutor.java From PlayerSQL with GNU General Public License v2.0 | 5 votes |
@EventHandler public void handle(PlayerKickEvent e) { Player player = e.getPlayer(); if (handled.get(player.getUniqueId()) != Lifecycle.DATA_SENT) { return; } DataSupply supply = new DataSupply();// So we magic send player data at kick event. supply.setId(player.getUniqueId()); supply.setGroup(group); if (isLocked(player.getUniqueId())) { supply.setBuf(EMPTY_ARRAY); } else { manager.lockUser(player); PlayerData dat = manager.getUserData(player, true); pending.put(player.getUniqueId(), dat); supply.setBuf(PlayerDataHelper.encode(dat)); } byte[] message = supply.encode(); if (message.length > Messenger.MAX_MESSAGE_SIZE) {// Overflow? supply.setBuf(EMPTY_ARRAY); message = supply.encode(); } player.sendPluginMessage(main, PlayerSqlProtocol.NAMESPACE, message);// BungeeCord received this before kicks }
Example 12
Source File: SubPlugin.java From SubServers-2 with Apache License 2.0 | 5 votes |
/** * Send a message to the BungeeCord Plugin Messaging Channel * * @param player Player that will send * @param message Message contents */ public void pmc(Player player, String... message) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); DataOutputStream data = new DataOutputStream(stream); try { for (String m : message) data.writeUTF(m); data.flush(); } catch (IOException e) { e.printStackTrace(); } player.sendPluginMessage(this, "BungeeCord", stream.toByteArray()); }
Example 13
Source File: SkyWarsReloaded.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public void sendBungeeMsg(Player player, String subchannel, String message) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(subchannel); if (!message.equalsIgnoreCase("none")) { out.writeUTF(message); } player.sendPluginMessage(this, "BungeeCord", out.toByteArray()); }
Example 14
Source File: EventExecutor.java From PlayerSQL with GNU General Public License v2.0 | 5 votes |
@EventHandler public void handle(PlayerJoinEvent event) { Player player = event.getPlayer(); if (!main.getConfig().getBoolean("bungee.mute")) { main.debug(String.format("PlayerJoin() -> send peer ready for %s", player.getName())); main.getHijUtils().addCustomChannel(player, PlayerSqlProtocol.NAMESPACE);// hacky add channels without register commands PeerReady ready = new PeerReady(); ready.setId(player.getUniqueId()); player.sendPluginMessage(main, PlayerSqlProtocol.NAMESPACE, ready.encode()); } manager.lockUser(player); UUID id = player.getUniqueId(); Object pend = pending.remove(id); if (pend == null) { FetchUserTask task = new FetchUserTask(player); pending.put(id, task); task.runTaskTimerAsynchronously(main, Config.SYN_DELAY, Config.SYN_DELAY); } else if (pend instanceof PlayerData) { main.debug("process pending data_buf on join event"); UUID guid = GuidResolveService.getService().getGuid(player); main.run(() -> { manager.pend(player, (PlayerData) pend); runAsync(() -> manager.updateDataLock(guid, true)); }); } }
Example 15
Source File: BungeeCordChannelExample.java From CloudNet with Apache License 2.0 | 5 votes |
public void sendToaRandomServerInGroup(Plugin plugin, Player player) { plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "cloudnet:main"); ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput(); byteArrayDataOutput.writeUTF("Connect"); byteArrayDataOutput.writeUTF("Lobby"); //Connect to the group Lobby player.sendPluginMessage(plugin, "cloudnet:main", byteArrayDataOutput.toByteArray()); }
Example 16
Source File: CraftServer.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void sendPluginMessage(Plugin source, String channel, byte[] message) { StandardMessenger.validatePluginMessage(getMessenger(), source, channel, message); for (Player player : getOnlinePlayers()) { player.sendPluginMessage(source, channel, message); } }
Example 17
Source File: DebugCommand.java From civcraft with GNU General Public License v2.0 | 4 votes |
public void packet_cmd() throws CivException { Player player = getPlayer(); player.sendPluginMessage(CivCraft.getPlugin(), "CAC", "Test Message".getBytes()); CivMessage.sendSuccess(player, "Sent test message"); }
Example 18
Source File: Utils.java From Skript with GNU General Public License v3.0 | 4 votes |
/** * Sends a plugin message. * * Example usage using the "GetServers" bungee plugin message channel via an overload: * <code> * Utils.sendPluginMessage("BungeeCord", r -> "GetServers".equals(r.readUTF()), "GetServers") * .thenAccept(response -> Bukkit.broadcastMessage(response.readUTF()) // comma delimited server broadcast * .exceptionally(ex -> { * Skript.warning("Failed to get servers because there are no players online"); * return null; * }); * </code> * * @param player the player to send the plugin message through * @param channel the channel for this plugin message * @param messageVerifier verifies that a plugin message is the response to the sent message * @param data the data to add to the outgoing message * @return a completable future for the message of the responding plugin message, if there is one. * this completable future will complete exceptionally if the player is null. */ public static CompletableFuture<ByteArrayDataInput> sendPluginMessage(Player player, String channel, Predicate<ByteArrayDataInput> messageVerifier, String... data) { CompletableFuture<ByteArrayDataInput> completableFuture = new CompletableFuture<>(); if (player == null) { completableFuture.completeExceptionally(new IllegalStateException("Can't send plugin messages from a null player")); return completableFuture; } Skript skript = Skript.getInstance(); Messenger messenger = Bukkit.getMessenger(); messenger.registerOutgoingPluginChannel(skript, channel); PluginMessageListener listener = (sendingChannel, sendingPlayer, message) -> { ByteArrayDataInput input = ByteStreams.newDataInput(message); if (channel.equals(sendingChannel) && sendingPlayer == player && !completableFuture.isDone() && !completableFuture.isCancelled() && messageVerifier.test(input)) { completableFuture.complete(input); } }; messenger.registerIncomingPluginChannel(skript, channel, listener); completableFuture.whenComplete((r, ex) -> messenger.unregisterIncomingPluginChannel(skript, channel, listener)); // if we haven't gotten a response after a minute, let's just assume there wil never be one Bukkit.getScheduler().scheduleSyncDelayedTask(skript, () -> { if (!completableFuture.isDone()) completableFuture.cancel(true); }, 60 * 20); ByteArrayDataOutput out = ByteStreams.newDataOutput(); Stream.of(data).forEach(out::writeUTF); player.sendPluginMessage(Skript.getInstance(), channel, out.toByteArray()); return completableFuture; }
Example 19
Source File: ModListener.java From RedProtect with GNU General Public License v3.0 | 4 votes |
private void denySchematica(Player player) { if (!player.hasPermission("redprotect.mods.schematica.bypass")) { player.sendPluginMessage(plugin, SCHEMATICA, getSchematicaPayload()); //executeAction(player, "schematica"); } }
Example 20
Source File: BungeeCordChannelExample.java From CloudNet with Apache License 2.0 | 4 votes |
public void sendToFallback(Plugin plugin, Player player) { plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "cloudnet:main"); ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput(); byteArrayDataOutput.writeUTF("Fallback"); //Connect to the fallback server in the iteration player.sendPluginMessage(plugin, "cloudnet:main", byteArrayDataOutput.toByteArray()); }