Java Code Examples for com.google.common.io.ByteArrayDataOutput#writeLong()
The following examples show how to use
com.google.common.io.ByteArrayDataOutput#writeLong() .
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: PlayerDataHelper.java From PlayerSQL with GNU General Public License v2.0 | 6 votes |
@SneakyThrows public static byte[] encode(PlayerData dat) { ByteArrayDataOutput output = ByteStreams.newDataOutput(); output.writeLong(dat.getUuid().getMostSignificantBits()); output.writeLong(dat.getUuid().getLeastSignificantBits()); output.writeDouble(dat.getHealth()); output.writeInt(dat.getFood()); output.writeInt(dat.getHand()); output.writeInt(dat.getExp()); write(output, dat.getInventory()); write(output, dat.getArmor()); write(output, dat.getChest()); write(output, dat.getEffect()); byte[] uncompressed = output.toByteArray(); output = ByteStreams.newDataOutput(); VarInt.writeUnsignedVarInt(output, uncompressed.length); byte[] compressed = LZ4.compress(uncompressed); if (Config.DEBUG) { PluginMain.getPlugin().log(String.format("PlayerDataHelper.encode LZ4 compressor %s -> %s", uncompressed.length, compressed.length)); } VarInt.writeUnsignedVarInt(output, compressed.length); output.write(compressed); return output.toByteArray(); }
Example 3
Source File: PacketOutUseItem.java From FishingBot with GNU General Public License v3.0 | 5 votes |
@Override public void write(ByteArrayDataOutput out, int protocolId) { switch (protocolId) { case ProtocolConstants.MINECRAFT_1_8: { out.writeLong(-1); //Position out.writeByte(255); //Face out.write(FishingBot.getInstance().getPlayer().getSlotData().toByteArray()); //Slot out.writeByte(0); //Cursor X out.writeByte(0); //Cursor Y out.writeByte(0); //Cursor Z new Thread(() -> { try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } networkHandler.sendPacket(new PacketOutArmAnimation()); }).start(); break; } case ProtocolConstants.MINECRAFT_1_13_2: case ProtocolConstants.MINECRAFT_1_13_1: case ProtocolConstants.MINECRAFT_1_13: case ProtocolConstants.MINECRAFT_1_12_2: case ProtocolConstants.MINECRAFT_1_12_1: case ProtocolConstants.MINECRAFT_1_12: case ProtocolConstants.MINECRAFT_1_11_1: case ProtocolConstants.MINECRAFT_1_11: case ProtocolConstants.MINECRAFT_1_10: case ProtocolConstants.MINECRAFT_1_9_4: case ProtocolConstants.MINECRAFT_1_9_2: case ProtocolConstants.MINECRAFT_1_9_1: case ProtocolConstants.MINECRAFT_1_9: case ProtocolConstants.MINECRAFT_1_14: case ProtocolConstants.MINECRAFT_1_14_1: case ProtocolConstants.MINECRAFT_1_14_2: case ProtocolConstants.MINECRAFT_1_14_3: case ProtocolConstants.MINECRAFT_1_14_4: default: { out.writeByte(0); //main hand break; } } }
Example 4
Source File: PacketOutKeepAlive.java From FishingBot with GNU General Public License v3.0 | 5 votes |
@Override public void write(ByteArrayDataOutput out, int protocolId) throws IOException { if(protocolId <= ProtocolConstants.MINECRAFT_1_12_1) { writeVarInt(Long.valueOf(getId()).intValue(), out); } else { out.writeLong(id); } }
Example 5
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 6
Source File: LoginActionMessage.java From FastLogin with MIT License | 5 votes |
@Override public void writeTo(ByteArrayDataOutput output) { output.writeInt(type.ordinal()); //Data is sent through a random player. We have to tell the Bukkit version of this plugin the target output.writeUTF(playerName); //proxy identifier to check if it's a acceptable proxy output.writeLong(proxyId.getMostSignificantBits()); output.writeLong(proxyId.getLeastSignificantBits()); }
Example 7
Source File: DataSupply.java From PlayerSQL with GNU General Public License v2.0 | 5 votes |
@Override protected void write(ByteArrayDataOutput out) { out.writeLong(id.getMostSignificantBits()); out.writeLong(id.getLeastSignificantBits()); out.writeUTF(group); out.writeInt(buf.length); out.write(buf); }
Example 8
Source File: PacketLevelEmitterFluid.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.writeLong(filterAmount); out.writeInt(type); }
Example 9
Source File: DataRequest.java From PlayerSQL with GNU General Public License v2.0 | 4 votes |
@Override protected void write(ByteArrayDataOutput buf) { buf.writeLong(id.getMostSignificantBits()); buf.writeLong(id.getLeastSignificantBits()); }
Example 10
Source File: PeerReady.java From PlayerSQL with GNU General Public License v2.0 | 4 votes |
@Override protected void write(ByteArrayDataOutput buf) { buf.writeLong(id.getMostSignificantBits()); buf.writeLong(id.getLeastSignificantBits()); }