本文整理匯總了Java中com.sk89q.worldguard.protection.ApplicableRegionSet.size方法的典型用法代碼示例。如果您正苦於以下問題:Java ApplicableRegionSet.size方法的具體用法?Java ApplicableRegionSet.size怎麽用?Java ApplicableRegionSet.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sk89q.worldguard.protection.ApplicableRegionSet
的用法示例。
在下文中一共展示了ApplicableRegionSet.size方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: queryRegions
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
private Set<String> queryRegions(Location location) {
RegionContainer container = worldGuard.getRegionContainer();
RegionQuery query = container.createQuery();
ApplicableRegionSet set = query.getApplicableRegions(location);
if (set.size() == 0) {
return Collections.emptySet();
}
final Set<String> regions = new HashSet<>();
for (ProtectedRegion r : set.getRegions()) {
regions.add(r.getId().toLowerCase());
}
return regions;
}
示例2: getRegions
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
Optional<RegionSet> getRegions(final Location loc) {
CraftoMessenger.debug(WorldGuardHandler.class, "getRegions(loc)", "Called! (" + (this.plugin) + ")");
if (!this.plugin.isPresent()) { return Optional.empty(); }
final ApplicableRegionSet applicableRegionSet = this.plugin.get().getRegionManager(loc.getWorld()).getApplicableRegions(loc);
CraftoMessenger.debug(WorldGuardHandler.class, "getRegions(loc)", "Got ApplicableRegionSet: " + applicableRegionSet + " (" + applicableRegionSet.size() + ")");
if (applicableRegionSet != null && applicableRegionSet.size() > 0) {
RegionSet regionSet = this.regionSets.get(applicableRegionSet);
if (regionSet == null) {
regionSet = new RegionSet(this, loc.getWorld(), applicableRegionSet);
this.regionSets.put(applicableRegionSet, regionSet);
}
CraftoMessenger.debug(WorldGuardHandler.class, "getRegions(loc)", "Returning RegionSet: " + regionSet + " (" + regionSet.getRegions().size() + ")");
return Optional.of(regionSet);
}
return Optional.empty();
}
示例3: GetRegionNamesAtPoint
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
/**
* Get the regions at the players' location
*
* @param player The player you wish to get the ApplicableRegions from
* @returns A list of strings with the names of the applicable regions. This is null if there are no regions where the player is.
*
*/
public ArrayList<String> GetRegionNamesAtPoint(Player player) throws WorldGuardAPIException {
if (_wgPlugin == null) {
throw new WorldGuardAPIException(WorldGuardExceptions.NotEnabled);
}
//This "wrapping" is required for WorldGuard APIs
LocalPlayer lplayer = _wgPlugin.wrapPlayer(player);
//We require a WE vector rather than a location.
Vector pt = lplayer.getPosition();
//Get the region manager for the world we are currently in.
RegionManager rm = _wgPlugin.getRegionManager(player.getWorld());
//This is the set of regions we are in.
ApplicableRegionSet set = rm.getApplicableRegions(pt);
//Just return null if we get nothing.
if (set.size() == 0) {
return null;
}
//Put the region names in a list.
ArrayList<String> regions = new ArrayList<String>();
//For each Region in the set, just add the string with the region name to the return variable.
for (ProtectedRegion region : set) {
regions.add(region.getId());
}
//Return the list
return regions;
}
示例4: allowRegion
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
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;
}
示例5: containsChunk
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
@Override
public boolean containsChunk(int chunkX, int chunkZ) {
if (!large) return super.containsChunk(chunkX, chunkZ);
BlockVector pos1 = new BlockVector(chunkX << 4, 0, chunkZ << 4);
BlockVector pos2 = new BlockVector(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15);
ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
ApplicableRegionSet set = manager.getApplicableRegions(chunkRegion);
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
}
示例6: containsRegion
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
@Override
public boolean containsRegion(int mcaX, int mcaZ) {
if (!large) return super.containsRegion(mcaX, mcaZ);
BlockVector pos1 = new BlockVector(mcaX << 9, 0, mcaZ << 9);
BlockVector pos2 = new BlockVector(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511);
ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2);
ApplicableRegionSet set = manager.getApplicableRegions(regionRegion);
return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__");
}
示例7: BlockInProtectedLand
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
@Override
public boolean BlockInProtectedLand(Block block) {
ApplicableRegionSet regions = getWorldGuard().getRegionManager(block.getWorld()).getApplicableRegions(block.getLocation());
if (regions.size() > 0)
for (ProtectedRegion region : regions ){
if (!region.getId().equalsIgnoreCase("__global__"))
return true;
}
return false;
}
示例8: RegionSet
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
RegionSet(final WorldGuardHandler handler, final World world, final ApplicableRegionSet set) {
this.set = set;
this.world = world;
if (set.size() > 0) { this.regions = new SortedList<>((f, s) -> f.getPriority() > s.getPriority() ? 1 : -1); }
else { this.regions = new SortedList<>(0); }
for (final ProtectedRegion protectedRegion : this.set.getRegions()) {
final Optional<Region> region = handler.getRegion(world, protectedRegion.getId());
if (region.isPresent()) { this.regions.add(region.get()); }
else { CraftoMessenger.warnStaff("Failed to find region " + protectedRegion.getId() + " that was included in a regionset!"); }
}
}
示例9: allowRegion
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
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;
}
示例10: WorldguardCheck
import com.sk89q.worldguard.protection.ApplicableRegionSet; //導入方法依賴的package包/類
/**
* Checks if the player is in, or near the specified WorldGuard regions.
* @param l The location to check.
* @return True or False, Is the location in one of these regions.
*/
public boolean WorldguardCheck(final Location l) {
//Checks if plugin is installed.
if (Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") != null) {
//Checks if WorldGuard is enabled
if (RandomCoords.getPlugin().config.getString("WorldGuard").equals("true")) {
final int X = l.getBlockX();
// int Y = l.getBlockY();
final int Z = l.getBlockZ();
//Calls the BufferZone
final int r = RandomCoords.getPlugin().config.getInt("CheckingRadius");
//Checks all coordinates within the buffer zone for a region
//See if allRegions is enabled.
if (RandomCoords.getPlugin().config.getStringList("Regions").contains("allRegions")) {
return RandomCoords.getPlugin().getWorldGuard().getRegionManager(l.getWorld()).getApplicableRegions(l).size() == 0;
} else {
RegionContainer container = RandomCoords.getPlugin().getWorldGuard().getRegionContainer();
RegionManager regions = container.get(l.getWorld());
int cub = RandomCoords.getPlugin().config.getInt("CheckingRadius");
BlockVector p1 = new BlockVector(l.getX() + cub, 0.0D, l.getZ() + cub);
BlockVector p2 = new BlockVector(l.getX() - cub, 256.0D, l.getZ() - cub);
ProtectedRegion cuboid = new ProtectedCuboidRegion("RandomCoordsREGION-DO-NOT-USE", p1, p2);
ProtectedRegion regionRadius = cuboid;
ApplicableRegionSet set = regions.getApplicableRegions(regionRadius);
if(set.size() == 0 ) {
return true;
}
List<String> regionsToCheck = new ArrayList<>();
for(String name : RandomCoords.getPlugin().config.getStringList("Regions")) {
if (set.getRegions().contains(regions.getRegion(name))) {
regionsToCheck.add(name);
}
}
return regionsToCheck == null || regionsToCheck.size() == 0;
}
}
return true;
} else {
return true;
}
}