Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5be31ebb5c | ||
|
|
962394b2ba | ||
|
|
7cf7c5f44c | ||
|
|
5b494a09ec | ||
|
|
5cfac5da4a | ||
|
|
203004951b | ||
|
|
765d7402fa | ||
|
|
151b5fc561 | ||
|
|
b489da7fe4 | ||
|
|
786a0f6f2b | ||
|
|
e2a940e01b | ||
|
|
518c3be478 | ||
|
|
6f3eaac008 | ||
|
|
31633e9466 | ||
|
|
02913780ec | ||
|
|
f03a2263d8 | ||
|
|
a8cd832c28 |
No files matched your search
@@ -1,3 +1,21 @@
|
||||
3.0b2:
|
||||
- Fixed issue where built-in permissions were not (re)loaded.
|
||||
- Fixed /god not working for others.
|
||||
|
||||
3.0b1:
|
||||
- Added parent-child relationships to regions.
|
||||
- Added global build flag.
|
||||
- Improved flag support.
|
||||
- Fixed no-PvP zone messages being sent to the wrong person.
|
||||
- Fixed commands so that they work in a recent version of Bukkit.
|
||||
- Fixed NullPointerException in explode hook.
|
||||
|
||||
2.3.1:
|
||||
- Fixed various cast exceptions with the blacklist loggers.
|
||||
- Added checks for unchecked exceptions when resolving permissions.
|
||||
- Fixed the item durability disable setting changing the damage value on
|
||||
an empty hand.
|
||||
|
||||
2.3:
|
||||
- /god now works very well.
|
||||
- Item (TNT, flint and steel, etc.) blocking should now work.
|
||||
|
||||
@@ -70,6 +70,8 @@ player-damage:
|
||||
regions:
|
||||
enable: on
|
||||
wand: 287
|
||||
default:
|
||||
build: true
|
||||
|
||||
blacklist:
|
||||
logging:
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ commands:
|
||||
aliases: ;
|
||||
region:
|
||||
description: Adjust protected regions
|
||||
usage: /<command> <define|claim|flag|delete|info|addowner|removeowner|list|save|load> ...
|
||||
usage: /<command> <define|claim|setparent|flag|delete|info|addowner|removeowner|addmember|removemember|list|save|load> ...
|
||||
aliases: rg, regions
|
||||
locate:
|
||||
description: Set your compass towards a person
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard;
|
||||
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
public abstract class LocalPlayer {
|
||||
|
||||
@@ -56,8 +56,8 @@ public class ConsoleLoggerHandler implements BlacklistLoggerHandler {
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
|
||||
// Block interact
|
||||
} else if (event instanceof BlockPlaceBlacklistEvent) {
|
||||
BlockPlaceBlacklistEvent evt = (BlockPlaceBlacklistEvent)event;
|
||||
} else if (event instanceof BlockInteractBlacklistEvent) {
|
||||
BlockInteractBlacklistEvent evt = (BlockInteractBlacklistEvent)event;
|
||||
logger.log(Level.INFO, "WorldGuard: " + event.getPlayer().getName()
|
||||
+ " tried to interact with " + getFriendlyItemName(evt.getType())
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
|
||||
@@ -172,7 +172,7 @@ public class DatabaseLoggerHandler implements BlacklistLoggerHandler {
|
||||
|
||||
// Use
|
||||
} else if (event instanceof ItemUseBlacklistEvent) {
|
||||
ItemDropBlacklistEvent evt = (ItemDropBlacklistEvent)event;
|
||||
ItemUseBlacklistEvent evt = (ItemUseBlacklistEvent)event;
|
||||
logEvent("USE", evt.getPlayer(), evt.getPlayer().getPosition(),
|
||||
evt.getType(), comment);
|
||||
|
||||
|
||||
@@ -255,12 +255,12 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
||||
|
||||
// Drop
|
||||
} else if (event instanceof ItemDropBlacklistEvent) {
|
||||
ItemAcquireBlacklistEvent evt = (ItemAcquireBlacklistEvent)event;
|
||||
ItemDropBlacklistEvent evt = (ItemDropBlacklistEvent)event;
|
||||
logEvent(event, "drop", evt.getType(), evt.getPosition(), comment);
|
||||
|
||||
// Use
|
||||
} else if (event instanceof ItemUseBlacklistEvent) {
|
||||
ItemDropBlacklistEvent evt = (ItemDropBlacklistEvent)event;
|
||||
ItemUseBlacklistEvent evt = (ItemUseBlacklistEvent)event;
|
||||
logEvent(event, "use", evt.getType(), evt.getPosition(), comment);
|
||||
|
||||
// Unknown
|
||||
|
||||
@@ -63,8 +63,10 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
|
||||
if (!plugin.itemDurability && event.getDamageLevel() == BlockDamageLevel.BROKEN) {
|
||||
ItemStack held = player.getItemInHand();
|
||||
held.setDamage((byte)-1);
|
||||
player.setItemInHand(held);
|
||||
if (held.getTypeId() > 0) {
|
||||
held.setDamage((byte)-1);
|
||||
player.setItemInHand(held);
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.useRegions && event.getDamageLevel() == BlockDamageLevel.BROKEN) {
|
||||
@@ -166,7 +168,7 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
public void onBlockIgnite(BlockIgniteEvent event) {
|
||||
IgniteCause cause = event.getCause();
|
||||
Block block = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
//Player player = event.getPlayer();
|
||||
World world = block.getWorld();
|
||||
boolean isFireSpread = cause == IgniteCause.SLOW_SPREAD
|
||||
|| cause == IgniteCause.SPREAD;
|
||||
@@ -206,22 +208,38 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.useRegions && player != null && !plugin.hasPermission(player, "/regionbypass")) {
|
||||
/*if (plugin.useRegions) {
|
||||
Vector pt = toVector(block);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
if (player != null && !plugin.hasPermission(player, "/regionbypass")) {
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_LIGHTER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
f (isFireSpread && !plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.FLINT_AND_STEEL
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).allowsLighter()) {
|
||||
if (cause == IgniteCause.LAVA && !plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_LAVA_FIRE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -258,7 +276,12 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
Block block = event.getBlock();
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Player && block.getType() == Material.CHEST) {
|
||||
if (entity instanceof Player
|
||||
&& (block.getType() == Material.CHEST
|
||||
|| block.getType() == Material.DISPENSER
|
||||
|| block.getType() == Material.FURNACE
|
||||
|| block.getType() == Material.BURNING_FURNACE
|
||||
|| block.getType() == Material.NOTE_BLOCK)) {
|
||||
Player player = (Player)entity;
|
||||
if (plugin.useRegions) {
|
||||
Vector pt = toVector(block);
|
||||
|
||||
@@ -22,13 +22,16 @@ package com.sk89q.worldguard.bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.*;
|
||||
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 static com.sk89q.worldguard.bukkit.BukkitUtil.*;
|
||||
|
||||
public class WorldGuardEntityListener extends EntityListener {
|
||||
@@ -78,18 +81,45 @@ public class WorldGuardEntityListener extends EntityListener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
if (plugin.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
|
||||
if (!plugin.regionManager.getApplicableRegions(pt).allowsPvP()) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||
if (!plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_PVP)) {
|
||||
((Player)attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null && attacker instanceof Monster) {
|
||||
if (attacker instanceof Creeper && plugin.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
|
||||
if (!plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_MOB_DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Creeper) {
|
||||
if (!plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,10 +202,17 @@ public class WorldGuardEntityListener extends EntityListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.regionManager.getApplicableRegions(BukkitUtil.toVector(event.getEntity().getLocation()))
|
||||
.allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.useRegions) {
|
||||
Vector pt = toVector(event.getEntity().getLocation());
|
||||
|
||||
if (!plugin.regionManager.getApplicableRegions(pt).allowsCreeperExplosions()) {
|
||||
if (!plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -186,10 +223,11 @@ public class WorldGuardEntityListener extends EntityListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.useRegions) {
|
||||
if (plugin.useRegions && event.getEntity() != null) {
|
||||
Vector pt = toVector(event.getEntity().getLocation());
|
||||
|
||||
if (!plugin.regionManager.getApplicableRegions(pt).allowsTNT()) {
|
||||
if (!plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_TNT)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -29,6 +27,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.*;
|
||||
import com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent;
|
||||
import com.sk89q.worldguard.protection.AreaFlags;
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
|
||||
|
||||
/**
|
||||
@@ -111,7 +110,7 @@ public class WorldGuardPlayerListener extends PlayerListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (item != null && plugin.blacklist != null && block != null) {
|
||||
if (plugin.blacklist != null && item != null && block != null) {
|
||||
if (!plugin.blacklist.check(
|
||||
new ItemUseBlacklistEvent(plugin.wrapPlayer(player),
|
||||
toVector(block.getRelative(event.getBlockFace())),
|
||||
@@ -120,6 +119,16 @@ public class WorldGuardPlayerListener extends PlayerListener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.useRegions && item != null && block != null && item.getTypeId() == 259) {
|
||||
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
||||
|
||||
if (!plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_LIGHTER)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,17 +20,9 @@
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.matchSinglePlayer;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -56,11 +48,12 @@ import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditAPI;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
import com.sk89q.worldguard.blacklist.BlacklistLogger;
|
||||
import com.sk89q.worldguard.blacklist.*;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Plugin for Bukkit.
|
||||
@@ -85,7 +78,8 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
|
||||
Blacklist blacklist;
|
||||
|
||||
RegionManager regionManager = new FlatRegionManager();
|
||||
GlobalFlags globalFlags = new GlobalFlags();
|
||||
RegionManager regionManager = new FlatRegionManager(globalFlags);
|
||||
ProtectionDatabase regionLoader;
|
||||
|
||||
Set<String> invinciblePlayers = new HashSet<String>();
|
||||
@@ -260,6 +254,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
public void loadConfiguration() {
|
||||
Configuration config = getConfiguration();
|
||||
config.load();
|
||||
perms.load();
|
||||
|
||||
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
||||
itemDurability = config.getBoolean("protection.item-durability", true);
|
||||
@@ -297,9 +292,10 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
disableSuffocationDamage = config.getBoolean("player-damage.disable-suffocation-damage", false);
|
||||
disableContactDamage = config.getBoolean("player-damage.disable-contact-damage", false);
|
||||
teleportOnSuffocation = config.getBoolean("player-damage.teleport-on-suffocation", false);
|
||||
|
||||
|
||||
useRegions = config.getBoolean("regions.enable", true);
|
||||
regionWand = config.getInt("regions.wand", 287);
|
||||
globalFlags.canBuild = config.getBoolean("regions.default.build", true);
|
||||
|
||||
try {
|
||||
regionLoader.load();
|
||||
@@ -430,6 +426,12 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
} catch (InsufficientPermissionsException e) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have sufficient permission.");
|
||||
return true;
|
||||
} catch (CommandHandlingException e) {
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
player.sendMessage(ChatColor.RED + "ERROR: " + t.getMessage());
|
||||
t.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,11 +442,10 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
* @param cmd
|
||||
* @param args
|
||||
* @return
|
||||
* @throws InsufficientArgumentsException
|
||||
* @throws InsufficientPermissionsException
|
||||
* @throws CommandHandlingException
|
||||
*/
|
||||
private boolean handleCommand(Player player, String cmd, String[] args)
|
||||
throws InsufficientArgumentsException, InsufficientPermissionsException {
|
||||
throws CommandHandlingException {
|
||||
|
||||
if (cmd.equalsIgnoreCase("stopfire")) {
|
||||
checkPermission(player, "/stopfire");
|
||||
@@ -483,13 +484,13 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
checkArgs(args, 0, 1);
|
||||
|
||||
// Allow setting other people invincible
|
||||
if (args.length > 1) {
|
||||
if (args.length > 0) {
|
||||
if (!hasPermission(player, "/godother")) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to make others invincible.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player other = matchSinglePlayer(getServer(), args[1]);
|
||||
Player other = matchSinglePlayer(getServer(), args[0]);
|
||||
if (other == null) {
|
||||
player.sendMessage(ChatColor.RED + "Player not found.");
|
||||
} else {
|
||||
@@ -522,13 +523,13 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
checkArgs(args, 0, 1);
|
||||
|
||||
// Allow healing other people
|
||||
if (args.length > 1) {
|
||||
if (args.length > 0) {
|
||||
if (!hasPermission(player, "/healother")) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to heal others.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player other = matchSinglePlayer(getServer(), args[1]);
|
||||
Player other = matchSinglePlayer(getServer(), args[0]);
|
||||
if (other == null) {
|
||||
player.sendMessage(ChatColor.RED + "Player not found.");
|
||||
} else {
|
||||
@@ -549,13 +550,13 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
checkArgs(args, 0, 1);
|
||||
|
||||
// Allow killing other people
|
||||
if (args.length > 1) {
|
||||
if (args.length > 0) {
|
||||
if (!hasPermission(player, "/slayother")) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to kill others.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player other = matchSinglePlayer(getServer(), args[1]);
|
||||
Player other = matchSinglePlayer(getServer(), args[0]);
|
||||
if (other == null) {
|
||||
player.sendMessage(ChatColor.RED + "Player not found.");
|
||||
} else {
|
||||
@@ -572,7 +573,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("stack")) {
|
||||
checkPermission(player, "stack");
|
||||
checkPermission(player, "/stack");
|
||||
checkArgs(args, 0, 0);
|
||||
|
||||
ItemStack[] items = player.getInventory().getContents();
|
||||
@@ -640,11 +641,11 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("locate")) {
|
||||
checkPermission(player, "locate");
|
||||
checkPermission(player, "/locate");
|
||||
checkArgs(args, 0, 3);
|
||||
|
||||
if (args.length == 2) {
|
||||
String name = args[1];
|
||||
if (args.length == 1) {
|
||||
String name = args[0];
|
||||
Player target = BukkitUtil.matchSinglePlayer(getServer(), name);
|
||||
if (target != null) {
|
||||
player.setCompassTarget(target.getLocation());
|
||||
@@ -652,13 +653,13 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Could not find player.");
|
||||
}
|
||||
} else if (args.length == 4) {
|
||||
} else if (args.length == 3) {
|
||||
try {
|
||||
Location loc = new Location(
|
||||
player.getWorld(),
|
||||
Integer.parseInt(args[0]),
|
||||
Integer.parseInt(args[1]),
|
||||
Integer.parseInt(args[2]),
|
||||
Integer.parseInt(args[3])
|
||||
Integer.parseInt(args[2])
|
||||
);
|
||||
player.setCompassTarget(loc);
|
||||
player.sendMessage(ChatColor.YELLOW + "Compass target set to "
|
||||
@@ -668,7 +669,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(ChatColor.RED + "Invalid number specified");
|
||||
}
|
||||
} else if (args.length == 1) {
|
||||
} else if (args.length == 0) {
|
||||
player.setCompassTarget(player.getWorld().getSpawnLocation());
|
||||
player.sendMessage(ChatColor.YELLOW + "Compass reset to the spawn location.");
|
||||
} else {
|
||||
@@ -681,14 +682,14 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
if (cmd.equalsIgnoreCase("region")) {
|
||||
checkArgs(args, 1, -1);
|
||||
|
||||
String action = args[1];
|
||||
String action = args[0];
|
||||
String[] subArgs = new String[args.length - 1];
|
||||
System.arraycopy(args, 1, subArgs, 0, args.length - 1);
|
||||
return handleRegionCommand(player, action, subArgs);
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("reloadwg")) {
|
||||
checkPermission(player, "reloadwg");
|
||||
checkPermission(player, "/reloadwg");
|
||||
checkArgs(args, 0, 0);
|
||||
|
||||
LoggerToChatHandler handler = new LoggerToChatHandler(player);
|
||||
@@ -719,11 +720,10 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
* @param player
|
||||
* @param action
|
||||
* @param args
|
||||
* @throws InsufficientPermissionsException
|
||||
* @throws InsufficientArgumentsException
|
||||
* @throws CommandHandlingException
|
||||
*/
|
||||
private boolean handleRegionCommand(Player player, String action, String[] args)
|
||||
throws InsufficientPermissionsException, InsufficientArgumentsException {
|
||||
throws CommandHandlingException {
|
||||
if (!useRegions) {
|
||||
player.sendMessage(ChatColor.RED + "Regions are disabled.");
|
||||
return true;
|
||||
@@ -740,7 +740,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
checkArgs(args, 1, -1, "/region define <id> [owner1 [owner2 [owners...]]]");
|
||||
|
||||
try {
|
||||
String id = args[1].toLowerCase();
|
||||
String id = args[0].toLowerCase();
|
||||
|
||||
WorldEditPlugin worldEdit = (WorldEditPlugin)wePlugin;
|
||||
WorldEditAPI api = worldEdit.getAPI();
|
||||
@@ -751,11 +751,11 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
BlockVector min = weRegion.getMinimumPoint().toBlockVector();
|
||||
BlockVector max = weRegion.getMaximumPoint().toBlockVector();
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(min, max);
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(id, min, max);
|
||||
if (args.length >= 2) {
|
||||
region.setOwners(parseDomainString(args, 2));
|
||||
region.setOwners(parseDomainString(args, 1));
|
||||
}
|
||||
regionManager.addRegion(id, region);
|
||||
regionManager.addRegion(region);
|
||||
regionLoader.save(regionManager);
|
||||
player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
|
||||
} catch (IncompleteRegionException e) {
|
||||
@@ -773,7 +773,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
checkArgs(args, 1, 1, "/region claim <id>");
|
||||
|
||||
try {
|
||||
String id = args[1].toLowerCase();
|
||||
String id = args[0].toLowerCase();
|
||||
|
||||
ProtectedRegion existing = regionManager.getRegion(id);
|
||||
|
||||
@@ -793,7 +793,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
BlockVector min = weRegion.getMinimumPoint().toBlockVector();
|
||||
BlockVector max = weRegion.getMaximumPoint().toBlockVector();
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(min, max);
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(id, min, max);
|
||||
|
||||
if (regionManager.overlapsUnownedRegion(region, wrapPlayer(player))) {
|
||||
player.sendMessage(ChatColor.RED + "This region overlaps with someone else's region.");
|
||||
@@ -802,7 +802,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
|
||||
region.getOwners().addPlayer(player.getName());
|
||||
|
||||
regionManager.addRegion(id, region);
|
||||
regionManager.addRegion(region);
|
||||
regionLoader.save(regionManager);
|
||||
player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
|
||||
} catch (IncompleteRegionException e) {
|
||||
@@ -820,9 +820,9 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
checkArgs(args, 3, 3, "/region flag <id> <flag> <none|allow|deny>");
|
||||
|
||||
try {
|
||||
String id = args[1].toLowerCase();
|
||||
String flagStr = args[2];
|
||||
String stateStr = args[3];
|
||||
String id = args[0].toLowerCase();
|
||||
String flagStr = args[1];
|
||||
String stateStr = args[2];
|
||||
ProtectedRegion region = regionManager.getRegion(id);
|
||||
|
||||
if (region == null) {
|
||||
@@ -843,23 +843,78 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
AreaFlags flags = region.getFlags();
|
||||
|
||||
if (flagStr.equalsIgnoreCase("build")) {
|
||||
flags.allowBuild = state;
|
||||
} else if (flagStr.equalsIgnoreCase("pvp")) {
|
||||
flags.allowPvP = state;
|
||||
} else if (flagStr.equalsIgnoreCase("tnt")) {
|
||||
flags.allowTNT = state;
|
||||
} else if (flagStr.equalsIgnoreCase("lighter")) {
|
||||
flags.allowLighter = state;
|
||||
if (flagStr.length() == 0) {
|
||||
player.sendMessage(ChatColor.RED + "A flag must be specified.");
|
||||
return true;
|
||||
// Custom flag
|
||||
} else if (flagStr.length() == 2 && flagStr.matches("^_[A-Za-z0-0]$")) {
|
||||
} else {
|
||||
player.sendMessage(ChatColor.RED + "Acceptable flags: build, pvp, tnt, lighter");
|
||||
flagStr = AreaFlags.fromAlias(flagStr);
|
||||
if (flagStr == null) {
|
||||
player.sendMessage(ChatColor.RED + "Unknown flag specified.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
AreaFlags flags = region.getFlags();
|
||||
flags.set(flagStr, state);
|
||||
regionLoader.save(regionManager);
|
||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated.");
|
||||
} catch (IOException e) {
|
||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase("setparent")) {
|
||||
if (!hasPermission(player, "/regionclaim")) {
|
||||
checkRegionPermission(player, "/regiondefine");
|
||||
}
|
||||
checkArgs(args, 1, 2, "/region setparent <id> <parent-id>");
|
||||
|
||||
String id = args[0].toLowerCase();
|
||||
String parentId = args.length > 1 ? args[1].toLowerCase() : null;
|
||||
|
||||
ProtectedRegion region = regionManager.getRegion(id);
|
||||
|
||||
if (region == null) {
|
||||
player.sendMessage(ChatColor.RED + "Could not find a region with ID: " + id);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondefine")
|
||||
&& !region.isOwner(wrapPlayer(player))) {
|
||||
player.sendMessage(ChatColor.RED + "You need to own the target regions");
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion parent = null;
|
||||
|
||||
// Set a parent
|
||||
if (parentId != null) {
|
||||
parent = regionManager.getRegion(parentId);
|
||||
|
||||
if (parent == null) {
|
||||
player.sendMessage(ChatColor.RED + "Could not find a region with ID: " + parentId);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondefine")
|
||||
&& !parent.isOwner(wrapPlayer(player))) {
|
||||
player.sendMessage(ChatColor.RED + "You need to own the parent region.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
region.setParent(parent);
|
||||
|
||||
regionLoader.save(regionManager);
|
||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated.");
|
||||
} catch (CircularInheritanceException e) {
|
||||
player.sendMessage(ChatColor.RED + "Circular inheritance detected. The operation failed.");
|
||||
} catch (IOException e) {
|
||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||
+ e.getMessage());
|
||||
@@ -872,7 +927,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
checkRegionPermission(player, "/regioninfo");
|
||||
checkArgs(args, 1, 1, "/region info <id>");
|
||||
|
||||
String id = args[1].toLowerCase();
|
||||
String id = args[0].toLowerCase();
|
||||
if (!regionManager.hasRegion(id)) {
|
||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
||||
+ id + "' doesn't exist.");
|
||||
@@ -881,47 +936,74 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
|
||||
ProtectedRegion region = regionManager.getRegion(id);
|
||||
AreaFlags flags = region.getFlags();
|
||||
DefaultDomain domain = region.getOwners();
|
||||
DefaultDomain owners = region.getOwners();
|
||||
DefaultDomain members = region.getMembers();
|
||||
|
||||
player.sendMessage(ChatColor.YELLOW + "Region ID: " + id);
|
||||
player.sendMessage(ChatColor.GRAY + "Type: " + region.getClass().getCanonicalName());
|
||||
player.sendMessage(ChatColor.GRAY + "Priority: " + region.getPriority());
|
||||
player.sendMessage(ChatColor.BLUE + "Build: " + flags.allowBuild.name());
|
||||
player.sendMessage(ChatColor.BLUE + "PvP: " + flags.allowPvP.name());
|
||||
player.sendMessage(ChatColor.BLUE + "TNT: " + flags.allowTNT.name());
|
||||
player.sendMessage(ChatColor.BLUE + "Lighter: " + flags.allowLighter.name());
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE + "Players: " + domain.toPlayersString());
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE + "Groups: " + domain.toGroupsString());
|
||||
player.sendMessage(ChatColor.YELLOW + "Region: " + id
|
||||
+ ChatColor.GRAY + " (type: " + region.getTypeName() + ")");
|
||||
player.sendMessage(ChatColor.BLUE + "Priority: " + region.getPriority());
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
for (Map.Entry<String, State> entry : flags.entrySet()) {
|
||||
if (s.length() > 0) {
|
||||
s.append(", ");
|
||||
}
|
||||
|
||||
if (entry.getValue() == State.ALLOW) {
|
||||
s.append("+");
|
||||
s.append(AreaFlags.getFlagName(entry.getKey()));
|
||||
} else if (entry.getValue() == State.DENY) {
|
||||
s.append("-");
|
||||
s.append(AreaFlags.getFlagName(entry.getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(ChatColor.BLUE + "Flags: " + s.toString());
|
||||
player.sendMessage(ChatColor.BLUE + "Parent: "
|
||||
+ (region.getParent() == null ? "(none)" : region.getParent().getId()));
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE + "Owners: "
|
||||
+ owners.toUserFriendlyString());
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE + "Members: "
|
||||
+ members.toUserFriendlyString());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase("addowner")) {
|
||||
if (action.equalsIgnoreCase("addowner") || action.equalsIgnoreCase("addmember")) {
|
||||
if (!hasPermission(player, "/regionclaim")) {
|
||||
checkRegionPermission(player, "/regiondefine");
|
||||
}
|
||||
checkArgs(args, 2, -1, "/region addowner <id> [owner1 [owner2 [owners...]]]");
|
||||
|
||||
checkArgs(args, 2, -1, "/region add[member|owner] <id> [player1 [group1 [players/groups...]]]");
|
||||
|
||||
boolean isOwner = action.equalsIgnoreCase("addowner");
|
||||
|
||||
String id = args[0].toLowerCase();
|
||||
if (!regionManager.hasRegion(id)) {
|
||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
||||
+ id + "' doesn't exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion existing = regionManager.getRegion(id);
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondefine")
|
||||
&& !existing.isOwner(wrapPlayer(player))) {
|
||||
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isOwner) {
|
||||
addToDomain(existing.getOwners(), args, 1);
|
||||
} else {
|
||||
addToDomain(existing.getMembers(), args, 1);
|
||||
}
|
||||
|
||||
try {
|
||||
String id = args[1].toLowerCase();
|
||||
if (!regionManager.hasRegion(id)) {
|
||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
||||
+ id + "' doesn't exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion existing = regionManager.getRegion(id);
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondefine")
|
||||
&& !existing.getOwners().contains(wrapPlayer(player))) {
|
||||
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
||||
return true;
|
||||
}
|
||||
|
||||
addToDomain(existing.getOwners(), args, 2);
|
||||
|
||||
regionLoader.save(regionManager);
|
||||
player.sendMessage(ChatColor.YELLOW + "Region updated!");
|
||||
player.sendMessage(ChatColor.GRAY + "Current owners: "
|
||||
+ existing.getOwners().toUserFriendlyString());
|
||||
player.sendMessage(ChatColor.GRAY + "Current members: "
|
||||
+ existing.getMembers().toUserFriendlyString());
|
||||
} catch (IOException e) {
|
||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||
+ e.getMessage());
|
||||
@@ -930,32 +1012,42 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase("removeowner")) {
|
||||
if (action.equalsIgnoreCase("removeowner") || action.equalsIgnoreCase("removemember")) {
|
||||
if (!hasPermission(player, "/regionclaim")) {
|
||||
checkRegionPermission(player, "/regiondefine");
|
||||
}
|
||||
checkArgs(args, 2, -1, "/region removeowner <id> [owner1 [owner2 [owners...]]]");
|
||||
|
||||
|
||||
boolean isOwner = action.equalsIgnoreCase("removeowner");
|
||||
|
||||
String id = args[0].toLowerCase();
|
||||
if (!regionManager.hasRegion(id)) {
|
||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
||||
+ id + "' doesn't exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion existing = regionManager.getRegion(id);
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondefine")
|
||||
&& !existing.isOwner(wrapPlayer(player))) {
|
||||
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isOwner) {
|
||||
removeFromDomain(existing.getOwners(), args, 1);
|
||||
} else {
|
||||
removeFromDomain(existing.getMembers(), args, 1);
|
||||
}
|
||||
|
||||
try {
|
||||
String id = args[1].toLowerCase();
|
||||
if (!regionManager.hasRegion(id)) {
|
||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
||||
+ id + "' doesn't exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion existing = regionManager.getRegion(id);
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondefine")
|
||||
&& !existing.getOwners().contains(wrapPlayer(player))) {
|
||||
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
||||
return true;
|
||||
}
|
||||
|
||||
removeFromDomain(existing.getOwners(), args, 2);
|
||||
|
||||
regionLoader.save(regionManager);
|
||||
player.sendMessage(ChatColor.YELLOW + "Region updated!");
|
||||
player.sendMessage(ChatColor.GRAY + "Current owners: "
|
||||
+ existing.getOwners().toUserFriendlyString());
|
||||
player.sendMessage(ChatColor.GRAY + "Current members: "
|
||||
+ existing.getMembers().toUserFriendlyString());
|
||||
} catch (IOException e) {
|
||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||
+ e.getMessage());
|
||||
@@ -970,9 +1062,9 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
|
||||
int page = 0;
|
||||
|
||||
if (args.length >= 2) {
|
||||
if (args.length >= 1) {
|
||||
try {
|
||||
page = Math.max(0, Integer.parseInt(args[1]) - 1);
|
||||
page = Math.max(0, Integer.parseInt(args[0]) - 1);
|
||||
} catch (NumberFormatException e) {
|
||||
page = 0;
|
||||
}
|
||||
@@ -1011,7 +1103,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
checkArgs(args, 0, 1, "/region delete <id>");
|
||||
|
||||
try {
|
||||
String id = args[1].toLowerCase();
|
||||
String id = args[0].toLowerCase();
|
||||
if (!regionManager.hasRegion(id)) {
|
||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
||||
+ id + "' doesn't exist.");
|
||||
@@ -1021,7 +1113,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
ProtectedRegion existing = regionManager.getRegion(id);
|
||||
|
||||
if (!canUseRegionCommand(player, "/regiondelete")
|
||||
&& !existing.getOwners().contains(wrapPlayer(player))) {
|
||||
&& !existing.isOwner(wrapPlayer(player))) {
|
||||
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
||||
return true;
|
||||
}
|
||||
@@ -1185,7 +1277,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
*/
|
||||
private void checkArgs(String[] args, int min, int max)
|
||||
throws InsufficientArgumentsException {
|
||||
if (args.length <= min || (max != -1 && args.length - 1 > max)) {
|
||||
if (args.length < min || (max != -1 && args.length > max)) {
|
||||
throw new InsufficientArgumentsException();
|
||||
}
|
||||
}
|
||||
@@ -1201,33 +1293,57 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
*/
|
||||
private void checkArgs(String[] args, int min, int max, String help)
|
||||
throws InsufficientArgumentsException {
|
||||
if (args.length <= min || (max != -1 && args.length - 1 > max)) {
|
||||
if (args.length < min || (max != -1 && args.length > max)) {
|
||||
throw new InsufficientArgumentsException(help);
|
||||
}
|
||||
}
|
||||
|
||||
boolean inGroup(Player player, String group) {
|
||||
return perms.inGroup(player.getName(), group);
|
||||
try {
|
||||
return perms.inGroup(player.getName(), group);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasPermission(Player player, String perm) {
|
||||
return player.isOp() || perms.hasPermission(player.getName(), perm);
|
||||
try {
|
||||
return player.isOp() || perms.hasPermission(player.getName(), perm);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
String[] getGroups(Player player) {
|
||||
return perms.getGroups(player.getName());
|
||||
try {
|
||||
return perms.getGroups(player.getName());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
BukkitPlayer wrapPlayer(Player player) {
|
||||
return new BukkitPlayer(this, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when command handling has raised an exception.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
private static class CommandHandlingException extends Exception {
|
||||
private static final long serialVersionUID = 7912130636812036780L;
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when a player has insufficient permissions.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
private static class InsufficientPermissionsException extends Exception {
|
||||
private static class InsufficientPermissionsException extends CommandHandlingException {
|
||||
private static final long serialVersionUID = 9087662707619954750L;
|
||||
}
|
||||
|
||||
@@ -1236,7 +1352,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
private static class InsufficientArgumentsException extends Exception {
|
||||
private static class InsufficientArgumentsException extends CommandHandlingException {
|
||||
private static final long serialVersionUID = 4153597953889773788L;
|
||||
private final String help;
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ public class DefaultDomain implements Domain {
|
||||
public String toGroupsString() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (Iterator<String> it = groups.iterator(); it.hasNext(); ) {
|
||||
str.append("*");
|
||||
str.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
str.append(", ");
|
||||
@@ -105,4 +106,21 @@ public class DefaultDomain implements Domain {
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
public String toUserFriendlyString() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
if (players.size() > 0) {
|
||||
str.append(toPlayersString());
|
||||
}
|
||||
|
||||
if (groups.size() > 0) {
|
||||
if (str.length() > 0) {
|
||||
str.append("; ");
|
||||
}
|
||||
|
||||
str.append(toGroupsString());
|
||||
}
|
||||
|
||||
return str.toString();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
@@ -30,175 +32,139 @@ import com.sk89q.worldguard.protection.AreaFlags.State;
|
||||
* @author sk89q
|
||||
*/
|
||||
public class ApplicableRegionSet {
|
||||
private GlobalFlags global;
|
||||
private Vector pt;
|
||||
private SortedMap<String,ProtectedRegion> regions;
|
||||
|
||||
public ApplicableRegionSet(Vector pt, SortedMap<String,ProtectedRegion> regions) {
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param pt
|
||||
* @param regions
|
||||
* @param global
|
||||
*/
|
||||
public ApplicableRegionSet(Vector pt, SortedMap<String,ProtectedRegion> regions,
|
||||
GlobalFlags global) {
|
||||
this.pt = pt;
|
||||
this.regions = regions;
|
||||
this.global = global;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player can build in an area.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean canBuild(LocalPlayer player) {
|
||||
return isFlagAllowed(AreaFlags.FLAG_BUILD, global.canBuild, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a flag.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean allowsFlag(String flag) {
|
||||
return isFlagAllowed(flag, true, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a flag is permitted.
|
||||
*
|
||||
* @param def default state if there are no regions defined
|
||||
* @param player null to not check owners and members
|
||||
* @return
|
||||
*/
|
||||
private boolean isFlagAllowed(String flag, boolean def, LocalPlayer player) {
|
||||
boolean found = false;
|
||||
boolean allowed = false; // Used for ALLOW override
|
||||
int lastPriority = 0;
|
||||
|
||||
// The algorithm is as follows:
|
||||
// While iterating through the list of regions, if an entry disallows
|
||||
// the flag, then put it into the needsClear set. If an entry allows
|
||||
// the flag and it has a parent, then its parent is put into hasCleared.
|
||||
// In the situation that the child is reached before the parent, upon
|
||||
// the parent being reached, even if the parent disallows, because the
|
||||
// parent will be in hasCleared, permission will be allowed. In the
|
||||
// other case, where the parent is reached first, if it does not allow
|
||||
// permissions, it will be placed into needsClear. If a child of
|
||||
// the parent is reached later, the parent will be removed from
|
||||
// needsClear. At the end, if needsClear is not empty, that means that
|
||||
// permission should not be given. If a parent has multiple children
|
||||
// and one child does not allow permissions, then it will be placed into
|
||||
// needsClear just like as if was a parent.
|
||||
|
||||
Set<ProtectedRegion> needsClear = new HashSet<ProtectedRegion>();
|
||||
Set<ProtectedRegion> hasCleared = new HashSet<ProtectedRegion>();
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
if (region.getFlags().allowBuild == State.ALLOW) continue;
|
||||
if (!region.contains(pt)) continue;
|
||||
|
||||
// Ignore lower priority regions
|
||||
if (found && region.getPriority() < lastPriority) {
|
||||
break;
|
||||
// Ignore non-build regions
|
||||
if (player != null && region.getFlags().get(AreaFlags.FLAG_PASSTHROUGH) == State.ALLOW) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!region.getOwners().contains(player)) {
|
||||
// Forget about regions that are not covered
|
||||
if (!region.contains(pt)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Allow DENY to override everything
|
||||
if (region.getFlags().get(flag) == State.DENY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
found = true;
|
||||
lastPriority = region.getPriority();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean allowsPvP() {
|
||||
boolean found = false;
|
||||
int lastPriority = 0;
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
if (!region.contains(pt)) continue;
|
||||
if (region.getFlags().allowPvP == State.DENY) return false;
|
||||
// Forget about regions that allow it, although make sure the
|
||||
// default state is now to allow
|
||||
if (region.getFlags().get(flag) == State.ALLOW) {
|
||||
allowed = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore lower priority regions
|
||||
if (found && region.getPriority() < lastPriority) {
|
||||
break;
|
||||
}
|
||||
|
||||
found = true;
|
||||
lastPriority = region.getPriority();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean allowsMobDamage() {
|
||||
boolean found = false;
|
||||
int lastPriority = 0;
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
if (!region.contains(pt)) continue;
|
||||
if (region.getFlags().allowMobDamage == State.DENY) return false;
|
||||
|
||||
// Ignore lower priority regions
|
||||
if (found && region.getPriority() < lastPriority) {
|
||||
break;
|
||||
if (player != null) {
|
||||
if (hasCleared.contains(region)) {
|
||||
// Already cleared, so do nothing
|
||||
} else {
|
||||
if (!region.isMember(player)) {
|
||||
needsClear.add(region);
|
||||
} else {
|
||||
// Need to clear all parents
|
||||
clearParents(needsClear, hasCleared, region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
found = true;
|
||||
lastPriority = region.getPriority();
|
||||
}
|
||||
|
||||
return true;
|
||||
return found == false ? def : allowed || needsClear.size() == 0;
|
||||
}
|
||||
|
||||
public boolean allowsCreeperExplosions() {
|
||||
boolean found = false;
|
||||
int lastPriority = 0;
|
||||
/**
|
||||
* Clear a region's parents for isFlagAllowed().
|
||||
*
|
||||
* @param needsClear
|
||||
* @param hasCleared
|
||||
* @param region
|
||||
*/
|
||||
private void clearParents(Set<ProtectedRegion> needsClear,
|
||||
Set<ProtectedRegion> hasCleared, ProtectedRegion region) {
|
||||
ProtectedRegion parent = region.getParent();
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
if (!region.contains(pt)) continue;
|
||||
if (region.getFlags().allowCreeperExplosions == State.DENY) return false;
|
||||
|
||||
// Ignore lower priority regions
|
||||
if (found && region.getPriority() < lastPriority) {
|
||||
break;
|
||||
while (parent != null) {
|
||||
if (!needsClear.remove(parent)) {
|
||||
hasCleared.add(parent);
|
||||
}
|
||||
|
||||
found = true;
|
||||
lastPriority = region.getPriority();
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean allowsTNT() {
|
||||
boolean found = false;
|
||||
int lastPriority = 0;
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
if (!region.contains(pt)) continue;
|
||||
if (region.getFlags().allowTNT == State.DENY) return false;
|
||||
|
||||
// Ignore lower priority regions
|
||||
if (found && region.getPriority() < lastPriority) {
|
||||
break;
|
||||
}
|
||||
|
||||
found = true;
|
||||
lastPriority = region.getPriority();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean allowsLighter() {
|
||||
boolean found = false;
|
||||
int lastPriority = 0;
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
if (!region.contains(pt)) continue;
|
||||
if (region.getFlags().allowLighter == State.DENY) return false;
|
||||
|
||||
// Ignore lower priority regions
|
||||
if (found && region.getPriority() < lastPriority) {
|
||||
break;
|
||||
}
|
||||
|
||||
found = true;
|
||||
lastPriority = region.getPriority();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean allowsFireSpread() {
|
||||
boolean found = false;
|
||||
int lastPriority = 0;
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
if (!region.contains(pt)) continue;
|
||||
if (region.getFlags().allowFireSpread == State.DENY) return false;
|
||||
|
||||
// Ignore lower priority regions
|
||||
if (found && region.getPriority() < lastPriority) {
|
||||
break;
|
||||
}
|
||||
|
||||
found = true;
|
||||
lastPriority = region.getPriority();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean allowsLavaFire() {
|
||||
boolean found = false;
|
||||
int lastPriority = 0;
|
||||
|
||||
for (ProtectedRegion region : regions.values()) {
|
||||
if (!region.contains(pt)) continue;
|
||||
if (region.getFlags().allowLavaFire == State.DENY) return false;
|
||||
|
||||
// Ignore lower priority regions
|
||||
if (found && region.getPriority() < lastPriority) {
|
||||
break;
|
||||
}
|
||||
|
||||
found = true;
|
||||
lastPriority = region.getPriority();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,12 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Holds the flags for a region.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
@@ -30,14 +35,98 @@ public class AreaFlags {
|
||||
DENY,
|
||||
};
|
||||
|
||||
public State allowBuild = State.NONE;
|
||||
public State allowPvP = State.NONE;
|
||||
public State allowMobDamage = State.NONE;
|
||||
public State allowCreeperExplosions = State.NONE;
|
||||
public State allowTNT = State.NONE;
|
||||
public State allowLighter = State.NONE;
|
||||
public State allowFireSpread = State.NONE;
|
||||
public State allowLavaFire = State.NONE;
|
||||
public static final String FLAG_PASSTHROUGH = "z";
|
||||
public static final String FLAG_BUILD = "b";
|
||||
public static final String FLAG_PVP = "p";
|
||||
public static final String FLAG_MOB_DAMAGE = "m";
|
||||
public static final String FLAG_CREEPER_EXPLOSION = "c";
|
||||
public static final String FLAG_TNT = "t";
|
||||
public static final String FLAG_LIGHTER = "l";
|
||||
public static final String FLAG_FIRE_SPREAD = "f";
|
||||
public static final String FLAG_LAVA_FIRE = "F";
|
||||
|
||||
/**
|
||||
* Get the user-friendly name of a flag. If a name isn't known, then
|
||||
* the flag is returned unchanged.
|
||||
*
|
||||
* @param flag
|
||||
* @return
|
||||
*/
|
||||
public static String getFlagName(String flag) {
|
||||
if (flag.equals(FLAG_PASSTHROUGH)) {
|
||||
return "passthrough";
|
||||
} else if (flag.equals(FLAG_BUILD)) {
|
||||
return "build";
|
||||
} else if (flag.equals(FLAG_PVP)) {
|
||||
return "PvP";
|
||||
} else if (flag.equals(FLAG_MOB_DAMAGE)) {
|
||||
return "mob damage";
|
||||
} else if (flag.equals(FLAG_CREEPER_EXPLOSION)) {
|
||||
return "creeper explosion";
|
||||
} else if (flag.equals(FLAG_TNT)) {
|
||||
return "TNT";
|
||||
} else if (flag.equals(FLAG_LIGHTER)) {
|
||||
return "lighter";
|
||||
} else if (flag.equals(FLAG_FIRE_SPREAD)) {
|
||||
return "fire spread";
|
||||
} else if (flag.equals(FLAG_LAVA_FIRE)) {
|
||||
return "lava fire spread";
|
||||
} else {
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a flag from an alias. May return null.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static String fromAlias(String name) {
|
||||
if (name.equalsIgnoreCase("passthrough")) {
|
||||
return FLAG_PASSTHROUGH;
|
||||
} else if (name.equalsIgnoreCase("build")) {
|
||||
return FLAG_BUILD;
|
||||
} else if (name.equalsIgnoreCase("pvp")) {
|
||||
return FLAG_PVP;
|
||||
} else if (name.equalsIgnoreCase("mobdamage")) {
|
||||
return FLAG_MOB_DAMAGE;
|
||||
} else if (name.equalsIgnoreCase("creeper")) {
|
||||
return FLAG_CREEPER_EXPLOSION;
|
||||
} else if (name.equalsIgnoreCase("tnt")) {
|
||||
return FLAG_TNT;
|
||||
} else if (name.equalsIgnoreCase("lighter")) {
|
||||
return FLAG_LIGHTER;
|
||||
} else if (name.equalsIgnoreCase("firespread")) {
|
||||
return FLAG_FIRE_SPREAD;
|
||||
} else if (name.equalsIgnoreCase("lavafirespread")) {
|
||||
return FLAG_LAVA_FIRE;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, State> states = new HashMap<String, State>();
|
||||
|
||||
public State get(String flag) {
|
||||
State state = states.get(flag);
|
||||
if (state == null) {
|
||||
return State.NONE;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public void set(String flag, State state) {
|
||||
if (state == State.NONE) {
|
||||
states.remove(flag);
|
||||
} else {
|
||||
states.put(flag, state);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Map.Entry<String, State>> entrySet() {
|
||||
return states.entrySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -46,14 +135,6 @@ public class AreaFlags {
|
||||
}
|
||||
|
||||
AreaFlags other = (AreaFlags)obj;
|
||||
|
||||
return other.allowBuild == allowBuild
|
||||
&& other.allowPvP == allowPvP
|
||||
&& other.allowMobDamage == allowMobDamage
|
||||
&& other.allowCreeperExplosions == allowCreeperExplosions
|
||||
&& other.allowTNT == allowTNT
|
||||
&& other.allowLighter == allowLighter
|
||||
&& other.allowFireSpread == allowFireSpread
|
||||
&& other.allowLavaFire == allowLavaFire;
|
||||
return other.states.equals(this);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -31,6 +32,8 @@ 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.util.ArrayReader;
|
||||
|
||||
/**
|
||||
* Represents a protected area database that uses CSV files.
|
||||
@@ -82,7 +85,7 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
|
||||
writer.writeNext(new String[] {
|
||||
id,
|
||||
"cuboid",
|
||||
"cuboid.2",
|
||||
String.valueOf(min.getBlockX()),
|
||||
String.valueOf(min.getBlockY()),
|
||||
String.valueOf(min.getBlockZ()),
|
||||
@@ -90,9 +93,12 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
String.valueOf(max.getBlockY()),
|
||||
String.valueOf(max.getBlockZ()),
|
||||
String.valueOf(cuboid.getPriority()),
|
||||
cuboid.getParent() != null ? cuboid.getParent().getId() : "",
|
||||
writeDomains(cuboid.getOwners()),
|
||||
writeDomains(cuboid.getMembers()),
|
||||
writeFlags(cuboid.getFlags()),
|
||||
cuboid.getEnterMessage(),
|
||||
cuboid.getEnterMessage() != null ? cuboid.getEnterMessage() : "",
|
||||
cuboid.getLeaveMessage() != null ? cuboid.getLeaveMessage() : "",
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
@@ -110,6 +116,8 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
public void load() throws IOException {
|
||||
Map<String,ProtectedRegion> regions =
|
||||
new HashMap<String,ProtectedRegion>();
|
||||
Map<ProtectedRegion,String> parentSets =
|
||||
new LinkedHashMap<ProtectedRegion, String>();
|
||||
|
||||
CSVReader reader = new CSVReader(new FileReader(file));
|
||||
|
||||
@@ -117,16 +125,21 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
String[] line;
|
||||
|
||||
while ((line = reader.readNext()) != null) {
|
||||
if (line.length >= 12) {
|
||||
String type = line[1];
|
||||
if (!type.equalsIgnoreCase("cuboid")) {
|
||||
logger.warning("Only cuboid region types are supported: "
|
||||
+ line);
|
||||
break;
|
||||
|
||||
if (line.length < 2) {
|
||||
logger.warning("Invalid region definition: " + line);
|
||||
continue;
|
||||
}
|
||||
|
||||
String id = line[0].toLowerCase();
|
||||
String type = line[1];
|
||||
ArrayReader<String> entries = new ArrayReader<String>(line);
|
||||
|
||||
if (type.equalsIgnoreCase("cuboid")) {
|
||||
if (line.length < 8) {
|
||||
logger.warning("Invalid region definition: " + line);
|
||||
continue;
|
||||
}
|
||||
|
||||
String id = line[0];
|
||||
Vector pt1 = new Vector(
|
||||
Integer.parseInt(line[2]),
|
||||
Integer.parseInt(line[3]),
|
||||
@@ -139,19 +152,51 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
BlockVector min = Vector.getMinimum(pt1, pt2).toBlockVector();
|
||||
BlockVector max = Vector.getMaximum(pt1, pt2).toBlockVector();
|
||||
|
||||
int priority = Integer.parseInt(line[8]);
|
||||
String ownersData = line[9];
|
||||
String flagsData = line[10];
|
||||
String enterMessage = line[11];
|
||||
int priority = entries.get(8) == null ? 0 : Integer.parseInt(entries.get(8));
|
||||
String ownersData = entries.get(9);
|
||||
String flagsData = entries.get(10);
|
||||
String enterMessage = nullEmptyString(entries.get(11));
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(min, max);
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(id, min, max);
|
||||
region.setPriority(priority);
|
||||
region.setFlags(parseFlags(flagsData));
|
||||
region.setOwners(this.parseDomains(ownersData));
|
||||
region.setEnterMessage(enterMessage);
|
||||
region.setFlags(parseFlags(flagsData));
|
||||
regions.put(id, region);
|
||||
} else {
|
||||
logger.warning("Line is invalid: " + line);
|
||||
} else if (type.equalsIgnoreCase("cuboid.2")) {
|
||||
Vector pt1 = new Vector(
|
||||
Integer.parseInt(line[2]),
|
||||
Integer.parseInt(line[3]),
|
||||
Integer.parseInt(line[4]));
|
||||
Vector pt2 = new Vector(
|
||||
Integer.parseInt(line[5]),
|
||||
Integer.parseInt(line[6]),
|
||||
Integer.parseInt(line[7]));
|
||||
|
||||
BlockVector min = Vector.getMinimum(pt1, pt2).toBlockVector();
|
||||
BlockVector max = Vector.getMaximum(pt1, pt2).toBlockVector();
|
||||
|
||||
int priority = entries.get(8) == null ? 0 : Integer.parseInt(entries.get(8));
|
||||
String parentId = entries.get(9);
|
||||
String ownersData = entries.get(10);
|
||||
String membersData = entries.get(11);
|
||||
String flagsData = entries.get(12);
|
||||
String enterMessage = nullEmptyString(entries.get(13));
|
||||
String leaveMessage = nullEmptyString(entries.get(14));
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(id, min, max);
|
||||
region.setPriority(priority);
|
||||
region.setFlags(parseFlags(flagsData));
|
||||
region.setOwners(this.parseDomains(ownersData));
|
||||
region.setMembers(this.parseDomains(membersData));
|
||||
region.setEnterMessage(enterMessage);
|
||||
region.setLeaveMessage(leaveMessage);
|
||||
regions.put(id, region);
|
||||
|
||||
// Link children to parents later
|
||||
if (parentId.length() > 0) {
|
||||
parentSets.put(region, parentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -161,6 +206,20 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<ProtectedRegion, String> entry : parentSets.entrySet()) {
|
||||
ProtectedRegion parent = regions.get(entry.getValue());
|
||||
if (parent != null) {
|
||||
try {
|
||||
entry.getKey().setParent(parent);
|
||||
} catch (CircularInheritanceException e) {
|
||||
logger.warning("Circular inheritance detect with '"
|
||||
+ entry.getValue() + "' detected as a parent");
|
||||
}
|
||||
} else {
|
||||
logger.warning("Unknown region parent: " + entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
this.regions = regions;
|
||||
}
|
||||
|
||||
@@ -191,6 +250,10 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
* @return
|
||||
*/
|
||||
private DefaultDomain parseDomains(String data) {
|
||||
if (data == null) {
|
||||
return new DefaultDomain();
|
||||
}
|
||||
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
Pattern pattern = Pattern.compile("^([A-Za-z]):(.*)$");
|
||||
|
||||
@@ -230,33 +293,32 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
* @return
|
||||
*/
|
||||
private AreaFlags parseFlags(String data) {
|
||||
if (data == null) {
|
||||
return new AreaFlags();
|
||||
}
|
||||
|
||||
AreaFlags flags = new AreaFlags();
|
||||
State curState = State.ALLOW;
|
||||
|
||||
for (int i = 0; i < data.length(); i++) {
|
||||
char flag = data.charAt(i);
|
||||
if (flag == '+') {
|
||||
char k = data.charAt(i);
|
||||
if (k == '+') {
|
||||
curState = State.ALLOW;
|
||||
} else if (flag == '-') {
|
||||
} else if (k == '-') {
|
||||
curState = State.DENY;
|
||||
} else if (flag == 'b') {
|
||||
flags.allowBuild = curState;
|
||||
} else if (flag == 'p') {
|
||||
flags.allowPvP = curState;
|
||||
} else if (flag == 'm') {
|
||||
flags.allowMobDamage = curState;
|
||||
} else if (flag == 'c') {
|
||||
flags.allowCreeperExplosions = curState;
|
||||
} else if (flag == 't') {
|
||||
flags.allowTNT = curState;
|
||||
} else if (flag == 'l') {
|
||||
flags.allowLighter = curState;
|
||||
} else if (flag == 'f') {
|
||||
flags.allowFireSpread = curState;
|
||||
} else if (flag == 'F') {
|
||||
flags.allowLavaFire = curState;
|
||||
} else {
|
||||
logger.warning("Unknown area flag/flag modifier: " + flag);
|
||||
String flag;
|
||||
if (k == '_') {
|
||||
if (i == data.length() - 1) {
|
||||
logger.warning("_ read ahead fail");
|
||||
break;
|
||||
}
|
||||
flag = "_" + data.charAt(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
flag = String.valueOf(k);
|
||||
}
|
||||
flags.set(flag, curState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,6 +364,22 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a null if a string is null or empty.
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
private String nullEmptyString(String str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
} else if (str.length() == 0) {
|
||||
return null;
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to write the list of flags.
|
||||
*
|
||||
@@ -310,14 +388,9 @@ public class CSVDatabase implements ProtectionDatabase {
|
||||
*/
|
||||
private String writeFlags(AreaFlags flags) {
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(writeFlag(flags.allowBuild, "b"));
|
||||
str.append(writeFlag(flags.allowPvP, "p"));
|
||||
str.append(writeFlag(flags.allowMobDamage, "m"));
|
||||
str.append(writeFlag(flags.allowCreeperExplosions, "c"));
|
||||
str.append(writeFlag(flags.allowTNT, "t"));
|
||||
str.append(writeFlag(flags.allowLighter, "l"));
|
||||
str.append(writeFlag(flags.allowFireSpread, "f"));
|
||||
str.append(writeFlag(flags.allowLavaFire, "F"));
|
||||
for (Map.Entry<String, State> entry : flags.entrySet()) {
|
||||
str.append(writeFlag(entry.getValue(), entry.getKey()));
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,12 +39,17 @@ public class FlatRegionManager implements RegionManager {
|
||||
* List of protected regions.
|
||||
*/
|
||||
private SortedMap<String,ProtectedRegion> regions;
|
||||
/**
|
||||
* Global flags.
|
||||
*/
|
||||
private GlobalFlags global;
|
||||
|
||||
/**
|
||||
* Construct the manager.
|
||||
*/
|
||||
public FlatRegionManager() {
|
||||
public FlatRegionManager(GlobalFlags global) {
|
||||
regions = new TreeMap<String,ProtectedRegion>();
|
||||
this.global = global;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,17 +76,27 @@ public class FlatRegionManager implements RegionManager {
|
||||
* @param id
|
||||
* @param region
|
||||
*/
|
||||
public void addRegion(String id, ProtectedRegion region) {
|
||||
regions.put(id, region);
|
||||
public void addRegion(ProtectedRegion region) {
|
||||
regions.put(region.getId(), region);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a region.
|
||||
* Removes a region and its children.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void removeRegion(String id) {
|
||||
ProtectedRegion region = regions.get(id);
|
||||
|
||||
regions.remove(id);
|
||||
|
||||
if (region != null) {
|
||||
for (Map.Entry<String, ProtectedRegion> entry : regions.entrySet()) {
|
||||
if (entry.getValue().getParent() == region) {
|
||||
removeRegion(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +125,7 @@ public class FlatRegionManager implements RegionManager {
|
||||
* @return
|
||||
*/
|
||||
public ApplicableRegionSet getApplicableRegions(Vector pt) {
|
||||
return new ApplicableRegionSet(pt, regions);
|
||||
return new ApplicableRegionSet(pt, regions, global);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// $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;
|
||||
|
||||
/**
|
||||
* Used for default flags.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class GlobalFlags {
|
||||
public boolean canBuild = true;
|
||||
}
|
||||
@@ -39,12 +39,13 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
||||
/**
|
||||
* Construct a new instance of this cuboid region.
|
||||
*
|
||||
* @param id
|
||||
* @param pos1
|
||||
* @param pos2
|
||||
* @param priority
|
||||
*/
|
||||
public ProtectedCuboidRegion(BlockVector min, BlockVector max) {
|
||||
super();
|
||||
public ProtectedCuboidRegion(String id, BlockVector min, BlockVector max) {
|
||||
super(id);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
@@ -85,6 +86,9 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
||||
max = pt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a point is inside this region.
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Vector pt) {
|
||||
int x = pt.getBlockX();
|
||||
@@ -94,4 +98,13 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
||||
&& y >= min.getBlockY() && y <= max.getBlockY()
|
||||
&& z >= min.getBlockZ() && z <= max.getBlockZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of region as a user-friendly name.
|
||||
*
|
||||
* @return type of region
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return "cuboid";
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
|
||||
/**
|
||||
@@ -30,34 +31,52 @@ import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
*/
|
||||
public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
|
||||
/**
|
||||
* Area message.
|
||||
* Holds the region's ID.
|
||||
*/
|
||||
private String enterMessage;
|
||||
/**
|
||||
* List of owners.
|
||||
*/
|
||||
private DefaultDomain owners = new DefaultDomain();
|
||||
private String id;
|
||||
/**
|
||||
* Priority.
|
||||
*/
|
||||
private int priority = 0;
|
||||
/**
|
||||
* Parent region.
|
||||
*/
|
||||
private ProtectedRegion parent;
|
||||
/**
|
||||
* List of owners.
|
||||
*/
|
||||
private DefaultDomain owners = new DefaultDomain();
|
||||
/**
|
||||
* List of members.
|
||||
*/
|
||||
private DefaultDomain members = new DefaultDomain();
|
||||
/**
|
||||
* Area flags.
|
||||
*/
|
||||
private AreaFlags flags = new AreaFlags();
|
||||
/**
|
||||
* Area message.
|
||||
*/
|
||||
private String enterMessage;
|
||||
/**
|
||||
* Area message.
|
||||
*/
|
||||
private String leaveMessage;
|
||||
|
||||
/**
|
||||
* Construct a new instance of this region.
|
||||
*
|
||||
* @param id
|
||||
* @param priority
|
||||
* @param owners
|
||||
* @param enterMessage
|
||||
*/
|
||||
public ProtectedRegion() {
|
||||
this.priority = 0;
|
||||
this.owners = new DefaultDomain();
|
||||
this.enterMessage = null;
|
||||
public ProtectedRegion(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,6 +93,41 @@ public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the parent
|
||||
*/
|
||||
public ProtectedRegion getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the parent. This checks to make sure that it will not result
|
||||
* in circular inheritance.
|
||||
*
|
||||
* @param parent the parent to set
|
||||
* @throws CircularInheritanceException
|
||||
*/
|
||||
public void setParent(ProtectedRegion parent) throws CircularInheritanceException {
|
||||
if (parent == null) {
|
||||
this.parent = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (parent == this) {
|
||||
throw new CircularInheritanceException();
|
||||
}
|
||||
|
||||
ProtectedRegion p = parent.getParent();
|
||||
while (p != null) {
|
||||
if (p == this) {
|
||||
throw new CircularInheritanceException();
|
||||
}
|
||||
p = p.getParent();
|
||||
}
|
||||
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Se flags.
|
||||
* @param flags
|
||||
@@ -95,6 +149,20 @@ public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
|
||||
public void setEnterMessage(String enterMessage) {
|
||||
this.enterMessage = enterMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the leaveMessage
|
||||
*/
|
||||
public String getLeaveMessage() {
|
||||
return leaveMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param leaveMessage the leaveMessage to set
|
||||
*/
|
||||
public void setLeaveMessage(String leaveMessage) {
|
||||
this.leaveMessage = leaveMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the owners
|
||||
@@ -110,6 +178,67 @@ public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
|
||||
this.owners = owners;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the members
|
||||
*/
|
||||
public DefaultDomain getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param owners the owners to set
|
||||
*/
|
||||
public void setMembers(DefaultDomain members) {
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a player is an owner of region or any of its parents.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean isOwner(LocalPlayer player) {
|
||||
if (owners.contains(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion parent = getParent();
|
||||
while (parent != null) {
|
||||
if (parent.getOwners().contains(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a player is a member of the region or any of its parents.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean isMember(LocalPlayer player) {
|
||||
if (owners.contains(player) || members.contains(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
ProtectedRegion parent = getParent();
|
||||
while (parent != null) {
|
||||
if (parent.getOwners().contains(player)
|
||||
|| parent.getMembers().contains(player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
parent = parent.getParent();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get flags.
|
||||
*
|
||||
@@ -143,6 +272,13 @@ public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of region as a user-friendly, lowercase name.
|
||||
*
|
||||
* @return type of region
|
||||
*/
|
||||
public abstract String getTypeName();
|
||||
|
||||
/**
|
||||
* Checks if two region intersects.
|
||||
*
|
||||
@@ -172,4 +308,13 @@ public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
|
||||
throw new UnsupportedIntersectionException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown when setting a parent would create a circular inheritance
|
||||
* situation.
|
||||
*
|
||||
*/
|
||||
public static class CircularInheritanceException extends Exception {
|
||||
private static final long serialVersionUID = 7479613488496776022L;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public interface RegionManager {
|
||||
* @param id
|
||||
* @param region
|
||||
*/
|
||||
public void addRegion(String id, ProtectedRegion region);
|
||||
public void addRegion(ProtectedRegion region);
|
||||
|
||||
/**
|
||||
* Return whether a region exists by an ID.
|
||||
@@ -71,7 +71,7 @@ public interface RegionManager {
|
||||
public ProtectedRegion getRegion(String id);
|
||||
|
||||
/**
|
||||
* Removes a region.
|
||||
* Removes a region, including inheriting children.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// $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.util;
|
||||
|
||||
public class ArrayReader<T> {
|
||||
private T[] arr;
|
||||
|
||||
public ArrayReader(T[] arr) {
|
||||
this.arr = arr;
|
||||
}
|
||||
|
||||
public T get(int index) {
|
||||
if (arr.length > index) {
|
||||
return arr[index];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public T get(int index, T def) {
|
||||
if (arr.length > index) {
|
||||
return arr[index];
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
@@ -72,7 +71,7 @@ public class TestPlayer extends LocalPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups() {
|
||||
public String[] getGroups() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -26,17 +26,22 @@ import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.AreaFlags.State;
|
||||
|
||||
public class ApplicableRegionSetTest {
|
||||
static String COURTYARD_ID = "courtyard";
|
||||
static String FOUNTAIN_ID = "fountain";
|
||||
static String NO_FIRE_ID = "nofire";
|
||||
static String MEMBER_GROUP = "member";
|
||||
static String COURTYARD_GROUP = "courtyard";
|
||||
|
||||
Vector inFountain = new Vector(2, 2, 2);
|
||||
Vector inCourtyard = new Vector(7, 7, 7);
|
||||
Vector outside = new Vector(15, 15, 15);
|
||||
Vector inNoFire = new Vector(150, 150, 150);
|
||||
RegionManager manager;
|
||||
ProtectedRegion courtyard;
|
||||
ProtectedRegion fountain;
|
||||
TestPlayer player1;
|
||||
TestPlayer player2;
|
||||
|
||||
@@ -47,6 +52,7 @@ public class ApplicableRegionSetTest {
|
||||
setUpPlayers();
|
||||
setUpCourtyardRegion();
|
||||
setUpFountainRegion();
|
||||
setUpNoFireRegion();
|
||||
}
|
||||
|
||||
void setUpPlayers() {
|
||||
@@ -62,24 +68,41 @@ public class ApplicableRegionSetTest {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
domain.addGroup(COURTYARD_GROUP);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(COURTYARD_ID,
|
||||
new BlockVector(0, 0, 0), new BlockVector(10, 10, 10));
|
||||
AreaFlags flags = new AreaFlags();
|
||||
flags.allowBuild = AreaFlags.State.NONE;
|
||||
flags.allowFireSpread = AreaFlags.State.ALLOW;
|
||||
flags.set(AreaFlags.FLAG_BUILD, State.NONE);
|
||||
flags.set(AreaFlags.FLAG_FIRE_SPREAD, State.ALLOW);
|
||||
region.setFlags(flags);
|
||||
region.setOwners(domain);
|
||||
manager.addRegion(COURTYARD_ID, region);
|
||||
manager.addRegion(region);
|
||||
|
||||
courtyard = region;
|
||||
}
|
||||
|
||||
void setUpFountainRegion() {
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(
|
||||
void setUpFountainRegion() throws Exception {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
domain.addGroup(MEMBER_GROUP);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(FOUNTAIN_ID,
|
||||
new BlockVector(0, 0, 0), new BlockVector(5, 5, 5));
|
||||
AreaFlags flags = new AreaFlags();
|
||||
flags.allowBuild = AreaFlags.State.ALLOW;
|
||||
flags.allowFireSpread = AreaFlags.State.DENY;
|
||||
flags.set(AreaFlags.FLAG_FIRE_SPREAD, State.DENY);
|
||||
region.setFlags(flags);
|
||||
manager.addRegion(FOUNTAIN_ID, region);
|
||||
region.setMembers(domain);
|
||||
manager.addRegion(region);
|
||||
|
||||
fountain = region;
|
||||
fountain.setParent(courtyard);
|
||||
}
|
||||
|
||||
void setUpNoFireRegion() throws Exception {
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(NO_FIRE_ID,
|
||||
new BlockVector(100, 100, 100), new BlockVector(200, 200, 200));
|
||||
AreaFlags flags = new AreaFlags();
|
||||
flags.set(AreaFlags.FLAG_FIRE_SPREAD, State.DENY);
|
||||
region.setFlags(flags);
|
||||
manager.addRegion(region);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,13 +111,17 @@ public class ApplicableRegionSetTest {
|
||||
|
||||
// Outside
|
||||
appl = manager.getApplicableRegions(outside);
|
||||
assertTrue(appl.allowsFireSpread());
|
||||
assertTrue(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
// Inside courtyard
|
||||
appl = manager.getApplicableRegions(inCourtyard);
|
||||
assertTrue(appl.allowsFireSpread());
|
||||
assertTrue(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
// Inside fountain
|
||||
appl = manager.getApplicableRegions(inFountain);
|
||||
assertFalse(appl.allowsFireSpread());
|
||||
assertFalse(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
|
||||
// Inside no fire zone
|
||||
appl = manager.getApplicableRegions(inNoFire);
|
||||
assertFalse(appl.allowsFlag(AreaFlags.FLAG_FIRE_SPREAD));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.AreaFlags.State;
|
||||
|
||||
public class CSVDatabaseTest {
|
||||
@Before
|
||||
@@ -63,9 +64,9 @@ public class CSVDatabaseTest {
|
||||
|
||||
private void checkTestRegion1(ProtectedRegion region) {
|
||||
AreaFlags flags = new AreaFlags();
|
||||
flags.allowFireSpread = AreaFlags.State.ALLOW;
|
||||
flags.allowPvP = AreaFlags.State.DENY;
|
||||
flags.allowLighter = AreaFlags.State.DENY;
|
||||
flags.set(AreaFlags.FLAG_FIRE_SPREAD, State.ALLOW);
|
||||
flags.set(AreaFlags.FLAG_PVP, State.DENY);
|
||||
flags.set(AreaFlags.FLAG_LIGHTER, State.DENY);
|
||||
region.setFlags(flags);
|
||||
|
||||
assertEquals(region.getFlags(), flags);
|
||||
@@ -75,12 +76,12 @@ public class CSVDatabaseTest {
|
||||
BlockVector min = new BlockVector(1, 2, 3);
|
||||
BlockVector max = new BlockVector(4, 5, 6);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(min, max);
|
||||
ProtectedRegion region = new ProtectedCuboidRegion("test2", min, max);
|
||||
|
||||
AreaFlags flags = new AreaFlags();
|
||||
flags.allowFireSpread = AreaFlags.State.ALLOW;
|
||||
flags.allowPvP = AreaFlags.State.DENY;
|
||||
flags.allowLighter = AreaFlags.State.DENY;
|
||||
flags.set(AreaFlags.FLAG_FIRE_SPREAD, State.ALLOW);
|
||||
flags.set(AreaFlags.FLAG_PVP, State.DENY);
|
||||
flags.set(AreaFlags.FLAG_LIGHTER, State.DENY);
|
||||
region.setFlags(flags);
|
||||
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
@@ -101,12 +102,12 @@ public class CSVDatabaseTest {
|
||||
BlockVector min = new BlockVector(7, 8, 9);
|
||||
BlockVector max = new BlockVector(10, 11, 12);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(min, max);
|
||||
ProtectedRegion region = new ProtectedCuboidRegion("test2", min, max);
|
||||
|
||||
AreaFlags flags = new AreaFlags();
|
||||
flags.allowFireSpread = AreaFlags.State.DENY;
|
||||
flags.allowPvP = AreaFlags.State.ALLOW;
|
||||
flags.allowMobDamage = AreaFlags.State.DENY;
|
||||
flags.set(AreaFlags.FLAG_FIRE_SPREAD, State.ALLOW);
|
||||
flags.set(AreaFlags.FLAG_PVP, State.ALLOW);
|
||||
flags.set(AreaFlags.FLAG_LIGHTER, State.DENY);
|
||||
region.setFlags(flags);
|
||||
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
|
||||
Reference in new issue
Block a user