本文整理汇总了Java中com.sk89q.worldguard.protection.regions.ProtectedRegion.getParent方法的典型用法代码示例。如果您正苦于以下问题:Java ProtectedRegion.getParent方法的具体用法?Java ProtectedRegion.getParent怎么用?Java ProtectedRegion.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldguard.protection.regions.ProtectedRegion
的用法示例。
在下文中一共展示了ProtectedRegion.getParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImportantWorldEditRegions
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
/**
* Get a list of regions around a location.
* - Returns highest priority, child instead of parent regions
* @param location The location to check for regions
* @return empty list if no regions found, 1 member if 1 region is a priority, more if regions with the same priority
*/
public static List<ProtectedRegion> getImportantWorldEditRegions(Location location) {
List<ProtectedRegion> result = new ArrayList<>();
Set<ProtectedRegion> regions = AreaShop.getInstance().getWorldGuardHandler().getApplicableRegionsSet(location);
if(regions != null) {
boolean first = true;
for(ProtectedRegion pr : regions) {
if(first) {
result.add(pr);
first = false;
} else {
if(pr.getPriority() > result.get(0).getPriority()) {
result.clear();
result.add(pr);
} else if(pr.getParent() != null && pr.getParent().equals(result.get(0))) {
result.clear();
result.add(pr);
} else {
result.add(pr);
}
}
}
}
return result;
}
示例2: extractParent
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
private static String extractParent(ProtectedRegion region) {
ProtectedRegion parent = region.getParent();
return parent != null ? parent.getId() : null;
}
示例3: encode
import com.sk89q.worldguard.protection.regions.ProtectedRegion; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void encode(BsonWriter writer, ProcessingProtectedRegion value, EncoderContext encoderContext) {
ProtectedRegion region = value.getRegion();
int priority = region.getPriority();
Map<Flag<?>, Object> flags = region.getFlags();
ProtectedRegion parent = region.getParent();
writer.writeStartDocument();
writer.writeString("name", region.getId());
writer.writeString("world", value.getWorld());
if (parent != null)
writer.writeString("parent", parent.getId());
if (priority != 0)
writer.writeInt32("priority", priority);
writer.writeString("type", region.getType().name());
if (region instanceof ProtectedCuboidRegion) {
Codec<BlockVector> blockVectorCodec = registry.get(BlockVector.class);
writer.writeName("min");
blockVectorCodec.encode(writer, region.getMinimumPoint(), encoderContext);
writer.writeName("max");
blockVectorCodec.encode(writer, region.getMaximumPoint(), encoderContext);
} else if (region instanceof ProtectedPolygonalRegion) {
Codec<BlockVector2D> blockVector2DCodec = registry.get(BlockVector2D.class);
writer.writeStartArray("points");
for (BlockVector2D point : region.getPoints())
blockVector2DCodec.encode(writer, point, encoderContext);
writer.writeEndArray();
writer.writeInt32("min_y", region.getMinimumPoint().getBlockY());
writer.writeInt32("max_y", region.getMaximumPoint().getBlockY());
}
if (!flags.isEmpty()) {
writer.writeName("flags");
registry.get(Document.class).encode(writer, toMapValues(flags), encoderContext);
}
Codec<DefaultDomain> defaultDomainCodec = registry.get(DefaultDomain.class);
writer.writeName("owners");
defaultDomainCodec.encode(writer, region.getOwners(), encoderContext);
writer.writeName("members");
defaultDomainCodec.encode(writer, region.getMembers(), encoderContext);
writer.writeEndDocument();
}