com.sk89q.worldguard.protection.regions.ProtectedRegion Java Examples

The following examples show how to use com.sk89q.worldguard.protection.regions.ProtectedRegion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldGuardHandler.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
public static ProtectedRegion getNetherRegionAt(Location location) {
    if (!Settings.nether_enabled || location == null) {
        return null;
    }
    RegionManager regionManager = getRegionManager(location.getWorld());
    if (regionManager == null) {
        return null;
    }
    Iterable<ProtectedRegion> applicableRegions = regionManager.getApplicableRegions(toVector(location));
    for (ProtectedRegion region : applicableRegions) {
        String id = region.getId().toLowerCase();
        if (!id.equalsIgnoreCase("__global__") && id.endsWith("nether")) {
            return region;
        }
    }
    return null;
}
 
Example #2
Source File: WorldGuardHook.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("null")
@Override
public Collection<? extends Region> getRegionsAt_i(@Nullable final Location l) {
	final ArrayList<Region> r = new ArrayList<>();
	
	if (l == null) // Working around possible cause of issue #280
		return Collections.emptyList();
	if (l.getWorld() == null)
		return Collections.emptyList();
	
	WorldGuardPlatform platform = WorldGuard.getInstance().getPlatform();
	RegionManager manager = platform.getRegionContainer().get(BukkitAdapter.adapt(l.getWorld()));
	if (manager == null)
		return r;
	ApplicableRegionSet applicable = manager.getApplicableRegions(BukkitAdapter.asBlockVector(l));
	if (applicable == null)
		return r;
	for (ProtectedRegion region : applicable)
		r.add(new WorldGuardRegion(l.getWorld(), region));
	return r;
}
 
Example #3
Source File: WorldGuardUtils.java    From WorldGuardExtraFlagsPlugin with MIT License 6 votes vote down vote up
public static <T> FlagValueCalculator createFlagValueCalculator(Player player, World world, Set<ProtectedRegion> regions, Flag<T> flag)
{
	List<ProtectedRegion> checkForRegions = new ArrayList<>();
	for(ProtectedRegion region : regions)
	{
		if (!WorldGuardUtils.hasBypass(player, world, region, flag))
		{
			checkForRegions.add(region);
		}
	}
	
	NormativeOrders.sort(checkForRegions);
	
	ProtectedRegion global = WorldGuardUtils.getCommunicator().getRegionContainer().get(world).getRegion(ProtectedRegion.GLOBAL_REGION);
	if (global != null) //Global region can be null
	{
		if (WorldGuardUtils.hasBypass(player, world, global, flag)) //Lets do like this for now to reduce dublicated code
		{
			global = null;
		}
	}
	
	return new FlagValueCalculator(checkForRegions, global);
}
 
Example #4
Source File: WorldGuardFilter.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void calculateRegions() {
    TaskManager.IMP.sync(new RunnableVal<Object>() {
        @Override
        public void run(Object value) {
            WorldGuardFilter.this.manager = WorldGuardPlugin.inst().getRegionManager(world);
            for (ProtectedRegion region : manager.getRegions().values()) {
                BlockVector min = region.getMinimumPoint();
                BlockVector max = region.getMaximumPoint();
                if (max.getBlockX() - min.getBlockX() > 1024 || max.getBlockZ() - min.getBlockZ() > 1024) {
                    Fawe.debug("Large or complex region shapes cannot be optimized. Filtering will be slower");
                    large = true;
                    break;
                }
                add(min.toVector2D(), max.toVector2D());
            }
        }
    });
}
 
Example #5
Source File: LimitLogic.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
public Map<CreatureType, Integer> getCreatureCount(us.talabrek.ultimateskyblock.api.IslandInfo islandInfo) {
    Map<CreatureType, Integer> mapCount = new HashMap<>();
    for (CreatureType type : CreatureType.values()) {
        mapCount.put(type, 0);
    }
    Location islandLocation = islandInfo.getIslandLocation();
    ProtectedRegion islandRegionAt = WorldGuardHandler.getIslandRegionAt(islandLocation);
    if (islandRegionAt != null) {
        // Nether and Overworld regions are more or less equal (same x,z coords)
        List<LivingEntity> creatures = WorldGuardHandler.getCreaturesInRegion(plugin.getWorldManager().getWorld(),
                islandRegionAt);
        World nether = plugin.getWorldManager().getNetherWorld();
        if (nether != null) {
            creatures.addAll(WorldGuardHandler.getCreaturesInRegion(nether, islandRegionAt));
        }
        for (LivingEntity creature : creatures) {
            CreatureType key = getCreatureType(creature);
            if (!mapCount.containsKey(key)) {
                mapCount.put(key, 0);
            }
            mapCount.put(key, mapCount.get(key) + 1);
        }
    }
    return mapCount;
}
 
Example #6
Source File: WorldGuard7FAWEHook.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("null")
@Override
public Collection<? extends Region> getRegionsAt_i(@Nullable final Location l) {
    final ArrayList<Region> r = new ArrayList<>();
    
    if (l == null) // Working around possible cause of issue #280
        return Collections.emptyList();
    if (l.getWorld() == null)
        return Collections.emptyList();
    RegionQuery query = WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery();
    if (query == null)
        return r;
    ApplicableRegionSet applicable = query.getApplicableRegions(BukkitAdapter.adapt(l));
    if (applicable == null)
        return r;
    final Iterator<ProtectedRegion> i = applicable.iterator();
    while (i.hasNext())
        r.add(new WorldGuardRegion(l.getWorld(), i.next()));
    return r;
}
 
Example #7
Source File: NPCRegionCondition.java    From BetonQuest with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Boolean execute(String playerID) throws QuestRuntimeException {
    NPC npc = CitizensAPI.getNPCRegistry().getById(ID);
    if (npc == null) {
        throw new QuestRuntimeException("NPC with ID " + ID + " does not exist");
    }
    Entity npcEntity = npc.getEntity();
    if (npcEntity == null) return false;

    Player player = PlayerConverter.getPlayer(playerID);
    WorldGuardPlatform worldguardPlatform = WorldGuard.getInstance().getPlatform();
    RegionManager manager = worldguardPlatform.getRegionContainer().get(BukkitAdapter.adapt(player.getWorld()));
    if (manager == null) {
        return false;
    }
    ApplicableRegionSet set = manager.getApplicableRegions(BlockVector3.at(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));

    for (ProtectedRegion compare : set) {
        if (compare.equals(region))
            return true;
    }
    return false;
}
 
Example #8
Source File: GeneralRegion.java    From AreaShop with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Save all blocks in a region for restoring later.
 * @param fileName The name of the file to save to (extension and folder will be added)
 * @return true if the region has been saved properly, otherwise false
 */
public boolean saveRegionBlocks(String fileName) {
	// Check if the region is correct
	ProtectedRegion region = getRegion();
	if(region == null) {
		AreaShop.debug("Region '" + getName() + "' does not exist in WorldGuard, save failed");
		return false;
	}
	// The path to save the schematic
	File saveFile = new File(plugin.getFileManager().getSchematicFolder() + File.separator + fileName);
	// Create parent directories
	File parent = saveFile.getParentFile();
	if(parent != null && !parent.exists()) {
		if(!parent.mkdirs()) {
			AreaShop.warn("Did not save region " + getName() + ", schematic directory could not be created: " + saveFile.getAbsolutePath());
			return false;
		}
	}
	boolean result = plugin.getWorldEditHandler().saveRegionBlocks(saveFile, this);
	if(result) {
		AreaShop.debug("Saved schematic for region " + getName());
	}
	return true;
}
 
Example #9
Source File: WorldGuardHandler.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
public static boolean isIslandIntersectingSpawn(Location islandLocation) {
    log.entering(CN, "isIslandIntersectingSpawn", islandLocation);
    try {
        int r = Settings.general_spawnSize;
        if (r == 0) {
            return false;
        }
        ProtectedRegion spawn = new ProtectedCuboidRegion("spawn", BlockVector3.at(-r, 0, -r), BlockVector3.at(r, 255, r));
        ProtectedCuboidRegion islandRegion = getIslandRegion(islandLocation);
        return !islandRegion.getIntersectingRegions(Collections.singletonList(spawn)).isEmpty();
    } catch (Exception e) {
        log.log(Level.SEVERE, "Unable to locate intersecting regions", e);
        return false;
    } finally {
        log.exiting(CN, "isIslandIntersectingSpawn");
    }
}
 
Example #10
Source File: AddCommand.java    From AreaShop with GNU General Public License v3.0 6 votes vote down vote up
@Override
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
	List<String> result = new ArrayList<>();
	if(toComplete == 2) {
		if(sender.hasPermission("areashop.createrent")) {
			result.add("rent");
		}
		if(sender.hasPermission("areashop.createbuy")) {
			result.add("buy");
		}
	} else if(toComplete == 3) {
		if(sender instanceof Player) {
			Player player = (Player)sender;
			if(sender.hasPermission("areashop.createrent") || sender.hasPermission("areashop.createbuy")) {
				for(ProtectedRegion region : plugin.getRegionManager(player.getWorld()).getRegions().values()) {
					result.add(region.getId());
				}
			}
		}
	}
	return result;
}
 
Example #11
Source File: WorldGuardSevenCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License 6 votes vote down vote up
@Override
public boolean doUnloadChunkFlagCheck(org.bukkit.World world, Chunk chunk) 
{
	for (ProtectedRegion region : this.getRegionContainer().get(world).getApplicableRegions(new ProtectedCuboidRegion("UnloadChunkFlagTester", BlockVector3.at(chunk.getX() * 16, 0, chunk.getZ() * 16), BlockVector3.at(chunk.getX() * 16 + 15, 256, chunk.getZ() * 16 + 15))))
	{
		if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY)
		{
			if (WorldGuardSevenCommunicator.supportsForceLoad)
			{
				chunk.setForceLoaded(true);
				chunk.load(true);
				
				return true;
			}
			
			return false;
		}
	}
	
	return true;
}
 
Example #12
Source File: HandlerWrapper.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
@Override
public boolean onCrossBoundary(LocalPlayer localPlayer, com.sk89q.worldedit.util.Location from, com.sk89q.worldedit.util.Location to, ApplicableRegionSet toSet, Set<ProtectedRegion> entered, Set<ProtectedRegion> exited, MoveType moveType)
{
	//It turns out that this is fired every time player moves
	//The plugin flags assume already that nothing changes unless region is crossed, so ignore when there isn't a region change
	//This optimization is already in place in the FVCH
	if (entered.isEmpty() && exited.isEmpty() && from.getExtent().equals(to.getExtent()))
	{
           return true;
       }
	
	return this.onCrossBoundary(((BukkitPlayer)localPlayer).getPlayer(), BukkitAdapter.adapt(from), BukkitAdapter.adapt(to), toSet, entered, exited, moveType);
}
 
Example #13
Source File: WorldGuardHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static ProtectedRegion getIslandRegionAt(Location location) {
    RegionManager regionManager = getRegionManager(location.getWorld());
    if (regionManager == null) {
        return null;
    }
    Iterable<ProtectedRegion> applicableRegions = regionManager.getApplicableRegions(toVector(location));
    for (ProtectedRegion region : applicableRegions) {
        String id = region.getId().toLowerCase();
        if (!id.equalsIgnoreCase("__global__") && (id.endsWith("island") || id.endsWith("nether"))) {
            return region;
        }
    }
    return null;
}
 
Example #14
Source File: WorldGuardHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static String getIslandNameAt(Location location) {
    RegionManager regionManager = getRegionManager(location.getWorld());
    Iterable<ProtectedRegion> applicableRegions = regionManager.getApplicableRegions(toVector(location));
    for (ProtectedRegion region : applicableRegions) {
        String id = region.getId().toLowerCase();
        if (!id.equalsIgnoreCase("__global__") && (id.endsWith("island") || id.endsWith("nether"))) {
            return id.substring(0, id.length() - 6);
        }
    }
    return null;
}
 
Example #15
Source File: WorldEditHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static void clearIsland(@NotNull final World islandWorld, @NotNull final ProtectedRegion region,
                               @Nullable final Runnable afterDeletion) {
    Validate.notNull(islandWorld, "IslandWorld cannot be null");
    Validate.notNull(region, "Region cannot be null");

    log.finer("Clearing island " + region);
    uSkyBlock plugin = uSkyBlock.getInstance();
    final long t = System.currentTimeMillis();
    final Region cube = getRegion(islandWorld, region);
    Runnable onCompletion = () -> {
        long diff = System.currentTimeMillis() - t;
        LogUtil.log(Level.INFO, String.format("Cleared island on %s in %d.%03d seconds",
                islandWorld.getName(), (diff / 1000), (diff % 1000)));
        if (afterDeletion != null) {
            afterDeletion.run();
        }
    };
    Set<BlockVector2> innerChunks;
    Set<Region> borderRegions = new HashSet<>();
    if (isOuterPossible()) {
        if (Settings.island_protectionRange == Settings.island_distance) {
            innerChunks = getInnerChunks(cube);
        } else {
            innerChunks = getOuterChunks(cube);
        }
    } else {
        innerChunks = getInnerChunks(cube);
        borderRegions = getBorderRegions(cube);
    }
    List<Chunk> chunkList = new ArrayList<>();
    for (BlockVector2 vector : innerChunks) {
        chunkList.add(islandWorld.getChunkAt(vector.getBlockX(), vector.getBlockZ()));
    }
    WorldEditClear weClear = new WorldEditClear(plugin, islandWorld, borderRegions, onCompletion);
    plugin.getWorldManager().getChunkRegenerator(islandWorld).regenerateChunks(chunkList, weClear);
}
 
Example #16
Source File: WorldGuardHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static void islandLock(final CommandSender sender, final String islandName) {
    try {
        RegionManager regionManager = getRegionManager(uSkyBlock.getInstance().getWorldManager().getWorld());
        if (regionManager.hasRegion(islandName + "island")) {
            ProtectedRegion region = regionManager.getRegion(islandName + "island");
            updateLockStatus(region, true);
            sender.sendMessage(tr("\u00a7eYour island is now locked. Only your party members may enter."));
        } else {
            sender.sendMessage(tr("\u00a74You must be the party leader to lock your island!"));
        }
    } catch (Exception ex) {
        LogUtil.log(Level.SEVERE, "ERROR: Failed to lock " + islandName + "'s Island (" + sender.getName() + ")", ex);
    }
}
 
Example #17
Source File: WorldEditHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static void unloadRegion(Location location) {
    ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(location);
    World world = location.getWorld();
    Region cube = getRegion(world, region);
    for (BlockVector2 chunk : cube.getChunks()) {
        world.unloadChunk(chunk.getBlockX(), chunk.getBlockZ(), true);
    }
}
 
Example #18
Source File: WorldEditHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static void loadRegion(Location location) {
    ProtectedRegion region = WorldGuardHandler.getIslandRegionAt(location);
    World world = location.getWorld();
    Region cube = getRegion(world, region);
    for (BlockVector2 chunk : cube.getChunks()) {
        world.unloadChunk(chunk.getBlockX(), chunk.getBlockZ(), true);
        world.loadChunk(chunk.getBlockX(), chunk.getBlockZ(), false);
    }
}
 
Example #19
Source File: WorldGuardHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
public static void islandUnlock(final CommandSender sender, final String islandName) {
    try {
        RegionManager regionManager = getRegionManager(uSkyBlock.getInstance().getWorldManager().getWorld());
        if (regionManager.hasRegion(islandName + "island")) {
            ProtectedRegion region = regionManager.getRegion(islandName + "island");
            updateLockStatus(region, false);
            sender.sendMessage(tr("\u00a7eYour island is unlocked and anyone may enter, however only you and your party members may build or remove blocks."));
        } else {
            sender.sendMessage(tr("\u00a74You must be the party leader to unlock your island!"));
        }
    } catch (Exception ex) {
        LogUtil.log(Level.SEVERE, "ERROR: Failed to unlock " + islandName + "'s Island (" + sender.getName() + ")", ex);
    }
}
 
Example #20
Source File: WorldGuardHandler7_beta_2.java    From AreaShop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setMembers(ProtectedRegion region, RegionAccessSet regionAccessSet) {
	DefaultDomain defaultDomain = buildDomain(regionAccessSet);
	if(!region.getMembers().toUserFriendlyString().equals(defaultDomain.toUserFriendlyString())) {
		region.setMembers(defaultDomain);
	}
}
 
Example #21
Source File: WorldGuardHelper112.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Location getMaximumPoint(ProtectedRegion region, World world) {
    return new Location(
            world,
            region.getMaximumPoint().getX(),
            region.getMaximumPoint().getY(),
            region.getMaximumPoint().getZ()
    );
}
 
Example #22
Source File: WorldGuardHelper112.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Location getMinimumPoint(ProtectedRegion region, World world) {
    return new Location(
            world,
            region.getMinimumPoint().getX(),
            region.getMinimumPoint().getY(),
            region.getMinimumPoint().getZ()
    );
}
 
Example #23
Source File: WorldGuardSixCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
@Override
public boolean doUnloadChunkFlagCheck(org.bukkit.World world, Chunk chunk) 
{
	for (ProtectedRegion region : this.getRegionContainer().get(world).getApplicableRegions(new ProtectedCuboidRegion("UnloadChunkFlagTester", new BlockVector(chunk.getX() * 16, 0, chunk.getZ() * 16), new BlockVector(chunk.getX() * 16 + 15, 256, chunk.getZ() * 16 + 15))))
	{
		if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY)
		{
			return false;
		}
	}
	
	return true;
}
 
Example #24
Source File: WorldGuardSevenCommunicator.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
@Override
public void doUnloadChunkFlagCheck(org.bukkit.World world)
{
	for (ProtectedRegion region : this.getRegionContainer().get(world).getRegions().values())
	{
		if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY)
		{
			System.out.println("Loading chunks for region " + region.getId() + " located in " + world.getName() + " due to chunk-unload flag being deny");
			
			BlockVector3 min = region.getMinimumPoint();
			BlockVector3 max = region.getMaximumPoint();

			for(int x = min.getBlockX() >> 4; x <= max.getBlockX() >> 4; x++)
			{
				for(int z = min.getBlockZ() >> 4; z <= max.getBlockZ() >> 4; z++)
				{
					world.getChunkAt(x, z).load(true);
					
					if (WorldGuardSevenCommunicator.supportsForceLoad)
					{
						world.getChunkAt(x, z).setForceLoaded(true);
					}
				}
			}
		}
	}
}
 
Example #25
Source File: WorldGuardHandler7_beta_1.java    From AreaShop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<org.bukkit.util.Vector> getRegionPoints(ProtectedRegion region) {
	List<org.bukkit.util.Vector> result = new ArrayList<>();
	for (BlockVector2D point : region.getPoints()) {
		result.add(new org.bukkit.util.Vector(point.getX(), 0,point.getZ()));
	}
	return result;
}
 
Example #26
Source File: WorldGuardHandler7_beta_2.java    From AreaShop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public RegionAccessSet getMembers(ProtectedRegion region) {
	RegionAccessSet result = new RegionAccessSet();
	result.getGroupNames().addAll(region.getMembers().getGroups());
	result.getPlayerNames().addAll(region.getMembers().getPlayers());
	result.getPlayerUniqueIds().addAll(region.getMembers().getUniqueIds());
	return result;
}
 
Example #27
Source File: Worldguard.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
private static Region adapt(ProtectedRegion region) {
    if (region instanceof ProtectedCuboidRegion) {
        return new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint());
    }
    if (region instanceof GlobalProtectedRegion) {
        return RegionWrapper.GLOBAL();
    }
    if (region instanceof ProtectedPolygonalRegion) {
        ProtectedPolygonalRegion casted = (ProtectedPolygonalRegion) region;
        BlockVector max = region.getMaximumPoint();
        BlockVector min = region.getMinimumPoint();
        return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY());
    }
    return new AdaptedRegion(region);
}
 
Example #28
Source File: WorldGuardHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
private static Set<ProtectedRegion> getRegions(ApplicableRegionSet set) {
    Set<ProtectedRegion> regions = new HashSet<>();
    for (ProtectedRegion region : set) {
        regions.add(region);
    }
    return regions;
}
 
Example #29
Source File: FastAsyncWorldEditWorldGuardHandler.java    From AreaShop with GNU General Public License v3.0 5 votes vote down vote up
@Override
public RegionAccessSet getOwners(ProtectedRegion region) {
	RegionAccessSet result = new RegionAccessSet();
	result.getGroupNames().addAll(region.getOwners().getGroups());
	result.getPlayerNames().addAll(region.getOwners().getPlayers());
	result.getPlayerUniqueIds().addAll(region.getOwners().getUniqueIds());
	return result;
}
 
Example #30
Source File: WorldUtil.java    From SonarPet with GNU General Public License v3.0 5 votes vote down vote up
public static boolean allowRegion(Location location) {
    if (EchoPet.getPlugin().getWorldGuardProvider().isHooked()) {
        WorldGuardPlugin wg = EchoPet.getPlugin().getWorldGuardProvider().getDependency();
        if (wg == null) {
            return true;
        }
        RegionManager regionManager = wg.getRegionManager(location.getWorld());

        if (regionManager == null) {
            return true;
        }

        ApplicableRegionSet set = regionManager.getApplicableRegions(location);

        if (set.size() <= 0) {
            return true;
        }

        boolean result = true;
        boolean hasSet = false;
        boolean def = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions.allowByDefault", true);

        ConfigurationSection cs = EchoPet.getPlugin().getMainConfig().getConfigurationSection("worldguard.regions");
        for (ProtectedRegion region : set) {
            for (String key : cs.getKeys(false)) {
                if (!key.equalsIgnoreCase("allowByDefault") && !key.equalsIgnoreCase("regionEnterCheck")) {
                    if (region.getId().equals(key)) {
                        if (!hasSet) {
                            result = EchoPet.getPlugin().getMainConfig().getBoolean("worldguard.regions." + key, true);
                            hasSet = true;
                        }
                    }
                }
            }
        }

        return hasSet ? result : def;
    }
    return true;
}