Ejemplo n.º 1
0
  @Override
  public void showPlayer(Hologram hologram, Player player) {

    PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;

    for (Object as : hologram.getArmorStands()) {
      PacketPlayOutSpawnEntityLiving packet =
          new PacketPlayOutSpawnEntityLiving((EntityArmorStand) as);
      ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
    }

    if (hologram.hasItem()) {

      EntityItem item = (EntityItem) hologram.getItem();
      PacketPlayOutSpawnEntity itemPacket = new PacketPlayOutSpawnEntity(item, 2, 0);
      playerConnection.sendPacket(itemPacket);

      PacketPlayOutEntityMetadata itemMetaDataPacket =
          new PacketPlayOutEntityMetadata(item.getId(), item.getDataWatcher(), true);
      playerConnection.sendPacket(itemMetaDataPacket);

      PacketPlayOutAttachEntity attachEntityPacket =
          new PacketPlayOutAttachEntity(0, item, (EntityArmorStand) hologram.getArmorStand(0));
      playerConnection.sendPacket(attachEntityPacket);
    }
  }
Ejemplo n.º 2
0
  @Override
  public void setItem(Hologram hologram, Object rawitem) {

    if (!(rawitem instanceof EntityItem))
      throw new IllegalStateException("The item has to be a instance of EntityItem!");

    EntityItem item = (EntityItem) rawitem;
    EntityArmorStand as = (EntityArmorStand) hologram.getArmorStand(0);

    if (hologram.hasItem()) {
      EntityItem oldItem = (EntityItem) hologram.getItem();

      for (Player p : hologram.getPlayers()) {
        PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(oldItem.getId());
        ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
      }
    }

    for (Player p : hologram.getPlayers()) {
      PlayerConnection playerConnection = ((CraftPlayer) p).getHandle().playerConnection;

      PacketPlayOutSpawnEntity itemPacket = new PacketPlayOutSpawnEntity(item, 2, 0);
      playerConnection.sendPacket(itemPacket);

      PacketPlayOutEntityMetadata itemMetaDataPacket =
          new PacketPlayOutEntityMetadata(item.getId(), item.getDataWatcher(), true);
      playerConnection.sendPacket(itemMetaDataPacket);

      PacketPlayOutAttachEntity attachEntityPacket = new PacketPlayOutAttachEntity(0, item, as);
      playerConnection.sendPacket(attachEntityPacket);
    }
  }
Ejemplo n.º 3
0
  @Override
  public Object create(Hologram hologram) {

    EntityArmorStand as = (EntityArmorStand) addMessage(hologram, hologram.getMessage(0));

    if (hologram.hasItem()) setItem(hologram, hologram.getItem());

    return as;
  }
Ejemplo n.º 4
0
  @Override
  public void removeItem(Hologram hologram) {

    if (hologram.hasItem()) {

      for (Player p : hologram.getPlayers()) {
        PacketPlayOutEntityDestroy packet =
            new PacketPlayOutEntityDestroy(((EntityItem) hologram.getItem()).getId());
        ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
      }
    }
  }
Ejemplo n.º 5
0
  @Override
  public void hidePlayer(Hologram hologram, Player player) {

    PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;

    if (hologram.hasItem()) {
      PacketPlayOutEntityDestroy packet =
          new PacketPlayOutEntityDestroy(((EntityItem) hologram.getItem()).getId());
      playerConnection.sendPacket(packet);
    }

    for (Object as : hologram.getArmorStands()) {
      PacketPlayOutEntityDestroy packet =
          new PacketPlayOutEntityDestroy(((EntityArmorStand) as).getId());
      playerConnection.sendPacket(packet);
    }
  }