mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-18 08:35:53 +01:00
More stuff works.
This commit is contained in:
parent
ede4873c6a
commit
d1cab0da7f
@ -33,7 +33,7 @@ public BukkitBlacklist(Boolean useAsWhitelist, WorldGuardPlugin plugin) {
|
||||
@Override
|
||||
public void broadcastNotification(String msg) {
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (plugin.hasPermission(player, "notify")) {
|
||||
if (plugin.hasPermission(player, "worldguard.notify")) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public void load() {
|
||||
|
||||
// Load configurations for each world
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
forWorld(world.getName());
|
||||
get(world);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,10 +87,11 @@ public void unload() {
|
||||
/**
|
||||
* Get the configuration for a world.
|
||||
*
|
||||
* @param worldName
|
||||
* @param world
|
||||
* @return
|
||||
*/
|
||||
public WorldConfiguration forWorld(String worldName) {
|
||||
public WorldConfiguration get(World world) {
|
||||
String worldName = world.getName();
|
||||
WorldConfiguration config = worlds.get(worldName);
|
||||
|
||||
if (config == null) {
|
||||
|
@ -84,9 +84,7 @@ public static void migrateRegions(WorldGuardPlugin plugin) {
|
||||
+ "and set as your primarily world's database.");
|
||||
|
||||
World w = plugin.getServer().getWorlds().get(0);
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager()
|
||||
.get(w.getName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(w);
|
||||
|
||||
// First load up the old database using the CSV loader
|
||||
CSVDatabase db = new CSVDatabase(oldDatabase);
|
||||
|
@ -68,11 +68,17 @@ public void registerEvents() {
|
||||
pm.registerEvent(Event.Type.BLOCK_BURN, this, Priority.High, plugin);
|
||||
pm.registerEvent(Event.Type.REDSTONE_CHANGE, this, Priority.High, plugin);
|
||||
}
|
||||
|
||||
|
||||
protected WorldConfiguration getWorldConfig(World world) {
|
||||
return plugin.getGlobalConfiguration().get(world);
|
||||
}
|
||||
|
||||
protected WorldConfiguration getWorldConfig(Player player) {
|
||||
return plugin.getGlobalConfiguration().get(player.getWorld());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is damaged (or broken)
|
||||
*
|
||||
* @param event Relevant event details
|
||||
* Called when a block is damaged.
|
||||
*/
|
||||
@Override
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
@ -83,13 +89,11 @@ public void onBlockDamage(BlockDamageEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block blockDamaged = event.getBlock();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(player.getWorld().getName());
|
||||
|
||||
if (wcfg.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) {
|
||||
if (!plugin.canBuild(player, blockDamaged.getLocation())) {
|
||||
// Cake are damaged and not broken when they are eaten, so we must
|
||||
// handle them a bit separately
|
||||
if (blockDamaged.getType() == Material.CAKE_BLOCK) {
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, blockDamaged)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!");
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -97,11 +101,9 @@ public void onBlockDamage(BlockDamageEvent event) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when a block is destroyed by a player.
|
||||
*
|
||||
* @param event Relevant event details
|
||||
* Called when a block is broken.
|
||||
*/
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
@ -110,8 +112,7 @@ public void onBlockBreak(BlockBreakEvent event) {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(player.getWorld().getName());
|
||||
WorldConfiguration wcfg = getWorldConfig(player);
|
||||
|
||||
if (!wcfg.itemDurability) {
|
||||
ItemStack held = player.getItemInHand();
|
||||
@ -121,12 +122,10 @@ public void onBlockBreak(BlockBreakEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.canBuild(player, event.getBlock().getLocation())) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, event.getBlock())) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
@ -149,13 +148,10 @@ public void onBlockBreak(BlockBreakEvent event) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block flows (water/lava)
|
||||
*
|
||||
* @param event Relevant event details
|
||||
* Called when fluids flow.
|
||||
*/
|
||||
@Override
|
||||
public void onBlockFlow(BlockFromToEvent event) {
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
@ -168,7 +164,7 @@ public void onBlockFlow(BlockFromToEvent event) {
|
||||
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(event.getBlock().getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
|
||||
|
||||
if (wcfg.simulateSponge && isWater) {
|
||||
int ox = blockTo.getX();
|
||||
@ -200,101 +196,52 @@ public void onBlockFlow(BlockFromToEvent event) {
|
||||
}
|
||||
}*/
|
||||
|
||||
// Check the fluid block (from) whether it is air. If so and the target block is protected, cancel the event
|
||||
if (wcfg.preventWaterDamage.size() > 0 && blockFrom.getTypeId() == 0) {
|
||||
int targetId = world.getBlockTypeIdAt(
|
||||
blockTo.getX(), blockTo.getY(), blockTo.getZ());
|
||||
if (wcfg.preventWaterDamage.contains(targetId)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.preventWaterDamage.size() > 0 && isWater) {
|
||||
int targetId = world.getBlockTypeIdAt(
|
||||
blockTo.getX(), blockTo.getY(), blockTo.getZ());
|
||||
if (wcfg.preventWaterDamage.contains(targetId)) {
|
||||
// Check the fluid block (from) whether it is air.
|
||||
// If so and the target block is protected, cancel the event
|
||||
if (wcfg.preventWaterDamage.size() > 0) {
|
||||
int targetId = blockTo.getTypeId();
|
||||
|
||||
if ((blockFrom.getTypeId() == 0 || isWater) &&
|
||||
wcfg.preventWaterDamage.contains(targetId)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.allowedLavaSpreadOver.size() > 0 && isLava) {
|
||||
int targetId = world.getBlockTypeIdAt(
|
||||
blockTo.getX(), blockTo.getY() - 1, blockTo.getZ());
|
||||
int targetId = blockTo.getRelative(0, -1, 0).getTypeId();
|
||||
|
||||
if (!wcfg.allowedLavaSpreadOver.contains(targetId)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(blockFrom.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world.getName());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.WATER_FLOW)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.WATER_FLOW,
|
||||
blockFrom.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block gets ignited
|
||||
*
|
||||
* @param event Relevant event details
|
||||
* Called when a block gets ignited.
|
||||
*/
|
||||
@Override
|
||||
public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
IgniteCause cause = event.getCause();
|
||||
Block block = event.getBlock();
|
||||
World world = block.getWorld();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(world.getName());
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(block);
|
||||
Player player = event.getPlayer();
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world.getName());
|
||||
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (player != null && !plugin.hasPermission(player, "region.bypass")) {
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !set.allows(DefaultFlag.LIGHTER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFireSpread && set.allows(DefaultFlag.FIRE_SPREAD)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.LAVA && !set.allows(DefaultFlag.LAVA_FIRE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.preventLavaFire && cause == IgniteCause.LAVA) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -329,6 +276,39 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(block);
|
||||
Player player = event.getPlayer();
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (player != null && !plugin.getGlobalRegionManager().hasBypass(player, world)) {
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !set.allows(DefaultFlag.LIGHTER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFireSpread && set.allows(DefaultFlag.FIRE_SPREAD)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.LAVA && !set.allows(DefaultFlag.LAVA_FIRE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -345,7 +325,7 @@ public void onBlockBurn(BlockBurnEvent event) {
|
||||
}
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(event.getBlock().getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
|
||||
|
||||
if (wcfg.disableFireSpread) {
|
||||
event.setCancelled(true);
|
||||
@ -380,7 +360,7 @@ public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
}
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(event.getBlock().getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
|
||||
|
||||
int id = event.getChangedTypeId();
|
||||
|
||||
@ -484,10 +464,10 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
||||
World world = blockPlaced.getWorld();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(world.getName());
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.canBuild(player, blockPlaced.getLocation())) {
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, blockPlaced.getLocation())) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -638,7 +618,7 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
||||
World world = blockTo.getWorld();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(world.getName());
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (wcfg.simulateSponge && wcfg.redstoneSponges) {
|
||||
int ox = blockTo.getX();
|
||||
@ -675,7 +655,7 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
||||
private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(world.getName());
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
|
||||
for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) {
|
||||
@ -699,7 +679,7 @@ private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||
private void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(world.getName());
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
// The negative x edge
|
||||
int cx = ox - wcfg.spongeRadius - 1;
|
||||
|
@ -75,7 +75,7 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(player.getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
if (wcfg.disableLavaDamage && type == DamageCause.LAVA) {
|
||||
event.setCancelled(true);
|
||||
@ -98,12 +98,12 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(player.getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld().getName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.PVP)) {
|
||||
((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||
@ -121,7 +121,7 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld().getName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!set.allows(DefaultFlag.MOB_DAMAGE)) {
|
||||
@ -149,12 +149,12 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(player.getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld().getName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.PVP)) {
|
||||
((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||
@ -166,7 +166,7 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
if (attacker != null && attacker instanceof Skeleton) {
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld().getName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.MOB_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
@ -203,7 +203,7 @@ public void onEntityDamage(EntityDamageEvent event) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(player.getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
if (wcfg.disableFallDamage && type == DamageCause.FALL) {
|
||||
event.setCancelled(true);
|
||||
@ -243,7 +243,8 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
Location l = event.getLocation();
|
||||
WorldConfiguration wcfg = cfg.forWorld(l.getWorld().getName());
|
||||
World world = l.getWorld();
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (event.getEntity() instanceof LivingEntity) {
|
||||
|
||||
@ -260,7 +261,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(l);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(wcfg.getWorldName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.CREEPER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
@ -275,7 +276,7 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(l);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(wcfg.getWorldName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.TNT)) {
|
||||
event.setCancelled(true);
|
||||
@ -292,7 +293,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
}
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(event.getEntity().getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||
|
||||
//CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
|
||||
CreatureType creaType = event.getCreatureType();
|
||||
|
@ -72,7 +72,7 @@ public void onPlayerJoin(PlayerEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(player.getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
if (wcfg.fireSpreadDisableToggle) {
|
||||
player.sendMessage(ChatColor.YELLOW
|
||||
@ -172,7 +172,7 @@ public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(player.getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
if (wcfg.enforceOneSession) {
|
||||
String name = player.getName();
|
||||
@ -198,7 +198,7 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
}
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(event.getPlayer().getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(event.getPlayer().getWorld());
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
Item ci = event.getItemDrop();
|
||||
@ -225,7 +225,7 @@ public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
}
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.forWorld(event.getPlayer().getWorld().getName());
|
||||
WorldConfiguration wcfg = cfg.get(event.getPlayer().getWorld());
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
Item ci = event.getItem();
|
||||
|
@ -20,7 +20,6 @@
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.command.Command;
|
||||
@ -37,7 +36,6 @@
|
||||
import com.sk89q.worldguard.bukkit.commands.ProtectionCommands;
|
||||
import com.sk89q.worldguard.bukkit.commands.ToggleCommands;
|
||||
import com.sk89q.worldguard.protection.*;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.Filter;
|
||||
@ -98,10 +96,6 @@ public boolean hasPermission(CommandSender player, String perm) {
|
||||
// Register command classes
|
||||
commands.register(ToggleCommands.class);
|
||||
commands.register(ProtectionCommands.class);
|
||||
|
||||
// Set up permissions
|
||||
perms = new PermissionsResolverManager(
|
||||
getConfiguration(), getServer(), "WorldGuard", logger);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,6 +105,10 @@ public void onEnable() {
|
||||
// Need to create the plugins/WorldGuard folder
|
||||
getDataFolder().mkdirs();
|
||||
|
||||
// Set up permissions
|
||||
perms = new PermissionsResolverManager(
|
||||
getConfiguration(), getServer(), "WorldGuard", logger);
|
||||
|
||||
// This must be done before configuration is laoded
|
||||
LegacyWorldGuardMigration.migrateBlacklist(this);
|
||||
|
||||
@ -586,48 +584,6 @@ public WorldEditPlugin getWorldEdit() throws CommandException {
|
||||
throw new CommandException("WorldEdit detection failed (report error).");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check if a player has permission to build at a location.
|
||||
*
|
||||
* @param player
|
||||
* @param loc
|
||||
* @return
|
||||
*/
|
||||
public boolean canBuild(Player player, Location loc) {
|
||||
WorldConfiguration worldConfig =
|
||||
configuration.forWorld(loc.getWorld().getName());
|
||||
|
||||
if (worldConfig.useRegions) {
|
||||
LocalPlayer localPlayer = wrapPlayer(player);
|
||||
|
||||
if (!hasPermission(player, "region.bypass")) {
|
||||
RegionManager mgr = getGlobalRegionManager()
|
||||
.get(player.getWorld().getName());
|
||||
|
||||
if (!mgr.getApplicableRegions(BukkitUtil.toVector(loc))
|
||||
.canBuild(localPlayer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has permission to build at a location.
|
||||
*
|
||||
* @param player
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
* @return
|
||||
*/
|
||||
public boolean canBuild(Player player, int x, int y, int z) {
|
||||
return canBuild(player, new Location(player.getWorld(), x, y, z));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a player as a LocalPlayer.
|
||||
|
@ -69,7 +69,7 @@ public void onVehicleCreate(VehicleCreateEvent event) {
|
||||
Vector pt = new Vector(vhclLoc.getBlockX(), vhclLoc.getBlockY(), vhclLoc.getBlockZ());
|
||||
|
||||
if (vhcl instanceof Minecart || vhcl instanceof Boat) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(vhcl.getWorld().getName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(vhcl.getWorld());
|
||||
ApplicableRegionSet applicableRegions = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!applicableRegions.allows(DefaultFlag.PLACE_VEHICLE)) {
|
||||
|
@ -20,6 +20,8 @@
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -32,6 +34,7 @@
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
@ -78,11 +81,10 @@ public static void define(CommandContext args, WorldGuardPlugin plugin,
|
||||
|
||||
// Get the list of region owners
|
||||
if (args.argsLength() > 1) {
|
||||
region.setOwners(RegionUtil.parseDomainString(args.getSlice(2), 1));
|
||||
region.setOwners(RegionUtil.parseDomainString(args.getSlice(1), 1));
|
||||
}
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(
|
||||
sel.getWorld().getName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(sel.getWorld());
|
||||
mgr.addRegion(region);
|
||||
|
||||
try {
|
||||
@ -133,13 +135,11 @@ public static void claim(CommandContext args, WorldGuardPlugin plugin,
|
||||
|
||||
// Get the list of region owners
|
||||
if (args.argsLength() > 1) {
|
||||
region.setOwners(RegionUtil.parseDomainString(args.getSlice(2), 1));
|
||||
region.setOwners(RegionUtil.parseDomainString(args.getSlice(1), 1));
|
||||
}
|
||||
|
||||
WorldConfiguration wcfg = plugin.getGlobalConfiguration()
|
||||
.forWorld(player.getWorld().getName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(
|
||||
sel.getWorld().getName());
|
||||
WorldConfiguration wcfg = plugin.getGlobalConfiguration().get(player.getWorld());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(sel.getWorld());
|
||||
|
||||
// Check whether the player has created too many regions
|
||||
if (wcfg.maxRegionCountPerPlayer >= 0
|
||||
@ -155,22 +155,20 @@ public static void claim(CommandContext args, WorldGuardPlugin plugin,
|
||||
throw new CommandException("This region already exists and you don't own it.");
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
ApplicableRegionSet regions = mgr.getApplicableRegions(region);
|
||||
|
||||
// Check if this region overlaps any other region
|
||||
if (regions.isAnyRegionAffected()) {
|
||||
if (!regions.isOwner(localPlayer)) {
|
||||
if (regions.size() > 0) {
|
||||
if (!regions.isOwnerOfAll(localPlayer)) {
|
||||
throw new CommandException("This region overlaps with someone else's region.");
|
||||
}
|
||||
|
||||
region.setPriority(regions.getAffectedRegionPriority() + 1);
|
||||
} else {
|
||||
if (wcfg.claimOnlyInsideExistingRegions) {
|
||||
throw new CommandException("You may only claim regions inside " +
|
||||
"existing regions that you or your group own.");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/*if (plugin.getGlobalConfiguration().getiConomy() != null && wcfg.useiConomy && wcfg.buyOnClaim) {
|
||||
if (iConomy.getBank().hasAccount(player.getName())) {
|
||||
@ -195,10 +193,10 @@ public static void claim(CommandContext args, WorldGuardPlugin plugin,
|
||||
}
|
||||
}*/
|
||||
|
||||
if (region.countBlocks() > wcfg.maxClaimVolume) {
|
||||
if (region.volume() > wcfg.maxClaimVolume) {
|
||||
player.sendMessage(ChatColor.RED + "This region is to large to claim.");
|
||||
player.sendMessage(ChatColor.RED +
|
||||
"Max. volume: " + wcfg.maxClaimVolume + ", your volume: " + region.countBlocks());
|
||||
"Max. volume: " + wcfg.maxClaimVolume + ", your volume: " + region.volume());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -237,7 +235,7 @@ public static void info(CommandContext args, WorldGuardPlugin plugin,
|
||||
id = args.getString(1).toLowerCase();
|
||||
}
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world.getName());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
if (!mgr.hasRegion(id)) {
|
||||
throw new CommandException("A region with ID '" + id + "' doesn't exist.");
|
||||
@ -267,11 +265,17 @@ public static void info(CommandContext args, WorldGuardPlugin plugin,
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
for (Flag<?> flag : DefaultFlag.getFlags()) {
|
||||
Object val = region.getFlag(flag);
|
||||
|
||||
if (val == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (s.length() > 0) {
|
||||
s.append(", ");
|
||||
}
|
||||
|
||||
s.append(flag.getName() + ": " + String.valueOf(region.getFlag(flag)));
|
||||
s.append(flag.getName() + ": " + String.valueOf(val));
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.BLUE + "Flags: " + s.toString());
|
||||
@ -282,4 +286,54 @@ public static void info(CommandContext args, WorldGuardPlugin plugin,
|
||||
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Members: "
|
||||
+ members.toUserFriendlyString());
|
||||
}
|
||||
|
||||
@Command(aliases = {"list"},
|
||||
usage = "[page] [world]",
|
||||
desc = "Get a list of regions",
|
||||
flags = "", min = 0, max = 2)
|
||||
@CommandPermissions({"worldguard.region.list"})
|
||||
public static void list(CommandContext args, WorldGuardPlugin plugin,
|
||||
CommandSender sender) throws CommandException {
|
||||
|
||||
World world;
|
||||
int page = 0;
|
||||
|
||||
if (args.argsLength() > 0) {
|
||||
page = args.getInteger(0);
|
||||
}
|
||||
|
||||
if (args.argsLength() > 1) {
|
||||
world = plugin.matchWorld(sender, args.getString(1));
|
||||
} else {
|
||||
world = plugin.checkPlayer(sender).getWorld();
|
||||
}
|
||||
|
||||
int listSize = 5;
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
Map<String, ProtectedRegion> regions = mgr.getRegions();
|
||||
int size = regions.size();
|
||||
int pages = (int) Math.ceil(size / (float) listSize);
|
||||
|
||||
String[] regionIDList = new String[size];
|
||||
int index = 0;
|
||||
for (String id : regions.keySet()) {
|
||||
regionIDList[index] = id;
|
||||
index++;
|
||||
}
|
||||
Arrays.sort(regionIDList);
|
||||
|
||||
sender.sendMessage(ChatColor.RED + "Regions (page "
|
||||
+ (page + 1) + " of " + pages + "):");
|
||||
|
||||
if (page < pages) {
|
||||
for (int i = page * listSize; i < page * listSize + listSize; i++) {
|
||||
if (i >= size) {
|
||||
break;
|
||||
}
|
||||
sender.sendMessage(ChatColor.YELLOW.toString() + (i + 1) +
|
||||
". " + regionIDList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +43,7 @@ public static void stopFire(CommandContext args, WorldGuardPlugin plugin,
|
||||
world = plugin.matchWorld(sender, args.getString(0));
|
||||
}
|
||||
|
||||
WorldConfiguration wcfg = plugin.getGlobalConfiguration()
|
||||
.forWorld(world.getName());
|
||||
WorldConfiguration wcfg = plugin.getGlobalConfiguration().get(world);
|
||||
|
||||
if (!wcfg.fireSpreadDisableToggle) {
|
||||
plugin.getServer().broadcastMessage(
|
||||
@ -75,8 +74,7 @@ public static void allowFire(CommandContext args, WorldGuardPlugin plugin,
|
||||
world = plugin.matchWorld(sender, args.getString(0));
|
||||
}
|
||||
|
||||
WorldConfiguration wcfg = plugin.getGlobalConfiguration()
|
||||
.forWorld(world.getName());
|
||||
WorldConfiguration wcfg = plugin.getGlobalConfiguration().get(world);
|
||||
|
||||
if (wcfg.fireSpreadDisableToggle) {
|
||||
plugin.getServer().broadcastMessage(ChatColor.YELLOW
|
||||
|
@ -81,6 +81,39 @@ public boolean canUse(LocalPlayer player) {
|
||||
public boolean allows(StateFlag flag) {
|
||||
return internalGetState(flag, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether a player is an owner of all regions in this set.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean isOwnerOfAll(LocalPlayer player) {
|
||||
for (ProtectedRegion region : applicable) {
|
||||
if (!region.isOwner(player)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether a player is an owner or member of all regions in
|
||||
* this set.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean isMemberOfAll(LocalPlayer player) {
|
||||
for (ProtectedRegion region : applicable) {
|
||||
if (!region.isMember(player)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a flag is permitted.
|
||||
@ -272,4 +305,13 @@ private void clearParents(Map<ProtectedRegion, ?> needsClear,
|
||||
parent = parent.getParent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of regions that are included.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int size() {
|
||||
return applicable.size();
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,14 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.databases.JSONDatabase;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.FlatRegionManager;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import java.io.File;
|
||||
@ -27,7 +33,10 @@
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* This class keeps track of region information for every world. It loads
|
||||
@ -45,6 +54,11 @@ public class GlobalRegionManager {
|
||||
*/
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Reference to the global configuration.
|
||||
*/
|
||||
private ConfigurationManager config;
|
||||
|
||||
/**
|
||||
* Map of managers per-world.
|
||||
*/
|
||||
@ -63,6 +77,7 @@ public class GlobalRegionManager {
|
||||
*/
|
||||
public GlobalRegionManager(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
config = plugin.getGlobalConfiguration();
|
||||
managers = new HashMap<String, RegionManager>();
|
||||
lastModified = new HashMap<String, Long>();
|
||||
}
|
||||
@ -111,9 +126,10 @@ public void unloadAll() {
|
||||
/**
|
||||
* Load region information for a world.
|
||||
*
|
||||
* @param name
|
||||
* @param world
|
||||
*/
|
||||
public void load(String name) {
|
||||
public void load(World world) {
|
||||
String name = world.getName();
|
||||
File file = getPath(name);
|
||||
|
||||
try {
|
||||
@ -137,7 +153,7 @@ public void load(String name) {
|
||||
public void preload() {
|
||||
// Load regions
|
||||
for (World world : plugin.getServer().getWorlds()) {
|
||||
load(world.getName());
|
||||
load(world);
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,7 +163,6 @@ public void preload() {
|
||||
*/
|
||||
public void reloadChanged() {
|
||||
for (String name : managers.keySet()) {
|
||||
|
||||
File file = getPath(name);
|
||||
|
||||
Long oldDate = lastModified.get(name);
|
||||
@ -158,7 +173,11 @@ public void reloadChanged() {
|
||||
|
||||
try {
|
||||
if (file.lastModified() > oldDate) {
|
||||
load(name);
|
||||
World world = plugin.getServer().getWorld(name);
|
||||
|
||||
if (world != null) {
|
||||
load(world);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
@ -168,16 +187,87 @@ public void reloadChanged() {
|
||||
/**
|
||||
* Get the region manager for a particular world.
|
||||
*
|
||||
* @param name
|
||||
* @param world
|
||||
* @return
|
||||
*/
|
||||
public RegionManager get(String name) {
|
||||
RegionManager manager = managers.get(name);
|
||||
public RegionManager get(World world) {
|
||||
RegionManager manager = managers.get(world.getName());
|
||||
|
||||
if (manager == null) {
|
||||
load(name);
|
||||
load(world);
|
||||
}
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the player can bypass.
|
||||
*
|
||||
* @param player
|
||||
* @param world
|
||||
* @return
|
||||
*/
|
||||
public boolean hasBypass(Player player, World world) {
|
||||
return plugin.hasPermission(player, "worldguard.region.bypass."
|
||||
+ world.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has permission to build at a block.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
public boolean canBuild(Player player, Block block) {
|
||||
return canBuild(player, block.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player has permission to build at a location.
|
||||
*
|
||||
* @param player
|
||||
* @param loc
|
||||
* @return
|
||||
*/
|
||||
public boolean canBuild(Player player, Location loc) {
|
||||
World world = loc.getWorld();
|
||||
WorldConfiguration worldConfig = config.get(world);
|
||||
|
||||
if (!worldConfig.useRegions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (!hasBypass(player, world)) {
|
||||
RegionManager mgr = get(world);
|
||||
|
||||
if (!mgr.getApplicableRegions(BukkitUtil.toVector(loc))
|
||||
.canBuild(localPlayer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a flag is allowed.
|
||||
*
|
||||
* @param flag
|
||||
* @param loc
|
||||
* @return
|
||||
*/
|
||||
public boolean allows(StateFlag flag, Location loc) {
|
||||
World world = loc.getWorld();
|
||||
WorldConfiguration worldConfig = config.get(world);
|
||||
|
||||
if (!worldConfig.useRegions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
return mgr.getApplicableRegions(toVector(loc)).allows(flag);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.databases.ProtectionDatabase;
|
||||
import java.util.Iterator;
|
||||
@ -191,6 +192,28 @@ public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||
return applicable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an object for a region for rules to be applied with.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
appRegions.addAll(regions.values());
|
||||
|
||||
List<ProtectedRegion> intersectRegions;
|
||||
|
||||
try {
|
||||
intersectRegions = checkRegion.getIntersectingRegions(appRegions);
|
||||
} catch (Exception e) {
|
||||
intersectRegions = new ArrayList<ProtectedRegion>();
|
||||
}
|
||||
|
||||
return new ApplicableRegionSet(intersectRegions, regions.get("__global__"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the provided region overlaps with any other region that
|
||||
* is not owned by the player.
|
||||
@ -200,7 +223,6 @@ public List<String> getApplicableRegionsIDs(Vector pt) {
|
||||
*/
|
||||
@Override
|
||||
public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer player) {
|
||||
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
|
||||
for (ProtectedRegion other : regions.values()) {
|
||||
@ -214,7 +236,7 @@ public boolean overlapsUnownedRegion(ProtectedRegion checkRegion, LocalPlayer pl
|
||||
List<ProtectedRegion> intersectRegions;
|
||||
try {
|
||||
intersectRegions = checkRegion.getIntersectingRegions(appRegions);
|
||||
} catch (Exception e) {
|
||||
} catch (UnsupportedIntersectionException e) {
|
||||
intersectRegions = new ArrayList<ProtectedRegion>();
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||
return new ApplicableRegionSet(appRegions, regions.get("__global__"));
|
||||
}
|
||||
|
||||
/*@Override
|
||||
@Override
|
||||
public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||
List<ProtectedRegion> appRegions = new ArrayList<ProtectedRegion>();
|
||||
appRegions.addAll(regions.values());
|
||||
@ -183,7 +183,7 @@ public ApplicableRegionSet getApplicableRegions(ProtectedRegion checkRegion) {
|
||||
}
|
||||
|
||||
return new ApplicableRegionSet(intersectRegions, regions.get("__global__"));
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of region IDs that contain a point.
|
||||
|
@ -125,8 +125,8 @@ public void save() throws IOException {
|
||||
* @param region
|
||||
* @return
|
||||
*/
|
||||
/*public abstract ApplicableRegionSet getApplicableRegions(
|
||||
ProtectedRegion region);*/
|
||||
public abstract ApplicableRegionSet getApplicableRegions(
|
||||
ProtectedRegion region);
|
||||
|
||||
/**
|
||||
* Get a list of region IDs that contain a point.
|
||||
|
@ -42,7 +42,7 @@ public BlockVector getMaximumPoint() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countBlocks() {
|
||||
public int volume() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ public String getTypeName() {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int countBlocks() {
|
||||
public int volume() {
|
||||
int xLength = max.getBlockX() - min.getBlockX() + 1;
|
||||
int yLength = max.getBlockY() - min.getBlockY() + 1;
|
||||
int zLength = max.getBlockZ() - min.getBlockZ() + 1;
|
||||
|
@ -269,7 +269,7 @@ public String getTypeName() {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int countBlocks() {
|
||||
public int volume() {
|
||||
int volume = 0;
|
||||
int numPoints = points.size();
|
||||
if (numPoints < 3) {
|
||||
|
@ -280,11 +280,11 @@ public <T extends Flag<V>, V> void setFlag(T flag, V val) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of Blocks in this region
|
||||
* Get the number of blocks in this region
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int countBlocks();
|
||||
public abstract int volume();
|
||||
|
||||
/**
|
||||
* Check to see if a point is inside this region.
|
||||
|
Loading…
Reference in New Issue
Block a user