Search in sources :

Example 1 with Zone

use of com.playmonumenta.scriptedquests.zones.Zone in project monumenta-structure-management by TeamMonumenta.

the class RespawnManager method getStructures.

public List<RespawningStructure> getStructures(Vector loc, boolean includeNearby) {
    List<RespawningStructure> structures = new ArrayList<RespawningStructure>();
    ZoneFragment zoneFragment = mZoneManager.getZoneFragment(loc);
    if (zoneFragment == null) {
        return structures;
    }
    String layerName = includeNearby ? ZONE_LAYER_NAME_NEARBY : ZONE_LAYER_NAME_INSIDE;
    List<Zone> zones = zoneFragment.getParentAndEclipsed(layerName);
    for (Zone zone : zones) {
        RespawningStructure struct = mStructuresByZone.get(zone);
        if (struct == null) {
            continue;
        }
        structures.add(struct);
    }
    return structures;
}
Also used : ZoneFragment(com.playmonumenta.scriptedquests.zones.ZoneFragment) Zone(com.playmonumenta.scriptedquests.zones.Zone) ArrayList(java.util.ArrayList)

Example 2 with Zone

use of com.playmonumenta.scriptedquests.zones.Zone in project scripted-quests by TeamMonumenta.

the class PrerequisiteZoneProperties method prerequisiteMet.

@Override
public boolean prerequisiteMet(QuestContext context) {
    Location loc = context.getEntityUsedForPrerequisites().getLocation();
    ZoneFragment fragment = Plugin.getInstance().mZoneManager.getZoneFragment(loc);
    // If no fragment exists here, neither do zones or layers.
    if (fragment == null) {
        return mRequiredLayers.isEmpty();
    }
    for (String layerName : mMentionedLayers) {
        Zone zone = fragment.getParent(layerName);
        // If there is no zone on this layer...
        if (zone == null) {
            // ...check that the layer is not a prerequisite...
            if (mRequiredLayers.contains(layerName)) {
                return false;
            }
            // ...and continue if it is not.
            continue;
        }
        // The zone's properties.
        Set<String> properties = zone.getProperties();
        // If there are any property prerequisites, ensure all are found.
        Set<String> requiredProperties = mProperties.get(layerName);
        if (requiredProperties != null && !properties.containsAll(requiredProperties)) {
            return false;
        }
        // For any negated property prerequisites, ensure none are found.
        // disjoint returns true if no elements are in common.
        Set<String> requiredNotProperties = mNotProperties.get(layerName);
        if (requiredNotProperties != null && !Collections.disjoint(requiredNotProperties, properties)) {
            return false;
        }
    }
    return true;
}
Also used : ZoneFragment(com.playmonumenta.scriptedquests.zones.ZoneFragment) Zone(com.playmonumenta.scriptedquests.zones.Zone) Location(org.bukkit.Location)

Example 3 with Zone

use of com.playmonumenta.scriptedquests.zones.Zone in project monumenta-structure-management by TeamMonumenta.

the class RespawningStructure method registerZone.

public boolean registerZone() {
    ZoneLayer zoneLayerInside = mPlugin.mRespawnManager.mZoneLayerInside;
    ZoneLayer zoneLayerNearby = mPlugin.mRespawnManager.mZoneLayerNearby;
    Zone insideZone = new Zone(zoneLayerInside, mInnerBounds.mLowerCorner.clone(), mInnerBounds.mUpperCorner.clone(), mName, new LinkedHashSet<String>());
    Zone nearbyZone = new Zone(zoneLayerNearby, mOuterBounds.mLowerCorner.clone(), mOuterBounds.mUpperCorner.clone(), mName, new LinkedHashSet<String>());
    zoneLayerInside.addZone(insideZone);
    zoneLayerNearby.addZone(nearbyZone);
    mPlugin.mRespawnManager.registerRespawningStructureZone(insideZone, this);
    mPlugin.mRespawnManager.registerRespawningStructureZone(nearbyZone, this);
    return true;
}
Also used : ZoneLayer(com.playmonumenta.scriptedquests.zones.ZoneLayer) Zone(com.playmonumenta.scriptedquests.zones.Zone)

Aggregations

Zone (com.playmonumenta.scriptedquests.zones.Zone)3 ZoneFragment (com.playmonumenta.scriptedquests.zones.ZoneFragment)2 ZoneLayer (com.playmonumenta.scriptedquests.zones.ZoneLayer)1 ArrayList (java.util.ArrayList)1 Location (org.bukkit.Location)1