Exemplo n.º 1
0
  @Override
  public Object addMessage(Hologram hologram, String message) {

    EntityArmorStand lastAs =
        hologram.getArmorStands().size() == 0
            ? null
            : (EntityArmorStand) hologram.getArmorStand(hologram.getArmorStands().size() - 1);
    EntityArmorStand as;

    if (lastAs != null) {
      as = new EntityArmorStand(lastAs.world);
      as.setInvisible(true);
      as.setCustomName(message);
      as.setCustomNameVisible(true);
      as.setSmall(true);
      as.setGravity(false);
      as.setLocation(
          lastAs.locX, lastAs.locY - hologram.getDistance(), lastAs.locZ, lastAs.yaw, lastAs.pitch);

    } else {
      Location loc = hologram.getLocation();

      as = new EntityArmorStand(((CraftWorld) loc.getWorld()).getHandle());
      as.setInvisible(true);
      as.setCustomName(message);
      as.setCustomNameVisible(true);
      as.setSmall(true);
      as.setGravity(false);
      as.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
    }

    for (Player p : hologram.getPlayers()) {
      PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving(as);
      ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
    }

    return as;
  }
Exemplo n.º 2
0
  @Override
  public Object setMessage(Hologram hologram, int index, String message) {

    if (index >= hologram.getArmorStands().size()) throw new IndexOutOfBoundsException();

    EntityArmorStand as = (EntityArmorStand) hologram.getArmorStands().get(index);

    as.setCustomName(message);

    for (Player p : hologram.getPlayers()) {
      PacketPlayOutEntityMetadata itemMetaDataPacket =
          new PacketPlayOutEntityMetadata(as.getId(), as.getDataWatcher(), true);
      ((CraftPlayer) p).getHandle().playerConnection.sendPacket(itemMetaDataPacket);
    }
    return as;
  }