Search in sources :

Example 1 with AbstractAreaTriggerManager

use of io.github.wysohn.triggerreactor.core.manager.trigger.area.AbstractAreaTriggerManager 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;
}
Also used : IEntity(io.github.wysohn.triggerreactor.core.bridge.entity.IEntity) Entity(org.spongepowered.api.entity.Entity) AbstractAreaTriggerManager(io.github.wysohn.triggerreactor.core.manager.trigger.area.AbstractAreaTriggerManager) IEntity(io.github.wysohn.triggerreactor.core.bridge.entity.IEntity) AreaTrigger(io.github.wysohn.triggerreactor.core.manager.trigger.area.AreaTrigger)

Example 2 with AbstractAreaTriggerManager

use of io.github.wysohn.triggerreactor.core.manager.trigger.area.AbstractAreaTriggerManager in project TriggerReactor by wysohn.

the class CommonFunctions method currentAreasAt.

/**
 * Get the name of area triggers containing the given location.
 *
 * @param location the location to check
 * @return array of AreaTrigger names. The array can be empty but never null.
 */
public String[] currentAreasAt(Location location) {
    AbstractAreaTriggerManager areaManager = plugin.getAreaManager();
    String[] names = areaManager.getAreas(LocationUtil.convertToSimpleLocation(location)).stream().map(Map.Entry::getValue).map(Trigger::getInfo).map(TriggerInfo::getTriggerName).toArray(String[]::new);
    return names;
}
Also used : AbstractAreaTriggerManager(io.github.wysohn.triggerreactor.core.manager.trigger.area.AbstractAreaTriggerManager) AreaTrigger(io.github.wysohn.triggerreactor.core.manager.trigger.area.AreaTrigger) Trigger(io.github.wysohn.triggerreactor.core.manager.trigger.Trigger)

Example 3 with AbstractAreaTriggerManager

use of io.github.wysohn.triggerreactor.core.manager.trigger.area.AbstractAreaTriggerManager 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;
}
Also used : Entity(org.bukkit.entity.Entity) IEntity(io.github.wysohn.triggerreactor.core.bridge.entity.IEntity) AbstractAreaTriggerManager(io.github.wysohn.triggerreactor.core.manager.trigger.area.AbstractAreaTriggerManager) IEntity(io.github.wysohn.triggerreactor.core.bridge.entity.IEntity) AreaTrigger(io.github.wysohn.triggerreactor.core.manager.trigger.area.AreaTrigger)

Aggregations

AbstractAreaTriggerManager (io.github.wysohn.triggerreactor.core.manager.trigger.area.AbstractAreaTriggerManager)3 AreaTrigger (io.github.wysohn.triggerreactor.core.manager.trigger.area.AreaTrigger)3 IEntity (io.github.wysohn.triggerreactor.core.bridge.entity.IEntity)2 Trigger (io.github.wysohn.triggerreactor.core.manager.trigger.Trigger)1 Entity (org.bukkit.entity.Entity)1 Entity (org.spongepowered.api.entity.Entity)1