@Override public void run() { ticks++; if (holo.showing && holo.following != null && holo.following.isOnline() && !holo.following.isDead()) { Location l = holo.following.getLocation(); for (int id : holo.entities.keySet()) { PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport( id, (int) (l.getX() * 32), (int) ((l.getY() + holo.entities.get(id)) * 32) + 30, (int) (l.getZ() * 32), (byte) 0, (byte) 0); for (Player p : players) ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); } } if (ticks >= (Integer) Configuration.getConfig("hologram.showtime") * 20 || !holo.showing) { holograms.remove(holo); following = null; destroy(); task.cancel(); } }
public void show(Location loc, Player... p) { if (showing) return; if ((Boolean) Configuration.getConfig("hologram.enabled")) { showing = true; Location first = loc.clone().add(0, lines.size() / 2 * distance, 0); for (int i = 0; i < lines.size(); i++) { entities.putAll(showLine(first.clone(), lines.get(i), p)); first.subtract(0, distance, 0); } HologramRunnable runnable = new HologramRunnable(this, p); runnable.task = MyZ.instance .getServer() .getScheduler() .runTaskTimerAsynchronously(MyZ.instance, runnable, 0, 1); } else for (Player ps : p) for (String s : lines) Messenger.sendMessage(ps, s); }