Skip to content

Commit

Permalink
add world.has_region tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 6, 2019
1 parent 37adde0 commit 2368663
Showing 1 changed file with 14 additions and 2 deletions.
@@ -1,5 +1,6 @@
package com.denizenscript.depenizen.bukkit.properties.worldguard;

import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.properties.Property;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.depenizen.bukkit.objects.worldguard.WorldGuardRegionTag;
Expand Down Expand Up @@ -62,19 +63,30 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <WorldTag.list_regions>
// @returns ListTag(Region)
// @returns ListTag(WorldGuardRegionTag)
// @description
// Returns a list of WorldGuard regions in this world.
// @Plugin Depenizen, WorldGuard
// -->
if (attribute.startsWith("list_regions")) {
ListTag regions = new ListTag();
for (ProtectedRegion r : manager.getRegions().values()) {
regions.add(new WorldGuardRegionTag(r, world).identify());
regions.addObject(new WorldGuardRegionTag(r, world));
}
return regions.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <WorldTag.has_region[<name>]>
// @returns BooleanTag
// @description
// Returns whether a region exists in this world for the given name.
// @Plugin Depenizen, WorldGuard
// -->
if (attribute.startsWith("has_region") && attribute.hasContext(1)) {
return new ElementTag(manager.hasRegion(attribute.getContext(1))).getAttribute(attribute.fulfill(1));
}

return null;
}

Expand Down

0 comments on commit 2368663

Please sign in to comment.