use of io.github.wysohn.triggerreactor.core.bridge.entity.IEntity in project TriggerReactor by wysohn.
the class AreaTrigger method getEntity.
public IEntity getEntity(UUID uuid) {
WeakReference<IEntity> ref = this.trackedEntities.get(uuid);
if (ref == null)
return null;
IEntity entity = ref.get();
// just remove it as it's got garbage-collected.
if (entity == null) {
this.trackedEntities.remove(uuid);
}
return entity;
}
use of io.github.wysohn.triggerreactor.core.bridge.entity.IEntity in project TriggerReactor by wysohn.
the class CommonFunctions method getEntitiesInArea.
/**
* Get list of entities tracked by this AreaTrigger.
*
* @param areaTriggerName name of AreaTrigger to get entities from
* @return List of entities. null if the AreaTrigger with specified name
* doesn't exist.
*/
public List<Entity> getEntitiesInArea(String areaTriggerName) {
AbstractAreaTriggerManager areaManager = plugin.getAreaManager();
AreaTrigger trigger = areaManager.get(areaTriggerName);
if (trigger == null)
return null;
List<Entity> entities = new ArrayList<>();
for (IEntity ie : trigger.getEntities()) entities.add(ie.get());
return entities;
}
use of io.github.wysohn.triggerreactor.core.bridge.entity.IEntity in project TriggerReactor by wysohn.
the class AreaTriggerManager method onSpawn.
@Listener
public void onSpawn(RespawnPlayerEvent e) {
SimpleLocation sloc = LocationUtil.convertToSimpleLocation(e.getTargetEntity().getLocation());
entityTrackMap.put(e.getTargetEntity().getUniqueId(), new WeakReference<IEntity>(new SpongeEntity(e.getTargetEntity())));
entityLocationMap.put(e.getTargetEntity().getUniqueId(), sloc);
getAreaForLocation(sloc).stream().map(Entry::getValue).forEach((trigger) -> trigger.addEntity(new SpongeEntity(e.getTargetEntity())));
}
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 : Sponge.getServer().getWorlds()) {
for (Entity e : w.getEntities()) {
UUID uuid = e.getUniqueId();
if (e.isRemoved() || !e.isLoaded())
continue;
SimpleLocation previous = null;
SimpleLocation current = LocationUtil.convertToSimpleLocation(e.getLocation());
entityLocationMap.put(uuid, current);
entityTrackMap.put(uuid, new WeakReference<IEntity>(new SpongeEntity(e)));
onEntityBlockMoveAsync(e, previous, current);
}
}
}
use of io.github.wysohn.triggerreactor.core.bridge.entity.IEntity in project TriggerReactor by wysohn.
the class AbstractCommonFunctions method getEntitiesInArea.
/**
* Get list of entities tracked by this AreaTrigger.
*
* @param areaTriggerName name of AreaTrigger to get entities from
* @return List of entities. null if the AreaTrigger with specified name doesn't exist.
*/
public List<Entity> getEntitiesInArea(String areaTriggerName) {
AbstractAreaTriggerManager areaManager = plugin.getAreaManager();
AreaTrigger trigger = areaManager.get(areaTriggerName);
if (trigger == null)
return null;
List<Entity> entities = new ArrayList<>();
for (IEntity ie : trigger.getEntities()) entities.add(ie.get());
return entities;
}
Aggregations