Skip to content

Commit

Permalink
WorldGuardRegionTag.parent and .children
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 18, 2021
1 parent 16699c2 commit c002e59
Showing 1 changed file with 33 additions and 0 deletions.
Expand Up @@ -209,6 +209,39 @@ public String getAttribute(Attribute attribute) {
return new ElementTag(region.getId()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <WorldGuardRegionTag.parent>
// @returns WorldGuardRegionTag
// @plugin Depenizen, WorldGuard
// @description
// Gets the parent region of this region (if any).
// -->
if (attribute.startsWith("parent")) {
ProtectedRegion parent = region.getParent();
if (parent == null) {
return null;
}
return new WorldGuardRegionTag(parent, world).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <WorldGuardRegionTag.children>
// @returns ListTag(WorldGuardRegionTag)
// @plugin Depenizen, WorldGuard
// @description
// Gets a list of all children of this region.
// -->
if (attribute.startsWith("children")) {
ListTag children = new ListTag();
RegionManager manager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world));
for (ProtectedRegion child : manager.getRegions().values()) {
if (child.getParent() == region) {
children.addObject(new WorldGuardRegionTag(child, world));
}
}
return children.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <WorldGuardRegionTag.members>
// @returns ListTag(PlayerTag)
Expand Down

0 comments on commit c002e59

Please sign in to comment.