public static void reflectionsetvalue(
      Field f, TileEntity tileEntity, ByteArrayDataInput dat, String fieldname) {
    try {
      if (f.getType().equals(Integer.TYPE)) f.setInt(tileEntity, Integer.parseInt(dat.readUTF()));
      if (f.getType().equals(Boolean.TYPE))
        f.setBoolean(tileEntity, Boolean.parseBoolean(dat.readUTF()));
      if (f.getType().equals(Short.TYPE)) f.setShort(tileEntity, Short.parseShort(dat.readUTF()));
      if (f.getType().equals(Float.TYPE)) f.setFloat(tileEntity, Float.parseFloat(dat.readUTF()));
      if (f.getType().equals(String.class)) f.set(tileEntity, dat.readUTF());

      if ((tileEntity instanceof INetworkHandlerListener)) {
        ((INetworkHandlerListener) tileEntity).onNetworkHandlerUpdate(fieldname);
      }
    } catch (Exception e) {
    }
  }
  @Override
  public void onPluginMessageReceived(String channel, Player player, byte[] message) {
    Bukkit.getLogger().info("Message received on channel " + channel);
    if (!channel.equals("BungeeMessaging")) return;

    ByteArrayDataInput in = ByteStreams.newDataInput(message);
    String subChannel = in.readUTF();
    int nbMessage = in.readInt();
    List<String> messageList = new ArrayList<String>();
    for (int i = 0; i < nbMessage; i++) {
      messageList.add(in.readUTF());
    }
    if (messageList.contains("delayed")) messageList.remove("delayed");

    Bukkit.getServer()
        .getPluginManager()
        .callEvent(new MessageReceivedEvent(player, subChannel, messageList));
  }
  private ClassPatch readPatch(JarEntry patchEntry, JarInputStream jis) throws IOException {
    log("\t%s", patchEntry.getName());
    ByteArrayDataInput input = ByteStreams.newDataInput(ByteStreams.toByteArray(jis));

    String name = input.readUTF();
    String sourceClassName = input.readUTF();
    String targetClassName = input.readUTF();
    boolean exists = input.readBoolean();
    int inputChecksum = 0;
    if (exists) {
      inputChecksum = input.readInt();
    }
    int patchLength = input.readInt();
    byte[] patchBytes = new byte[patchLength];
    input.readFully(patchBytes);

    return new ClassPatch(
        name, sourceClassName, targetClassName, exists, inputChecksum, patchBytes);
  }
Esempio n. 4
0
  @Override
  public FMLPacket consumePacket(byte[] data) {
    ByteArrayDataInput dat = ByteStreams.newDataInput(data);
    int versionListSize = dat.readInt();
    modVersions = Maps.newHashMapWithExpectedSize(versionListSize);
    for (int i = 0; i < versionListSize; i++) {
      String modName = dat.readUTF();
      String modVersion = dat.readUTF();
      modVersions.put(modName, modVersion);
    }

    int missingModSize = dat.readInt();
    missingMods = Lists.newArrayListWithExpectedSize(missingModSize);

    for (int i = 0; i < missingModSize; i++) {
      missingMods.add(dat.readUTF());
    }
    return this;
  }
Esempio n. 5
0
 @Override
 public void read(ByteArrayDataInput in) {
   playerName = in.readUTF();
   x = in.readInt();
   y = in.readInt();
   z = in.readInt();
   size = in.readInt();
   types = in.readInt();
   remove = in.readBoolean();
   upgrade = in.readChar();
   downgrade = in.readChar();
 }
Esempio n. 6
0
 @Override
 public FMLPacket consumePacket(byte[] data) {
   sentModList = Lists.newArrayList();
   ByteArrayDataInput in = ByteStreams.newDataInput(data);
   int listSize = in.readInt();
   for (int i = 0; i < listSize; i++) {
     sentModList.add(in.readUTF());
   }
   try {
     compatibilityLevel = in.readByte();
   } catch (IllegalStateException e) {
     FMLLog.fine("No compatibility byte found - the server is too old");
   }
   return this;
 }
 @Override
 void readData(ByteArrayDataInput in) {
   entityId = in.readInt();
   newName = in.readUTF();
 }
 @Override
 public void handlePacketData(ByteArrayDataInput dataStream) {
   super.handlePacketData(dataStream);
   tier = EnergyCubeTier.getFromName(dataStream.readUTF());
 }
Esempio n. 9
0
 @Override
 public void readSpawnData(ByteArrayDataInput data) {
   playerName = data.readUTF();
   // skinUrl = "http://skins.minecraft.net/MinecraftSkins/"
   // + StringUtils.stripControlCodes(playerName) + ".png";
 }
Esempio n. 10
0
  @Override
  protected void read(ByteArrayDataInput dataStream) {
    super.read(dataStream);

    oreDictName = dataStream.readUTF();
  }
Esempio n. 11
0
 public void serialize(ByteArrayDataInput in) {
   this.id = in.readInt();
   this.type = ServerType.getType(in.readUTF());
 }
  public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
    ByteArrayDataInput dat = ByteStreams.newDataInput(packet.data);
    int x = dat.readInt();
    int y = dat.readInt();
    int z = dat.readInt();
    int typ = dat.readInt();
    World world = ModularForceFieldSystem.proxy.getClientWorld();

    switch (typ) {
      case 100:
        String DataPacket = dat.readUTF();

        for (String blockupdate : DataPacket.split(">")) {
          if (blockupdate.length() > 0) {
            String[] projector = blockupdate.split("<");
            String[] Corrdinaten = projector[1].split("/");
            String[] temp = projector[0].split("!");
            String[] Dim = temp[1].split("/");
            String[] ProjectorCorr = temp[0].split("/");

            if (Integer.parseInt(Dim[0].trim()) == world.provider.dimensionId) {
              if (world.getChunkFromBlockCoords(
                      Integer.parseInt(Corrdinaten[0].trim()),
                      Integer.parseInt(Corrdinaten[2].trim()))
                  .isChunkLoaded) {
                TileEntity te =
                    world.getBlockTileEntity(
                        Integer.parseInt(Corrdinaten[0].trim()),
                        Integer.parseInt(Corrdinaten[1].trim()),
                        Integer.parseInt(Corrdinaten[2].trim()));
                if ((te instanceof TileEntityForceField)) {
                  TileEntity proj =
                      world.getBlockTileEntity(
                          Integer.parseInt(ProjectorCorr[2].trim()),
                          Integer.parseInt(ProjectorCorr[1].trim()),
                          Integer.parseInt(ProjectorCorr[0].trim()));
                  if ((proj instanceof TileEntityProjector)) {
                    ((TileEntityForceField) te)
                        .setTexturfile(((TileEntityProjector) proj).getForceFieldTexturfile());
                    ((TileEntityForceField) te)
                        .setTexturid(((TileEntityProjector) proj).getForceFieldTexturID());
                    ((TileEntityForceField) te)
                        .setForcefieldCamoblockid(
                            ((TileEntityProjector) proj).getForcefieldCamoblockid());
                    ((TileEntityForceField) te)
                        .setForcefieldCamoblockmeta(
                            ((TileEntityProjector) proj).getForcefieldCamoblockmeta());
                  }
                }
              }
            }
          }
        }

        break;
      case 1:
        String fieldname = dat.readUTF();

        TileEntity tileEntity = world.getBlockTileEntity(x, y, z);

        if ((tileEntity instanceof TileEntityMFFS)) {
          try {
            Field f = ReflectionHelper.findField(TileEntityMFFS.class, new String[] {fieldname});
            reflectionsetvalue(f, tileEntity, dat, fieldname);
          } catch (Exception e) {
          }
        }

        if ((tileEntity instanceof TileEntityCapacitor)) {
          try {
            Field f =
                ReflectionHelper.findField(TileEntityCapacitor.class, new String[] {fieldname});
            reflectionsetvalue(f, tileEntity, dat, fieldname);
          } catch (Exception e) {
          }
        }

        if ((tileEntity instanceof TileEntityExtractor)) {
          try {
            Field f =
                ReflectionHelper.findField(TileEntityExtractor.class, new String[] {fieldname});
            reflectionsetvalue(f, tileEntity, dat, fieldname);
          } catch (Exception e) {
          }
        }

        if ((tileEntity instanceof TileEntityConverter)) {
          try {
            Field f =
                ReflectionHelper.findField(TileEntityConverter.class, new String[] {fieldname});
            reflectionsetvalue(f, tileEntity, dat, fieldname);
          } catch (Exception e) {
          }
        }

        if ((tileEntity instanceof TileEntityProjector)) {
          try {
            Field f =
                ReflectionHelper.findField(TileEntityProjector.class, new String[] {fieldname});
            reflectionsetvalue(f, tileEntity, dat, fieldname);
          } catch (Exception e) {
          }
        }

        if ((tileEntity instanceof TileEntityDefenseStation)) {
          try {
            Field f =
                ReflectionHelper.findField(
                    TileEntityDefenseStation.class, new String[] {fieldname});
            reflectionsetvalue(f, tileEntity, dat, fieldname);
          } catch (Exception e) {
          }
        }

        if ((tileEntity instanceof TileEntitySecurityStation)) {
          try {
            Field f =
                ReflectionHelper.findField(
                    TileEntitySecurityStation.class, new String[] {fieldname});
            reflectionsetvalue(f, tileEntity, dat, fieldname);
          } catch (Exception e) {
          }
        }

        if ((tileEntity instanceof TileEntitySecStorage)) {
          try {
            Field f =
                ReflectionHelper.findField(TileEntitySecStorage.class, new String[] {fieldname});
            reflectionsetvalue(f, tileEntity, dat, fieldname);
          } catch (Exception e) {
          }
        }

        if ((tileEntity instanceof TileEntityControlSystem))
          try {
            Field f =
                ReflectionHelper.findField(TileEntityControlSystem.class, new String[] {fieldname});
            reflectionsetvalue(f, tileEntity, dat, fieldname);
          } catch (Exception e) {
          }
        break;
    }
  }