Search in sources :

Example 11 with SimpleChunkLocation

use of io.github.wysohn.triggerreactor.core.manager.location.SimpleChunkLocation in project TriggerReactor by wysohn.

the class AbstractAreaTriggerManager method deleteArea.

/**
 * Try to remove Area Trigger by given name
 * @param name
 * @return false if can't find any Area Trigger with the name; true if deleted.
 */
public boolean deleteArea(String name) {
    AreaTrigger trigger = nameMapper.get(name);
    if (trigger == null)
        return false;
    for (SimpleChunkLocation scloc : Area.getAllChunkLocations(trigger.area)) {
        Map<Area, AreaTrigger> map = areaTriggers.get(scloc);
        map.remove(trigger.area);
    }
    deleteInfo(trigger);
    nameMapper.remove(name);
    return true;
}
Also used : Area(io.github.wysohn.triggerreactor.core.manager.location.Area) SimpleChunkLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleChunkLocation)

Example 12 with SimpleChunkLocation

use of io.github.wysohn.triggerreactor.core.manager.location.SimpleChunkLocation in project TriggerReactor by wysohn.

the class AbstractAreaTriggerManager method deleteArea.

/**
 * Try to remove Area Trigger at given location.
 * @param location
 * @return false if no area found at location; true if deleted
 */
public boolean deleteArea(SimpleLocation sloc) {
    Entry<Area, AreaTrigger> areaEntry = getAreaForLocation(sloc);
    if (areaEntry == null)
        return false;
    AreaTrigger trigger = areaEntry.getValue();
    for (SimpleChunkLocation scloc : Area.getAllChunkLocations(areaEntry.getKey())) {
        Map<Area, AreaTrigger> map = areaTriggers.get(scloc);
        map.remove(areaEntry.getKey());
    }
    deleteInfo(nameMapper.remove(trigger.getTriggerName()));
    return true;
}
Also used : Area(io.github.wysohn.triggerreactor.core.manager.location.Area) SimpleChunkLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleChunkLocation)

Aggregations

SimpleChunkLocation (io.github.wysohn.triggerreactor.core.manager.location.SimpleChunkLocation)12 Area (io.github.wysohn.triggerreactor.core.manager.location.Area)6 SimpleLocation (io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation)5 File (java.io.File)3 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Trigger (io.github.wysohn.triggerreactor.core.manager.trigger.AbstractTriggerManager.Trigger)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Vector3i (com.flowpowered.math.vector.Vector3i)1 IInventory (io.github.wysohn.triggerreactor.core.bridge.IInventory)1 IItemStack (io.github.wysohn.triggerreactor.core.bridge.IItemStack)1 ILocation (io.github.wysohn.triggerreactor.core.bridge.ILocation)1 IPlayer (io.github.wysohn.triggerreactor.core.bridge.player.IPlayer)1 AbstractAreaSelectionManager (io.github.wysohn.triggerreactor.core.manager.AbstractAreaSelectionManager)1 AbstractExecutorManager (io.github.wysohn.triggerreactor.core.manager.AbstractExecutorManager)1 AbstractPermissionManager (io.github.wysohn.triggerreactor.core.manager.AbstractPermissionManager)1 AbstractPlaceholderManager (io.github.wysohn.triggerreactor.core.manager.AbstractPlaceholderManager)1 AbstractPlayerLocationManager (io.github.wysohn.triggerreactor.core.manager.AbstractPlayerLocationManager)1