Java Code Examples for com.google.common.io.ByteArrayDataOutput#writeInt()
The following examples show how to use
com.google.common.io.ByteArrayDataOutput#writeInt() .
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: BukkitBridge.java From BungeeTabListPlus with GNU General Public License v3.0 | 6 votes |
void requestMissingData() throws IOException { synchronized (this) { if (requestAll) { Server connection = getConnection(); if (connection != null) { List<DataKey<?>> keys = new ArrayList<>(getActiveKeys()); ByteArrayDataOutput data = ByteStreams.newDataOutput(); data.writeByte(this instanceof PlayerBridgeDataCache ? BridgeProtocolConstants.MESSAGE_ID_REQUEST_DATA : BridgeProtocolConstants.MESSAGE_ID_REQUEST_DATA_SERVER); data.writeInt(connectionId); data.writeInt(nextOutgoingMessageId++); data.writeInt(keys.size()); for (DataKey<?> key : keys) { DataStreamUtils.writeDataKey(data, key); data.writeInt(idMap.getNetId(key)); } byte[] message = data.toByteArray(); messagesPendingConfirmation.add(message); lastMessageSent = System.currentTimeMillis(); connection.sendData(BridgeProtocolConstants.CHANNEL, message); } requestAll = false; } } }
Example 2
Source File: PacketSolderingStation.java From ExtraCells1 with MIT License | 5 votes |
@Override public void write(ByteArrayDataOutput out) { out.writeUTF(playerName); out.writeInt(x); out.writeInt(y); out.writeInt(z); out.writeInt(deltaSize); out.writeInt(deltaTypes); out.writeInt(slotID); }
Example 3
Source File: PacketMEBattery.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); }
Example 4
Source File: CompressingSerializer.java From elasticactors with Apache License 2.0 | 5 votes |
@Override public ByteBuffer serialize(I object) throws IOException { byte[] serializedObject = delegate.serialize(object); if(serializedObject.length > compressionThreshold) { byte[] compressedBytes = lz4Compressor.compress(serializedObject); ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(compressedBytes.length+8); dataOutput.write(MAGIC_HEADER); dataOutput.writeInt(serializedObject.length); dataOutput.write(compressedBytes); return ByteBuffer.wrap(dataOutput.toByteArray()); } else { return ByteBuffer.wrap(serializedObject); } }
Example 5
Source File: CompressingSerializer.java From elasticactors with Apache License 2.0 | 5 votes |
@Override public byte[] serialize(I object) throws IOException { byte[] serializedObject = delegate.serialize(object); if(serializedObject.length > compressionThreshold) { byte[] compressedBytes = lz4Compressor.compress(serializedObject); ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(compressedBytes.length+8); dataOutput.write(MAGIC_HEADER); dataOutput.writeInt(serializedObject.length); dataOutput.write(compressedBytes); return dataOutput.toByteArray(); } else { return serializedObject; } }
Example 6
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 7
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 8
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 9
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 10
Source File: BukkitBridge.java From BungeeTabListPlus with GNU General Public License v3.0 | 5 votes |
@Override protected <T> void addActiveKey(DataKey<T> key) { super.addActiveKey(key); try { synchronized (this) { Server connection = getConnection(); if (connection != null) { ByteArrayDataOutput data = ByteStreams.newDataOutput(); data.writeByte(this instanceof PlayerBridgeDataCache ? BridgeProtocolConstants.MESSAGE_ID_REQUEST_DATA : BridgeProtocolConstants.MESSAGE_ID_REQUEST_DATA_SERVER); data.writeInt(connectionId); data.writeInt(nextOutgoingMessageId++); data.writeInt(1); DataStreamUtils.writeDataKey(data, key); data.writeInt(idMap.getNetId(key)); byte[] message = data.toByteArray(); messagesPendingConfirmation.add(message); lastMessageSent = System.currentTimeMillis(); connection.sendData(BridgeProtocolConstants.CHANNEL, message); } else { requestAll = true; } } } catch (Throwable th) { rlExecutor.execute(() -> { logger.log(Level.SEVERE, "Unexpected exception", th); }); requestAll = true; } }
Example 11
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 12
Source File: PacketTerminalFluid.java From ExtraCells1 with MIT License | 5 votes |
@Override public void write(ByteArrayDataOutput out) { out.writeByte(type); out.writeInt(world.provider.dimensionId); out.writeInt(x); out.writeInt(y); out.writeInt(z); out.writeInt(fluidID); out.writeInt(amount); }
Example 13
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 14
Source File: CheckPermMessage.java From ChangeSkin with MIT License | 5 votes |
@Override public void writeTo(ByteArrayDataOutput out) { out.writeInt(targetSkin.getRowId()); out.writeUTF(targetSkin.getEncodedValue()); out.writeUTF(targetSkin.getSignature()); out.writeUTF(receiverUUD.toString()); out.writeBoolean(skinPerm); out.writeBoolean(isOp); }
Example 15
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 16
Source File: ModListener.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public static byte[] createWDLPacket1() { ByteArrayDataOutput output = ByteStreams.newDataOutput(); output.writeInt(1); output.writeBoolean(false); output.writeInt(0); output.writeBoolean(false); output.writeBoolean(false); output.writeBoolean(false); output.writeBoolean(false); return output.toByteArray(); }
Example 17
Source File: ClassWriter.java From turbine with Apache License 2.0 | 5 votes |
private static byte[] finishClass( ConstantPool pool, ByteArrayDataOutput body, ClassFile classfile) { ByteArrayDataOutput result = ByteStreams.newDataOutput(); result.writeInt(MAGIC); result.writeShort(MINOR_VERSION); result.writeShort(classfile.module() != null ? MODULE_MAJOR_VERSION : MAJOR_VERSION); writeConstantPool(pool, result); result.write(body.toByteArray()); return result.toByteArray(); }
Example 18
Source File: TestVarULongSerializer.java From util with Apache License 2.0 | 4 votes |
public void testInt(int i) throws IOException { final VarULongSerializer serializer = new VarULongSerializer(); final ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeInt(i); assertEquals(i, serializer.read(ByteStreams.newDataInput(out.toByteArray())).longValue()); }
Example 19
Source File: RedisBungeeListener.java From RedisBungee with Eclipse Public License 1.0 | 4 votes |
private void serializeCollection(Collection<?> collection, ByteArrayDataOutput output) { output.writeInt(collection.size()); for (Object o : collection) { output.writeUTF(o.toString()); } }
Example 20
Source File: ModListener.java From RedProtect with GNU General Public License v3.0 | 4 votes |
public static byte[] createWDLPacket0() { ByteArrayDataOutput output = ByteStreams.newDataOutput(); output.writeInt(0); output.writeBoolean(false); return output.toByteArray(); }