本文整理匯總了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();
}