Java Code Examples for com.google.common.io.ByteArrayDataOutput#writeUTF()
The following examples show how to use
com.google.common.io.ByteArrayDataOutput#writeUTF() .
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: 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 2
Source File: LobbyCommand.java From HubBasics with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void execute(CommandSender commandSender, String[] strings) { ServerInfo serverInfo = this.getLobby(); if (serverInfo != null && commandSender instanceof ProxiedPlayer) { ProxiedPlayer player = (ProxiedPlayer) commandSender; if (!player.getServer().getInfo().getName().equals(serverInfo.getName())) { player.connect(getLobby()); } else { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("HubBasics"); out.writeUTF("Lobby"); player.sendData("BungeeCord", out.toByteArray()); } } else if (serverInfo == null) { commandSender.sendMessage(new TextComponent(Messages.get(commandSender, "LOBBY_NOT_DEFINED"))); } else { commandSender.sendMessage(new TextComponent(Messages.get(commandSender, "COMMAND_PLAYER"))); } }
Example 3
Source File: SkyWarsReloaded.java From SkyWarsReloaded with GNU General Public License v3.0 | 6 votes |
public void sendSWRMessage(Player player, String server, ArrayList<String> messages) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Forward"); out.writeUTF(server); out.writeUTF("SWRMessaging"); ByteArrayOutputStream msgbytes = new ByteArrayOutputStream(); DataOutputStream msgout = new DataOutputStream(msgbytes); try { for (String msg: messages) { msgout.writeUTF(msg); } } catch (IOException e) { e.printStackTrace(); } out.writeShort(msgbytes.toByteArray().length); out.write(msgbytes.toByteArray()); player.sendPluginMessage(this, "BungeeCord", out.toByteArray()); }
Example 4
Source File: MobSelector.java From CloudNet with Apache License 2.0 | 6 votes |
@EventHandler public void handleInventoryClick(InventoryClickEvent e) { if (!(e.getWhoClicked() instanceof Player)) { return; } if (inventories().contains(e.getInventory()) && e.getCurrentItem() != null && e.getSlot() == e.getRawSlot()) { e.setCancelled(true); if (ItemStackBuilder.getMaterialIgnoreVersion(mobConfig.getItemLayout().getItemName(), mobConfig.getItemLayout().getItemId()) == e.getCurrentItem().getType()) { MobImpl mob = find(e.getInventory()); if (mob.getServerPosition().containsKey(e.getSlot())) { if (CloudAPI.getInstance().getServerId().equalsIgnoreCase(mob.getServerPosition().get(e.getSlot()))) { return; } ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput(); byteArrayDataOutput.writeUTF("Connect"); byteArrayDataOutput.writeUTF(mob.getServerPosition().get(e.getSlot())); ((Player) e.getWhoClicked()).sendPluginMessage(CloudServer.getInstance().getPlugin(), "BungeeCord", byteArrayDataOutput.toByteArray()); } } } }
Example 5
Source File: PluginMessageMessenger.java From LuckPerms with MIT License | 5 votes |
@Override public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(outgoingMessage.asEncodedString()); byte[] message = out.toByteArray(); dispatchMessage(message); }
Example 6
Source File: PacketBusFluidImport.java From ExtraCells1 with MIT License | 5 votes |
@Override public void write(ByteArrayDataOutput out) { out.writeInt(world.provider.dimensionId); out.writeInt(x); out.writeInt(y); out.writeInt(z); out.writeUTF(playername); out.writeInt(action); }
Example 7
Source File: BungeeSender.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
private void sendForwardedBungeecordMessage(final String subChannel, final String... data) { final ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Forward"); out.writeUTF("ONLINE"); out.writeUTF(subChannel); final ByteArrayDataOutput dataOut = ByteStreams.newDataOutput(); for (final String element : data) { dataOut.writeUTF(element); } final byte[] dataBytes = dataOut.toByteArray(); out.writeShort(dataBytes.length); out.write(dataBytes); bukkitService.sendBungeeMessage(out.toByteArray()); }
Example 8
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 9
Source File: HLocation.java From HubBasics with GNU Lesser General Public License v3.0 | 5 votes |
public void teleport(Player player) { if (this.server != null) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Connect"); out.writeUTF(this.server); player.sendPluginMessage(HubBasics.getInstance(), "BungeeCord", out.toByteArray()); } else { player.teleport(this.toBukkitLocation()); } }
Example 10
Source File: RedisBungeeListener.java From RedisBungee with Eclipse Public License 1.0 | 5 votes |
private void serializeMultiset(Multiset<String> collection, ByteArrayDataOutput output) { output.writeInt(collection.elementSet().size()); for (Multiset.Entry<String> entry : collection.entrySet()) { output.writeUTF(entry.getElement()); output.writeInt(entry.getCount()); } }
Example 11
Source File: ClassWriter.java From turbine with Apache License 2.0 | 5 votes |
static void writeConstantPool(ConstantPool constantPool, ByteArrayDataOutput output) { output.writeShort(constantPool.nextEntry); for (ConstantPool.Entry e : constantPool.constants()) { output.writeByte(e.kind().tag()); Value value = e.value(); switch (e.kind()) { case CLASS_INFO: case STRING: case MODULE: case PACKAGE: output.writeShort(((IntValue) value).value()); break; case INTEGER: output.writeInt(((IntValue) value).value()); break; case DOUBLE: output.writeDouble(((DoubleValue) value).value()); break; case FLOAT: output.writeFloat(((FloatValue) value).value()); break; case LONG: output.writeLong(((LongValue) value).value()); break; case UTF8: output.writeUTF(((StringValue) value).value()); break; } } }
Example 12
Source File: BungeeCordImpl.java From helper with MIT License | 5 votes |
@Override public void appendPayload(ByteArrayDataOutput out) { out.writeUTF(this.playerName); out.writeUTF(this.channelName); out.writeShort(this.data.length); out.write(this.data); }
Example 13
Source File: RedisBungeeListener.java From RedisBungee with Eclipse Public License 1.0 | 5 votes |
private void serializeMultimap(Multimap<String, String> collection, boolean includeNames, ByteArrayDataOutput output) { output.writeInt(collection.keySet().size()); for (Map.Entry<String, Collection<String>> entry : collection.asMap().entrySet()) { output.writeUTF(entry.getKey()); if (includeNames) { serializeCollection(entry.getValue(), output); } else { output.writeInt(entry.getValue().size()); } } }
Example 14
Source File: ForwardMessage.java From ChangeSkin with MIT License | 5 votes |
@Override public void writeTo(ByteArrayDataOutput out) { out.writeUTF(commandName); out.writeUTF(args); out.writeBoolean(isSource); out.writeBoolean(isOP); }
Example 15
Source File: PermResultMessage.java From ChangeSkin with MIT License | 5 votes |
@Override public void writeTo(ByteArrayDataOutput out) { out.writeBoolean(allowed); out.writeInt(skin.getRowId()); out.writeUTF(skin.getEncodedValue()); out.writeUTF(skin.getSignature()); out.writeUTF(receiverUUID.toString()); }
Example 16
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 17
Source File: BungeeCordImpl.java From helper with MIT License | 4 votes |
@Override public void appendPayload(ByteArrayDataOutput out) { out.writeUTF(this.serverName); }
Example 18
Source File: BungeeCordImpl.java From helper with MIT License | 4 votes |
@Override public void appendPayload(ByteArrayDataOutput out) { out.writeUTF(this.serverName); }
Example 19
Source File: BungeeCordImpl.java From helper with MIT License | 4 votes |
@Override public void appendPayload(ByteArrayDataOutput out) { out.writeUTF(this.playerName); out.writeUTF(this.message); }
Example 20
Source File: SkinUpdateMessage.java From ChangeSkin with MIT License | 4 votes |
@Override public void writeTo(ByteArrayDataOutput out) { out.writeUTF(playerName); }