use of io.github.wysohn.triggerreactor.core.bridge.entity.IEntity in project TriggerReactor by wysohn.
the class AreaTriggerManager method reload.
@Override
public void reload() {
super.reload();
// re-register entities
for (World w : Bukkit.getWorlds()) {
for (Entity e : w.getEntities()) {
UUID uuid = e.getUniqueId();
if (e.isDead() || !e.isValid())
continue;
SimpleLocation previous = null;
SimpleLocation current = LocationUtil.convertToSimpleLocation(e.getLocation());
entityLocationMap.put(uuid, current);
entityTrackMap.put(uuid, new WeakReference<IEntity>(new BukkitEntity(e)));
onEntityBlockMoveAsync(e, previous, current);
}
}
}
use of io.github.wysohn.triggerreactor.core.bridge.entity.IEntity in project TriggerReactor by wysohn.
the class AreaTriggerManager method onSpawn.
@EventHandler
public void onSpawn(EntitySpawnEvent e) {
SimpleLocation sloc = LocationUtil.convertToSimpleLocation(e.getLocation());
entityTrackMap.put(e.getEntity().getUniqueId(), new WeakReference<IEntity>(new BukkitEntity(e.getEntity())));
entityLocationMap.put(e.getEntity().getUniqueId(), sloc);
getAreaForLocation(sloc).stream().map(Map.Entry::getValue).forEach((trigger) -> trigger.addEntity(new BukkitEntity(e.getEntity())));
}
use of io.github.wysohn.triggerreactor.core.bridge.entity.IEntity in project TriggerReactor by wysohn.
the class AreaTrigger method getEntities.
public List<IEntity> getEntities() {
List<IEntity> entities = new ArrayList<>();
Set<UUID> remove = new HashSet<>();
for (Map.Entry<UUID, WeakReference<IEntity>> entry : this.trackedEntities.entrySet()) {
WeakReference<IEntity> ref = entry.getValue();
IEntity entity = ref.get();
if (entity != null) {
entities.add(entity);
} else {
remove.remove(entry.getKey());
}
}
for (UUID uuid : remove) {
this.trackedEntities.remove(uuid);
}
return entities;
}
Aggregations