Example usage for com.google.common.io ByteArrayDataInput readBoolean

List of usage examples for com.google.common.io ByteArrayDataInput readBoolean

Introduction

In this page you can find the example usage for com.google.common.io ByteArrayDataInput readBoolean.

Prototype

@Override
    boolean readBoolean();

Source Link

Usage

From source file:micdoodle8.mods.galacticraft.core.tile.GCCoreTileEntityTreasureChest.java

@Override
public void handlePacketData(INetworkManager network, int type, Packet250CustomPayload packet,
        EntityPlayer player, ByteArrayDataInput dataStream) {
    try {/*  w  ww . ja  v a  2s. c o  m*/
        if (this.worldObj.isRemote) {
            this.locked = dataStream.readBoolean();
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }
}

From source file:micdoodle8.mods.galacticraft.mars.tile.GCMarsTileEntityTerraformer.java

@Override
public void readPacket(ByteArrayDataInput data) {
    if (this.worldObj.isRemote) {
        this.setEnergyStored(data.readFloat());
        this.treesDisabled = data.readBoolean();
        this.grassDisabled = data.readBoolean();
        this.disableCooldown = data.readInt();
        int terraformBubbleEntityID = data.readInt();
        this.terraformBubble = (GCMarsEntityTerraformBubble) (terraformBubbleEntityID == -1 ? null
                : this.worldObj.getEntityByID(terraformBubbleEntityID));
        this.terraformableBlocksListSize = data.readInt();
        this.grassBlocksListSize = data.readInt();
        this.size = data.readFloat();

        int firstStack = -1;
        int itemID = -1;
        int stackSize = -1;
        int stackMetadata = -1;

        for (int i = 0; i < 3; i++) {
            firstStack = data.readInt();
            itemID = data.readInt();//w  w w  .j ava2 s . c o  m
            stackSize = data.readInt();
            stackMetadata = data.readInt();

            if (firstStack != -1) {
                this.containingItems[firstStack] = new ItemStack(itemID, stackSize, stackMetadata);
            }
        }

        this.waterTank.setFluid(new FluidStack(GalacticraftCore.fluidFuel, data.readInt()));
    }
}

From source file:micdoodle8.mods.galacticraft.core.tile.GCCoreTileEntityRefinery.java

@Override
public void readPacket(ByteArrayDataInput data) {
    if (this.worldObj.isRemote) {
        this.setEnergyStored(data.readFloat());
        this.processTicks = data.readInt();
        this.oilTank.setFluid(new FluidStack(GalacticraftCore.fluidOil, data.readInt()));
        this.fuelTank.setFluid(new FluidStack(GalacticraftCore.fluidFuel, data.readInt()));
        this.disabled = data.readBoolean();
        this.disableCooldown = data.readInt();
    }//w w  w .  j  a v a  2 s  .c  o m
}

From source file:shadowmage.ancient_warfare.common.vehicles.missiles.MissileBase.java

@Override
public void readSpawnData(ByteArrayDataInput data) {
    this.missileType = data.readInt();
    this.ammoType = AmmoRegistry.instance().getAmmoEntry(missileType);
    if (this.ammoType == null) {
        this.ammoType = Ammo.ammoArrow;
    }/*from  w w  w . j av  a 2s. c om*/
    this.prevRotationYaw = this.rotationYaw = data.readFloat();
    this.prevRotationPitch = this.rotationPitch = data.readFloat();
    this.inGround = data.readBoolean();
    this.blockX = data.readInt();
    this.blockY = data.readInt();
    this.blockZ = data.readInt();
    this.blockID = data.readInt();
    this.blockMeta = data.readInt();
    this.rocketBurnTime = data.readInt();
    boolean hasLauncher = data.readBoolean();
    if (hasLauncher) {
        Entity launcher = worldObj.getEntityByID(data.readInt());
    }
}

From source file:micdoodle8.mods.galacticraft.core.tile.GCCoreTileEntitySolar.java

@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet,
        EntityPlayer player, ByteArrayDataInput dataStream) {
    try {//from w  ww . j  a  va  2  s  .  c o m
        this.mainBlockPosition = new Vector3(dataStream.readInt(), dataStream.readInt(), dataStream.readInt());
        this.solarStrength = dataStream.readInt();
        this.setEnergyStored(dataStream.readFloat());
        this.generateWatts = dataStream.readFloat();
        this.disableCooldown = dataStream.readInt();
        this.disabled = dataStream.readBoolean();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.papaharni.amcbungee.events.PluginMessage.java

@EventHandler(priority = EventPriority.LOW)
public void onPluginMessage(PluginMessageEvent e) {
    if (!e.getTag().equalsIgnoreCase("BungeeCord"))
        return;//from   w  ww  . j a v a  2s .c o  m

    ByteArrayDataInput in = ByteStreams.newDataInput(e.getData());
    String sub = in.readUTF();
    if (!sub.equalsIgnoreCase("MyBungee"))
        return;

    String cat = in.readUTF();
    UUID uuid = UUID.fromString(in.readUTF());
    if (cat.equalsIgnoreCase("age")) {
        int age = in.readInt();
        AMCBungee.getInstance().getLogger().log(Level.INFO, "Found {0} with UUID {1} and Age of {2}",
                new Object[] { cat, uuid.toString(), age });
        AMCBungee.getPlayerAge().put(uuid, age);
    } else if (cat.equalsIgnoreCase("gender")) {
        String gender = in.readUTF();
        AMCBungee.getInstance().getLogger().log(Level.INFO, "Found {0} with UUID {1} and Gender {2}",
                new Object[] { cat, uuid.toString(), gender });
        AMCBungee.getPlayerGender().put(uuid, gender);
    } else if (cat.equalsIgnoreCase("verify")) {
        boolean bol = in.readBoolean();
        if (bol)
            AMCBungee.getPlayerVerification().add(uuid);
        else
            AMCBungee.getPlayerVerification().remove(uuid);
        AMCBungee.getInstance().getLogger().log(Level.INFO, "Found {0} with UUID {1} is Verify? {2}",
                new Object[] { cat, uuid.toString(), bol });
    } else if (cat.equalsIgnoreCase("chat")) {
        String ignore = in.readUTF();
        String msg = in.readUTF().replace("__", " ");
        for (Map.Entry<String, ServerInfo> me : ProxyServer.getInstance().getServers().entrySet()) {
            if (me.getKey().equalsIgnoreCase(ignore) || me.getValue().getName().equalsIgnoreCase(ignore))
                continue;
            for (ProxiedPlayer pp : me.getValue().getPlayers())
                pp.sendMessage(Language.convertString(ChatColor.WHITE + "[" + ChatColor.BLUE
                        + Language.getMsg(AMCBungee.getInstance(), pp.getUniqueId(), "server." + ignore, ignore)
                        + ChatColor.WHITE + "]" + msg));
        }
    }
}

From source file:micdoodle8.mods.galacticraft.core.entities.GCCoreEntityLander.java

@Override
public void readNetworkedData(ByteArrayDataInput dataStream) {
    if (this.worldObj.isRemote) {
        int cargoLength = dataStream.readInt();

        if (this.containedItems == null || this.containedItems.length == 0) {
            this.containedItems = new ItemStack[cargoLength];
            PacketDispatcher.sendPacketToServer(PacketUtil.createPacket(GalacticraftCore.CHANNEL,
                    EnumPacketServer.UPDATE_DYNAMIC_ENTITY_INV, new Object[] { this.entityId }));
        }/*from  w  w  w.  java  2 s  .c o m*/

        this.fuelTank.setFluid(new FluidStack(GalacticraftCore.fluidFuel, dataStream.readInt()));

        this.setWaitForPlayer(dataStream.readBoolean());

        this.onGround = dataStream.readBoolean();
    } else {
        this.motionX = dataStream.readDouble() / 8000.0D;
        this.motionY = dataStream.readDouble() / 8000.0D;
        this.motionZ = dataStream.readDouble() / 8000.0D;

        this.rotationPitch = dataStream.readFloat();
        this.rotationYaw = dataStream.readFloat();
    }
}

From source file:io.github.apfelcreme.LitePortals.Bungee.Listener.BukkitMessageListener.java

/**
 * listener for the bukkit communication channel
 *
 * @param event an event object//from ww w  . j  av a 2 s .c o  m
 * @throws IOException
 */
@EventHandler
public void onPluginMessageReceived(PluginMessageEvent event) throws IOException {
    if (!event.getTag().equals("LitePortals")) {
        return;
    }
    if (!(event.getSender() instanceof Server)) {
        return;
    }

    ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
    String subChannel = in.readUTF();
    if (subChannel.equals("PORTALWASBUILT")) {
        Portal portal = new Portal(UUID.fromString(in.readUTF()), new Location(in.readUTF(), in.readUTF(),
                in.readDouble(), in.readDouble(), in.readDouble(), in.readDouble()));
        portalWasBuilt(portal);
    } else if (subChannel.equals("PLAYERBROKEPORTAL")) {
        UUID breaker = UUID.fromString(in.readUTF());
        Location location = new Location(in.readUTF(), in.readUTF(), in.readDouble(), in.readDouble(),
                in.readDouble(), null);
        portalGotDestroyed(breaker, location);
    } else if (subChannel.equals("PLAYERUSEDPORTAL")) {
        UUID player = UUID.fromString(in.readUTF());
        Location location = new Location(in.readUTF(), in.readUTF(), in.readDouble(), in.readDouble(),
                in.readDouble(), null);
        Portal portal = PortalManager.getInstance().portalExists(location);
        teleport(player, portal);
    } else if (subChannel.equals("POSITIONANSWER")) {
        UUID player = UUID.fromString(in.readUTF());
        boolean portalExists = in.readBoolean();
        if (portalExists) {
            // there is a portal or a portal structure there
            Location location = new Location(in.readUTF(), in.readUTF(), in.readDouble(), in.readDouble(),
                    in.readDouble(), null);
            printInfo(player, location);
        } else {
            LitePortals.sendMessage(player,
                    LitePortalsConfig.getInstance().getText("error.notStandingInAPortal"));
        }
    }
}

From source file:codecrafter47.bungeetablistplus.managers.RedisPlayerManager.java

@EventHandler
@SuppressWarnings("unchecked")
public void onRedisMessage(PubSubMessageEvent event) {
    String channel = event.getChannel();
    if (channel.equals(CHANNEL_DATA_REQUEST)) {
        ByteArrayDataInput input = ByteStreams.newDataInput(Base64.getDecoder().decode(event.getMessage()));
        try {/*from   w  w w  . ja  v  a  2s . com*/
            UUID uuid = DataStreamUtils.readUUID(input);

            ConnectedPlayer player = connectedPlayerManager.getPlayerIfPresent(uuid);
            if (player != null) {
                DataKey<?> key = DataStreamUtils.readDataKey(input, keyRegistry, missingDataKeyLogger);

                if (key != null) {
                    player.addDataChangeListener((DataKey<Object>) key,
                            new DataChangeListener(uuid, (DataKey<Object>) key));
                    updateData(uuid, (DataKey<Object>) key, player.get(key));
                }

            }
        } catch (IOException ex) {
            logger.log(Level.SEVERE, "Unexpected error reading redis message", ex);
        }
    } else if (channel.equals(CHANNEL_DATA_UPDATE)) {
        ByteArrayDataInput input = ByteStreams.newDataInput(Base64.getDecoder().decode(event.getMessage()));
        try {
            UUID uuid = DataStreamUtils.readUUID(input);

            RedisPlayer player = byUUID.get(uuid);
            if (player != null) {
                DataCache cache = player.getData();
                DataKey<?> key = DataStreamUtils.readDataKey(input, keyRegistry, missingDataKeyLogger);

                if (key != null) {
                    boolean removed = input.readBoolean();

                    if (removed) {

                        plugin.runInMainThread(() -> cache.updateValue(key, null));
                    } else {

                        Object value = typeRegistry.getTypeAdapter(key.getType()).read(input);
                        plugin.runInMainThread(() -> cache.updateValue((DataKey<Object>) key, value));
                    }
                }
            }
        } catch (IOException ex) {
            logger.log(Level.SEVERE, "Unexpected error reading redis message", ex);
        }
    } else if (channel.equals(CHANNEL_DATA_OLD) || channel.equals(CHANNEL_REQUEST_DATA_OLD)) {
        logger.warning("BungeeTabListPlus on at least one proxy in your network is outdated.");
    }
}

From source file:shadowmage.ancient_warfare.common.vehicles.VehicleBase.java

@Override
public void readSpawnData(ByteArrayDataInput data) {
    this.setHealth(data.readFloat());
    IVehicleType type = VehicleType.getVehicleType(data.readInt());
    this.setVehicleType(type, data.readInt());
    this.upgradeHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.ammoHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.moveHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.firingHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.firingVarsHelper.readFromNBT(ByteTools.readNBTTagCompound(data));
    this.localLaunchPower = data.readFloat();
    this.localTurretPitch = data.readFloat();
    this.localTurretRotation = data.readFloat();
    this.localTurretDestPitch = data.readFloat();
    this.localTurretDestRot = data.readFloat();
    this.firingHelper.clientLaunchSpeed = localLaunchPower;
    this.firingHelper.clientTurretPitch = localTurretPitch;
    this.firingHelper.clientTurretYaw = localTurretRotation;
    this.upgradeHelper.updateUpgradeStats();
    this.teamNum = data.readInt();
    this.localTurretRotationHome = data.readFloat();
    this.isSettingUp = data.readBoolean();
    if (this.isSettingUp) {
        this.setupTicks = data.readInt();
    }/*  w  w w.j  av  a 2  s  .com*/
    this.setPosition(posX, posY, posZ);//this is to reset the bounding box, because the size of the entity changed during vehicleType setup 
}