Search in sources :

Example 1 with DynamicVisualizerEntity

use of com.loohp.interactionvisualizer.entityholders.DynamicVisualizerEntity in project InteractionVisualizer by LOOHP.

the class PacketManager method dynamicEntity.

public static void dynamicEntity() {
    Bukkit.getScheduler().runTaskTimerAsynchronously(InteractionVisualizer.plugin, () -> {
        Iterator<DynamicVisualizerEntity> itr = dynamicTracking.keySet().iterator();
        while (itr.hasNext()) {
            DynamicVisualizerEntity entity = itr.next();
            Set<Player> players = dynamicTracking.get(entity);
            if (players == null || players.isEmpty()) {
                itr.remove();
                continue;
            }
            Iterator<Player> itr2 = players.iterator();
            while (itr2.hasNext()) {
                Player player = itr2.next();
                Location location = player.getEyeLocation();
                if (!location.getWorld().equals(entity.getWorld())) {
                    itr2.remove();
                } else {
                    ServerPacketSender.teleportEntity(player, entity.getEntityId(), entity.getViewingLocation(location, location.getDirection()));
                }
            }
        }
    }, 0, 2);
}
Also used : Player(org.bukkit.entity.Player) DynamicVisualizerEntity(com.loohp.interactionvisualizer.entityholders.DynamicVisualizerEntity) Location(org.bukkit.Location)

Aggregations

DynamicVisualizerEntity (com.loohp.interactionvisualizer.entityholders.DynamicVisualizerEntity)1 Location (org.bukkit.Location)1 Player (org.bukkit.entity.Player)1