当前位置: 首页>>代码示例>>Java>>正文


Java ProtectedRegion.getParent方法代码示例

本文整理汇总了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;
}
 
开发者ID:NLthijs48,项目名称:AreaShop,代码行数:31,代码来源:Utils.java

示例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;
}
 
开发者ID:maxikg,项目名称:mongowg,代码行数:5,代码来源:ProcessingProtectedRegion.java

示例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();
}
 
开发者ID:maxikg,项目名称:mongowg,代码行数:45,代码来源:ProcessingProtectedRegionCodec.java


注:本文中的com.sk89q.worldguard.protection.regions.ProtectedRegion.getParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。