com.google.common.io.ByteArrayDataOutput#writeInt ( )源码实例Demo

下面列出了com.google.common.io.ByteArrayDataOutput#writeInt ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: BungeeTabListPlus   文件: BukkitBridge.java
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;
        }
    }
}
 
源代码2 项目: ExtraCells1   文件: PacketMEBattery.java
@Override
public void write(ByteArrayDataOutput out)
{
	out.writeInt(world.provider.dimensionId);
	out.writeInt(x);
	out.writeInt(y);
	out.writeInt(z);
	out.writeUTF(playername);
}
 
源代码3 项目: turbine   文件: ClassWriter.java
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();
}
 
源代码4 项目: RedProtect   文件: ModListener.java
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();
}
 
源代码5 项目: FastLogin   文件: LoginActionMessage.java
@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());
}
 
源代码6 项目: ChangeSkin   文件: CheckPermMessage.java
@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);
}
 
源代码7 项目: ChangeSkin   文件: PermResultMessage.java
@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());
}
 
源代码8 项目: ExtraCells1   文件: PacketTerminalFluid.java
@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);
}
 
源代码9 项目: PlayerSQL   文件: DataSupply.java
@Override
protected void write(ByteArrayDataOutput out) {
    out.writeLong(id.getMostSignificantBits());
    out.writeLong(id.getLeastSignificantBits());
    out.writeUTF(group);
    out.writeInt(buf.length);
    out.write(buf);
}
 
源代码10 项目: BungeeTabListPlus   文件: BukkitBridge.java
@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;
    }
}
 
源代码11 项目: ExtraCells1   文件: PacketBusFluidImport.java
@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);
}
 
源代码12 项目: RedisBungee   文件: RedisBungeeListener.java
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());
    }
}
 
源代码13 项目: RedisBungee   文件: RedisBungeeListener.java
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());
        }
    }
}
 
源代码14 项目: ExtraCells1   文件: PacketLevelEmitterFluid.java
@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);
}
 
源代码15 项目: elasticactors   文件: CompressingSerializer.java
@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;
    }
}
 
源代码16 项目: elasticactors   文件: CompressingSerializer.java
@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);
    }
}
 
源代码17 项目: ExtraCells1   文件: PacketSolderingStation.java
@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);
}
 
源代码18 项目: RedProtect   文件: ModListener.java
public static byte[] createWDLPacket0() {
    ByteArrayDataOutput output = ByteStreams.newDataOutput();
    output.writeInt(0);
    output.writeBoolean(false);
    return output.toByteArray();
}
 
源代码19 项目: util   文件: TestVarULongSerializer.java
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());
}
 
源代码20 项目: RedisBungee   文件: RedisBungeeListener.java
private void serializeCollection(Collection<?> collection, ByteArrayDataOutput output) {
    output.writeInt(collection.size());
    for (Object o : collection) {
        output.writeUTF(o.toString());
    }
}