mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-24 03:25:24 +01:00
added multiworld support for regions and json region database
This commit is contained in:
parent
4505bb6f4e
commit
f61a9ab5cc
@ -14,7 +14,7 @@
|
||||
<include name="Bukkit.jar" />
|
||||
<include name="WorldEdit.jar" />
|
||||
<include name="prtree.jar" />
|
||||
<include name="json-simple-1.1.jar" />
|
||||
<include name="gson-1.7-SNAPSHOT.jar" />
|
||||
</fileset>
|
||||
|
||||
<target name="init">
|
||||
@ -47,7 +47,7 @@
|
||||
<copy tofile="${build.dir}/defaults/blacklist.txt" file="blacklist.txt"/>
|
||||
<jar jarfile="${dist.dir}/WorldGuard.jar" basedir="${build.dir}" manifest="manifest.mf">
|
||||
<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>
|
||||
</target>
|
||||
|
||||
|
BIN
lib/gson-1.7-SNAPSHOT.jar
Normal file
BIN
lib/gson-1.7-SNAPSHOT.jar
Normal file
Binary file not shown.
Binary file not shown.
@ -27,7 +27,7 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
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.truezip.jar=lib/truezip.jar
|
||||
file.reference.WorldEdit.jar=lib/WorldEdit.jar
|
||||
@ -38,7 +38,7 @@ javac.classpath=\
|
||||
${file.reference.prtree.jar}:\
|
||||
${file.reference.truezip.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
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.bukkit.block.Block;
|
||||
@ -35,7 +36,7 @@
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.events.*;
|
||||
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.*;
|
||||
|
||||
public class WorldGuardBlockListener extends BlockListener {
|
||||
@ -70,10 +71,8 @@ public void onBlockDamage(BlockDamageEvent event) {
|
||||
|
||||
if (plugin.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) {
|
||||
Vector pt = toVector(blockDamaged);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (!plugin.hasPermission(player, "/regionbypass")
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
if (!plugin.canBuild(player, pt)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!");
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -105,10 +104,8 @@ public void onBlockBreak(BlockBreakEvent event) {
|
||||
|
||||
if (plugin.useRegions) {
|
||||
Vector pt = BukkitUtil.toVector(event.getBlock());
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (!plugin.hasPermission(player, "/regionbypass")
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
if (!plugin.canBuild(player, pt)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -274,26 +271,26 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
&& !plugin.globalRegionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !plugin.regionManager.getApplicableRegions(pt)
|
||||
&& !plugin.globalRegionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_LIGHTER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
f (isFireSpread && !plugin.regionManager.getApplicableRegions(pt)
|
||||
f (isFireSpread && !plugin.globalRegionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.LAVA && !plugin.regionManager.getApplicableRegions(pt)
|
||||
if (cause == IgniteCause.LAVA && !plugin.globalRegionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_LAVA_FIRE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -391,10 +388,11 @@ public void onBlockInteract(BlockInteractEvent event) {
|
||||
if (plugin.useRegions) {
|
||||
Vector pt = toVector(block);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionmanager(player.getWorld().getName());
|
||||
|
||||
if (!plugin.hasPermission(player, "/regionbypass")
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).allowsFlag(AreaFlags.FLAG_CHEST_ACCESS)
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
&& !mgr.getApplicableRegions(pt).allowsFlag(AreaFlags.FLAG_CHEST_ACCESS)
|
||||
&& !mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -433,10 +431,8 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
||||
|
||||
if (plugin.useRegions) {
|
||||
Vector pt = toVector(blockPlaced);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (!plugin.hasPermission(player, "/regionbypass")
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
if (!plugin.canBuild(player, pt)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -478,8 +474,10 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
||||
|
||||
if (plugin.useRegions && event.getItemInHand().getTypeId() == plugin.regionWand) {
|
||||
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) {
|
||||
player.sendMessage(ChatColor.YELLOW + "Can you build? "
|
||||
@ -504,10 +502,8 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
||||
if (plugin.useRegions && type == Material.CAKE_BLOCK) {
|
||||
|
||||
Vector pt = toVector(blockClicked);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (!plugin.hasPermission(player, "/regionbypass")
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
if (!plugin.canBuild(player, pt)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
|
||||
byte newData = (byte) (blockClicked.getData() - 1);
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@ -32,7 +33,7 @@
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
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.*;
|
||||
|
||||
public class WorldGuardEntityListener extends EntityListener {
|
||||
@ -91,8 +92,9 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
if (plugin.useRegions) {
|
||||
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)) {
|
||||
((Player)attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||
event.setCancelled(true);
|
||||
@ -109,15 +111,16 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
|
||||
if (plugin.useRegions) {
|
||||
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)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Creeper) {
|
||||
if (!plugin.regionManager.getApplicableRegions(pt)
|
||||
if (!mgr.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -144,8 +147,9 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
if (plugin.useRegions) {
|
||||
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)) {
|
||||
((Player)attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||
event.setCancelled(true);
|
||||
@ -156,8 +160,9 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
if (attacker != null && attacker instanceof Skeleton) {
|
||||
if (plugin.useRegions) {
|
||||
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)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -254,8 +259,9 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
|
||||
if (plugin.useRegions) {
|
||||
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)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -269,8 +275,9 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
||||
|
||||
if (plugin.useRegions && event.getEntity() != null) {
|
||||
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)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.blacklist.events.ItemAcquireBlacklistEvent;
|
||||
import org.bukkit.entity.Item;
|
||||
import com.sk89q.worldguard.blacklist.events.ItemDropBlacklistEvent;
|
||||
@ -30,7 +31,7 @@
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.*;
|
||||
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.*;
|
||||
|
||||
/**
|
||||
@ -116,10 +117,8 @@ public void onPlayerItem(PlayerItemEvent event) {
|
||||
|
||||
if (plugin.useRegions && !event.isBlock() && block != null) {
|
||||
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (!plugin.hasPermission(player, "/regionbypass")
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
if (!plugin.canBuild(player, pt)) {
|
||||
player.sendMessage(ChatColor.DARK_RED
|
||||
+ "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
@ -139,8 +138,9 @@ public void onPlayerItem(PlayerItemEvent event) {
|
||||
|
||||
if (plugin.useRegions && item != null && block != null && item.getTypeId() == 259) {
|
||||
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)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -19,8 +19,11 @@
|
||||
|
||||
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.toVector;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
@ -31,14 +34,12 @@
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginLoader;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
import com.sk89q.bukkit.migration.PermissionsResolverManager;
|
||||
@ -49,7 +50,6 @@
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditAPI;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
@ -58,8 +58,12 @@
|
||||
import com.sk89q.worldguard.blacklist.loggers.*;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.*;
|
||||
import com.sk89q.worldguard.protection.AreaFlags.State;
|
||||
import com.sk89q.worldguard.protection.ProtectedRegion.CircularInheritanceException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.GlobalRegionManager;
|
||||
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.
|
||||
@ -84,9 +88,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
|
||||
Blacklist blacklist;
|
||||
|
||||
GlobalFlags globalFlags = new GlobalFlags();
|
||||
RegionManager regionManager = new FlatRegionManager(globalFlags);
|
||||
ProtectionDatabase regionLoader;
|
||||
GlobalRegionManager globalRegionManager;
|
||||
|
||||
Set<String> invinciblePlayers = new HashSet<String>();
|
||||
Set<String> amphibiousPlayers = new HashSet<String>();
|
||||
@ -158,7 +160,8 @@ public void onEnable() {
|
||||
createDefaultConfiguration("config.yml");
|
||||
createDefaultConfiguration("blacklist.txt");
|
||||
|
||||
regionLoader = new CSVDatabase(new File(folder, "regions.txt"));
|
||||
globalRegionManager = new GlobalRegionManager(this);
|
||||
|
||||
perms = new PermissionsResolverManager(getConfiguration(), getServer(),
|
||||
"WorldGuard", logger);
|
||||
permsListener = new PermissionsResolverServerListener(perms);
|
||||
@ -316,6 +319,8 @@ public void loadConfiguration() {
|
||||
|
||||
useRegions = config.getBoolean("regions.enable", true);
|
||||
regionWand = config.getInt("regions.wand", 287);
|
||||
|
||||
GlobalFlags globalFlags = new GlobalFlags();
|
||||
globalFlags.canBuild = config.getBoolean("regions.default.build", true);
|
||||
globalFlags.canAccessChests = config.getBoolean("regions.default.chest-access", false);
|
||||
globalFlags.canPvP = config.getBoolean("regions.default.pvp", true);
|
||||
@ -323,10 +328,29 @@ public void loadConfiguration() {
|
||||
globalFlags.canTnt = config.getBoolean("regions.default.tnt", true);
|
||||
globalFlags.allowCreeper = config.getBoolean("regions.default.creeper", true);
|
||||
globalFlags.allowMobDamage = config.getBoolean("regions.default.mobdamage", true);
|
||||
globalRegionManager.setGlobalFlags(globalFlags);
|
||||
|
||||
try {
|
||||
regionLoader.load();
|
||||
regionManager.setRegions(regionLoader.getRegions());
|
||||
File CSVfile = new File(this.getDataFolder(), "regions.txt");
|
||||
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 (IOException e) {
|
||||
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();
|
||||
|
||||
WorldEditPlugin worldEdit = (WorldEditPlugin)wePlugin;
|
||||
World w = player.getWorld();
|
||||
|
||||
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 max = weRegion.getMaximumPoint().toBlockVector();
|
||||
@ -791,8 +816,9 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
|
||||
if (args.length >= 2) {
|
||||
region.setOwners(parseDomainString(args, 1));
|
||||
}
|
||||
regionManager.addRegion(region);
|
||||
regionLoader.save(regionManager);
|
||||
RegionManager mgr = globalRegionManager.getRegionmanager(w.getName());
|
||||
mgr.addRegion(region);
|
||||
mgr.save();
|
||||
player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
|
||||
} catch (IncompleteRegionException e) {
|
||||
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 {
|
||||
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.getOwners().contains(wrapPlayer(player))) {
|
||||
@ -830,15 +857,15 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
|
||||
|
||||
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.");
|
||||
return true;
|
||||
}
|
||||
|
||||
region.getOwners().addPlayer(player.getName());
|
||||
|
||||
regionManager.addRegion(region);
|
||||
regionLoader.save(regionManager);
|
||||
mgr.addRegion(region);
|
||||
mgr.save();
|
||||
player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
|
||||
} catch (IncompleteRegionException e) {
|
||||
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 flagStr = args[1];
|
||||
String stateStr = args[2];
|
||||
ProtectedRegion region = regionManager.getRegion(id);
|
||||
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
|
||||
ProtectedRegion region = mgr.getRegion(id);
|
||||
|
||||
if (region == null) {
|
||||
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();
|
||||
flags.set(flagStr, state);
|
||||
regionLoader.save(regionManager);
|
||||
mgr.save();
|
||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated.");
|
||||
} catch (IOException e) {
|
||||
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 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) {
|
||||
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
|
||||
if (parentId != null) {
|
||||
parent = regionManager.getRegion(parentId);
|
||||
parent = mgr.getRegion(parentId);
|
||||
|
||||
if (parent == null) {
|
||||
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 {
|
||||
region.setParent(parent);
|
||||
|
||||
regionLoader.save(regionManager);
|
||||
mgr.save();
|
||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated.");
|
||||
} catch (CircularInheritanceException e) {
|
||||
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");
|
||||
checkArgs(args, 1, 1, "/region info <id>");
|
||||
|
||||
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
|
||||
String id = args[0].toLowerCase();
|
||||
if (!regionManager.hasRegion(id)) {
|
||||
if (!mgr.hasRegion(id)) {
|
||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
||||
+ id + "' doesn't exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion region = regionManager.getRegion(id);
|
||||
ProtectedRegion region = mgr.getRegion(id);
|
||||
AreaFlags flags = region.getFlags();
|
||||
DefaultDomain owners = region.getOwners();
|
||||
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...]]]");
|
||||
|
||||
boolean isOwner = action.equalsIgnoreCase("addowner");
|
||||
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
|
||||
|
||||
String id = args[0].toLowerCase();
|
||||
if (!regionManager.hasRegion(id)) {
|
||||
if (!mgr.hasRegion(id)) {
|
||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
||||
+ id + "' doesn't exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion existing = regionManager.getRegion(id);
|
||||
ProtectedRegion existing = mgr.getRegion(id);
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondefine")
|
||||
&& !existing.isOwner(wrapPlayer(player))) {
|
||||
@ -1033,7 +1064,7 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
|
||||
}
|
||||
|
||||
try {
|
||||
regionLoader.save(regionManager);
|
||||
mgr.save();
|
||||
player.sendMessage(ChatColor.YELLOW + "Region updated!");
|
||||
player.sendMessage(ChatColor.GRAY + "Current owners: "
|
||||
+ 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...]]]");
|
||||
|
||||
boolean isOwner = action.equalsIgnoreCase("removeowner");
|
||||
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
|
||||
|
||||
String id = args[0].toLowerCase();
|
||||
if (!regionManager.hasRegion(id)) {
|
||||
if (!mgr.hasRegion(id)) {
|
||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
||||
+ id + "' doesn't exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion existing = regionManager.getRegion(id);
|
||||
ProtectedRegion existing = mgr.getRegion(id);
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondefine")
|
||||
&& !existing.isOwner(wrapPlayer(player))) {
|
||||
@ -1077,7 +1109,7 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
|
||||
}
|
||||
|
||||
try {
|
||||
regionLoader.save(regionManager);
|
||||
mgr.save();
|
||||
player.sendMessage(ChatColor.YELLOW + "Region updated!");
|
||||
player.sendMessage(ChatColor.GRAY + "Current owners: "
|
||||
+ 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 pages = (int)Math.ceil(size / (float)CMD_LIST_SIZE);
|
||||
|
||||
@ -1139,13 +1172,15 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
|
||||
|
||||
try {
|
||||
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 '"
|
||||
+ id + "' doesn't exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion existing = regionManager.getRegion(id);
|
||||
ProtectedRegion existing = mgr.getRegion(id);
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondelete")
|
||||
&& !existing.isOwner(wrapPlayer(player))) {
|
||||
@ -1153,8 +1188,8 @@ private boolean handleRegionCommand(Player player, String action, String[] args)
|
||||
return true;
|
||||
}
|
||||
|
||||
regionManager.removeRegion(id);
|
||||
regionLoader.save(regionManager);
|
||||
mgr.removeRegion(id);
|
||||
mgr.save();
|
||||
player.sendMessage(ChatColor.YELLOW + "Region removed!");
|
||||
} catch (IOException e) {
|
||||
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");
|
||||
|
||||
try {
|
||||
regionLoader.save(regionManager);
|
||||
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
|
||||
mgr.save();
|
||||
player.sendMessage(ChatColor.YELLOW + "Region database saved to file!");
|
||||
} catch (IOException e) {
|
||||
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");
|
||||
|
||||
try {
|
||||
regionLoader.load(regionManager);
|
||||
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
|
||||
mgr.load();
|
||||
player.sendMessage(ChatColor.YELLOW + "Region database loaded from file!");
|
||||
} catch (IOException e) {
|
||||
player.sendMessage(ChatColor.RED + "Region database failed to load: "
|
||||
@ -1341,28 +1378,42 @@ private void checkArgs(String[] args, int min, int max, String help)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RegionManager getRegionManager() {
|
||||
return regionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the region loader.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ProtectionDatabase getRegionLoader() {
|
||||
return regionLoader;
|
||||
public GlobalRegionManager getGlobalRegionManager() {
|
||||
return globalRegionManager;
|
||||
}
|
||||
|
||||
public boolean canBuild(Player player, int x, int y, int z) {
|
||||
|
||||
if (useRegions) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
LocalPlayer localPlayer = wrapPlayer(player);
|
||||
|
||||
if (!hasPermission(player, "/regionbypass")
|
||||
&& !regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
if (!hasPermission(player, "/regionbypass")) {
|
||||
RegionManager mgr = globalRegionManager.getRegionmanager(player.getWorld().getName());
|
||||
|
||||
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;
|
||||
} else {
|
||||
|
@ -19,13 +19,15 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
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.
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import java.util.Comparator;
|
||||
|
||||
class DescendingPriorityComparator implements Comparator<ProtectedRegion> {
|
||||
|
@ -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();
|
||||
}
|
@ -17,8 +17,10 @@
|
||||
* 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.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@ -31,8 +33,10 @@
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.AreaFlags.State;
|
||||
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 com.sk89q.worldguard.util.ArrayReader;
|
||||
|
||||
/**
|
109
src/com/sk89q/worldguard/protection/dbs/JSONContainer.java
Normal file
109
src/com/sk89q/worldguard/protection/dbs/JSONContainer.java
Normal 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;
|
||||
}
|
||||
}
|
168
src/com/sk89q/worldguard/protection/dbs/JSONDatabase.java
Normal file
168
src/com/sk89q/worldguard/protection/dbs/JSONDatabase.java
Normal 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;
|
||||
}
|
||||
}
|
@ -17,8 +17,10 @@
|
||||
* 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.util.Map;
|
||||
|
@ -17,8 +17,9 @@
|
||||
* 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.List;
|
||||
import java.util.Map;
|
||||
@ -26,6 +27,14 @@
|
||||
import java.util.TreeMap;
|
||||
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.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
|
||||
@ -34,22 +43,21 @@
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class FlatRegionManager implements RegionManager {
|
||||
public class FlatRegionManager extends RegionManager {
|
||||
/**
|
||||
* List of protected regions.
|
||||
*/
|
||||
private Map<String,ProtectedRegion> regions;
|
||||
/**
|
||||
* Global flags.
|
||||
*/
|
||||
private GlobalFlags global;
|
||||
|
||||
|
||||
/**
|
||||
* Construct the manager.
|
||||
*/
|
||||
public FlatRegionManager(GlobalFlags global) {
|
||||
public FlatRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
|
||||
|
||||
super(global, regionloader);
|
||||
regions = new TreeMap<String,ProtectedRegion>();
|
||||
this.global = global;
|
||||
this.load();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,4 +188,21 @@ public boolean overlapsUnownedRegion(ProtectedRegion region, LocalPlayer player)
|
||||
public int size() {
|
||||
return regions.size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save the list of regions.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void save() throws IOException
|
||||
{
|
||||
if(this.regionloader == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
regionloader.save(this);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* 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.Collections;
|
||||
@ -28,18 +28,22 @@
|
||||
import org.khelekore.prtree.PRTree;
|
||||
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.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;
|
||||
|
||||
/**
|
||||
* List of protected regions.
|
||||
*/
|
||||
private Map<String,ProtectedRegion> regions;
|
||||
/**
|
||||
* Global flags.
|
||||
*/
|
||||
private GlobalFlags global;
|
||||
|
||||
/**
|
||||
* Converter to get coordinates of the tree.
|
||||
@ -55,10 +59,11 @@ public class PRTreeRegionManager implements RegionManager {
|
||||
/**
|
||||
* Construct the manager.
|
||||
*/
|
||||
public PRTreeRegionManager(GlobalFlags global) {
|
||||
public PRTreeRegionManager(GlobalFlags global, ProtectionDatabase regionloader) throws IOException {
|
||||
super(global, regionloader);
|
||||
regions = new TreeMap<String,ProtectedRegion>();
|
||||
tree = new PRTree<ProtectedRegion>(converter, BRANCH_FACTOR);
|
||||
this.global = global;
|
||||
this.load();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -200,4 +205,14 @@ public int size() {
|
||||
return regions.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the list of regions.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void save() throws IOException
|
||||
{
|
||||
regionloader.save(this);
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
* 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.Map;
|
@ -17,7 +17,7 @@
|
||||
* 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.*;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* 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 com.sk89q.worldedit.BlockVector;
|
@ -17,12 +17,13 @@
|
||||
* 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.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
@ -79,6 +84,26 @@ public String getId() {
|
||||
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.
|
||||
*
|
||||
@ -182,6 +207,7 @@ public void setLeaveMessage(String leaveMessage) {
|
||||
* @return the owners
|
||||
*/
|
||||
public DefaultDomain getOwners() {
|
||||
|
||||
return owners;
|
||||
}
|
||||
|
||||
@ -196,6 +222,7 @@ public void setOwners(DefaultDomain owners) {
|
||||
* @return the members
|
||||
*/
|
||||
public DefaultDomain getMembers() {
|
||||
|
||||
return members;
|
||||
}
|
||||
|
@ -17,8 +17,9 @@
|
||||
* 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;
|
||||
|
||||
public class ProtectedRegionMBRConverter implements MBRConverter<ProtectedRegion> {
|
@ -19,6 +19,11 @@
|
||||
|
||||
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.Test;
|
||||
import static org.junit.Assert.*;
|
||||
@ -27,7 +32,8 @@
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
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.List;
|
||||
|
||||
@ -50,7 +56,7 @@ public class ApplicableRegionSetTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
manager = new FlatRegionManager(new GlobalFlags());
|
||||
manager = new FlatRegionManager(new GlobalFlags(), null);
|
||||
|
||||
setUpPlayers();
|
||||
setUpCourtyardRegion();
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
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.util.Map;
|
||||
import java.util.HashMap;
|
||||
@ -28,7 +31,8 @@
|
||||
import static org.junit.Assert.*;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
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 {
|
||||
@Before
|
||||
|
Loading…
Reference in New Issue
Block a user