Example usage for com.google.common.io ByteStreams newDataOutput

List of usage examples for com.google.common.io ByteStreams newDataOutput

Introduction

In this page you can find the example usage for com.google.common.io ByteStreams newDataOutput.

Prototype

public static ByteArrayDataOutput newDataOutput() 

Source Link

Document

Returns a new ByteArrayDataOutput instance with a default size.

Usage

From source file:com.minestein.novauniverse.util.bungee.ServerConnection.java

public static void connect(Player playerToSend, String serverName) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeUTF("Connect");
    out.writeUTF(serverName);/* w ww .j  a  v a 2s.co  m*/
    playerToSend.sendPluginMessage(Main.plugin, "BungeeCord", out.toByteArray());
}

From source file:com.yubico.u2f.data.messages.key.CodecTestUtils.java

public static byte[] encodeAuthenticateResponse(RawAuthenticateResponse rawAuthenticateResponse) {
    ByteArrayDataOutput encoded = ByteStreams.newDataOutput();
    encoded.write(rawAuthenticateResponse.getUserPresence());
    encoded.writeInt((int) rawAuthenticateResponse.getCounter());
    encoded.write(rawAuthenticateResponse.getSignature());
    return encoded.toByteArray();
}

From source file:com.minestein.novacore.util.general.ServerConnection.java

/**
 * Connects the toSend player to the server via BungeeCord.
 *
 * @param toSend The player to send./*  www . ja  v a  2  s.co  m*/
 * @param server The server's display name to send the player to.
 */
public static void connect(Player toSend, String server) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeUTF("Connect");
    out.writeUTF(server);
    toSend.sendPluginMessage(Core.plugin, "BungeeCord", out.toByteArray());
}

From source file:com.yubico.u2f.data.messages.key.CodecTestUtils.java

public static byte[] encodeRegisterResponse(RawRegisterResponse rawRegisterResponse)
        throws U2fBadInputException {
    byte[] keyHandle = rawRegisterResponse.keyHandle;
    if (keyHandle.length > 255) {
        throw new U2fBadInputException("keyHandle length cannot be longer than 255 bytes!");
    }/*  w w w  .j  av  a2 s. co  m*/

    try {
        ByteArrayDataOutput encoded = ByteStreams.newDataOutput();
        encoded.write(RawRegisterResponse.REGISTRATION_RESERVED_BYTE_VALUE);
        encoded.write(rawRegisterResponse.userPublicKey);
        encoded.write((byte) keyHandle.length);
        encoded.write(keyHandle);
        encoded.write(rawRegisterResponse.attestationCertificate.getEncoded());
        encoded.write(rawRegisterResponse.signature);
        return encoded.toByteArray();
    } catch (CertificateEncodingException e) {
        throw new U2fBadInputException("Error when encoding attestation certificate.", e);
    }
}

From source file:de.bl4ckskull666.mu1ti1ingu41.commands.MainField.java

public static void useCommand(CommandSender s, String[] a) {
    if (a.length > 0) {
        if (a[0].equalsIgnoreCase("reload")) {
            if (!s.hasPermission("mu1ti1ing41.admin")) {
                Language.sendMessage(Mu1ti1ingu41.getPlugin(), s, "command.reload.no-permission",
                        "You dont have permission to use this command.");
                return;
            }/*from www  .j  a v  a2 s .co m*/

            Language.loadLanguage();

            ByteArrayDataOutput out = ByteStreams.newDataOutput();
            out.writeUTF("Mu1ti1ingu41");
            out.writeUTF("reload");

            for (Map.Entry<String, ServerInfo> me : ProxyServer.getInstance().getServers().entrySet())
                me.getValue().sendData("BungeeCord", out.toByteArray(), true);

            Language.sendMessage(Mu1ti1ingu41.getPlugin(), s, "command.reload.successful",
                    "Language files has been reloaded.");
            return;
        } else if (a[0].equalsIgnoreCase("test")) {

        }
    }

    if (!(s instanceof ProxiedPlayer)) {
        s.sendMessage(Mu1ti1ingu41.castMessage("This command can only run by a player."));
        return;
    }

    ProxiedPlayer p = (ProxiedPlayer) s;
    if (a.length < 1) {
        Language.sendMessage(Mu1ti1ingu41.getPlugin(), p, "command.need-language",
                "Please select one of the following language :");
        String ava = "";
        for (String str : Mu1ti1ingu41.getPlugin().getConfig().getConfigurationSection("short-language")
                .getKeys(false))
            ava += (ava.isEmpty() ? "e" : "9, e") + str;
        p.sendMessage(Mu1ti1ingu41.castMessage(ava));
        return;
    }

    if (Mu1ti1ingu41.getPlugin().getConfig().getString("short-language." + a[0].toLowerCase(), "").isEmpty()) {
        Language.sendMessage(Mu1ti1ingu41.getPlugin(), p, "command.unknown-language",
                "Can't find the wished language.");
        return;
    }

    UUIDLanguages._players.put(p.getUniqueId(),
            Mu1ti1ingu41.getPlugin().getConfig().getString("short-language." + a[0].toLowerCase()));

    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeUTF("Mu1ti1ingu41");
    out.writeUTF("player");
    out.writeUTF(p.getUniqueId().toString());
    out.writeUTF(Mu1ti1ingu41.getPlugin().getConfig().getString("short-language." + a[0].toLowerCase()));

    for (Map.Entry<String, ServerInfo> me : ProxyServer.getInstance().getServers().entrySet()) {
        me.getValue().sendData("BungeeCord", out.toByteArray(), true);
    }

    Language.sendMessage(Mu1ti1ingu41.getPlugin(), p, "command.changed-language",
            "The Wished Language has been changed.");
}

From source file:ubic.gemma.model.analysis.expression.coexpression.IdArray.java

private static byte[] pack(EWAHCompressedBitmap bitmap) {
    ByteArrayDataOutput os = ByteStreams.newDataOutput();
    try {//from   w w w.j ava  2s. c o m
        bitmap.serialize(os);
        return os.toByteArray();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:tk.playerforcehd.networklib.bungee.packets.pluginmessage.MSG_sendCommand.java

/**
 * Let's a player execute a command on his subserver
 *
 * @param player  the player who execute it
 * @param command the command which get executed
 */// www.  j  ava 2  s  .  c  o  m
public static void sendCommandToPlayer(ProxiedPlayer player, String command) {
    ByteArrayDataOutput stream = ByteStreams.newDataOutput();
    stream.writeUTF("executeCommand");
    stream.writeUTF(player.getName() + ":" + command);
    player.sendData("BungeeCord", stream.toByteArray());
}

From source file:org.opendaylight.controller.cluster.datastore.DataTreeCandidatePayload.java

/**
 * @deprecated Use CommitTransactionPayload instead
 *//*from  w ww  . j  a  v a 2 s.  c  om*/
@Deprecated
static DataTreeCandidatePayload create(final DataTreeCandidate candidate) {
    final ByteArrayDataOutput out = ByteStreams.newDataOutput();
    try {
        DataTreeCandidateInputOutput.writeDataTreeCandidate(out, candidate);
    } catch (IOException e) {
        throw new IllegalArgumentException(String.format("Failed to serialize candidate %s", candidate), e);
    }

    return new DataTreeCandidatePayload(out.toByteArray());
}

From source file:org.opendaylight.controller.cluster.datastore.persisted.AbortTransactionPayload.java

public static AbortTransactionPayload create(final TransactionIdentifier transactionId) throws IOException {
    final ByteArrayDataOutput out = ByteStreams.newDataOutput();
    transactionId.writeTo(out);/*w  ww .  ja v a  2 s. c o  m*/
    return new AbortTransactionPayload(transactionId, out.toByteArray());
}

From source file:cherry.foundation.crypto.SecureLongEncoder.java

@Override
protected byte[] typeToBytes(Long p) {
    ByteArrayDataOutput out = ByteStreams.newDataOutput();
    out.writeLong(p.longValue());
    return out.toByteArray();
}