Esempio 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());
 }
Esempio n. 2
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();
 }
Esempio n. 3
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();
 }
  /** 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;
  }
  @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());
      }
    }
  }
Esempio n. 6
0
 public final Packet makePacket() {
   ByteArrayDataOutput out = ByteStreams.newDataOutput();
   out.writeByte(getPacketId());
   write(out);
   return PacketDispatcher.getPacket(CHANNEL, out.toByteArray());
 }
Esempio n. 7
0
 @Override
 protected byte[] typeToBytes(Long p) {
   ByteArrayDataOutput out = ByteStreams.newDataOutput();
   out.writeLong(p.longValue());
   return out.toByteArray();
 }