Example usage for io.netty.buffer ByteBuf readBoolean

List of usage examples for io.netty.buffer ByteBuf readBoolean

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf readBoolean.

Prototype

public abstract boolean readBoolean();

Source Link

Document

Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.

Usage

From source file:mca.network.packets.PacketUpdateFurnace.java

License:Open Source License

@Override
public void fromBytes(ByteBuf byteBuf) {
    entityId = byteBuf.readInt();
    state = byteBuf.readBoolean();
}

From source file:me.undergroundminer3.uee4.emcAirEnergy.TileAirConsumer.java

License:Minecraft Mod Public

@Override
public void handleUpdatePacket(final PacketUpdate packet) throws IOException {
    PacketPayload payload = packet.payload;
    ByteBuf data = payload.stream;
    powered = data.readBoolean();

}

From source file:minechess.common.network.PacketPlaySound.java

License:LGPL

@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
    super.decodeInto(ctx, buffer);
    sound = ByteBufUtils.readUTF8String(buffer);
    volume = buffer.readFloat();/*  w w  w  . j  a  v a2s . c o m*/
    pitch = buffer.readFloat();
    bool = buffer.readBoolean();
}

From source file:net.doubledoordev.inventorylock.network.Reply.java

License:Open Source License

@Override
public void fromBytes(ByteBuf buf) {
    key = BlockPos.fromLong(buf.readLong());
    int i = buf.readInt();
    while (i-- > 0)
        value.add(ByteBufUtils.readUTF8String(buf));
    pub = buf.readBoolean();
}

From source file:net.openbyte.server.CodeUpdateServer.java

License:MIT License

public void startTestClient() throws Exception {
    if (isTestClientRunning || !getNetworkManager().isRunning()) {
        return;//from   w  ww  .ja  v a 2s . c  o  m
    }
    EventLoopGroup workerGroup = new NioEventLoopGroup();
    Bootstrap clientBootstrap = new Bootstrap().group(workerGroup).channel(NioSocketChannel.class)
            .handler(new ChannelInitializer<SocketChannel>() {
                @Override
                protected void initChannel(SocketChannel ch) throws Exception {
                    ch.pipeline().addLast(new ChannelHandlerAdapter() {
                        @Override
                        public void channelActive(ChannelHandlerContext context) throws Exception {
                            System.out.println(
                                    "Test client channel is active, sending validation packet to server!");
                            String name = "TEST_CLIENT";
                            String email = "client@example.org";
                            int clientId = -1; // test id

                            ByteBuf packet = new PacketBuilder().varInt(0x00).string(name).string(email)
                                    .varInt(clientId).build();

                            context.writeAndFlush(packet);
                        }

                        String authenticationId = null;

                        @Override
                        public void channelRead(ChannelHandlerContext context, Object msg) throws Exception {
                            ByteBuf read = (ByteBuf) msg;
                            int packetId = ByteBufDecoders.readVarInt(read);
                            System.out.println("Test client has received a packet (ID: " + packetId + ")");
                            if (packetId == 0x00) {
                                // okay packet
                                boolean validated = read.readBoolean();
                                if (!validated) {
                                    System.out.println(
                                            "Test client has not been given access to server. Stopping authentication process.");
                                    return;
                                }
                                authenticationId = ByteBufDecoders.readUTF8(read);
                                System.out.println("Test client has authenticated successfully! ("
                                        + authenticationId + ")");
                                System.out.println("Running server protocol tests...");
                                System.out.println("Running get clients packet protocol...");
                                ByteBuf packet = new PacketBuilder().varInt(0x03).string(authenticationId)
                                        .build();
                                System.out.println("Sending protocol packet (get clients)...");
                                context.writeAndFlush(packet);
                                System.out.println("Awaiting for packet response...");
                            }
                            if (packetId == 0x03) {
                                if (authPacketSent) {
                                    System.out.println("Authentication security failed!");
                                    System.exit(0);
                                }
                                // get client response
                                int clientsConnected = ByteBufDecoders.readVarInt(read);
                                String clients = ByteBufDecoders.readUTF8(read);

                                System.out.println(
                                        "Protocol packet (get clients) successfully executed with following results.");
                                System.out.println("Amount of clients connected: " + clientsConnected
                                        + ", clients connected:");
                                System.out.println(clients);

                                //System.out.println("Test client successfully executed tests.");
                                //System.exit(0);

                                System.out.println(
                                        "Running authentication security test (use fake authentication id)...");
                                ByteBuf packet = new PacketBuilder().varInt(0x03)
                                        .string(UUID.randomUUID().toString()).build();
                                context.writeAndFlush(packet);
                                System.out.println("Invalid authentication packet sent!");
                                authPacketSent = true;
                            }
                            if (packetId == 0x05) {
                                System.out.println("Security measures have been tested successfully!");
                                System.out.println("Tests are done, running disconnect protocol...");

                                ByteBuf packet = new PacketBuilder().varInt(0x08).string(authenticationId)
                                        .string("TEST_CLIENT").build();

                                context.writeAndFlush(packet);
                                System.out.println("Tests have completed. Conclusive results: SUCCESS");
                                System.exit(0);
                            }
                        }
                    });
                }
            });
    clientBootstrap.connect(InetAddress.getLocalHost(), 4000).sync();
    isTestClientRunning = true;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInClientSettings.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    this.locale = Locale.forLanguageTag(Codec.readString(buf));
    this.viewDistance = (short) buf.readByte();
    this.chatFlags = buf.readByte();
    this.chatColors = buf.readBoolean();

    this.skinParts = (byte) buf.readUnsignedByte();

    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInPlayerCompleteMove.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    double x = buf.readDouble();
    double y = buf.readDouble();
    double z = buf.readDouble();

    super.location = new Location(null, x, y, z);

    this.newYaw = buf.readFloat();
    this.newPitch = buf.readFloat();

    super.onGround = buf.readBoolean();
    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInPlayerConfirmTransaction.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    buf.readByte(); //ignore windowId, we'd have the window the player has open anyhow

    this.actionNumber = buf.readShort();
    this.accepted = buf.readBoolean();

    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInPlayerFall.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    this.onGround = buf.readBoolean();

    return this;
}

From source file:net.tridentsdk.packets.play.in.PacketPlayInPlayerLook.java

License:Open Source License

@Override
public Packet decode(ByteBuf buf) {
    this.newYaw = buf.readFloat();
    this.newPitch = buf.readFloat();
    this.onGround = buf.readBoolean();

    return this;
}