Exemplo n.º 1
0
 private void sendMessage(Player player, String[] message, String channel) {
   ByteArrayDataOutput out = ByteStreams.newDataOutput();
   for (int i = 0; i < message.length; ++i) {
     out.writeUTF(message[i]);
   }
   player.sendPluginMessage(plugin, channel, out.toByteArray());
 }
 @Override
 protected void writeData(ByteArrayDataOutput out) throws IOException {
   out.writeInt(x);
   out.writeShort(y);
   out.writeInt(z);
   out.writeInt(charge);
 }
Exemplo n.º 3
0
 @Override
 public byte[] generatePacket(Object... data) {
   ByteArrayDataOutput dat = ByteStreams.newDataOutput();
   Set<ModContainer> activeMods = FMLNetworkHandler.instance().getNetworkModList();
   dat.writeInt(activeMods.size());
   for (ModContainer mc : activeMods) {
     dat.writeUTF(mc.getModId());
   }
   dat.writeByte(FMLNetworkHandler.getCompatibilityLevel());
   return dat.toByteArray();
 }
Exemplo n.º 4
0
  /** create the custom250packet from the current data in this packet. */
  protected void constructPacket() {
    ByteArrayDataOutput data = ByteStreams.newDataOutput();

    /**
     * write the packet type number to the stream, decoded in packetHandler to create a new packet
     */
    data.writeInt(this.getPacketType());

    /** write default packet data NBTCompound to the stream */
    NBTWriter.writeTagToStream(packetData, data);

    /** write custom data to the output stream */
    this.writeDataToStream(data);
    this.packet250 = new Packet250CustomPayload();
    packet250.isChunkDataPacket = this.chunkPacket;
    packet250.channel = this.getChannel();
    packet250.data = data.toByteArray();
    packet250.length = packet250.data.length;
  }
Exemplo n.º 5
0
 @Override
 public void write(ByteArrayDataOutput out) {
   out.writeUTF(playerName);
   out.writeInt(x);
   out.writeInt(y);
   out.writeInt(z);
   out.writeInt(size);
   out.writeInt(types);
   out.writeBoolean(remove);
   out.writeChar(upgrade);
   out.writeChar(downgrade);
 }
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent event) {

    Player player = event.getPlayer();

    for (Portal portal : ConfigPortals.portals) {

      if (portal.containsBlock(player.getLocation())
          && player.hasPermission(portal.getPermission())) {

        player.teleport(player.getWorld().getSpawnLocation());

        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        out.writeUTF("Connect");
        out.writeUTF(portal.getServer());

        player.sendPluginMessage(Main.getInstance(), "BungeeCord", out.toByteArray());
      }
    }
  }
Exemplo n.º 7
0
 @Override
 public byte[] generatePacket(Object... data) {
   @SuppressWarnings("unchecked")
   Map<String, String> modVersions = (Map<String, String>) data[0];
   @SuppressWarnings("unchecked")
   List<String> missingMods = (List<String>) data[1];
   ByteArrayDataOutput dat = ByteStreams.newDataOutput();
   dat.writeInt(modVersions.size());
   for (Entry<String, String> version : modVersions.entrySet()) {
     dat.writeUTF(version.getKey());
     dat.writeUTF(version.getValue());
   }
   dat.writeInt(missingMods.size());
   for (String missing : missingMods) {
     dat.writeUTF(missing);
   }
   return dat.toByteArray();
 }
Exemplo n.º 8
0
 @Override
 public void writeToStream(ByteArrayDataOutput stream) {
   this.key.writeToStream(stream);
   stream.writeInt(this.value);
   this.data.writeToStream(stream);
 }
 @Override
 public void write(ByteArrayDataOutput out) {
   out.writeInt(windowId);
   out.writeInt(marketId);
 }
Exemplo n.º 10
0
  @Override
  public void writeSpawnData(ByteArrayDataOutput data) {
    NBTTagCompound tags = returnStack.getTagCompound().getCompoundTag("InfiTool");
    data.writeShort(returnStack.itemID);
    data.writeFloat(rotationYaw);
    data.writeInt(tags.getInteger("RenderHandle"));
    data.writeInt(tags.getInteger("RenderHead"));
    data.writeInt(tags.getInteger("RenderAccessory"));

    int effects = 0;
    if (tags.hasKey("Effect1")) effects++;
    if (tags.hasKey("Effect2")) effects++;
    if (tags.hasKey("Effect3")) effects++;
    if (tags.hasKey("Effect4")) effects++;
    if (tags.hasKey("Effect5")) effects++;
    if (tags.hasKey("Effect6")) effects++;
    data.writeInt(effects);

    switch (effects) {
      case 6:
        data.writeInt(tags.getInteger("Effect6"));
      case 5:
        data.writeInt(tags.getInteger("Effect5"));
      case 4:
        data.writeInt(tags.getInteger("Effect4"));
      case 3:
        data.writeInt(tags.getInteger("Effect3"));
      case 2:
        data.writeInt(tags.getInteger("Effect2"));
      case 1:
        data.writeInt(tags.getInteger("Effect1"));
    }
  }
Exemplo n.º 11
0
 @Override
 public void write(Object o, ByteArrayDataOutput dat) {
   dat.writeShort((Short) o);
 }
Exemplo n.º 12
0
 @Override
 public void write(Object o, ByteArrayDataOutput dat) {
   dat.writeChar((Character) o);
 }
Exemplo n.º 13
0
 @Override
 protected void write(ByteArrayDataOutput output) {
   output.writeInt(cost);
 }
 @Override
 public void writeSpawnData(ByteArrayDataOutput data) {
   data.writeInt(angler.entityId);
 }
Exemplo n.º 15
0
 /** These two methods are for sending data down to the client When the mob first spawns */
 @Override
 public void writeSpawnData(ByteArrayDataOutput data) {
   data.writeUTF(playerName == null ? "Unknown" : playerName);
 }
Exemplo n.º 16
0
 public final Packet makePacket() {
   ByteArrayDataOutput out = ByteStreams.newDataOutput();
   out.writeByte(getPacketId());
   write(out);
   return PacketDispatcher.getPacket(CHANNEL, out.toByteArray());
 }
Exemplo n.º 17
0
 @Override
 public void write(Object o, ByteArrayDataOutput dat) {
   dat.writeInt((Integer) o);
 }
Exemplo n.º 18
0
 @Override
 public void write(Object o, ByteArrayDataOutput dat) {
   dat.writeFloat((Float) o);
 }
Exemplo n.º 19
0
 @Override
 public void write(Object o, ByteArrayDataOutput dat) {
   dat.writeByte((Byte) o);
 }
Exemplo n.º 20
0
 @Override
 public void writeSpawnData(ByteArrayDataOutput data) {
   data.writeInt(this.BirthTick);
   data.writeInt(this.EnumToInt(DinoInside));
   // data.writeChars(this.ParentOwner);
 }
Exemplo n.º 21
0
 @Override
 public void write(Object o, ByteArrayDataOutput dat) {
   dat.writeLong((Long) o);
 }
 @Override
 void writeData(ByteArrayDataOutput out) {
   out.writeInt(entityId);
   out.writeUTF(newName);
 }
Exemplo n.º 23
0
 @Override
 protected byte[] typeToBytes(Long p) {
   ByteArrayDataOutput out = ByteStreams.newDataOutput();
   out.writeLong(p.longValue());
   return out.toByteArray();
 }