added multiworld support for regions and json region database

This commit is contained in:
Redecouverte 2011-02-24 11:19:35 +01:00
parent 4505bb6f4e
commit f61a9ab5cc
26 changed files with 1909 additions and 1333 deletions

View File

@ -14,7 +14,7 @@
<include name="Bukkit.jar" /> <include name="Bukkit.jar" />
<include name="WorldEdit.jar" /> <include name="WorldEdit.jar" />
<include name="prtree.jar" /> <include name="prtree.jar" />
<include name="json-simple-1.1.jar" /> <include name="gson-1.7-SNAPSHOT.jar" />
</fileset> </fileset>
<target name="init"> <target name="init">
@ -47,7 +47,7 @@
<copy tofile="${build.dir}/defaults/blacklist.txt" file="blacklist.txt"/> <copy tofile="${build.dir}/defaults/blacklist.txt" file="blacklist.txt"/>
<jar jarfile="${dist.dir}/WorldGuard.jar" basedir="${build.dir}" manifest="manifest.mf"> <jar jarfile="${dist.dir}/WorldGuard.jar" basedir="${build.dir}" manifest="manifest.mf">
<zipgroupfileset dir="lib" includes="prtree.jar" /> <zipgroupfileset dir="lib" includes="prtree.jar" />
<zipgroupfileset dir="lib" includes="json-simple-1.1.jar" /> <zipgroupfileset dir="lib" includes="gson-1.7-SNAPSHOT.jar" />
</jar> </jar>
</target> </target>

BIN
lib/gson-1.7-SNAPSHOT.jar Normal file

Binary file not shown.

Binary file not shown.

View File

@ -27,7 +27,7 @@ dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath= endorsed.classpath=
excludes= excludes=
file.reference.Bukkit.jar=lib/Bukkit.jar file.reference.Bukkit.jar=lib/Bukkit.jar
file.reference.json-simple-1.1.jar=lib\\json-simple-1.1.jar file.reference.gson-1.7-SNAPSHOT.jar=lib\\gson-1.7-SNAPSHOT.jar
file.reference.prtree.jar=lib/prtree.jar file.reference.prtree.jar=lib/prtree.jar
file.reference.truezip.jar=lib/truezip.jar file.reference.truezip.jar=lib/truezip.jar
file.reference.WorldEdit.jar=lib/WorldEdit.jar file.reference.WorldEdit.jar=lib/WorldEdit.jar
@ -38,7 +38,7 @@ javac.classpath=\
${file.reference.prtree.jar}:\ ${file.reference.prtree.jar}:\
${file.reference.truezip.jar}:\ ${file.reference.truezip.jar}:\
${file.reference.WorldEdit.jar}:\ ${file.reference.WorldEdit.jar}:\
${file.reference.json-simple-1.1.jar} ${file.reference.gson-1.7-SNAPSHOT.jar}
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false

View File

@ -19,6 +19,7 @@
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -35,7 +36,7 @@
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.blacklist.events.*; import com.sk89q.worldguard.blacklist.events.*;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.AreaFlags; import com.sk89q.worldguard.protection.regions.AreaFlags;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*; import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
public class WorldGuardBlockListener extends BlockListener { public class WorldGuardBlockListener extends BlockListener {
@ -70,10 +71,8 @@ public void onBlockDamage(BlockDamageEvent event) {
if (plugin.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) { if (plugin.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) {
Vector pt = toVector(blockDamaged); Vector pt = toVector(blockDamaged);
LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (!plugin.hasPermission(player, "/regionbypass") if (!plugin.canBuild(player, pt)) {
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!"); player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!");
event.setCancelled(true); event.setCancelled(true);
@ -105,10 +104,8 @@ public void onBlockBreak(BlockBreakEvent event) {
if (plugin.useRegions) { if (plugin.useRegions) {
Vector pt = BukkitUtil.toVector(event.getBlock()); Vector pt = BukkitUtil.toVector(event.getBlock());
LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (!plugin.hasPermission(player, "/regionbypass") if (!plugin.canBuild(player, pt)) {
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -274,26 +271,26 @@ public void onBlockIgnite(BlockIgniteEvent event) {
LocalPlayer localPlayer = plugin.wrapPlayer(player); LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (cause == IgniteCause.FLINT_AND_STEEL if (cause == IgniteCause.FLINT_AND_STEEL
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) { && !plugin.globalRegionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (cause == IgniteCause.FLINT_AND_STEEL if (cause == IgniteCause.FLINT_AND_STEEL
&& !plugin.regionManager.getApplicableRegions(pt) && !plugin.globalRegionManager.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_LIGHTER)) { .allowsFlag(AreaFlags.FLAG_LIGHTER)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
f (isFireSpread && !plugin.regionManager.getApplicableRegions(pt) f (isFireSpread && !plugin.globalRegionManager.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD)) { .allowsFlag(AreaFlags.FLAG_FIRE_SPREAD)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (cause == IgniteCause.LAVA && !plugin.regionManager.getApplicableRegions(pt) if (cause == IgniteCause.LAVA && !plugin.globalRegionManager.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_LAVA_FIRE)) { .allowsFlag(AreaFlags.FLAG_LAVA_FIRE)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -391,10 +388,11 @@ public void onBlockInteract(BlockInteractEvent event) {
if (plugin.useRegions) { if (plugin.useRegions) {
Vector pt = toVector(block); Vector pt = toVector(block);
LocalPlayer localPlayer = plugin.wrapPlayer(player); LocalPlayer localPlayer = plugin.wrapPlayer(player);
RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(player.getWorld().getName());
if (!plugin.hasPermission(player, "/regionbypass") if (!plugin.hasPermission(player, "/regionbypass")
&& !plugin.regionManager.getApplicableRegions(pt).allowsFlag(AreaFlags.FLAG_CHEST_ACCESS) && !mgr.getApplicableRegions(pt).allowsFlag(AreaFlags.FLAG_CHEST_ACCESS)
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) { && !mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -433,10 +431,8 @@ public void onBlockPlace(BlockPlaceEvent event) {
if (plugin.useRegions) { if (plugin.useRegions) {
Vector pt = toVector(blockPlaced); Vector pt = toVector(blockPlaced);
LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (!plugin.hasPermission(player, "/regionbypass") if (!plugin.canBuild(player, pt)) {
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -478,8 +474,10 @@ public void onBlockRightClick(BlockRightClickEvent event) {
if (plugin.useRegions && event.getItemInHand().getTypeId() == plugin.regionWand) { if (plugin.useRegions && event.getItemInHand().getTypeId() == plugin.regionWand) {
Vector pt = toVector(blockClicked); Vector pt = toVector(blockClicked);
ApplicableRegionSet app = plugin.regionManager.getApplicableRegions(pt);
List<String> regions = plugin.regionManager.getApplicableRegionsIDs(pt); RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(player.getWorld().getName());
ApplicableRegionSet app = mgr.getApplicableRegions(pt);
List<String> regions = mgr.getApplicableRegionsIDs(pt);
if (regions.size() > 0) { if (regions.size() > 0) {
player.sendMessage(ChatColor.YELLOW + "Can you build? " player.sendMessage(ChatColor.YELLOW + "Can you build? "
@ -504,10 +502,8 @@ public void onBlockRightClick(BlockRightClickEvent event) {
if (plugin.useRegions && type == Material.CAKE_BLOCK) { if (plugin.useRegions && type == Material.CAKE_BLOCK) {
Vector pt = toVector(blockClicked); Vector pt = toVector(blockClicked);
LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (!plugin.hasPermission(player, "/regionbypass") if (!plugin.canBuild(player, pt)) {
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area."); player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
byte newData = (byte) (blockClicked.getData() - 1); byte newData = (byte) (blockClicked.getData() - 1);

View File

@ -19,6 +19,7 @@
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -32,7 +33,7 @@
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldguard.protection.AreaFlags; import com.sk89q.worldguard.protection.regions.AreaFlags;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*; import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
public class WorldGuardEntityListener extends EntityListener { public class WorldGuardEntityListener extends EntityListener {
@ -91,8 +92,9 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (attacker != null && attacker instanceof Player) { if (attacker != null && attacker instanceof Player) {
if (plugin.useRegions) { if (plugin.useRegions) {
Vector pt = toVector(defender.getLocation()); Vector pt = toVector(defender.getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(player.getWorld().getName());
if (!plugin.regionManager.getApplicableRegions(pt) if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_PVP)) { .allowsFlag(AreaFlags.FLAG_PVP)) {
((Player)attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area."); ((Player)attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
event.setCancelled(true); event.setCancelled(true);
@ -109,15 +111,16 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (plugin.useRegions) { if (plugin.useRegions) {
Vector pt = toVector(defender.getLocation()); Vector pt = toVector(defender.getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(player.getWorld().getName());
if (!plugin.regionManager.getApplicableRegions(pt) if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_MOB_DAMAGE)) { .allowsFlag(AreaFlags.FLAG_MOB_DAMAGE)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (attacker instanceof Creeper) { if (attacker instanceof Creeper) {
if (!plugin.regionManager.getApplicableRegions(pt) if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) { .allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -144,8 +147,9 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
if (attacker != null && attacker instanceof Player) { if (attacker != null && attacker instanceof Player) {
if (plugin.useRegions) { if (plugin.useRegions) {
Vector pt = toVector(defender.getLocation()); Vector pt = toVector(defender.getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(player.getWorld().getName());
if (!plugin.regionManager.getApplicableRegions(pt) if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_PVP)) { .allowsFlag(AreaFlags.FLAG_PVP)) {
((Player)attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area."); ((Player)attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
event.setCancelled(true); event.setCancelled(true);
@ -156,8 +160,9 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
if (attacker != null && attacker instanceof Skeleton) { if (attacker != null && attacker instanceof Skeleton) {
if (plugin.useRegions) { if (plugin.useRegions) {
Vector pt = toVector(defender.getLocation()); Vector pt = toVector(defender.getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(player.getWorld().getName());
if (!plugin.regionManager.getApplicableRegions(pt) if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_MOB_DAMAGE)) { .allowsFlag(AreaFlags.FLAG_MOB_DAMAGE)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -254,8 +259,9 @@ public void onEntityExplode(EntityExplodeEvent event) {
if (plugin.useRegions) { if (plugin.useRegions) {
Vector pt = toVector(event.getEntity().getLocation()); Vector pt = toVector(event.getEntity().getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(event.getEntity().getWorld().getName());
if (!plugin.regionManager.getApplicableRegions(pt) if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) { .allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -269,8 +275,9 @@ public void onEntityExplode(EntityExplodeEvent event) {
if (plugin.useRegions && event.getEntity() != null) { if (plugin.useRegions && event.getEntity() != null) {
Vector pt = toVector(event.getEntity().getLocation()); Vector pt = toVector(event.getEntity().getLocation());
RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(event.getEntity().getWorld().getName());
if (!plugin.regionManager.getApplicableRegions(pt) if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_TNT)) { .allowsFlag(AreaFlags.FLAG_TNT)) {
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -19,6 +19,7 @@
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
import com.sk89q.worldguard.blacklist.events.ItemAcquireBlacklistEvent; import com.sk89q.worldguard.blacklist.events.ItemAcquireBlacklistEvent;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import com.sk89q.worldguard.blacklist.events.ItemDropBlacklistEvent; import com.sk89q.worldguard.blacklist.events.ItemDropBlacklistEvent;
@ -30,7 +31,7 @@
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.*; import com.sk89q.worldguard.*;
import com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent; import com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent;
import com.sk89q.worldguard.protection.AreaFlags; import com.sk89q.worldguard.protection.regions.AreaFlags;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*; import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
/** /**
@ -116,10 +117,8 @@ public void onPlayerItem(PlayerItemEvent event) {
if (plugin.useRegions && !event.isBlock() && block != null) { if (plugin.useRegions && !event.isBlock() && block != null) {
Vector pt = toVector(block.getRelative(event.getBlockFace())); Vector pt = toVector(block.getRelative(event.getBlockFace()));
LocalPlayer localPlayer = plugin.wrapPlayer(player);
if (!plugin.hasPermission(player, "/regionbypass") if (!plugin.canBuild(player, pt)) {
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
player.sendMessage(ChatColor.DARK_RED player.sendMessage(ChatColor.DARK_RED
+ "You don't have permission for this area."); + "You don't have permission for this area.");
event.setCancelled(true); event.setCancelled(true);
@ -139,8 +138,9 @@ public void onPlayerItem(PlayerItemEvent event) {
if (plugin.useRegions && item != null && block != null && item.getTypeId() == 259) { if (plugin.useRegions && item != null && block != null && item.getTypeId() == 259) {
Vector pt = toVector(block.getRelative(event.getBlockFace())); Vector pt = toVector(block.getRelative(event.getBlockFace()));
RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(player.getWorld().getName());
if (!plugin.regionManager.getApplicableRegions(pt) if (!mgr.getApplicableRegions(pt)
.allowsFlag(AreaFlags.FLAG_LIGHTER)) { .allowsFlag(AreaFlags.FLAG_LIGHTER)) {
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -19,8 +19,11 @@
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import com.sk89q.worldguard.protection.dbs.CSVDatabase;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
import static com.sk89q.worldguard.bukkit.BukkitUtil.matchSinglePlayer; import static com.sk89q.worldguard.bukkit.BukkitUtil.matchSinglePlayer;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.util.logging.*; import java.util.logging.*;
@ -31,14 +34,12 @@
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginLoader;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.config.Configuration; import org.bukkit.util.config.Configuration;
import com.sk89q.bukkit.migration.PermissionsResolverManager; import com.sk89q.bukkit.migration.PermissionsResolverManager;
@ -49,7 +50,6 @@
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.ItemType; import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditAPI;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
@ -58,8 +58,12 @@
import com.sk89q.worldguard.blacklist.loggers.*; import com.sk89q.worldguard.blacklist.loggers.*;
import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.*; import com.sk89q.worldguard.protection.*;
import com.sk89q.worldguard.protection.AreaFlags.State; import com.sk89q.worldguard.protection.regionmanager.GlobalRegionManager;
import com.sk89q.worldguard.protection.ProtectedRegion.CircularInheritanceException; import com.sk89q.worldguard.protection.regions.AreaFlags;
import com.sk89q.worldguard.protection.regions.AreaFlags.State;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException;
import org.bukkit.World;
/** /**
* Plugin for Bukkit. * Plugin for Bukkit.
@ -84,9 +88,7 @@ public class WorldGuardPlugin extends JavaPlugin {
Blacklist blacklist; Blacklist blacklist;
GlobalFlags globalFlags = new GlobalFlags(); GlobalRegionManager globalRegionManager;
RegionManager regionManager = new FlatRegionManager(globalFlags);
ProtectionDatabase regionLoader;
Set<String> invinciblePlayers = new HashSet<String>(); Set<String> invinciblePlayers = new HashSet<String>();
Set<String> amphibiousPlayers = new HashSet<String>(); Set<String> amphibiousPlayers = new HashSet<String>();
@ -158,7 +160,8 @@ public void onEnable() {
createDefaultConfiguration("config.yml"); createDefaultConfiguration("config.yml");
createDefaultConfiguration("blacklist.txt"); createDefaultConfiguration("blacklist.txt");
regionLoader = new CSVDatabase(new File(folder, "regions.txt")); globalRegionManager = new GlobalRegionManager(this);
perms = new PermissionsResolverManager(getConfiguration(), getServer(), perms = new PermissionsResolverManager(getConfiguration(), getServer(),
"WorldGuard", logger); "WorldGuard", logger);
permsListener = new PermissionsResolverServerListener(perms); permsListener = new PermissionsResolverServerListener(perms);
@ -316,6 +319,8 @@ public void loadConfiguration() {
useRegions = config.getBoolean("regions.enable", true); useRegions = config.getBoolean("regions.enable", true);
regionWand = config.getInt("regions.wand", 287); regionWand = config.getInt("regions.wand", 287);
GlobalFlags globalFlags = new GlobalFlags();
globalFlags.canBuild = config.getBoolean("regions.default.build", true); globalFlags.canBuild = config.getBoolean("regions.default.build", true);
globalFlags.canAccessChests = config.getBoolean("regions.default.chest-access", false); globalFlags.canAccessChests = config.getBoolean("regions.default.chest-access", false);
globalFlags.canPvP = config.getBoolean("regions.default.pvp", true); globalFlags.canPvP = config.getBoolean("regions.default.pvp", true);
@ -323,10 +328,29 @@ public void loadConfiguration() {
globalFlags.canTnt = config.getBoolean("regions.default.tnt", true); globalFlags.canTnt = config.getBoolean("regions.default.tnt", true);
globalFlags.allowCreeper = config.getBoolean("regions.default.creeper", true); globalFlags.allowCreeper = config.getBoolean("regions.default.creeper", true);
globalFlags.allowMobDamage = config.getBoolean("regions.default.mobdamage", true); globalFlags.allowMobDamage = config.getBoolean("regions.default.mobdamage", true);
globalRegionManager.setGlobalFlags(globalFlags);
try { try {
regionLoader.load(); File CSVfile = new File(this.getDataFolder(), "regions.txt");
regionManager.setRegions(regionLoader.getRegions()); if (CSVfile.exists()) {
logger.info("WorldGuard: Converting old regions.txt to new format....");
World w = this.getServer().getWorlds().get(0);
RegionManager mgr = globalRegionManager.getRegionmanager(w.getName());
CSVDatabase db = new CSVDatabase(CSVfile);
db.load();
for (Map.Entry<String, ProtectedRegion> entry : db.getRegions().entrySet()) {
mgr.addRegion(entry.getValue());
}
mgr.save();
CSVfile.renameTo(new File(this.getDataFolder(), "region.txt.old"));
logger.info("WorldGuard: Done.");
}
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
} catch (IOException e) { } catch (IOException e) {
logger.warning("WorldGuard: Failed to load regions: " logger.warning("WorldGuard: Failed to load regions: "
@ -780,9 +804,10 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
String id = args[0].toLowerCase(); String id = args[0].toLowerCase();
WorldEditPlugin worldEdit = (WorldEditPlugin)wePlugin; WorldEditPlugin worldEdit = (WorldEditPlugin)wePlugin;
World w = player.getWorld();
LocalSession session = worldEdit.getSession(player); LocalSession session = worldEdit.getSession(player);
Region weRegion = session.getSelection(new BukkitWorld(player.getWorld())); Region weRegion = session.getSelection(new BukkitWorld(w));
BlockVector min = weRegion.getMinimumPoint().toBlockVector(); BlockVector min = weRegion.getMinimumPoint().toBlockVector();
BlockVector max = weRegion.getMaximumPoint().toBlockVector(); BlockVector max = weRegion.getMaximumPoint().toBlockVector();
@ -791,8 +816,9 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
if (args.length >= 2) { if (args.length >= 2) {
region.setOwners(parseDomainString(args, 1)); region.setOwners(parseDomainString(args, 1));
} }
regionManager.addRegion(region); RegionManager mgr = globalRegionManager.getRegionmanager(w.getName());
regionLoader.save(regionManager); mgr.addRegion(region);
mgr.save();
player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + "."); player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
} catch (IncompleteRegionException e) { } catch (IncompleteRegionException e) {
player.sendMessage(ChatColor.RED + "You must first define an area in WorldEdit."); player.sendMessage(ChatColor.RED + "You must first define an area in WorldEdit.");
@ -810,8 +836,9 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
try { try {
String id = args[0].toLowerCase(); String id = args[0].toLowerCase();
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
ProtectedRegion existing = regionManager.getRegion(id); ProtectedRegion existing = mgr.getRegion(id);
if (existing != null) { if (existing != null) {
if (!existing.getOwners().contains(wrapPlayer(player))) { if (!existing.getOwners().contains(wrapPlayer(player))) {
@ -830,15 +857,15 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
ProtectedRegion region = new ProtectedCuboidRegion(id, min, max); ProtectedRegion region = new ProtectedCuboidRegion(id, min, max);
if (regionManager.overlapsUnownedRegion(region, wrapPlayer(player))) { if (mgr.overlapsUnownedRegion(region, wrapPlayer(player))) {
player.sendMessage(ChatColor.RED + "This region overlaps with someone else's region."); player.sendMessage(ChatColor.RED + "This region overlaps with someone else's region.");
return true; return true;
} }
region.getOwners().addPlayer(player.getName()); region.getOwners().addPlayer(player.getName());
regionManager.addRegion(region); mgr.addRegion(region);
regionLoader.save(regionManager); mgr.save();
player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + "."); player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
} catch (IncompleteRegionException e) { } catch (IncompleteRegionException e) {
player.sendMessage(ChatColor.RED + "You must first define an area in WorldEdit."); player.sendMessage(ChatColor.RED + "You must first define an area in WorldEdit.");
@ -858,7 +885,8 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
String id = args[0].toLowerCase(); String id = args[0].toLowerCase();
String flagStr = args[1]; String flagStr = args[1];
String stateStr = args[2]; String stateStr = args[2];
ProtectedRegion region = regionManager.getRegion(id); RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
ProtectedRegion region = mgr.getRegion(id);
if (region == null) { if (region == null) {
player.sendMessage(ChatColor.RED + "Could not find a region by that ID."); player.sendMessage(ChatColor.RED + "Could not find a region by that ID.");
@ -893,7 +921,7 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
AreaFlags flags = region.getFlags(); AreaFlags flags = region.getFlags();
flags.set(flagStr, state); flags.set(flagStr, state);
regionLoader.save(regionManager); mgr.save();
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated."); player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated.");
} catch (IOException e) { } catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: " player.sendMessage(ChatColor.RED + "Region database failed to save: "
@ -911,8 +939,9 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
String id = args[0].toLowerCase(); String id = args[0].toLowerCase();
String parentId = args.length > 1 ? args[1].toLowerCase() : null; String parentId = args.length > 1 ? args[1].toLowerCase() : null;
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
ProtectedRegion region = regionManager.getRegion(id); ProtectedRegion region = mgr.getRegion(id);
if (region == null) { if (region == null) {
player.sendMessage(ChatColor.RED + "Could not find a region with ID: " + id); player.sendMessage(ChatColor.RED + "Could not find a region with ID: " + id);
@ -929,7 +958,7 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
// Set a parent // Set a parent
if (parentId != null) { if (parentId != null) {
parent = regionManager.getRegion(parentId); parent = mgr.getRegion(parentId);
if (parent == null) { if (parent == null) {
player.sendMessage(ChatColor.RED + "Could not find a region with ID: " + parentId); player.sendMessage(ChatColor.RED + "Could not find a region with ID: " + parentId);
@ -946,7 +975,7 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
try { try {
region.setParent(parent); region.setParent(parent);
regionLoader.save(regionManager); mgr.save();
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated."); player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated.");
} catch (CircularInheritanceException e) { } catch (CircularInheritanceException e) {
player.sendMessage(ChatColor.RED + "Circular inheritance detected. The operation failed."); player.sendMessage(ChatColor.RED + "Circular inheritance detected. The operation failed.");
@ -962,14 +991,15 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
checkRegionPermission(player, "/regioninfo"); checkRegionPermission(player, "/regioninfo");
checkArgs(args, 1, 1, "/region info <id>"); checkArgs(args, 1, 1, "/region info <id>");
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
String id = args[0].toLowerCase(); String id = args[0].toLowerCase();
if (!regionManager.hasRegion(id)) { if (!mgr.hasRegion(id)) {
player.sendMessage(ChatColor.RED + "A region with ID '" player.sendMessage(ChatColor.RED + "A region with ID '"
+ id + "' doesn't exist."); + id + "' doesn't exist.");
return true; return true;
} }
ProtectedRegion region = regionManager.getRegion(id); ProtectedRegion region = mgr.getRegion(id);
AreaFlags flags = region.getFlags(); AreaFlags flags = region.getFlags();
DefaultDomain owners = region.getOwners(); DefaultDomain owners = region.getOwners();
DefaultDomain members = region.getMembers(); DefaultDomain members = region.getMembers();
@ -1010,15 +1040,16 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
checkArgs(args, 2, -1, "/region add[member|owner] <id> [player1 [group1 [players/groups...]]]"); checkArgs(args, 2, -1, "/region add[member|owner] <id> [player1 [group1 [players/groups...]]]");
boolean isOwner = action.equalsIgnoreCase("addowner"); boolean isOwner = action.equalsIgnoreCase("addowner");
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
String id = args[0].toLowerCase(); String id = args[0].toLowerCase();
if (!regionManager.hasRegion(id)) { if (!mgr.hasRegion(id)) {
player.sendMessage(ChatColor.RED + "A region with ID '" player.sendMessage(ChatColor.RED + "A region with ID '"
+ id + "' doesn't exist."); + id + "' doesn't exist.");
return true; return true;
} }
ProtectedRegion existing = regionManager.getRegion(id); ProtectedRegion existing = mgr.getRegion(id);
if (!canUseRegionCommand(player, "/regiondefine") if (!canUseRegionCommand(player, "/regiondefine")
&& !existing.isOwner(wrapPlayer(player))) { && !existing.isOwner(wrapPlayer(player))) {
@ -1033,7 +1064,7 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
} }
try { try {
regionLoader.save(regionManager); mgr.save();
player.sendMessage(ChatColor.YELLOW + "Region updated!"); player.sendMessage(ChatColor.YELLOW + "Region updated!");
player.sendMessage(ChatColor.GRAY + "Current owners: " player.sendMessage(ChatColor.GRAY + "Current owners: "
+ existing.getOwners().toUserFriendlyString()); + existing.getOwners().toUserFriendlyString());
@ -1054,15 +1085,16 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
checkArgs(args, 2, -1, "/region removeowner <id> [owner1 [owner2 [owners...]]]"); checkArgs(args, 2, -1, "/region removeowner <id> [owner1 [owner2 [owners...]]]");
boolean isOwner = action.equalsIgnoreCase("removeowner"); boolean isOwner = action.equalsIgnoreCase("removeowner");
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
String id = args[0].toLowerCase(); String id = args[0].toLowerCase();
if (!regionManager.hasRegion(id)) { if (!mgr.hasRegion(id)) {
player.sendMessage(ChatColor.RED + "A region with ID '" player.sendMessage(ChatColor.RED + "A region with ID '"
+ id + "' doesn't exist."); + id + "' doesn't exist.");
return true; return true;
} }
ProtectedRegion existing = regionManager.getRegion(id); ProtectedRegion existing = mgr.getRegion(id);
if (!canUseRegionCommand(player, "/regiondefine") if (!canUseRegionCommand(player, "/regiondefine")
&& !existing.isOwner(wrapPlayer(player))) { && !existing.isOwner(wrapPlayer(player))) {
@ -1077,7 +1109,7 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
} }
try { try {
regionLoader.save(regionManager); mgr.save();
player.sendMessage(ChatColor.YELLOW + "Region updated!"); player.sendMessage(ChatColor.YELLOW + "Region updated!");
player.sendMessage(ChatColor.GRAY + "Current owners: " player.sendMessage(ChatColor.GRAY + "Current owners: "
+ existing.getOwners().toUserFriendlyString()); + existing.getOwners().toUserFriendlyString());
@ -1105,7 +1137,8 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
} }
} }
Map<String,ProtectedRegion> regions = regionManager.getRegions(); RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
Map<String,ProtectedRegion> regions = mgr.getRegions();
int size = regions.size(); int size = regions.size();
int pages = (int)Math.ceil(size / (float)CMD_LIST_SIZE); int pages = (int)Math.ceil(size / (float)CMD_LIST_SIZE);
@ -1139,13 +1172,15 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
try { try {
String id = args[0].toLowerCase(); String id = args[0].toLowerCase();
if (!regionManager.hasRegion(id)) { RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
if (!mgr.hasRegion(id)) {
player.sendMessage(ChatColor.RED + "A region with ID '" player.sendMessage(ChatColor.RED + "A region with ID '"
+ id + "' doesn't exist."); + id + "' doesn't exist.");
return true; return true;
} }
ProtectedRegion existing = regionManager.getRegion(id); ProtectedRegion existing = mgr.getRegion(id);
if (!canUseRegionCommand(player, "/regiondelete") if (!canUseRegionCommand(player, "/regiondelete")
&& !existing.isOwner(wrapPlayer(player))) { && !existing.isOwner(wrapPlayer(player))) {
@ -1153,8 +1188,8 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
return true; return true;
} }
regionManager.removeRegion(id); mgr.removeRegion(id);
regionLoader.save(regionManager); mgr.save();
player.sendMessage(ChatColor.YELLOW + "Region removed!"); player.sendMessage(ChatColor.YELLOW + "Region removed!");
} catch (IOException e) { } catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: " player.sendMessage(ChatColor.RED + "Region database failed to save: "
@ -1169,7 +1204,8 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
checkArgs(args, 0, 0, "/region save"); checkArgs(args, 0, 0, "/region save");
try { try {
regionLoader.save(regionManager); RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
mgr.save();
player.sendMessage(ChatColor.YELLOW + "Region database saved to file!"); player.sendMessage(ChatColor.YELLOW + "Region database saved to file!");
} catch (IOException e) { } catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: " player.sendMessage(ChatColor.RED + "Region database failed to save: "
@ -1184,7 +1220,8 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
checkArgs(args, 0, 0, "/region load"); checkArgs(args, 0, 0, "/region load");
try { try {
regionLoader.load(regionManager); RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
mgr.load();
player.sendMessage(ChatColor.YELLOW + "Region database loaded from file!"); player.sendMessage(ChatColor.YELLOW + "Region database loaded from file!");
} catch (IOException e) { } catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to load: " player.sendMessage(ChatColor.RED + "Region database failed to load: "
@ -1341,27 +1378,41 @@ private void checkArgs(String[] args, int min, int max, String help)
* *
* @return * @return
*/ */
public RegionManager getRegionManager() { public GlobalRegionManager getGlobalRegionManager() {
return regionManager; return globalRegionManager;
}
/**
* Get the region loader.
*
* @return
*/
public ProtectionDatabase getRegionLoader() {
return regionLoader;
} }
public boolean canBuild(Player player, int x, int y, int z) { public boolean canBuild(Player player, int x, int y, int z) {
if (useRegions) { if (useRegions) {
Vector pt = new Vector(x, y, z); Vector pt = new Vector(x, y, z);
LocalPlayer localPlayer = wrapPlayer(player); LocalPlayer localPlayer = wrapPlayer(player);
if (!hasPermission(player, "/regionbypass") if (!hasPermission(player, "/regionbypass")) {
&& !regionManager.getApplicableRegions(pt).canBuild(localPlayer)) { RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
return false;
if (!mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
return false;
}
}
return true;
} else {
return true;
}
}
public boolean canBuild(Player player, Vector pt) {
if (useRegions) {
LocalPlayer localPlayer = wrapPlayer(player);
if (!hasPermission(player, "/regionbypass")) {
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
if (!mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
return false;
}
} }
return true; return true;

View File

@ -19,13 +19,15 @@
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.AreaFlags.State; import com.sk89q.worldguard.protection.regions.AreaFlags;
import com.sk89q.worldguard.protection.regions.AreaFlags.State;
/** /**
* Represents a set of regions and their rules as applied to one point. * Represents a set of regions and their rules as applied to one point.

View File

@ -19,6 +19,7 @@
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import java.util.Comparator; import java.util.Comparator;
class DescendingPriorityComparator implements Comparator<ProtectedRegion> { class DescendingPriorityComparator implements Comparator<ProtectedRegion> {

View File

@ -1,112 +0,0 @@
// $Id$
/*
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.protection;
import java.util.List;
import java.util.Map;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer;
/**
* An interface for getting, setting, and looking up regions. The most
* simple implementation uses a flat list and iterates through the entire
* list to look for applicable regions, but a more complicated (and more
* efficient) implementation may use space partitioning techniques.
*
* @author sk89q
*/
public interface RegionManager {
/**
* Get a list of protected regions.
*
* @return
*/
public Map<String, ProtectedRegion> getRegions();
/**
* Set a list of protected regions.
*
* @return
*/
public void setRegions(Map<String,ProtectedRegion> regions);
/**
* Adds a region.
*
* @param id
* @param region
*/
public void addRegion(ProtectedRegion region);
/**
* Return whether a region exists by an ID.
*
* @param id
* @return
*/
public boolean hasRegion(String id);
/**
* Get a region by its ID.
*
* @param id
*/
public ProtectedRegion getRegion(String id);
/**
* Removes a region, including inheriting children.
*
* @param id
*/
public void removeRegion(String id);
/**
* Get an object for a point for rules to be applied with.
*
* @param pt
* @return
*/
public ApplicableRegionSet getApplicableRegions(Vector pt);
/**
* Get a list of region IDs that contain a point.
*
* @param pt
* @return
*/
public List<String> getApplicableRegionsIDs(Vector pt);
/**
* Returns true if the provided region overlaps with any other region that
* is not owned by the player.
*
* @param region
* @param player
* @return
*/
public boolean overlapsUnownedRegion(ProtectedRegion region, LocalPlayer player);
/**
* Get the number of regions.
*
* @return
*/
public int size();
}

View File

@ -17,8 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection.dbs;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@ -31,8 +33,10 @@
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.AreaFlags.State; import com.sk89q.worldguard.protection.regions.AreaFlags;
import com.sk89q.worldguard.protection.ProtectedRegion.CircularInheritanceException; import com.sk89q.worldguard.protection.regions.AreaFlags.State;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException;
import com.sk89q.worldguard.util.ArrayReader; import com.sk89q.worldguard.util.ArrayReader;
/** /**

View File

@ -0,0 +1,109 @@
// $Id$
/*
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.protection.dbs;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.regions.AreaFlags;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
/**
*
* @author Redecouverte
*/
public class JSONContainer {
private static Logger logger = Logger.getLogger("Minecraft.WorldGuard");
private HashMap<String,ProtectedCuboidRegion> cRegions;
private HashMap<String,ProtectedPolygonalRegion> pRegions;
public JSONContainer(Map<String,ProtectedRegion> regions)
{
this.cRegions = new HashMap<String,ProtectedCuboidRegion>();
this.pRegions = new HashMap<String,ProtectedPolygonalRegion>();
for (Map.Entry<String,ProtectedRegion> entry : regions.entrySet()) {
String id = entry.getKey();
ProtectedRegion region = entry.getValue();
region.setParentId();
if(region instanceof ProtectedCuboidRegion)
{
cRegions.put(id, (ProtectedCuboidRegion)region);
}
else if(region instanceof ProtectedPolygonalRegion)
{
pRegions.put(id, (ProtectedPolygonalRegion)region);
}
else
{
logger.info("regions of type '" + region.getClass().toString() + "' are not supported for saving, yet.");
}
}
}
public Map<String, ProtectedRegion> getRegions() {
HashMap<String, ProtectedRegion> ret = new HashMap<String, ProtectedRegion>();
ret.putAll(this.cRegions);
ret.putAll(this.pRegions);
for (Map.Entry<String, ProtectedRegion> entry : ret.entrySet()) {
String id = entry.getKey();
ProtectedRegion region = entry.getValue();
String parentId = region.getParentId();
if (parentId != null) {
try {
region.setParent(ret.get(parentId));
} catch (CircularInheritanceException ex) {
}
} else {
try {
region.setParent(null);
} catch (CircularInheritanceException ex) {
}
}
if(region.getOwners() == null)
{
region.setOwners(new DefaultDomain());
}
else if(region.getMembers() == null)
{
region.setMembers(new DefaultDomain());
}
else if(region.getFlags() == null)
{
region.setFlags(new AreaFlags());
}
}
return ret;
}
}

View File

@ -0,0 +1,168 @@
// $Id$
/*
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.protection.dbs;
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
import com.sk89q.worldguard.protection.dbs.JSONContainer;
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.String;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
/**
* Represents a protected area database that uses JSON files.
*
* @author Redecouverte
*/
public class JSONDatabase implements ProtectionDatabase {
private static Logger logger = Logger.getLogger("Minecraft.WorldGuard");
/**
* References the json db folder.
*/
private File file;
/**
* Holds the list of regions.
*/
private Map<String,ProtectedRegion> regions;
/**
* Construct the database with a path to a file. No file is read or
* written at this time.
*
* @param file
*/
public JSONDatabase(File file) {
this.file = file;
}
/**
* Helper function to read a file into a String
*/
private static String readFileAsString(File file) throws java.io.IOException {
byte[] buffer = new byte[(int) file.length()];
BufferedInputStream f = null;
try {
f = new BufferedInputStream(new FileInputStream(file.getAbsolutePath()));
f.read(buffer);
} finally {
if (f != null) {
try {
f.close();
} catch (IOException ignored) {
}
}
}
return new String(buffer);
}
/**
* Load the database from file.
*/
public void load() throws IOException {
Gson gson = new Gson();
JSONContainer jContainer = gson.fromJson(readFileAsString(file), JSONContainer.class);
this.regions = jContainer.getRegions();
}
/**
* Saves the database.
*/
public void save() throws IOException {
Gson gson = new Gson();
String jsonData = gson.toJson(new JSONContainer(this.regions), JSONContainer.class);
writeStringToFile(jsonData, this.file);
}
/**
* Writes a String to a file.
*
* @throws IOException
*/
public static void writeStringToFile(String string, File file) throws IOException {
FileWriter writer = null;
try {
writer = new FileWriter(file);
writer.write(string);
} finally {
try {
if (writer != null) {
writer.close();
}
} catch (IOException e) {
}
}
}
/**
* Load the list of regions into a region manager.
*
* @throws IOException
*/
public void load(RegionManager manager) throws IOException {
load();
manager.setRegions(regions);
}
/**
* Save the list of regions from a region manager.
*
* @throws IOException
*/
public void save(RegionManager manager) throws IOException {
regions = manager.getRegions();
save();
}
/**
* Get a list of protected regions.
*
* @return
*/
public Map<String,ProtectedRegion> getRegions() {
return regions;
}
/**
* Get a list of protected regions.
*
* @return
*/
public void setRegions(Map<String,ProtectedRegion> regions) {
this.regions = regions;
}
}

View File

@ -17,8 +17,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection.dbs;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;

View File

@ -17,8 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection.regionmanager;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -26,6 +27,14 @@
import java.util.TreeMap; import java.util.TreeMap;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.GlobalFlags;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
import java.io.FileNotFoundException;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* A very simple implementation of the region manager that uses a flat list * A very simple implementation of the region manager that uses a flat list
@ -34,22 +43,21 @@
* *
* @author sk89q * @author sk89q
*/ */
public class FlatRegionManager implements RegionManager { public class FlatRegionManager extends RegionManager {
/** /**
* List of protected regions. * List of protected regions.
*/ */
private Map<String,ProtectedRegion> regions; private Map<String,ProtectedRegion> regions;
/**
* Global flags.
*/
private GlobalFlags global;
/** /**
* Construct the manager. * Construct the manager.
*/ */
public FlatRegionManager(GlobalFlags global) { public FlatRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
regions = new TreeMap<String,ProtectedRegion>();
this.global = global; super(global, regionloader);
regions = new TreeMap<String,ProtectedRegion>();
this.load();
} }
/** /**
@ -180,4 +188,21 @@ public boolean overlapsUnownedRegion(ProtectedRegion region, LocalPlayer player)
public int size() { public int size() {
return regions.size(); return regions.size();
} }
/**
* Save the list of regions.
*
* @throws IOException
*/
public void save() throws IOException
{
if(this.regionloader == null)
{
return;
}
regionloader.save(this);
}
} }

View File

@ -0,0 +1,89 @@
// $Id$
/*
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.protection.regionmanager;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.GlobalFlags;
import com.sk89q.worldguard.protection.dbs.JSONDatabase;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.bukkit.World;
/**
*
* @author Redecouverte
*/
public class GlobalRegionManager {
private WorldGuardPlugin wg;
private HashMap<String, RegionManager> managers;
private GlobalFlags globalFlags;
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
public GlobalRegionManager(WorldGuardPlugin wg) {
this.wg = wg;
this.managers = new HashMap<String, RegionManager>();
this.globalFlags = new GlobalFlags();
for (World w : wg.getServer().getWorlds()) {
loadWorld(w.getName());
}
}
private void loadWorld(String name) {
String filename = name + ".regions.json";
try {
managers.put(name, new FlatRegionManager(globalFlags, new JSONDatabase(new File(wg.getDataFolder(), filename))));
} catch (FileNotFoundException e) {
} catch (IOException e) {
logger.warning("WorldGuard: Failed to load regions from file " + filename + " : "
+ e.getMessage());
}
}
public RegionManager getRegionmanager(String worldName) {
RegionManager ret = this.managers.get(worldName);
if (ret == null) {
if (wg.getServer().getWorld(worldName) != null) {
loadWorld(worldName);
}
}
return ret;
}
public void setGlobalFlags(GlobalFlags globalflags) {
if (globalflags != null) {
this.globalFlags = globalflags;
for (Map.Entry<String, RegionManager> entry : managers.entrySet()) {
entry.getValue().setGlobalFlags(globalflags);
}
}
}
}

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection.regionmanager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -28,18 +28,22 @@
import org.khelekore.prtree.PRTree; import org.khelekore.prtree.PRTree;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.GlobalFlags;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegionMBRConverter;
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
import java.io.IOException;
import java.util.HashMap;
public class PRTreeRegionManager implements RegionManager { public class PRTreeRegionManager extends RegionManager {
private static final int BRANCH_FACTOR = 30; private static final int BRANCH_FACTOR = 30;
/** /**
* List of protected regions. * List of protected regions.
*/ */
private Map<String,ProtectedRegion> regions; private Map<String,ProtectedRegion> regions;
/**
* Global flags.
*/
private GlobalFlags global;
/** /**
* Converter to get coordinates of the tree. * Converter to get coordinates of the tree.
@ -55,10 +59,11 @@ public class PRTreeRegionManager implements RegionManager {
/** /**
* Construct the manager. * Construct the manager.
*/ */
public PRTreeRegionManager(GlobalFlags global) { public PRTreeRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
super(global, regionloader);
regions = new TreeMap<String,ProtectedRegion>(); regions = new TreeMap<String,ProtectedRegion>();
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR); tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
this.global = global; this.load();
} }
/** /**
@ -200,4 +205,14 @@ public int size() {
return regions.size(); return regions.size();
} }
/**
* Save the list of regions.
*
* @throws IOException
*/
public void save() throws IOException
{
regionloader.save(this);
}
} }

View File

@ -0,0 +1,181 @@
// $Id$
/*
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.protection.regionmanager;
import java.util.List;
import java.util.Map;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.GlobalFlags;
import com.sk89q.worldguard.protection.dbs.ProtectionDatabase;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.logging.Logger;
/**
* An abstract class for getting, setting, and looking up regions. The most
* simple implementation uses a flat list and iterates through the entire
* list to look for applicable regions, but a more complicated (and more
* efficient) implementation may use space partitioning techniques.
*
* @author sk89q
*/
public abstract class RegionManager {
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
/**
* Global flags.
*/
protected GlobalFlags global;
protected ProtectionDatabase regionloader;
public RegionManager(GlobalFlags global, ProtectionDatabase regionloader)
{
this.global = global;
this.regionloader = regionloader;
}
/**
* Load the list of regions.
*
* @throws IOException
*/
public void load() throws IOException
{
if(this.regionloader == null)
{
return;
}
try {
this.regionloader.load();
this.setRegions(this.regionloader.getRegions());
} catch (FileNotFoundException e) {
} catch (IOException e) {
logger.warning("WorldGuard: Failed to load regions: "
+ e.getMessage());
}
}
/**
* Save the list of regions.
*
* @throws IOException
*/
public abstract void save() throws IOException;
/**
* Get a list of protected regions.
*
* @return
*/
public abstract Map<String, ProtectedRegion> getRegions();
/**
* Set a list of protected regions.
*
* @return
*/
public abstract void setRegions(Map<String,ProtectedRegion> regions);
/**
* Adds a region.
*
* @param id
* @param region
*/
public abstract void addRegion(ProtectedRegion region);
/**
* Return whether a region exists by an ID.
*
* @param id
* @return
*/
public abstract boolean hasRegion(String id);
/**
* Get a region by its ID.
*
* @param id
*/
public abstract ProtectedRegion getRegion(String id);
/**
* Removes a region, including inheriting children.
*
* @param id
*/
public abstract void removeRegion(String id);
/**
* Get an object for a point for rules to be applied with.
*
* @param pt
* @return
*/
public abstract ApplicableRegionSet getApplicableRegions(Vector pt);
/**
* Get a list of region IDs that contain a point.
*
* @param pt
* @return
*/
public abstract List<String> getApplicableRegionsIDs(Vector pt);
/**
* Returns true if the provided region overlaps with any other region that
* is not owned by the player.
*
* @param region
* @param player
* @return
*/
public abstract boolean overlapsUnownedRegion(ProtectedRegion region, LocalPlayer player);
/**
* Get the number of regions.
*
* @return
*/
public abstract int size();
/**
* Sets the global flags.
*
* @return
*/
public void setGlobalFlags(GlobalFlags globalflags)
{
global = globalflags;
}
}

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection.regions;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection.regions;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;

View File

@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection.regions;
import java.util.List; import java.util.List;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;

View File

@ -17,12 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection.regions;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer; import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
/** /**
* Represents a region of any shape and size that can be protected. * Represents a region of any shape and size that can be protected.
@ -39,9 +40,13 @@ public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
*/ */
private int priority = 0; private int priority = 0;
/** /**
* Parent region. * Holds the parent.
*/ */
private ProtectedRegion parent; private transient ProtectedRegion parent;
/**
* Holds the parent's Id. Used for serialization, don't touch it.
*/
private String parentId;
/** /**
* List of owners. * List of owners.
*/ */
@ -79,6 +84,26 @@ public String getId() {
return id; return id;
} }
/**
* @return the parentId.
*/
public String getParentId() {
this.setParentId();
return parentId;
}
/**
* @set the parentId. Used for serialization, don't touch it.
*/
public void setParentId() {
if (this.parent != null) {
this.parentId = parent.getId();
} else {
this.parentId = null;
}
}
/** /**
* Get the lower point of the cuboid. * Get the lower point of the cuboid.
* *
@ -182,6 +207,7 @@ public void setLeaveMessage(String leaveMessage) {
* @return the owners * @return the owners
*/ */
public DefaultDomain getOwners() { public DefaultDomain getOwners() {
return owners; return owners;
} }
@ -196,6 +222,7 @@ public void setOwners(DefaultDomain owners) {
* @return the members * @return the members
*/ */
public DefaultDomain getMembers() { public DefaultDomain getMembers() {
return members; return members;
} }

View File

@ -17,8 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection.regions;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.khelekore.prtree.MBRConverter; import org.khelekore.prtree.MBRConverter;
public class ProtectedRegionMBRConverter implements MBRConverter<ProtectedRegion> { public class ProtectedRegionMBRConverter implements MBRConverter<ProtectedRegion> {

View File

@ -19,6 +19,11 @@
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
import com.sk89q.worldguard.protection.regionmanager.FlatRegionManager;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
@ -27,7 +32,8 @@
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.TestPlayer; import com.sk89q.worldguard.TestPlayer;
import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.AreaFlags.State; import com.sk89q.worldguard.protection.regions.AreaFlags;
import com.sk89q.worldguard.protection.regions.AreaFlags.State;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -50,7 +56,7 @@ public class ApplicableRegionSetTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
manager = new FlatRegionManager(new GlobalFlags()); manager = new FlatRegionManager(new GlobalFlags(), null);
setUpPlayers(); setUpPlayers();
setUpCourtyardRegion(); setUpCourtyardRegion();

View File

@ -19,6 +19,9 @@
package com.sk89q.worldguard.protection; package com.sk89q.worldguard.protection;
import com.sk89q.worldguard.protection.dbs.CSVDatabase;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import java.io.*; import java.io.*;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
@ -28,7 +31,8 @@
import static org.junit.Assert.*; import static org.junit.Assert.*;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.AreaFlags.State; import com.sk89q.worldguard.protection.regions.AreaFlags;
import com.sk89q.worldguard.protection.regions.AreaFlags.State;
public class CSVDatabaseTest { public class CSVDatabaseTest {
@Before @Before