Java Code Examples for com.sk89q.worldguard.protection.managers.RegionManager#hasRegion()

The following examples show how to use com.sk89q.worldguard.protection.managers.RegionManager#hasRegion() . 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: RadiationCommandHandler.java    From CraftserveRadiation with Apache License 2.0 5 votes vote down vote up
private void flagGlobal(RegionManager regionManager, boolean value) {
    Objects.requireNonNull(regionManager, "regionMark");

    if (regionManager.hasRegion(GLOBAL_REGION_ID)) {
        ProtectedRegion existing = Objects.requireNonNull(regionManager.getRegion(GLOBAL_REGION_ID));
        this.flag(existing, value);
    } else {
        ProtectedRegion region = new GlobalProtectedRegion(GLOBAL_REGION_ID);
        this.flag(region, value);
        regionManager.addRegion(region);
    }
}
 
Example 2
Source File: WorldGuardHandler.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
private static boolean noOrOldRegion(RegionManager regionManager, String regionId, IslandInfo island) {
    if (!regionManager.hasRegion(regionId)) {
        return true;
    }
    if (regionManager.getRegion(regionId).getOwners().size() == 0) {
        return true;
    }
    return !island.getRegionVersion().equals(getVersion());
}
 
Example 3
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 4
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 5
Source File: RadiationCommandHandler.java    From CraftserveRadiation with Apache License 2.0 4 votes vote down vote up
private void define(RegionManager regionManager, ProtectedRegion region) {
    Objects.requireNonNull(regionManager, "regionManager");
    Objects.requireNonNull(region, "region");

    String id = region.getId();
    if (regionManager.hasRegion(id)) {
        ProtectedRegion existing = Objects.requireNonNull(regionManager.getRegion(id));
        region.copyFrom(existing);
    }

    this.flag(region, false);
    region.setFlag(Flags.PASSTHROUGH, StateFlag.State.ALLOW);
    regionManager.addRegion(region);
}