mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-25 01:21:38 +01:00
configuration is now per-world, updated permissions, made commands compatible with console where possible, /region flag now checks correctly for permissions, & some fixes
This commit is contained in:
parent
71a6d8ab44
commit
9b4a7c705b
@ -6,6 +6,7 @@
|
|||||||
CREATE TABLE `blacklist_events` (
|
CREATE TABLE `blacklist_events` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`event` varchar(25) NOT NULL,
|
`event` varchar(25) NOT NULL,
|
||||||
|
`world` varchar(32) NOT NULL,
|
||||||
`player` varchar(16) NOT NULL,
|
`player` varchar(16) NOT NULL,
|
||||||
`x` int(11) NOT NULL,
|
`x` int(11) NOT NULL,
|
||||||
`y` int(11) NOT NULL,
|
`y` int(11) NOT NULL,
|
||||||
@ -18,4 +19,6 @@ CREATE TABLE `blacklist_events` (
|
|||||||
|
|
||||||
-- Required update if you have an older version of the table:
|
-- Required update if you have an older version of the table:
|
||||||
|
|
||||||
ALTER TABLE `blacklist_events` ADD `comment` VARCHAR( 255 ) NULL
|
ALTER TABLE `blacklist_events` ADD `comment` VARCHAR( 255 ) NULL
|
||||||
|
|
||||||
|
ALTER TABLE `blacklist_events` ADD `world` VARCHAR( 32 ) NOT NULL
|
@ -44,6 +44,7 @@
|
|||||||
<copy tofile="${build.dir}/plugin.yml" file="plugin.yml"/>
|
<copy tofile="${build.dir}/plugin.yml" file="plugin.yml"/>
|
||||||
<replace file="${build.dir}/plugin.yml" token="WGVERSIONMACRO" value="${version}"/>
|
<replace file="${build.dir}/plugin.yml" token="WGVERSIONMACRO" value="${version}"/>
|
||||||
<mkdir dir="${build.dir}/defaults"/>
|
<mkdir dir="${build.dir}/defaults"/>
|
||||||
|
<copy tofile="${build.dir}/defaults/global.yml" file="global.yml"/>
|
||||||
<copy tofile="${build.dir}/defaults/config.yml" file="config.yml"/>
|
<copy tofile="${build.dir}/defaults/config.yml" file="config.yml"/>
|
||||||
<copy tofile="${build.dir}/defaults/blacklist.txt" file="blacklist.txt"/>
|
<copy tofile="${build.dir}/defaults/blacklist.txt" file="blacklist.txt"/>
|
||||||
<jar jarfile="${dist.dir}/WorldGuard.jar" basedir="${build.dir}" manifest="manifest.mf">
|
<jar jarfile="${dist.dir}/WorldGuard.jar" basedir="${build.dir}" manifest="manifest.mf">
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
summary-on-start: on
|
summary-on-start: on
|
||||||
|
|
||||||
suppress-tick-sync-warnings: false
|
|
||||||
|
|
||||||
protection:
|
protection:
|
||||||
enforce-single-session: on
|
enforce-single-session: on
|
||||||
item-durability: on
|
item-durability: on
|
||||||
@ -101,7 +99,7 @@ blacklist:
|
|||||||
table: blacklist_events
|
table: blacklist_events
|
||||||
file:
|
file:
|
||||||
enable: on
|
enable: on
|
||||||
path: worldguard/logs/%Y-%m-%d.log
|
path: worldguard/logs/%w-%Y-%m-%d.log
|
||||||
open-files: 10
|
open-files: 10
|
||||||
|
|
||||||
# See http://wiki.sk89q.com/wiki/WorldGuard/Permissions/Bukkit
|
# See http://wiki.sk89q.com/wiki/WorldGuard/Permissions/Bukkit
|
||||||
|
3
global.yml
Normal file
3
global.yml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
|
suppress-tick-sync-warnings: false
|
48
permissions_list.txt
Normal file
48
permissions_list.txt
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
worldguard.god.other
|
||||||
|
worldguard.god.self
|
||||||
|
|
||||||
|
worldguard.slay.other
|
||||||
|
worldguard.slay.self
|
||||||
|
|
||||||
|
worldguard.heal.other
|
||||||
|
worldguard.heal.self
|
||||||
|
|
||||||
|
worldguard.stack
|
||||||
|
|
||||||
|
worldguard.stopfire
|
||||||
|
|
||||||
|
worldguard.allowfire
|
||||||
|
|
||||||
|
worldguard.locate
|
||||||
|
|
||||||
|
worldguard.region.flag.ownregions
|
||||||
|
worldguard.region.flag.memberregions
|
||||||
|
worldguard.region.flag.foreignregions
|
||||||
|
|
||||||
|
worldguard.region.info.ownregions
|
||||||
|
worldguard.region.info.memberregions
|
||||||
|
worldguard.region.info.foreignregions
|
||||||
|
|
||||||
|
worldguard.region.list
|
||||||
|
|
||||||
|
worldguard.region.load
|
||||||
|
|
||||||
|
worldguard.region.removeowner.own
|
||||||
|
worldguard.region.removeowner.all
|
||||||
|
|
||||||
|
worldguard.region.removemember.own
|
||||||
|
worldguard.region.removemember.all
|
||||||
|
|
||||||
|
worldguard.region.save
|
||||||
|
|
||||||
|
worldguard.region.setparent.own
|
||||||
|
worldguard.region.setparent.all
|
||||||
|
|
||||||
|
worldguard.reloadwg
|
||||||
|
|
||||||
|
worldguard.region.delete.own
|
||||||
|
worldguard.region.delete.all
|
||||||
|
|
||||||
|
worldguard.region.define
|
||||||
|
|
||||||
|
worldguard.region.claim
|
@ -34,6 +34,14 @@ public class ConsoleLoggerHandler implements BlacklistLoggerHandler {
|
|||||||
*/
|
*/
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||||
|
|
||||||
|
|
||||||
|
private String worldName;
|
||||||
|
|
||||||
|
public ConsoleLoggerHandler(String worldName)
|
||||||
|
{
|
||||||
|
this.worldName = worldName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log an event.
|
* Log an event.
|
||||||
*
|
*
|
||||||
@ -44,55 +52,55 @@ public void logEvent(BlacklistEvent event, String comment) {
|
|||||||
// Block break
|
// Block break
|
||||||
if (event instanceof BlockBreakBlacklistEvent) {
|
if (event instanceof BlockBreakBlacklistEvent) {
|
||||||
BlockBreakBlacklistEvent evt = (BlockBreakBlacklistEvent)event;
|
BlockBreakBlacklistEvent evt = (BlockBreakBlacklistEvent)event;
|
||||||
logger.log(Level.INFO, "WorldGuard: " + event.getPlayer().getName()
|
logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName()
|
||||||
+ " tried to break " + getFriendlyItemName(evt.getType())
|
+ " tried to break " + getFriendlyItemName(evt.getType())
|
||||||
+ (comment != null ? " (" + comment + ")" : ""));
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
|
|
||||||
// Block place
|
// Block place
|
||||||
} else if (event instanceof BlockPlaceBlacklistEvent) {
|
} else if (event instanceof BlockPlaceBlacklistEvent) {
|
||||||
BlockPlaceBlacklistEvent evt = (BlockPlaceBlacklistEvent)event;
|
BlockPlaceBlacklistEvent evt = (BlockPlaceBlacklistEvent)event;
|
||||||
logger.log(Level.INFO, "WorldGuard: " + event.getPlayer().getName()
|
logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName()
|
||||||
+ " tried to place " + getFriendlyItemName(evt.getType())
|
+ " tried to place " + getFriendlyItemName(evt.getType())
|
||||||
+ (comment != null ? " (" + comment + ")" : ""));
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
|
|
||||||
// Block interact
|
// Block interact
|
||||||
} else if (event instanceof BlockInteractBlacklistEvent) {
|
} else if (event instanceof BlockInteractBlacklistEvent) {
|
||||||
BlockInteractBlacklistEvent evt = (BlockInteractBlacklistEvent)event;
|
BlockInteractBlacklistEvent evt = (BlockInteractBlacklistEvent)event;
|
||||||
logger.log(Level.INFO, "WorldGuard: " + event.getPlayer().getName()
|
logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName()
|
||||||
+ " tried to interact with " + getFriendlyItemName(evt.getType())
|
+ " tried to interact with " + getFriendlyItemName(evt.getType())
|
||||||
+ (comment != null ? " (" + comment + ")" : ""));
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
|
|
||||||
// Destroy with
|
// Destroy with
|
||||||
} else if (event instanceof DestroyWithBlacklistEvent) {
|
} else if (event instanceof DestroyWithBlacklistEvent) {
|
||||||
DestroyWithBlacklistEvent evt = (DestroyWithBlacklistEvent)event;
|
DestroyWithBlacklistEvent evt = (DestroyWithBlacklistEvent)event;
|
||||||
logger.log(Level.INFO, "WorldGuard: " + event.getPlayer().getName()
|
logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName()
|
||||||
+ " tried to destroy with " + getFriendlyItemName(evt.getType())
|
+ " tried to destroy with " + getFriendlyItemName(evt.getType())
|
||||||
+ (comment != null ? " (" + comment + ")" : ""));
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
|
|
||||||
// Acquire
|
// Acquire
|
||||||
} else if (event instanceof ItemAcquireBlacklistEvent) {
|
} else if (event instanceof ItemAcquireBlacklistEvent) {
|
||||||
ItemAcquireBlacklistEvent evt = (ItemAcquireBlacklistEvent)event;
|
ItemAcquireBlacklistEvent evt = (ItemAcquireBlacklistEvent)event;
|
||||||
logger.log(Level.INFO, "WorldGuard: " + event.getPlayer().getName()
|
logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName()
|
||||||
+ " tried to acquire " + getFriendlyItemName(evt.getType())
|
+ " tried to acquire " + getFriendlyItemName(evt.getType())
|
||||||
+ (comment != null ? " (" + comment + ")" : ""));
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
|
|
||||||
// Drop
|
// Drop
|
||||||
} else if (event instanceof ItemDropBlacklistEvent) {
|
} else if (event instanceof ItemDropBlacklistEvent) {
|
||||||
ItemDropBlacklistEvent evt = (ItemDropBlacklistEvent)event;
|
ItemDropBlacklistEvent evt = (ItemDropBlacklistEvent)event;
|
||||||
logger.log(Level.INFO, "WorldGuard: " + event.getPlayer().getName()
|
logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName()
|
||||||
+ " tried to drop " + getFriendlyItemName(evt.getType())
|
+ " tried to drop " + getFriendlyItemName(evt.getType())
|
||||||
+ (comment != null ? " (" + comment + ")" : ""));
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
|
|
||||||
// Use
|
// Use
|
||||||
} else if (event instanceof ItemUseBlacklistEvent) {
|
} else if (event instanceof ItemUseBlacklistEvent) {
|
||||||
ItemUseBlacklistEvent evt = (ItemUseBlacklistEvent)event;
|
ItemUseBlacklistEvent evt = (ItemUseBlacklistEvent)event;
|
||||||
logger.log(Level.INFO, "WorldGuard: " + event.getPlayer().getName()
|
logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName()
|
||||||
+ " tried to use " + getFriendlyItemName(evt.getType())
|
+ " tried to use " + getFriendlyItemName(evt.getType())
|
||||||
+ (comment != null ? " (" + comment + ")" : ""));
|
+ (comment != null ? " (" + comment + ")" : ""));
|
||||||
|
|
||||||
// Unknown
|
// Unknown
|
||||||
} else {
|
} else {
|
||||||
logger.log(Level.INFO, "WorldGuard: " + event.getPlayer().getName()
|
logger.log(Level.INFO, "WorldGuard: [" + worldName + "] " + event.getPlayer().getName()
|
||||||
+ " caught unknown event: " + event.getClass().getCanonicalName());
|
+ " caught unknown event: " + event.getClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,10 @@ public class DatabaseLoggerHandler implements BlacklistLoggerHandler {
|
|||||||
* Table.
|
* Table.
|
||||||
*/
|
*/
|
||||||
private String table;
|
private String table;
|
||||||
|
/**
|
||||||
|
* World name.
|
||||||
|
*/
|
||||||
|
private String worldName;
|
||||||
/**
|
/**
|
||||||
* Database connection.
|
* Database connection.
|
||||||
*/
|
*/
|
||||||
@ -73,11 +77,12 @@ public class DatabaseLoggerHandler implements BlacklistLoggerHandler {
|
|||||||
* @param user
|
* @param user
|
||||||
* @param pass
|
* @param pass
|
||||||
*/
|
*/
|
||||||
public DatabaseLoggerHandler(String dsn, String user, String pass, String table) {
|
public DatabaseLoggerHandler(String dsn, String user, String pass, String table, String worldName) {
|
||||||
this.dsn = dsn;
|
this.dsn = dsn;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.pass = pass;
|
this.pass = pass;
|
||||||
this.table = table;
|
this.table = table;
|
||||||
|
this.worldName = worldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,16 +115,17 @@ private void logEvent(String event, LocalPlayer player, Vector pos, int item,
|
|||||||
Connection conn = getConnection();
|
Connection conn = getConnection();
|
||||||
PreparedStatement stmt = conn.prepareStatement(
|
PreparedStatement stmt = conn.prepareStatement(
|
||||||
"INSERT INTO " + table
|
"INSERT INTO " + table
|
||||||
+ "(event, player, x, y, z, item, time, comment) VALUES "
|
+ "(event, world, player, x, y, z, item, time, comment) VALUES "
|
||||||
+ "(?, ?, ?, ?, ?, ?, ?, ?)");
|
+ "(?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
stmt.setString(1, event);
|
stmt.setString(1, event);
|
||||||
stmt.setString(2, player.getName());
|
stmt.setString(2, worldName);
|
||||||
stmt.setInt(3, pos.getBlockX());
|
stmt.setString(3, player.getName());
|
||||||
stmt.setInt(4, pos.getBlockY());
|
stmt.setInt(4, pos.getBlockX());
|
||||||
stmt.setInt(5, pos.getBlockZ());
|
stmt.setInt(5, pos.getBlockY());
|
||||||
stmt.setInt(6, item);
|
stmt.setInt(6, pos.getBlockZ());
|
||||||
stmt.setInt(7, (int)(System.currentTimeMillis() / 1000));
|
stmt.setInt(7, item);
|
||||||
stmt.setString(8, comment);
|
stmt.setInt(8, (int)(System.currentTimeMillis() / 1000));
|
||||||
|
stmt.setString(9, comment);
|
||||||
stmt.executeUpdate();
|
stmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
logger.log(Level.SEVERE, "Failed to log blacklist event to database: "
|
logger.log(Level.SEVERE, "Failed to log blacklist event to database: "
|
||||||
|
@ -57,6 +57,10 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
|||||||
* Path pattern.
|
* Path pattern.
|
||||||
*/
|
*/
|
||||||
private String pathPattern;
|
private String pathPattern;
|
||||||
|
/**
|
||||||
|
* World name.
|
||||||
|
*/
|
||||||
|
private String worldName;
|
||||||
/**
|
/**
|
||||||
* Cache of writers.
|
* Cache of writers.
|
||||||
*/
|
*/
|
||||||
@ -68,8 +72,9 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
|||||||
*
|
*
|
||||||
* @param pathPattern
|
* @param pathPattern
|
||||||
*/
|
*/
|
||||||
public FileLoggerHandler(String pathPattern) {
|
public FileLoggerHandler(String pathPattern, String worldName) {
|
||||||
this.pathPattern = pathPattern;
|
this.pathPattern = pathPattern;
|
||||||
|
this.worldName = worldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,12 +83,13 @@ public FileLoggerHandler(String pathPattern) {
|
|||||||
* @param pathPattern
|
* @param pathPattern
|
||||||
* @param cacheSize
|
* @param cacheSize
|
||||||
*/
|
*/
|
||||||
public FileLoggerHandler(String pathPattern, int cacheSize) {
|
public FileLoggerHandler(String pathPattern, int cacheSize, String worldName) {
|
||||||
if (cacheSize < 1) {
|
if (cacheSize < 1) {
|
||||||
throw new IllegalArgumentException("Cache size cannot be less than 1");
|
throw new IllegalArgumentException("Cache size cannot be less than 1");
|
||||||
}
|
}
|
||||||
this.pathPattern = pathPattern;
|
this.pathPattern = pathPattern;
|
||||||
this.cacheSize = cacheSize;
|
this.cacheSize = cacheSize;
|
||||||
|
this.worldName = worldName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,6 +116,12 @@ private String buildPath(String playerName) {
|
|||||||
rep = rep.substring(0, 32);
|
rep = rep.substring(0, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}else if (group.matches("%w")) {
|
||||||
|
rep = worldName.toLowerCase().replaceAll("[^A-Za-z0-9_]", "_");
|
||||||
|
if (rep.length() > 32) { // Actual max length is 16
|
||||||
|
rep = rep.substring(0, 32);
|
||||||
|
}
|
||||||
|
|
||||||
// Date and time
|
// Date and time
|
||||||
} else if (group.matches("%Y")) {
|
} else if (group.matches("%Y")) {
|
||||||
rep = String.valueOf(calendar.get(Calendar.YEAR));
|
rep = String.valueOf(calendar.get(Calendar.YEAR));
|
||||||
|
@ -31,7 +31,7 @@ public BukkitBlacklist(WorldGuardPlugin plugin) {
|
|||||||
|
|
||||||
public void broadcastNotification(String msg) {
|
public void broadcastNotification(String msg) {
|
||||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
if (plugin.hasPermission(player, "/worldguardnotify")) {
|
if (plugin.getWgConfiguration().hasPermission(player, "/worldguardnotify")) {
|
||||||
player.sendMessage(msg);
|
player.sendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,16 @@
|
|||||||
|
|
||||||
public class BukkitPlayer extends LocalPlayer {
|
public class BukkitPlayer extends LocalPlayer {
|
||||||
private Player player;
|
private Player player;
|
||||||
private WorldGuardPlugin plugin;
|
private WorldGuardConfiguration config;
|
||||||
|
|
||||||
public BukkitPlayer(WorldGuardPlugin plugin, Player player) {
|
public BukkitPlayer(WorldGuardConfiguration config, Player player) {
|
||||||
this.plugin = plugin;
|
this.config = config;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BukkitPlayer wrapPlayer(WorldGuardConfiguration config, Player player) {
|
||||||
|
return new BukkitPlayer(config, player);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -40,7 +44,7 @@ public String getName() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasGroup(String group) {
|
public boolean hasGroup(String group) {
|
||||||
return plugin.inGroup(player, group);
|
return config.inGroup(player, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,7 +65,7 @@ public void ban(String msg) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getGroups() {
|
public String[] getGroups() {
|
||||||
return plugin.getGroups(player);
|
return config.getGroups(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
public class BukkitUtil {
|
public class BukkitUtil {
|
||||||
|
|
||||||
|
|
||||||
private BukkitUtil() {
|
private BukkitUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,4 +52,5 @@ public static Player matchSinglePlayer(Server server, String name) {
|
|||||||
}
|
}
|
||||||
return players.get(0);
|
return players.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -69,10 +69,13 @@ public void onBlockDamage(BlockDamageEvent event) {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block blockDamaged = event.getBlock();
|
Block blockDamaged = event.getBlock();
|
||||||
|
|
||||||
if (plugin.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
|
if (wcfg.useRegions && blockDamaged.getType() == Material.CAKE_BLOCK) {
|
||||||
Vector pt = toVector(blockDamaged);
|
Vector pt = toVector(blockDamaged);
|
||||||
|
|
||||||
if (!plugin.canBuild(player, pt)) {
|
if (!cfg.canBuild(player, pt)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!");
|
player.sendMessage(ChatColor.DARK_RED + "You're not invited to this tea party!");
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -93,8 +96,10 @@ public void onBlockBreak(BlockBreakEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
if (!plugin.itemDurability) {
|
if (!wcfg.itemDurability) {
|
||||||
ItemStack held = player.getItemInHand();
|
ItemStack held = player.getItemInHand();
|
||||||
if (held.getTypeId() > 0) {
|
if (held.getTypeId() > 0) {
|
||||||
held.setDurability((short) -1);
|
held.setDurability((short) -1);
|
||||||
@ -102,27 +107,27 @@ public void onBlockBreak(BlockBreakEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = BukkitUtil.toVector(event.getBlock());
|
Vector pt = BukkitUtil.toVector(event.getBlock());
|
||||||
|
|
||||||
if (!plugin.canBuild(player, pt)) {
|
if (!cfg.canBuild(player, pt)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.blacklist != null) {
|
if (wcfg.getBlacklist() != null) {
|
||||||
if (!plugin.blacklist.check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new BlockBreakBlacklistEvent(plugin.wrapPlayer(player),
|
new BlockBreakBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
||||||
toVector(event.getBlock()),
|
toVector(event.getBlock()),
|
||||||
event.getBlock().getTypeId()), false, false)) {
|
event.getBlock().getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.blacklist.check(
|
if (wcfg.getBlacklist().check(
|
||||||
new DestroyWithBlacklistEvent(plugin.wrapPlayer(player),
|
new DestroyWithBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
||||||
toVector(event.getBlock()),
|
toVector(event.getBlock()),
|
||||||
player.getItemInHand().getTypeId()), false, false)) {
|
player.getItemInHand().getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -151,17 +156,20 @@ public void onBlockFlow(BlockFromToEvent event) {
|
|||||||
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
|
boolean isWater = blockFrom.getTypeId() == 8 || blockFrom.getTypeId() == 9;
|
||||||
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
|
boolean isLava = blockFrom.getTypeId() == 10 || blockFrom.getTypeId() == 11;
|
||||||
|
|
||||||
if (plugin.simulateSponge && isWater) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||||
|
|
||||||
|
if (wcfg.simulateSponge && isWater) {
|
||||||
int ox = blockTo.getX();
|
int ox = blockTo.getX();
|
||||||
int oy = blockTo.getY();
|
int oy = blockTo.getY();
|
||||||
int oz = blockTo.getZ();
|
int oz = blockTo.getZ();
|
||||||
|
|
||||||
for (int cx = -plugin.spongeRadius; cx <= plugin.spongeRadius; cx++) {
|
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
|
||||||
for (int cy = -plugin.spongeRadius; cy <= plugin.spongeRadius; cy++) {
|
for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) {
|
||||||
for (int cz = -plugin.spongeRadius; cz <= plugin.spongeRadius; cz++) {
|
for (int cz = -wcfg.spongeRadius; cz <= wcfg.spongeRadius; cz++) {
|
||||||
Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||||
if (sponge.getTypeId() == 19
|
if (sponge.getTypeId() == 19
|
||||||
&& (!plugin.redstoneSponges || !sponge.isBlockIndirectlyPowered())) {
|
&& (!wcfg.redstoneSponges || !sponge.isBlockIndirectlyPowered())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -182,28 +190,28 @@ public void onBlockFlow(BlockFromToEvent event) {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
// Check the fluid block (from) whether it is air. If so and the target block is protected, cancel the event
|
// Check the fluid block (from) whether it is air. If so and the target block is protected, cancel the event
|
||||||
if(plugin.preventWaterDamage.size() > 0 && blockFrom.getTypeId() == 0) {
|
if(wcfg.preventWaterDamage.size() > 0 && blockFrom.getTypeId() == 0) {
|
||||||
int targetId = world.getBlockTypeIdAt(
|
int targetId = world.getBlockTypeIdAt(
|
||||||
blockTo.getX(), blockTo.getY(), blockTo.getZ());
|
blockTo.getX(), blockTo.getY(), blockTo.getZ());
|
||||||
if (plugin.preventWaterDamage.contains(targetId)) {
|
if (wcfg.preventWaterDamage.contains(targetId)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.preventWaterDamage.size() > 0 && isWater) {
|
if (wcfg.preventWaterDamage.size() > 0 && isWater) {
|
||||||
int targetId = world.getBlockTypeIdAt(
|
int targetId = world.getBlockTypeIdAt(
|
||||||
blockTo.getX(), blockTo.getY(), blockTo.getZ());
|
blockTo.getX(), blockTo.getY(), blockTo.getZ());
|
||||||
if (plugin.preventWaterDamage.contains(targetId)) {
|
if (wcfg.preventWaterDamage.contains(targetId)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.allowedLavaSpreadOver.size() > 0 && isLava) {
|
if (wcfg.allowedLavaSpreadOver.size() > 0 && isLava) {
|
||||||
int targetId = world.getBlockTypeIdAt(
|
int targetId = world.getBlockTypeIdAt(
|
||||||
blockTo.getX(), blockTo.getY() - 1, blockTo.getZ());
|
blockTo.getX(), blockTo.getY() - 1, blockTo.getZ());
|
||||||
if (!plugin.allowedLavaSpreadOver.contains(targetId)) {
|
if (!wcfg.allowedLavaSpreadOver.contains(targetId)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -236,40 +244,43 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
|||||||
|
|
||||||
IgniteCause cause = event.getCause();
|
IgniteCause cause = event.getCause();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
//Player player = event.getPlayer();
|
|
||||||
World world = block.getWorld();
|
World world = block.getWorld();
|
||||||
|
|
||||||
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
||||||
|
|
||||||
if (plugin.preventLavaFire && cause == IgniteCause.LAVA) {
|
if (wcfg.preventLavaFire && cause == IgniteCause.LAVA) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableFireSpread && isFireSpread) {
|
if (wcfg.disableFireSpread && isFireSpread) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.blockLighter && cause == IgniteCause.FLINT_AND_STEEL) {
|
if (wcfg.blockLighter && cause == IgniteCause.FLINT_AND_STEEL) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.fireSpreadDisableToggle && isFireSpread) {
|
if (wcfg.fireSpreadDisableToggle && isFireSpread) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableFireSpreadBlocks.size() > 0 && isFireSpread) {
|
if (wcfg.disableFireSpreadBlocks.size() > 0 && isFireSpread) {
|
||||||
int x = block.getX();
|
int x = block.getX();
|
||||||
int y = block.getY();
|
int y = block.getY();
|
||||||
int z = block.getZ();
|
int z = block.getZ();
|
||||||
|
|
||||||
if (plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y - 1, z))
|
if (wcfg.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y - 1, z))
|
||||||
|| plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x + 1, y, z))
|
|| wcfg.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x + 1, y, z))
|
||||||
|| plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x - 1, y, z))
|
|| wcfg.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x - 1, y, z))
|
||||||
|| plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z - 1))
|
|| wcfg.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z - 1))
|
||||||
|| plugin.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z + 1))) {
|
|| wcfg.disableFireSpreadBlocks.contains(world.getBlockTypeIdAt(x, y, z + 1))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -322,20 +333,23 @@ public void onBlockBurn(BlockBurnEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableFireSpread) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||||
|
|
||||||
|
if (wcfg.disableFireSpread) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.fireSpreadDisableToggle) {
|
if (wcfg.fireSpreadDisableToggle) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableFireSpreadBlocks.size() > 0) {
|
if (wcfg.disableFireSpreadBlocks.size() > 0) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
if (plugin.disableFireSpreadBlocks.contains(block.getTypeId())) {
|
if (wcfg.disableFireSpreadBlocks.contains(block.getTypeId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -355,19 +369,22 @@ public void onBlockPhysics(BlockPhysicsEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||||
|
|
||||||
int id = event.getChangedTypeId();
|
int id = event.getChangedTypeId();
|
||||||
|
|
||||||
if (id == 13 && plugin.noPhysicsGravel) {
|
if (id == 13 && wcfg.noPhysicsGravel) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == 12 && plugin.noPhysicsSand) {
|
if (id == 12 && wcfg.noPhysicsSand) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == 90 && plugin.allowPortalAnywhere) {
|
if (id == 90 && wcfg.allowPortalAnywhere) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -388,7 +405,10 @@ public void onBlockInteract(BlockInteractEvent event) {
|
|||||||
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getBlock().getWorld().getName());
|
||||||
|
|
||||||
if (entity instanceof Player
|
if (entity instanceof Player
|
||||||
&& (block.getType() == Material.CHEST
|
&& (block.getType() == Material.CHEST
|
||||||
|| block.getType() == Material.DISPENSER
|
|| block.getType() == Material.DISPENSER
|
||||||
@ -396,12 +416,12 @@ public void onBlockInteract(BlockInteractEvent event) {
|
|||||||
|| block.getType() == Material.BURNING_FURNACE
|
|| block.getType() == Material.BURNING_FURNACE
|
||||||
|| block.getType() == Material.NOTE_BLOCK)) {
|
|| block.getType() == Material.NOTE_BLOCK)) {
|
||||||
Player player = (Player)entity;
|
Player player = (Player)entity;
|
||||||
if (plugin.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(block);
|
Vector pt = toVector(block);
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(cfg, player);
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
if (!plugin.hasPermission(player, "/regionbypass")
|
if (!cfg.hasPermission(player, "/regionbypass")
|
||||||
&& !mgr.getApplicableRegions(pt).allowsFlag(AreaFlags.FLAG_CHEST_ACCESS)
|
&& !mgr.getApplicableRegions(pt).allowsFlag(AreaFlags.FLAG_CHEST_ACCESS)
|
||||||
&& !mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
|
&& !mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||||
@ -411,11 +431,11 @@ public void onBlockInteract(BlockInteractEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.blacklist != null && entity instanceof Player) {
|
if (wcfg.getBlacklist() != null && entity instanceof Player) {
|
||||||
Player player = (Player)entity;
|
Player player = (Player)entity;
|
||||||
|
|
||||||
if (!plugin.blacklist.check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new BlockInteractBlacklistEvent(plugin.wrapPlayer(player), toVector(block),
|
new BlockInteractBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player), toVector(block),
|
||||||
block.getTypeId()), false, false)) {
|
block.getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -439,28 +459,31 @@ public void onBlockPlace(BlockPlaceEvent event) {
|
|||||||
Block blockPlaced = event.getBlock();
|
Block blockPlaced = event.getBlock();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
World world = blockPlaced.getWorld();
|
World world = blockPlaced.getWorld();
|
||||||
|
|
||||||
if (plugin.useRegions) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(blockPlaced);
|
Vector pt = toVector(blockPlaced);
|
||||||
|
|
||||||
if (!plugin.canBuild(player, pt)) {
|
if (!cfg.canBuild(player, pt)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.blacklist != null) {
|
if (wcfg.getBlacklist() != null) {
|
||||||
if (!plugin.blacklist.check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new BlockPlaceBlacklistEvent(plugin.wrapPlayer(player), toVector(blockPlaced),
|
new BlockPlaceBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player), toVector(blockPlaced),
|
||||||
blockPlaced.getTypeId()), false, false)) {
|
blockPlaced.getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.simulateSponge && blockPlaced.getTypeId() == 19) {
|
if (wcfg.simulateSponge && blockPlaced.getTypeId() == 19) {
|
||||||
if (plugin.redstoneSponges && blockPlaced.isBlockIndirectlyPowered()) {
|
if (wcfg.redstoneSponges && blockPlaced.isBlockIndirectlyPowered()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,8 +505,11 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
|||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Block blockClicked = event.getBlock();
|
Block blockClicked = event.getBlock();
|
||||||
|
|
||||||
if (plugin.useRegions && event.getItemInHand().getTypeId() == plugin.regionWand) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(blockClicked.getWorld().getName());
|
||||||
|
|
||||||
|
if (wcfg.useRegions && event.getItemInHand().getTypeId() == wcfg.regionWand) {
|
||||||
Vector pt = toVector(blockClicked);
|
Vector pt = toVector(blockClicked);
|
||||||
|
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
@ -492,7 +518,7 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
|||||||
|
|
||||||
if (regions.size() > 0) {
|
if (regions.size() > 0) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Can you build? "
|
player.sendMessage(ChatColor.YELLOW + "Can you build? "
|
||||||
+ (app.canBuild(plugin.wrapPlayer(player)) ? "Yes" : "No"));
|
+ (app.canBuild(BukkitPlayer.wrapPlayer(cfg, player)) ? "Yes" : "No"));
|
||||||
|
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
for (Iterator<String> it = regions.iterator(); it.hasNext(); ) {
|
for (Iterator<String> it = regions.iterator(); it.hasNext(); ) {
|
||||||
@ -510,11 +536,11 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
|||||||
|
|
||||||
Material type = blockClicked.getType();
|
Material type = blockClicked.getType();
|
||||||
|
|
||||||
if (plugin.useRegions && type == Material.CAKE_BLOCK) {
|
if (wcfg.useRegions && type == Material.CAKE_BLOCK) {
|
||||||
|
|
||||||
Vector pt = toVector(blockClicked);
|
Vector pt = toVector(blockClicked);
|
||||||
|
|
||||||
if (!plugin.canBuild(player, pt)) {
|
if (!cfg.canBuild(player, pt)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||||
|
|
||||||
byte newData = (byte) (blockClicked.getData() - 1);
|
byte newData = (byte) (blockClicked.getData() - 1);
|
||||||
@ -539,10 +565,13 @@ public void onBlockRightClick(BlockRightClickEvent event) {
|
|||||||
@Override
|
@Override
|
||||||
public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
||||||
|
|
||||||
World world = event.getBlock().getWorld();
|
|
||||||
Block blockTo = event.getBlock();
|
Block blockTo = event.getBlock();
|
||||||
|
World world = blockTo.getWorld();
|
||||||
|
|
||||||
if (plugin.simulateSponge && plugin.redstoneSponges) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
|
if (wcfg.simulateSponge && wcfg.redstoneSponges) {
|
||||||
int ox = blockTo.getX();
|
int ox = blockTo.getX();
|
||||||
int oy = blockTo.getY();
|
int oy = blockTo.getY();
|
||||||
int oz = blockTo.getZ();
|
int oz = blockTo.getZ();
|
||||||
@ -575,9 +604,13 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
|
|||||||
* @param oz
|
* @param oz
|
||||||
*/
|
*/
|
||||||
private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||||
for (int cx = -plugin.spongeRadius; cx <= plugin.spongeRadius; cx++) {
|
|
||||||
for (int cy = -plugin.spongeRadius; cy <= plugin.spongeRadius; cy++) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
for (int cz = -plugin.spongeRadius; cz <= plugin.spongeRadius; cz++) {
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
|
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
|
||||||
|
for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) {
|
||||||
|
for (int cz = -wcfg.spongeRadius; cz <= wcfg.spongeRadius; cz++) {
|
||||||
if (isBlockWater(world, ox + cx, oy + cy, oz + cz)) {
|
if (isBlockWater(world, ox + cx, oy + cy, oz + cz)) {
|
||||||
world.getBlockAt(ox + cx, oy + cy, oz + cz)
|
world.getBlockAt(ox + cx, oy + cy, oz + cz)
|
||||||
.setTypeId(0);
|
.setTypeId(0);
|
||||||
@ -596,10 +629,14 @@ private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
|||||||
* @param oz
|
* @param oz
|
||||||
*/
|
*/
|
||||||
private void addSpongeWater(World world, int ox, int oy, int oz) {
|
private void addSpongeWater(World world, int ox, int oy, int oz) {
|
||||||
|
|
||||||
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(world.getName());
|
||||||
|
|
||||||
// The negative x edge
|
// The negative x edge
|
||||||
int cx = ox - plugin.spongeRadius - 1;
|
int cx = ox - wcfg.spongeRadius - 1;
|
||||||
for (int cy = oy - plugin.spongeRadius - 1; cy <= oy + plugin.spongeRadius + 1; cy++) {
|
for (int cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||||
for (int cz = oz - plugin.spongeRadius - 1; cz <= oz + plugin.spongeRadius + 1; cz++) {
|
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||||
if (isBlockWater(world, cx, cy, cz)) {
|
if (isBlockWater(world, cx, cy, cz)) {
|
||||||
setBlockToWater(world, cx + 1, cy, cz);
|
setBlockToWater(world, cx + 1, cy, cz);
|
||||||
}
|
}
|
||||||
@ -607,9 +644,9 @@ private void addSpongeWater(World world, int ox, int oy, int oz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The positive x edge
|
// The positive x edge
|
||||||
cx = ox + plugin.spongeRadius + 1;
|
cx = ox + wcfg.spongeRadius + 1;
|
||||||
for (int cy = oy - plugin.spongeRadius - 1; cy <= oy + plugin.spongeRadius + 1; cy++) {
|
for (int cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||||
for (int cz = oz - plugin.spongeRadius - 1; cz <= oz + plugin.spongeRadius + 1; cz++) {
|
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||||
if (isBlockWater(world, cx, cy, cz)) {
|
if (isBlockWater(world, cx, cy, cz)) {
|
||||||
setBlockToWater(world, cx - 1, cy, cz);
|
setBlockToWater(world, cx - 1, cy, cz);
|
||||||
}
|
}
|
||||||
@ -617,9 +654,9 @@ private void addSpongeWater(World world, int ox, int oy, int oz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The negative y edge
|
// The negative y edge
|
||||||
int cy = oy - plugin.spongeRadius - 1;
|
int cy = oy - wcfg.spongeRadius - 1;
|
||||||
for (cx = ox - plugin.spongeRadius - 1; cx <= ox + plugin.spongeRadius + 1; cx++) {
|
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||||
for (int cz = oz - plugin.spongeRadius - 1; cz <= oz + plugin.spongeRadius + 1; cz++) {
|
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||||
if (isBlockWater(world, cx, cy, cz)) {
|
if (isBlockWater(world, cx, cy, cz)) {
|
||||||
setBlockToWater(world, cx, cy + 1, cz);
|
setBlockToWater(world, cx, cy + 1, cz);
|
||||||
}
|
}
|
||||||
@ -627,9 +664,9 @@ private void addSpongeWater(World world, int ox, int oy, int oz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The positive y edge
|
// The positive y edge
|
||||||
cy = oy + plugin.spongeRadius + 1;
|
cy = oy + wcfg.spongeRadius + 1;
|
||||||
for (cx = ox - plugin.spongeRadius - 1; cx <= ox + plugin.spongeRadius + 1; cx++) {
|
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||||
for (int cz = oz - plugin.spongeRadius - 1; cz <= oz + plugin.spongeRadius + 1; cz++) {
|
for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) {
|
||||||
if (isBlockWater(world, cx, cy, cz)) {
|
if (isBlockWater(world, cx, cy, cz)) {
|
||||||
setBlockToWater(world, cx, cy - 1, cz);
|
setBlockToWater(world, cx, cy - 1, cz);
|
||||||
}
|
}
|
||||||
@ -637,9 +674,9 @@ private void addSpongeWater(World world, int ox, int oy, int oz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The negative z edge
|
// The negative z edge
|
||||||
int cz = oz - plugin.spongeRadius - 1;
|
int cz = oz - wcfg.spongeRadius - 1;
|
||||||
for (cx = ox - plugin.spongeRadius - 1; cx <= ox + plugin.spongeRadius + 1; cx++) {
|
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||||
for (cy = oy - plugin.spongeRadius - 1; cy <= oy + plugin.spongeRadius + 1; cy++) {
|
for (cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||||
if (isBlockWater(world, cx, cy, cz)) {
|
if (isBlockWater(world, cx, cy, cz)) {
|
||||||
setBlockToWater(world, cx, cy, cz + 1);
|
setBlockToWater(world, cx, cy, cz + 1);
|
||||||
}
|
}
|
||||||
@ -647,9 +684,9 @@ private void addSpongeWater(World world, int ox, int oy, int oz) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The positive z edge
|
// The positive z edge
|
||||||
cz = oz + plugin.spongeRadius + 1;
|
cz = oz + wcfg.spongeRadius + 1;
|
||||||
for (cx = ox - plugin.spongeRadius - 1; cx <= ox + plugin.spongeRadius + 1; cx++) {
|
for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) {
|
||||||
for (cy = oy - plugin.spongeRadius - 1; cy <= oy + plugin.spongeRadius + 1; cy++) {
|
for (cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) {
|
||||||
if (isBlockWater(world, cx, cy, cz)) {
|
if (isBlockWater(world, cx, cy, cz)) {
|
||||||
setBlockToWater(world, cx, cy, cz - 1);
|
setBlockToWater(world, cx, cy, cz - 1);
|
||||||
}
|
}
|
||||||
@ -693,4 +730,4 @@ private boolean isBlockWater(World world, int ox, int oy, int oz) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
419
src/com/sk89q/worldguard/bukkit/WorldGuardConfiguration.java
Normal file
419
src/com/sk89q/worldguard/bukkit/WorldGuardConfiguration.java
Normal file
@ -0,0 +1,419 @@
|
|||||||
|
// $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.bukkit;
|
||||||
|
|
||||||
|
import com.sk89q.bukkit.migration.PermissionsResolverManager;
|
||||||
|
import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
|
import com.sk89q.worldguard.TickSyncDelayLoggerFilter;
|
||||||
|
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||||
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.InsufficientPermissionsException;
|
||||||
|
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||||
|
import com.sk89q.worldguard.protection.dbs.CSVDatabase;
|
||||||
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Filter;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Michael
|
||||||
|
*/
|
||||||
|
public class WorldGuardConfiguration {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||||
|
private PermissionsResolverServerListener permsListener;
|
||||||
|
private PermissionsResolverManager perms;
|
||||||
|
private WorldGuardPlugin wg;
|
||||||
|
private Map<String, WorldGuardWorldConfiguration> worldConfig;
|
||||||
|
private Set<String> invinciblePlayers = new HashSet<String>();
|
||||||
|
private Set<String> amphibiousPlayers = new HashSet<String>();
|
||||||
|
private boolean suppressTickSyncWarnings;
|
||||||
|
|
||||||
|
private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$");
|
||||||
|
|
||||||
|
public WorldGuardConfiguration(WorldGuardPlugin wg) {
|
||||||
|
this.wg = wg;
|
||||||
|
this.worldConfig = new HashMap<String, WorldGuardWorldConfiguration>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldGuardWorldConfiguration getWorldConfig(String worldName) {
|
||||||
|
WorldGuardWorldConfiguration ret = worldConfig.get(worldName);
|
||||||
|
if (ret == null) {
|
||||||
|
ret = createWorldConfig(worldName);
|
||||||
|
worldConfig.put(worldName, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private WorldGuardWorldConfiguration createWorldConfig(String worldName) {
|
||||||
|
File configFile = new File(wg.getDataFolder(), worldName + ".yml");
|
||||||
|
File blacklistFile = new File(wg.getDataFolder(), worldName + "_blacklist.txt");
|
||||||
|
|
||||||
|
return new WorldGuardWorldConfiguration(wg, worldName, configFile, blacklistFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEnable() {
|
||||||
|
checkOldConfigFiles();
|
||||||
|
checkOldCSVDB();
|
||||||
|
|
||||||
|
perms = new PermissionsResolverManager(wg.getConfiguration(), wg.getServer(), "WorldGuard", logger);
|
||||||
|
permsListener = new PermissionsResolverServerListener(perms);
|
||||||
|
|
||||||
|
invinciblePlayers.clear();
|
||||||
|
amphibiousPlayers.clear();
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (Player player : wg.getServer().getOnlinePlayers()) {
|
||||||
|
if (inGroup(player, "wg-invincible")) {
|
||||||
|
invinciblePlayers.add(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inGroup(player, "wg-amphibious")) {
|
||||||
|
amphibiousPlayers.add(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) { // Thrown if loaded too early
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File configFile = new File(wg.getDataFolder(), "global.yml");
|
||||||
|
WorldGuardWorldConfiguration.createDefaultConfiguration(configFile, "global.yml");
|
||||||
|
Configuration config = new Configuration(configFile);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
suppressTickSyncWarnings = config.getBoolean("suppress-tick-sync-warnings", false);
|
||||||
|
|
||||||
|
if (suppressTickSyncWarnings) {
|
||||||
|
Logger.getLogger("Minecraft").setFilter(new TickSyncDelayLoggerFilter());
|
||||||
|
} else {
|
||||||
|
Filter filter = Logger.getLogger("Minecraft").getFilter();
|
||||||
|
if (filter != null && filter instanceof TickSyncDelayLoggerFilter) {
|
||||||
|
Logger.getLogger("Minecraft").setFilter(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
worldConfig.clear();
|
||||||
|
;
|
||||||
|
for (World w : wg.getServer().getWorlds()) {
|
||||||
|
String worldName = w.getName();
|
||||||
|
worldConfig.put(worldName, createWorldConfig(worldName));
|
||||||
|
}
|
||||||
|
|
||||||
|
permsListener.register(wg);
|
||||||
|
perms.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkOldConfigFiles() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
File oldFile = new File(wg.getDataFolder(), "config.yml");
|
||||||
|
if (oldFile.exists()) {
|
||||||
|
logger.info("WorldGuard: WARNING: config.yml is outdated, please reapply your configuration in <world>.yml and global.yml");
|
||||||
|
logger.info("WorldGuard: WARNING: config.yml renamed to config.yml.old");
|
||||||
|
oldFile.renameTo(new File(wg.getDataFolder(), "config.yml.old"));
|
||||||
|
}
|
||||||
|
oldFile = new File(wg.getDataFolder(), "blacklist.txt");
|
||||||
|
if (oldFile.exists()) {
|
||||||
|
logger.info("WorldGuard: WARNING: blacklist.txt is outdated, please reapply your configuration in <world>_blacklist.txt");
|
||||||
|
logger.info("WorldGuard: WARNING: blacklist.txt renamed to blacklist.txt.old");
|
||||||
|
oldFile.renameTo(new File(wg.getDataFolder(), "blacklist.txt.old"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkOldCSVDB() {
|
||||||
|
try {
|
||||||
|
File CSVfile = new File(wg.getDataFolder(), "regions.txt");
|
||||||
|
if (CSVfile.exists()) {
|
||||||
|
|
||||||
|
logger.info("WorldGuard: Converting old regions.txt to new format....");
|
||||||
|
|
||||||
|
World w = wg.getServer().getWorlds().get(0);
|
||||||
|
RegionManager mgr = wg.getGlobalRegionManager().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(wg.getDataFolder(), "regions.txt.old"));
|
||||||
|
|
||||||
|
logger.info("WorldGuard: Done.");
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.warning("WorldGuard: Failed to load regions: "
|
||||||
|
+ e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisable() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBuild(Player player, int x, int y, int z) {
|
||||||
|
|
||||||
|
if (getWorldConfig(player.getWorld().getName()).useRegions) {
|
||||||
|
Vector pt = new Vector(x, y, z);
|
||||||
|
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(this, player);
|
||||||
|
|
||||||
|
if (!hasPermission(player, "/regionbypass")) {
|
||||||
|
RegionManager mgr = wg.getGlobalRegionManager().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 (getWorldConfig(player.getWorld().getName()).useRegions) {
|
||||||
|
LocalPlayer localPlayer = BukkitPlayer.wrapPlayer(this, player);
|
||||||
|
|
||||||
|
if (!hasPermission(player, "/regionbypass")) {
|
||||||
|
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
|
if (!mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inGroup(Player player, String group) {
|
||||||
|
try {
|
||||||
|
return perms.inGroup(player.getName(), group);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getGroups(Player player) {
|
||||||
|
try {
|
||||||
|
return perms.getGroups(player.getName());
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
return new String[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasPermission(Player player, String perm) {
|
||||||
|
try {
|
||||||
|
return player.isOp() || perms.hasPermission(player.getName(), "worldguard." + perm);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Checks for the command or /region.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param cmd
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean canUseRegionCommand(Player player, String cmd) {
|
||||||
|
return hasPermission(player, "region")
|
||||||
|
|| hasPermission(player, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if there are sufficient permissions, otherwise an exception
|
||||||
|
* is raised in that case.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param permission
|
||||||
|
* @throws InsufficientPermissionsException
|
||||||
|
*/
|
||||||
|
public void checkRegionPermission(CommandSender sender, String permission)
|
||||||
|
throws InsufficientPermissionsException {
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = (Player)sender;
|
||||||
|
if (!hasPermission(player, permission)) {
|
||||||
|
throw new InsufficientPermissionsException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if there are sufficient permissions, otherwise an exception
|
||||||
|
* is raised in that case.
|
||||||
|
*
|
||||||
|
* @param sender
|
||||||
|
* @param permission
|
||||||
|
* @throws InsufficientPermissionsException
|
||||||
|
*/
|
||||||
|
public void checkPermission(CommandSender sender, String permission)
|
||||||
|
throws InsufficientPermissionsException {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!hasPermission((Player)sender, permission)) {
|
||||||
|
throw new InsufficientPermissionsException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a group/player DefaultDomain specification for areas.
|
||||||
|
*
|
||||||
|
* @param domain
|
||||||
|
* @param split
|
||||||
|
* @param startIndex
|
||||||
|
*/
|
||||||
|
public static void addToDomain(DefaultDomain domain,
|
||||||
|
String[] split, int startIndex) {
|
||||||
|
for (int i = startIndex; i < split.length; i++) {
|
||||||
|
String s = split[i];
|
||||||
|
Matcher m = groupPattern.matcher(s);
|
||||||
|
if (m.matches()) {
|
||||||
|
domain.addGroup(m.group(1));
|
||||||
|
} else {
|
||||||
|
domain.addPlayer(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a group/player DefaultDomain specification for areas.
|
||||||
|
*
|
||||||
|
* @param domain
|
||||||
|
* @param split
|
||||||
|
* @param startIndex
|
||||||
|
*/
|
||||||
|
public static void removeFromDomain(DefaultDomain domain,
|
||||||
|
String[] split, int startIndex) {
|
||||||
|
for (int i = startIndex; i < split.length; i++) {
|
||||||
|
String s = split[i];
|
||||||
|
Matcher m = groupPattern.matcher(s);
|
||||||
|
if (m.matches()) {
|
||||||
|
domain.removeGroup(m.group(1));
|
||||||
|
} else {
|
||||||
|
domain.removePlayer(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a group/player DefaultDomain specification for areas.
|
||||||
|
*
|
||||||
|
* @param split
|
||||||
|
* @param startIndex
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static DefaultDomain parseDomainString(String[] split, int startIndex) {
|
||||||
|
DefaultDomain domain = new DefaultDomain();
|
||||||
|
|
||||||
|
for (int i = startIndex; i < split.length; i++) {
|
||||||
|
String s = split[i];
|
||||||
|
Matcher m = groupPattern.matcher(s);
|
||||||
|
if (m.matches()) {
|
||||||
|
domain.addGroup(m.group(1));
|
||||||
|
} else {
|
||||||
|
domain.addPlayer(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isAmphibiousPlayer(String playerName) {
|
||||||
|
|
||||||
|
if (amphibiousPlayers.contains(playerName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInvinciblePlayer(String playerName) {
|
||||||
|
|
||||||
|
if (invinciblePlayers.contains(playerName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAmphibiousPlayer(String playerName) {
|
||||||
|
amphibiousPlayers.add(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addInvinciblePlayer(String playerName) {
|
||||||
|
invinciblePlayers.add(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAmphibiousPlayer(String playerName) {
|
||||||
|
amphibiousPlayers.remove(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeInvinciblePlayer(String playerName) {
|
||||||
|
invinciblePlayers.remove(playerName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forgetPlayerAllBlacklists(LocalPlayer player) {
|
||||||
|
|
||||||
|
for (Map.Entry<String, WorldGuardWorldConfiguration> entry : worldConfig.entrySet()) {
|
||||||
|
Blacklist bl = entry.getValue().getBlacklist();
|
||||||
|
if (bl != null) {
|
||||||
|
bl.forgetPlayer(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldGuardPlugin getWorldGuardPlugin()
|
||||||
|
{
|
||||||
|
return this.wg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -61,17 +61,20 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
|||||||
if (defender instanceof Player) {
|
if (defender instanceof Player) {
|
||||||
Player player = (Player)defender;
|
Player player = (Player)defender;
|
||||||
|
|
||||||
if (plugin.invinciblePlayers.contains(player.getName())) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
|
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableLavaDamage && type == DamageCause.LAVA) {
|
if (wcfg.disableLavaDamage && type == DamageCause.LAVA) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableContactDamage && type == DamageCause.CONTACT) {
|
if (wcfg.disableContactDamage && type == DamageCause.CONTACT) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -86,13 +89,16 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
|||||||
if (defender instanceof Player) {
|
if (defender instanceof Player) {
|
||||||
Player player = (Player)defender;
|
Player player = (Player)defender;
|
||||||
|
|
||||||
if (plugin.invinciblePlayers.contains(player.getName())) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
|
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attacker != null && attacker instanceof Player) {
|
if (attacker != null && attacker instanceof Player) {
|
||||||
if (plugin.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(defender.getLocation());
|
Vector pt = toVector(defender.getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
@ -106,12 +112,12 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attacker != null && attacker instanceof Monster) {
|
if (attacker != null && attacker instanceof Monster) {
|
||||||
if (attacker instanceof Creeper && plugin.blockCreeperExplosions) {
|
if (attacker instanceof Creeper && wcfg.blockCreeperExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(defender.getLocation());
|
Vector pt = toVector(defender.getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
@ -141,13 +147,16 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
|||||||
if (defender instanceof Player) {
|
if (defender instanceof Player) {
|
||||||
Player player = (Player)defender;
|
Player player = (Player)defender;
|
||||||
|
|
||||||
if (plugin.invinciblePlayers.contains(player.getName())) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
|
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attacker != null && attacker instanceof Player) {
|
if (attacker != null && attacker instanceof Player) {
|
||||||
if (plugin.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(defender.getLocation());
|
Vector pt = toVector(defender.getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
@ -160,7 +169,7 @@ public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attacker != null && attacker instanceof Skeleton) {
|
if (attacker != null && attacker instanceof Skeleton) {
|
||||||
if (plugin.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(defender.getLocation());
|
Vector pt = toVector(defender.getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
@ -200,40 +209,43 @@ public void onEntityDamage(EntityDamageEvent event) {
|
|||||||
if (defender instanceof Player) {
|
if (defender instanceof Player) {
|
||||||
Player player = (Player)defender;
|
Player player = (Player)defender;
|
||||||
|
|
||||||
if (plugin.invinciblePlayers.contains(player.getName())) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
|
if (cfg.isInvinciblePlayer(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableFallDamage && type == DamageCause.FALL) {
|
if (wcfg.disableFallDamage && type == DamageCause.FALL) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableFireDamage && (type == DamageCause.FIRE
|
if (wcfg.disableFireDamage && (type == DamageCause.FIRE
|
||||||
|| type == DamageCause.FIRE_TICK)) {
|
|| type == DamageCause.FIRE_TICK)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableDrowningDamage && type == DamageCause.DROWNING) {
|
if (wcfg.disableDrowningDamage && type == DamageCause.DROWNING) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.teleportOnSuffocation && type == DamageCause.SUFFOCATION) {
|
if (wcfg.teleportOnSuffocation && type == DamageCause.SUFFOCATION) {
|
||||||
findFreePosition(player);
|
findFreePosition(player);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.disableSuffocationDamage && type == DamageCause.SUFFOCATION) {
|
if (wcfg.disableSuffocationDamage && type == DamageCause.SUFFOCATION) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == DamageCause.DROWNING
|
if (type == DamageCause.DROWNING
|
||||||
&& plugin.amphibiousPlayers.contains(player.getName())) {
|
&& cfg.isAmphibiousPlayer(player.getName())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -248,18 +260,23 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName());
|
||||||
|
|
||||||
if (event.getEntity() instanceof LivingEntity) {
|
if (event.getEntity() instanceof LivingEntity) {
|
||||||
if (plugin.blockCreeperBlockDamage) {
|
|
||||||
|
|
||||||
|
if (wcfg.blockCreeperBlockDamage) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.blockCreeperExplosions) {
|
if (wcfg.blockCreeperExplosions) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Vector pt = toVector(event.getEntity().getLocation());
|
Vector pt = toVector(event.getEntity().getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
|
||||||
|
|
||||||
@ -270,12 +287,12 @@ public void onEntityExplode(EntityExplodeEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // Shall assume that this is TNT
|
} else { // Shall assume that this is TNT
|
||||||
if (plugin.blockTNT) {
|
if (wcfg.blockTNT) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.useRegions && event.getEntity() != null) {
|
if (wcfg.useRegions && event.getEntity() != null) {
|
||||||
Vector pt = toVector(event.getEntity().getLocation());
|
Vector pt = toVector(event.getEntity().getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
|
||||||
|
|
||||||
@ -294,26 +311,29 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName());
|
||||||
|
|
||||||
CreatureType creaType = (CreatureType)CreatureType.valueOf(event.getMobType().toString());
|
CreatureType creaType = (CreatureType)CreatureType.valueOf(event.getMobType().toString());
|
||||||
String creaName = "";
|
String creaName = "";
|
||||||
Boolean cancelEvent = false;
|
Boolean cancelEvent = false;
|
||||||
|
|
||||||
switch(creaType) {
|
switch(creaType) {
|
||||||
case SPIDER: if (plugin.blockCreatureSpawn.contains("spider")) { cancelEvent = true; } creaName = "spider"; break;
|
case SPIDER: if (wcfg.blockCreatureSpawn.contains("spider")) { cancelEvent = true; } creaName = "spider"; break;
|
||||||
case ZOMBIE: if (plugin.blockCreatureSpawn.contains("zombie")) { cancelEvent = true; } creaName = "zombie"; break;
|
case ZOMBIE: if (wcfg.blockCreatureSpawn.contains("zombie")) { cancelEvent = true; } creaName = "zombie"; break;
|
||||||
case CREEPER: if (plugin.blockCreatureSpawn.contains("creeper")) { cancelEvent = true; } creaName = "creeper"; break;
|
case CREEPER: if (wcfg.blockCreatureSpawn.contains("creeper")) { cancelEvent = true; } creaName = "creeper"; break;
|
||||||
case SKELETON: if (plugin.blockCreatureSpawn.contains("skeleton")) { cancelEvent = true; } creaName = "skeleton"; break;
|
case SKELETON: if (wcfg.blockCreatureSpawn.contains("skeleton")) { cancelEvent = true; } creaName = "skeleton"; break;
|
||||||
case SQUID: if (plugin.blockCreatureSpawn.contains("squid")) { cancelEvent = true; } creaName = "squid"; break;
|
case SQUID: if (wcfg.blockCreatureSpawn.contains("squid")) { cancelEvent = true; } creaName = "squid"; break;
|
||||||
case PIG_ZOMBIE: if (plugin.blockCreatureSpawn.contains("pigzombie")) { cancelEvent = true; } creaName = "pigzombie"; break;
|
case PIG_ZOMBIE: if (wcfg.blockCreatureSpawn.contains("pigzombie")) { cancelEvent = true; } creaName = "pigzombie"; break;
|
||||||
case GHAST: if (plugin.blockCreatureSpawn.contains("ghast")) { cancelEvent = true; } creaName = "ghast"; break;
|
case GHAST: if (wcfg.blockCreatureSpawn.contains("ghast")) { cancelEvent = true; } creaName = "ghast"; break;
|
||||||
case SLIME: if (plugin.blockCreatureSpawn.contains("slime")) { cancelEvent = true; } creaName = "slime"; break;
|
case SLIME: if (wcfg.blockCreatureSpawn.contains("slime")) { cancelEvent = true; } creaName = "slime"; break;
|
||||||
case PIG: if (plugin.blockCreatureSpawn.contains("pig")) { cancelEvent = true; } creaName = "pig"; break;
|
case PIG: if (wcfg.blockCreatureSpawn.contains("pig")) { cancelEvent = true; } creaName = "pig"; break;
|
||||||
case COW: if (plugin.blockCreatureSpawn.contains("cow")) { cancelEvent = true; } creaName = "cow"; break;
|
case COW: if (wcfg.blockCreatureSpawn.contains("cow")) { cancelEvent = true; } creaName = "cow"; break;
|
||||||
case SHEEP: if (plugin.blockCreatureSpawn.contains("sheep")) { cancelEvent = true; } creaName = "sheep"; break;
|
case SHEEP: if (wcfg.blockCreatureSpawn.contains("sheep")) { cancelEvent = true; } creaName = "sheep"; break;
|
||||||
case CHICKEN: if (plugin.blockCreatureSpawn.contains("chicken")) { cancelEvent = true; } creaName = "chicken"; break;
|
case CHICKEN: if (wcfg.blockCreatureSpawn.contains("chicken")) { cancelEvent = true; } creaName = "chicken"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.useRegions && creaName != "") {
|
if (wcfg.useRegions && creaName != "") {
|
||||||
Vector pt = toVector(event.getEntity().getLocation());
|
Vector pt = toVector(event.getEntity().getLocation());
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());
|
||||||
|
|
||||||
|
@ -59,18 +59,21 @@ public WorldGuardPlayerListener(WorldGuardPlugin plugin) {
|
|||||||
@Override
|
@Override
|
||||||
public void onPlayerJoin(PlayerEvent event) {
|
public void onPlayerJoin(PlayerEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (plugin.fireSpreadDisableToggle) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
|
if (wcfg.fireSpreadDisableToggle) {
|
||||||
player.sendMessage(ChatColor.YELLOW
|
player.sendMessage(ChatColor.YELLOW
|
||||||
+ "Fire spread is currently globally disabled.");
|
+ "Fire spread is currently globally disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.inGroup(player, "wg-invincible")) {
|
if (cfg.inGroup(player, "wg-invincible")) {
|
||||||
plugin.invinciblePlayers.add(player.getName());
|
cfg.addInvinciblePlayer(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.inGroup(player, "wg-amphibious")) {
|
if (cfg.inGroup(player, "wg-amphibious")) {
|
||||||
plugin.amphibiousPlayers.add(player.getName());
|
cfg.addAmphibiousPlayer(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,11 +85,14 @@ public void onPlayerJoin(PlayerEvent event) {
|
|||||||
@Override
|
@Override
|
||||||
public void onPlayerQuit(PlayerEvent event) {
|
public void onPlayerQuit(PlayerEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
plugin.invinciblePlayers.remove(player.getName());
|
|
||||||
plugin.amphibiousPlayers.remove(player.getName());
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
if (plugin.blacklist != null) {
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
plugin.blacklist.forgetPlayer(plugin.wrapPlayer(player));
|
|
||||||
}
|
cfg.removeInvinciblePlayer(player.getName());
|
||||||
|
cfg.removeAmphibiousPlayer(player.getName());
|
||||||
|
|
||||||
|
cfg.forgetPlayerAllBlacklists(BukkitPlayer.wrapPlayer(cfg, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,7 +112,10 @@ public void onPlayerItem(PlayerItemEvent event) {
|
|||||||
Block block = event.getBlockClicked();
|
Block block = event.getBlockClicked();
|
||||||
ItemStack item = event.getItem();
|
ItemStack item = event.getItem();
|
||||||
|
|
||||||
if (!plugin.itemDurability) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
|
if (!wcfg.itemDurability) {
|
||||||
// Hoes
|
// Hoes
|
||||||
if (item.getTypeId() >= 290 && item.getTypeId() <= 294) {
|
if (item.getTypeId() >= 290 && item.getTypeId() <= 294) {
|
||||||
item.setDurability((byte)-1);
|
item.setDurability((byte)-1);
|
||||||
@ -114,10 +123,10 @@ public void onPlayerItem(PlayerItemEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.useRegions && !event.isBlock() && block != null) {
|
if (wcfg.useRegions && !event.isBlock() && block != null) {
|
||||||
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
||||||
|
|
||||||
if (!plugin.canBuild(player, pt)) {
|
if (!cfg.canBuild(player, pt)) {
|
||||||
player.sendMessage(ChatColor.DARK_RED
|
player.sendMessage(ChatColor.DARK_RED
|
||||||
+ "You don't have permission for this area.");
|
+ "You don't have permission for this area.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -125,9 +134,9 @@ public void onPlayerItem(PlayerItemEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.blacklist != null && item != null && block != null) {
|
if (wcfg.getBlacklist() != null && item != null && block != null) {
|
||||||
if (!plugin.blacklist.check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new ItemUseBlacklistEvent(plugin.wrapPlayer(player),
|
new ItemUseBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, player),
|
||||||
toVector(block.getRelative(event.getBlockFace())),
|
toVector(block.getRelative(event.getBlockFace())),
|
||||||
item.getTypeId()), false, false)) {
|
item.getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -135,7 +144,7 @@ public void onPlayerItem(PlayerItemEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.useRegions && item != null && block != null && item.getTypeId() == 259) {
|
if (wcfg.useRegions && item != null && block != null && item.getTypeId() == 259) {
|
||||||
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
@ -155,8 +164,11 @@ public void onPlayerItem(PlayerItemEvent event) {
|
|||||||
@Override
|
@Override
|
||||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if (plugin.enforceOneSession) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());
|
||||||
|
|
||||||
|
if (wcfg.enforceOneSession) {
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
|
|
||||||
for (Player pl : plugin.getServer().getOnlinePlayers()) {
|
for (Player pl : plugin.getServer().getOnlinePlayers()) {
|
||||||
@ -179,11 +191,14 @@ public void onPlayerDropItem(PlayerDropItemEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.blacklist != null) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
||||||
|
|
||||||
|
if (wcfg.getBlacklist() != null) {
|
||||||
Item ci = event.getItemDrop();
|
Item ci = event.getItemDrop();
|
||||||
|
|
||||||
if (!plugin.blacklist.check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new ItemDropBlacklistEvent(plugin.wrapPlayer(event
|
new ItemDropBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, event
|
||||||
.getPlayer()), toVector(ci.getLocation()), ci
|
.getPlayer()), toVector(ci.getLocation()), ci
|
||||||
.getItemStack().getTypeId()), false, false)) {
|
.getItemStack().getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -205,11 +220,14 @@ public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.blacklist != null) {
|
WorldGuardConfiguration cfg = plugin.getWgConfiguration();
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(event.getPlayer().getWorld().getName());
|
||||||
|
|
||||||
|
if (wcfg.getBlacklist() != null) {
|
||||||
Item ci = event.getItem();
|
Item ci = event.getItem();
|
||||||
|
|
||||||
if (!plugin.blacklist.check(
|
if (!wcfg.getBlacklist().check(
|
||||||
new ItemAcquireBlacklistEvent(plugin.wrapPlayer(event
|
new ItemAcquireBlacklistEvent(BukkitPlayer.wrapPlayer(cfg, event
|
||||||
.getPlayer()), toVector(ci.getLocation()), ci
|
.getPlayer()), toVector(ci.getLocation()), ci
|
||||||
.getItemStack().getTypeId()), false, false)) {
|
.getItemStack().getTypeId()), false, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -15,45 +15,20 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldguard.bukkit;
|
package com.sk89q.worldguard.bukkit;
|
||||||
|
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.dbs.CSVDatabase;
|
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.server.PluginEvent;
|
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.util.config.Configuration;
|
|
||||||
import com.nijikokun.bukkit.iConomy.iConomy;
|
|
||||||
import com.sk89q.bukkit.migration.PermissionsResolverManager;
|
|
||||||
import com.sk89q.bukkit.migration.PermissionsResolverServerListener;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardServerListener;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
|
||||||
import com.sk89q.worldguard.TickSyncDelayLoggerFilter;
|
|
||||||
import com.sk89q.worldguard.blacklist.*;
|
|
||||||
import com.sk89q.worldguard.blacklist.loggers.*;
|
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler;
|
||||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
|
||||||
import com.sk89q.worldguard.protection.*;
|
import com.sk89q.worldguard.protection.*;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.GlobalRegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.GlobalRegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin for Bukkit.
|
* Plugin for Bukkit.
|
||||||
@ -61,118 +36,41 @@
|
|||||||
* @author sk89qs
|
* @author sk89qs
|
||||||
*/
|
*/
|
||||||
public class WorldGuardPlugin extends JavaPlugin {
|
public class WorldGuardPlugin extends JavaPlugin {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||||
|
|
||||||
private final WorldGuardPlayerListener playerListener =
|
private final WorldGuardPlayerListener playerListener =
|
||||||
new WorldGuardPlayerListener(this);
|
new WorldGuardPlayerListener(this);
|
||||||
private final WorldGuardBlockListener blockListener =
|
private final WorldGuardBlockListener blockListener =
|
||||||
new WorldGuardBlockListener(this);
|
new WorldGuardBlockListener(this);
|
||||||
private final WorldGuardEntityListener entityListener =
|
private final WorldGuardEntityListener entityListener =
|
||||||
new WorldGuardEntityListener(this);
|
new WorldGuardEntityListener(this);
|
||||||
private final WorldGuardServerListener serverListener =
|
private final WorldGuardServerListener serverListener =
|
||||||
new WorldGuardServerListener(this);
|
new WorldGuardServerListener(this);
|
||||||
|
|
||||||
private PermissionsResolverServerListener permsListener;
|
private final CommandHandler commandHandler = new CommandHandler(this);
|
||||||
private PermissionsResolverManager perms;
|
private final GlobalRegionManager globalRegionManager = new GlobalRegionManager(this);
|
||||||
|
private final WorldGuardConfiguration configuration = new WorldGuardConfiguration(this);
|
||||||
private GlobalRegionManager globalRegionManager;
|
|
||||||
private CommandHandler commandHandler;
|
|
||||||
|
|
||||||
Blacklist blacklist;
|
|
||||||
|
|
||||||
public Set<String> invinciblePlayers = new HashSet<String>();
|
|
||||||
public Set<String> amphibiousPlayers = new HashSet<String>();
|
|
||||||
public boolean fireSpreadDisableToggle;
|
|
||||||
|
|
||||||
public static iConomy iConomy;
|
|
||||||
|
|
||||||
// Configuration follows
|
|
||||||
public boolean suppressTickSyncWarnings;
|
|
||||||
public boolean enforceOneSession;
|
|
||||||
public boolean itemDurability;
|
|
||||||
public boolean classicWater;
|
|
||||||
public boolean simulateSponge;
|
|
||||||
public int spongeRadius;
|
|
||||||
public boolean redstoneSponges;
|
|
||||||
public boolean noPhysicsGravel;
|
|
||||||
public boolean noPhysicsSand;
|
|
||||||
public boolean allowPortalAnywhere;
|
|
||||||
public Set<Integer> preventWaterDamage;
|
|
||||||
public boolean blockTNT;
|
|
||||||
public boolean blockLighter;
|
|
||||||
public boolean disableFireSpread;
|
|
||||||
public Set<Integer> disableFireSpreadBlocks;
|
|
||||||
public boolean preventLavaFire;
|
|
||||||
public Set<Integer> allowedLavaSpreadOver;
|
|
||||||
public boolean blockCreeperExplosions;
|
|
||||||
public boolean blockCreeperBlockDamage;
|
|
||||||
public int loginProtection;
|
|
||||||
public int spawnProtection;
|
|
||||||
public boolean kickOnDeath;
|
|
||||||
public boolean exactRespawn;
|
|
||||||
public boolean teleportToHome;
|
|
||||||
public boolean disableContactDamage;
|
|
||||||
public boolean disableFallDamage;
|
|
||||||
public boolean disableLavaDamage;
|
|
||||||
public boolean disableFireDamage;
|
|
||||||
public boolean disableDrowningDamage;
|
|
||||||
public boolean disableSuffocationDamage;
|
|
||||||
public boolean teleportOnSuffocation;
|
|
||||||
public boolean useRegions;
|
|
||||||
public boolean useiConomy;
|
|
||||||
public boolean buyOnClaim;
|
|
||||||
public int buyOnClaimPrice;
|
|
||||||
public int regionWand = 287;
|
|
||||||
public String blockCreatureSpawn = "";
|
|
||||||
/**
|
|
||||||
* Construct the plugin.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public WorldGuardPlugin() {
|
|
||||||
super();
|
|
||||||
this.commandHandler = new CommandHandler(this);
|
|
||||||
|
|
||||||
logger.info("WorldGuard loaded.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on plugin enable.
|
* Called on plugin enable.
|
||||||
*/
|
*/
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
PluginDescriptionFile desc = this.getDescription();
|
|
||||||
File folder = this.getDataFolder();
|
|
||||||
|
|
||||||
folder.mkdirs();
|
|
||||||
|
|
||||||
createDefaultConfiguration("config.yml");
|
|
||||||
createDefaultConfiguration("blacklist.txt");
|
|
||||||
|
|
||||||
globalRegionManager = new GlobalRegionManager(this);
|
|
||||||
|
|
||||||
perms = new PermissionsResolverManager(getConfiguration(), getServer(),
|
|
||||||
"WorldGuard", logger);
|
|
||||||
permsListener = new PermissionsResolverServerListener(perms);
|
|
||||||
|
|
||||||
loadConfiguration();
|
getDataFolder().mkdirs();
|
||||||
postReload();
|
globalRegionManager.onEnable();
|
||||||
registerEvents();
|
registerEvents();
|
||||||
|
|
||||||
if (suppressTickSyncWarnings) {
|
logger.info("WorldGuard " + this.getDescription().getVersion() + " enabled.");
|
||||||
Logger.getLogger("Minecraft").setFilter(new TickSyncDelayLoggerFilter());
|
|
||||||
} else {
|
|
||||||
Filter filter = Logger.getLogger("Minecraft").getFilter();
|
|
||||||
if (filter != null && filter instanceof TickSyncDelayLoggerFilter) {
|
|
||||||
Logger.getLogger("Minecraft").setFilter(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("WorldGuard " + desc.getVersion() + " enabled.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on plugin disable.
|
* Called on plugin disable.
|
||||||
*/
|
*/
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
|
||||||
|
globalRegionManager.onDisable();
|
||||||
|
|
||||||
logger.info("WorldGuard " + this.getDescription().getVersion() + " disabled.");
|
logger.info("WorldGuard " + this.getDescription().getVersion() + " disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,288 +78,33 @@ public void onDisable() {
|
|||||||
* Register used events.
|
* Register used events.
|
||||||
*/
|
*/
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.High);
|
|
||||||
registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.High);
|
|
||||||
registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal);
|
|
||||||
registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Priority.High);
|
|
||||||
registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal);
|
|
||||||
registerEvent(Event.Type.BLOCK_INTERACT, blockListener, Priority.High);
|
|
||||||
registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.High);
|
|
||||||
registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.High);
|
|
||||||
registerEvent(Event.Type.BLOCK_BURN, blockListener, Priority.High);
|
|
||||||
registerEvent(Event.Type.REDSTONE_CHANGE, blockListener, Priority.High);
|
|
||||||
|
|
||||||
registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.High);
|
PluginManager pm = getServer().getPluginManager();
|
||||||
registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.High);
|
|
||||||
registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.High);
|
|
||||||
|
|
||||||
registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.High);
|
pm.registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.High, this);
|
||||||
registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.High);
|
pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Priority.High, this);
|
||||||
registerEvent(Event.Type.PLAYER_PICKUP_ITEM, playerListener, Priority.High);
|
pm.registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal, this);
|
||||||
registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal);
|
pm.registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Priority.High, this);
|
||||||
registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal);
|
pm.registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal, this);
|
||||||
registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal);
|
pm.registerEvent(Event.Type.BLOCK_INTERACT, blockListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_BURN, blockListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Event.Type.REDSTONE_CHANGE, blockListener, Priority.High, this);
|
||||||
|
|
||||||
this.getServer().getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE, serverListener, Priority.Monitor, this);
|
pm.registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Priority.High, this);
|
||||||
|
|
||||||
permsListener.register(this);
|
pm.registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_PICKUP_ITEM, playerListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
|
||||||
|
|
||||||
// 25 equals about 1s real time
|
// 25 equals about 1s real time
|
||||||
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new TimedFlagsTimer(this), 25*5, 25*5);
|
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new TimedFlagsTimer(this), 25 * 5, 25 * 5);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register an event.
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param listener
|
|
||||||
* @param priority
|
|
||||||
*/
|
|
||||||
private void registerEvent(Event.Type type, Listener listener, Priority priority) {
|
|
||||||
getServer().getPluginManager().registerEvent(type, listener, priority, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a default configuration file from the .jar.
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
private void createDefaultConfiguration(String name) {
|
|
||||||
File actual = new File(getDataFolder(), name);
|
|
||||||
if (!actual.exists()) {
|
|
||||||
|
|
||||||
InputStream input =
|
|
||||||
WorldGuardPlugin.class.getResourceAsStream("/defaults/" + name);
|
|
||||||
if (input != null) {
|
|
||||||
FileOutputStream output = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
output = new FileOutputStream(actual);
|
|
||||||
byte[] buf = new byte[8192];
|
|
||||||
int length = 0;
|
|
||||||
while ((length = input.read(buf)) > 0) {
|
|
||||||
output.write(buf, 0, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("WorldGuard: Default configuration file written: "
|
|
||||||
+ name);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (input != null)
|
|
||||||
input.close();
|
|
||||||
} catch (IOException e) {}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (output != null)
|
|
||||||
output.close();
|
|
||||||
} catch (IOException e) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the configuration.
|
|
||||||
*/
|
|
||||||
public void loadConfiguration() {
|
|
||||||
Configuration config = getConfiguration();
|
|
||||||
config.load();
|
|
||||||
perms.load();
|
|
||||||
|
|
||||||
suppressTickSyncWarnings = config.getBoolean("suppress-tick-sync-warnings", false);
|
|
||||||
|
|
||||||
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
|
||||||
itemDurability = config.getBoolean("protection.item-durability", true);
|
|
||||||
|
|
||||||
classicWater = config.getBoolean("simulation.classic-water", false);
|
|
||||||
simulateSponge = config.getBoolean("simulation.sponge.enable", true);
|
|
||||||
spongeRadius = Math.max(1, config.getInt("simulation.sponge.radius", 3)) - 1;
|
|
||||||
redstoneSponges = config.getBoolean("simulation.sponge.redstone", false);
|
|
||||||
|
|
||||||
noPhysicsGravel = config.getBoolean("physics.no-physics-gravel", false);
|
|
||||||
noPhysicsSand = config.getBoolean("physics.no-physics-sand", false);
|
|
||||||
allowPortalAnywhere = config.getBoolean("physics.allow-portal-anywhere", false);
|
|
||||||
preventWaterDamage = new HashSet<Integer>(config.getIntList("physics.disable-water-damage-blocks", null));
|
|
||||||
|
|
||||||
blockTNT = config.getBoolean("ignition.block-tnt", false);
|
|
||||||
blockLighter = config.getBoolean("ignition.block-lighter", false);
|
|
||||||
|
|
||||||
preventLavaFire = config.getBoolean("fire.disable-lava-fire-spread", true);
|
|
||||||
disableFireSpread = config.getBoolean("fire.disable-all-fire-spread", false);
|
|
||||||
disableFireSpreadBlocks = new HashSet<Integer>(config.getIntList("fire.disable-fire-spread-blocks", null));
|
|
||||||
allowedLavaSpreadOver = new HashSet<Integer>(config.getIntList("fire.lava-spread-blocks", null));
|
|
||||||
|
|
||||||
blockCreeperExplosions = config.getBoolean("mobs.block-creeper-explosions", false);
|
|
||||||
blockCreeperBlockDamage = config.getBoolean("mobs.block-creeper-block-damage", false);
|
|
||||||
|
|
||||||
loginProtection = config.getInt("spawn.login-protection", 3);
|
|
||||||
spawnProtection = config.getInt("spawn.spawn-protection", 0);
|
|
||||||
kickOnDeath = config.getBoolean("spawn.kick-on-death", false);
|
|
||||||
exactRespawn = config.getBoolean("spawn.exact-respawn", false);
|
|
||||||
teleportToHome = config.getBoolean("spawn.teleport-to-home-on-death", false);
|
|
||||||
|
|
||||||
disableFallDamage = config.getBoolean("player-damage.disable-fall-damage", false);
|
|
||||||
disableLavaDamage = config.getBoolean("player-damage.disable-lava-damage", false);
|
|
||||||
disableFireDamage = config.getBoolean("player-damage.disable-fire-damage", false);
|
|
||||||
disableDrowningDamage = config.getBoolean("player-damage.disable-drowning-damage", false);
|
|
||||||
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);
|
|
||||||
|
|
||||||
for (String creature : config.getStringList("mobs.block-creature-spawn", null)) {
|
|
||||||
blockCreatureSpawn += creature.toLowerCase() + " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
useiConomy = config.getBoolean("iconomy.enable", false);
|
|
||||||
buyOnClaim = config.getBoolean("iconomy.buy-on-claim", false);
|
|
||||||
buyOnClaimPrice = config.getInt("iconomy.buy-on-claim-price", 1);
|
|
||||||
|
|
||||||
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);
|
|
||||||
globalFlags.canLighter = config.getBoolean("regions.default.lighter", true);
|
|
||||||
globalFlags.canTnt = config.getBoolean("regions.default.tnt", true);
|
|
||||||
globalFlags.allowCreeper = config.getBoolean("regions.default.creeper", true);
|
|
||||||
globalFlags.allowMobDamage = config.getBoolean("regions.default.mobdamage", true);
|
|
||||||
globalFlags.allowWaterflow = config.getBoolean("regions.default.waterflow", true);
|
|
||||||
globalRegionManager.setGlobalFlags(globalFlags);
|
|
||||||
|
|
||||||
try {
|
|
||||||
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(), "regions.txt.old"));
|
|
||||||
|
|
||||||
logger.info("WorldGuard: Done.");
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.warning("WorldGuard: Failed to load regions: "
|
|
||||||
+ e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Console log configuration
|
|
||||||
boolean logConsole = config.getBoolean("blacklist.logging.console.enable", true);
|
|
||||||
|
|
||||||
// Database log configuration
|
|
||||||
boolean logDatabase = config.getBoolean("blacklist.logging.database.enable", false);
|
|
||||||
String dsn = config.getString("blacklist.logging.database.dsn", "jdbc:mysql://localhost:3306/minecraft");
|
|
||||||
String user = config.getString("blacklist.logging.database.user", "root");
|
|
||||||
String pass = config.getString("blacklist.logging.database.pass", "");
|
|
||||||
String table = config.getString("blacklist.logging.database.table", "blacklist_events");
|
|
||||||
|
|
||||||
// File log configuration
|
|
||||||
boolean logFile = config.getBoolean("blacklist.logging.file.enable", false);
|
|
||||||
String logFilePattern = config.getString("blacklist.logging.file.path", "worldguard/logs/%Y-%m-%d.log");
|
|
||||||
int logFileCacheSize = Math.max(1, config.getInt("blacklist.logging.file.open-files", 10));
|
|
||||||
|
|
||||||
// Load the blacklist
|
|
||||||
try {
|
|
||||||
// If there was an existing blacklist, close loggers
|
|
||||||
if (blacklist != null) {
|
|
||||||
blacklist.getLogger().close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// First load the blacklist data from worldguard-blacklist.txt
|
|
||||||
Blacklist blist = new BukkitBlacklist(this);
|
|
||||||
blist.load(new File(getDataFolder(), "blacklist.txt"));
|
|
||||||
|
|
||||||
// If the blacklist is empty, then set the field to null
|
|
||||||
// and save some resources
|
|
||||||
if (blist.isEmpty()) {
|
|
||||||
this.blacklist = null;
|
|
||||||
} else {
|
|
||||||
this.blacklist = blist;
|
|
||||||
logger.log(Level.INFO, "WorldGuard: Blacklist loaded.");
|
|
||||||
|
|
||||||
BlacklistLogger blacklistLogger = blist.getLogger();
|
|
||||||
|
|
||||||
if (logDatabase) {
|
|
||||||
blacklistLogger.addHandler(new DatabaseLoggerHandler(dsn, user, pass, table));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logConsole) {
|
|
||||||
blacklistLogger.addHandler(new ConsoleLoggerHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logFile) {
|
|
||||||
FileLoggerHandler handler =
|
|
||||||
new FileLoggerHandler(logFilePattern, logFileCacheSize);
|
|
||||||
blacklistLogger.addHandler(handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
logger.log(Level.WARNING, "WorldGuard blacklist does not exist.");
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.log(Level.WARNING, "Could not load WorldGuard blacklist: "
|
|
||||||
+ e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print an overview of settings
|
|
||||||
if (config.getBoolean("summary-on-start", true)) {
|
|
||||||
logger.log(Level.INFO, enforceOneSession ? "WorldGuard: Single session is enforced."
|
|
||||||
: "WorldGuard: Single session is NOT ENFORCED.");
|
|
||||||
logger.log(Level.INFO, blockTNT ? "WorldGuard: TNT ignition is blocked."
|
|
||||||
: "WorldGuard: TNT ignition is PERMITTED.");
|
|
||||||
logger.log(Level.INFO, blockLighter ? "WorldGuard: Lighters are blocked."
|
|
||||||
: "WorldGuard: Lighters are PERMITTED.");
|
|
||||||
logger.log(Level.INFO, preventLavaFire ? "WorldGuard: Lava fire is blocked."
|
|
||||||
: "WorldGuard: Lava fire is PERMITTED.");
|
|
||||||
if (disableFireSpread) {
|
|
||||||
logger.log(Level.INFO, "WorldGuard: All fire spread is disabled.");
|
|
||||||
} else {
|
|
||||||
if (disableFireSpreadBlocks.size() > 0) {
|
|
||||||
logger.log(Level.INFO, "WorldGuard: Fire spread is limited to "
|
|
||||||
+ disableFireSpreadBlocks.size() + " block types.");
|
|
||||||
} else {
|
|
||||||
logger.log(Level.INFO, "WorldGuard: Fire spread is UNRESTRICTED.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Temporary
|
|
||||||
perms.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Populates various lists.
|
|
||||||
*/
|
|
||||||
public void postReload() {
|
|
||||||
invinciblePlayers.clear();
|
|
||||||
amphibiousPlayers.clear();
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
|
||||||
if (inGroup(player, "wg-invincible")) {
|
|
||||||
invinciblePlayers.add(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inGroup(player, "wg-amphibious")) {
|
|
||||||
amphibiousPlayers.add(player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (NullPointerException e) { // Thrown if loaded too early
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -469,91 +112,25 @@ public void postReload() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||||
|
return commandHandler.handleCommand(sender, cmd, commandLabel, args);
|
||||||
return commandHandler.handleCommand(sender, cmd, commandLabel, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the region manager.
|
* Get the GlobalRegionManager.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public GlobalRegionManager getGlobalRegionManager() {
|
public GlobalRegionManager getGlobalRegionManager() {
|
||||||
return globalRegionManager;
|
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 mgr = globalRegionManager.getRegionManager(player.getWorld().getName());
|
* Get the WorldGuardConfiguraton.
|
||||||
|
*
|
||||||
if (!mgr.getApplicableRegions(pt).canBuild(localPlayer)) {
|
* @return
|
||||||
return false;
|
*/
|
||||||
}
|
public WorldGuardConfiguration getWgConfiguration() {
|
||||||
}
|
return configuration;
|
||||||
|
|
||||||
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 {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean inGroup(Player player, String group) {
|
|
||||||
try {
|
|
||||||
return perms.inGroup(player.getName(), group);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasPermission(Player player, String perm) {
|
|
||||||
try {
|
|
||||||
return player.isOp() || perms.hasPermission(player.getName(), perm);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getGroups(Player player) {
|
|
||||||
try {
|
|
||||||
return perms.getGroups(player.getName());
|
|
||||||
} catch (Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public BukkitPlayer wrapPlayer(Player player) {
|
|
||||||
return new BukkitPlayer(this, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,307 @@
|
|||||||
|
// $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.bukkit;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||||
|
import com.sk89q.worldguard.blacklist.BlacklistLogger;
|
||||||
|
import com.sk89q.worldguard.blacklist.loggers.ConsoleLoggerHandler;
|
||||||
|
import com.sk89q.worldguard.blacklist.loggers.DatabaseLoggerHandler;
|
||||||
|
import com.sk89q.worldguard.blacklist.loggers.FileLoggerHandler;
|
||||||
|
import com.sk89q.worldguard.protection.GlobalFlags;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import org.bukkit.util.config.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Michael
|
||||||
|
*/
|
||||||
|
public class WorldGuardWorldConfiguration {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||||
|
|
||||||
|
private WorldGuardPlugin wp;
|
||||||
|
|
||||||
|
private String worldName;
|
||||||
|
private File configFile;
|
||||||
|
private File blacklistFile;
|
||||||
|
|
||||||
|
private Blacklist blacklist;
|
||||||
|
|
||||||
|
|
||||||
|
/* Configuration data start */
|
||||||
|
public boolean fireSpreadDisableToggle;
|
||||||
|
public boolean enforceOneSession;
|
||||||
|
public boolean itemDurability;
|
||||||
|
public boolean classicWater;
|
||||||
|
public boolean simulateSponge;
|
||||||
|
public int spongeRadius;
|
||||||
|
public boolean redstoneSponges;
|
||||||
|
public boolean noPhysicsGravel;
|
||||||
|
public boolean noPhysicsSand;
|
||||||
|
public boolean allowPortalAnywhere;
|
||||||
|
public Set<Integer> preventWaterDamage;
|
||||||
|
public boolean blockTNT;
|
||||||
|
public boolean blockLighter;
|
||||||
|
public boolean disableFireSpread;
|
||||||
|
public Set<Integer> disableFireSpreadBlocks;
|
||||||
|
public boolean preventLavaFire;
|
||||||
|
public Set<Integer> allowedLavaSpreadOver;
|
||||||
|
public boolean blockCreeperExplosions;
|
||||||
|
public boolean blockCreeperBlockDamage;
|
||||||
|
public int loginProtection;
|
||||||
|
public int spawnProtection;
|
||||||
|
public boolean kickOnDeath;
|
||||||
|
public boolean exactRespawn;
|
||||||
|
public boolean teleportToHome;
|
||||||
|
public boolean disableContactDamage;
|
||||||
|
public boolean disableFallDamage;
|
||||||
|
public boolean disableLavaDamage;
|
||||||
|
public boolean disableFireDamage;
|
||||||
|
public boolean disableDrowningDamage;
|
||||||
|
public boolean disableSuffocationDamage;
|
||||||
|
public boolean teleportOnSuffocation;
|
||||||
|
public boolean useRegions;
|
||||||
|
public int regionWand = 287;
|
||||||
|
public String blockCreatureSpawn;
|
||||||
|
/* Configuration data end */
|
||||||
|
|
||||||
|
|
||||||
|
public WorldGuardWorldConfiguration(WorldGuardPlugin wp, String worldName, File configFile, File blacklistFile)
|
||||||
|
{
|
||||||
|
this.wp = wp;
|
||||||
|
this.worldName = worldName;
|
||||||
|
this.configFile = configFile;
|
||||||
|
this.blacklistFile = blacklistFile;
|
||||||
|
|
||||||
|
createDefaultConfiguration(configFile, "config.yml");
|
||||||
|
createDefaultConfiguration(blacklistFile, "blacklist.txt");
|
||||||
|
|
||||||
|
loadConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a default configuration file from the .jar.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public static void createDefaultConfiguration(File actual, String defaultName) {
|
||||||
|
|
||||||
|
if (!actual.exists()) {
|
||||||
|
|
||||||
|
InputStream input =
|
||||||
|
WorldGuardPlugin.class.getResourceAsStream("/defaults/" + defaultName);
|
||||||
|
if (input != null) {
|
||||||
|
FileOutputStream output = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
output = new FileOutputStream(actual);
|
||||||
|
byte[] buf = new byte[8192];
|
||||||
|
int length = 0;
|
||||||
|
while ((length = input.read(buf)) > 0) {
|
||||||
|
output.write(buf, 0, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("WorldGuard: Default configuration file written: " + defaultName);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (input != null) {
|
||||||
|
input.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (output != null) {
|
||||||
|
output.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the configuration.
|
||||||
|
*/
|
||||||
|
private void loadConfiguration() {
|
||||||
|
Configuration config = new Configuration(this.configFile);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
||||||
|
itemDurability = config.getBoolean("protection.item-durability", true);
|
||||||
|
|
||||||
|
classicWater = config.getBoolean("simulation.classic-water", false);
|
||||||
|
simulateSponge = config.getBoolean("simulation.sponge.enable", true);
|
||||||
|
spongeRadius = Math.max(1, config.getInt("simulation.sponge.radius", 3)) - 1;
|
||||||
|
redstoneSponges = config.getBoolean("simulation.sponge.redstone", false);
|
||||||
|
|
||||||
|
noPhysicsGravel = config.getBoolean("physics.no-physics-gravel", false);
|
||||||
|
noPhysicsSand = config.getBoolean("physics.no-physics-sand", false);
|
||||||
|
allowPortalAnywhere = config.getBoolean("physics.allow-portal-anywhere", false);
|
||||||
|
preventWaterDamage = new HashSet<Integer>(config.getIntList("physics.disable-water-damage-blocks", null));
|
||||||
|
|
||||||
|
blockTNT = config.getBoolean("ignition.block-tnt", false);
|
||||||
|
blockLighter = config.getBoolean("ignition.block-lighter", false);
|
||||||
|
|
||||||
|
preventLavaFire = config.getBoolean("fire.disable-lava-fire-spread", true);
|
||||||
|
disableFireSpread = config.getBoolean("fire.disable-all-fire-spread", false);
|
||||||
|
disableFireSpreadBlocks = new HashSet<Integer>(config.getIntList("fire.disable-fire-spread-blocks", null));
|
||||||
|
allowedLavaSpreadOver = new HashSet<Integer>(config.getIntList("fire.lava-spread-blocks", null));
|
||||||
|
|
||||||
|
blockCreeperExplosions = config.getBoolean("mobs.block-creeper-explosions", false);
|
||||||
|
blockCreeperBlockDamage = config.getBoolean("mobs.block-creeper-block-damage", false);
|
||||||
|
|
||||||
|
loginProtection = config.getInt("spawn.login-protection", 3);
|
||||||
|
spawnProtection = config.getInt("spawn.spawn-protection", 0);
|
||||||
|
kickOnDeath = config.getBoolean("spawn.kick-on-death", false);
|
||||||
|
exactRespawn = config.getBoolean("spawn.exact-respawn", false);
|
||||||
|
teleportToHome = config.getBoolean("spawn.teleport-to-home-on-death", false);
|
||||||
|
|
||||||
|
disableFallDamage = config.getBoolean("player-damage.disable-fall-damage", false);
|
||||||
|
disableLavaDamage = config.getBoolean("player-damage.disable-lava-damage", false);
|
||||||
|
disableFireDamage = config.getBoolean("player-damage.disable-fire-damage", false);
|
||||||
|
disableDrowningDamage = config.getBoolean("player-damage.disable-drowning-damage", false);
|
||||||
|
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);
|
||||||
|
|
||||||
|
for (String creature : config.getStringList("mobs.block-creature-spawn", null)) {
|
||||||
|
blockCreatureSpawn += creature.toLowerCase() + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
globalFlags.canLighter = config.getBoolean("regions.default.lighter", true);
|
||||||
|
globalFlags.canTnt = config.getBoolean("regions.default.tnt", true);
|
||||||
|
globalFlags.allowCreeper = config.getBoolean("regions.default.creeper", true);
|
||||||
|
globalFlags.allowMobDamage = config.getBoolean("regions.default.mobdamage", true);
|
||||||
|
wp.getGlobalRegionManager().setGlobalFlags(worldName, globalFlags);
|
||||||
|
|
||||||
|
|
||||||
|
// Console log configuration
|
||||||
|
boolean logConsole = config.getBoolean("blacklist.logging.console.enable", true);
|
||||||
|
|
||||||
|
// Database log configuration
|
||||||
|
boolean logDatabase = config.getBoolean("blacklist.logging.database.enable", false);
|
||||||
|
String dsn = config.getString("blacklist.logging.database.dsn", "jdbc:mysql://localhost:3306/minecraft");
|
||||||
|
String user = config.getString("blacklist.logging.database.user", "root");
|
||||||
|
String pass = config.getString("blacklist.logging.database.pass", "");
|
||||||
|
String table = config.getString("blacklist.logging.database.table", "blacklist_events");
|
||||||
|
|
||||||
|
// File log configuration
|
||||||
|
boolean logFile = config.getBoolean("blacklist.logging.file.enable", false);
|
||||||
|
String logFilePattern = config.getString("blacklist.logging.file.path", "worldguard/logs/%Y-%m-%d.log");
|
||||||
|
int logFileCacheSize = Math.max(1, config.getInt("blacklist.logging.file.open-files", 10));
|
||||||
|
|
||||||
|
// Load the blacklist
|
||||||
|
try {
|
||||||
|
// If there was an existing blacklist, close loggers
|
||||||
|
if (blacklist != null) {
|
||||||
|
blacklist.getLogger().close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// First load the blacklist data from worldguard-blacklist.txt
|
||||||
|
Blacklist blist = new BukkitBlacklist(wp);
|
||||||
|
blist.load(blacklistFile);
|
||||||
|
|
||||||
|
// If the blacklist is empty, then set the field to null
|
||||||
|
// and save some resources
|
||||||
|
if (blist.isEmpty()) {
|
||||||
|
this.blacklist = null;
|
||||||
|
} else {
|
||||||
|
this.blacklist = blist;
|
||||||
|
logger.log(Level.INFO, "WorldGuard: Blacklist loaded.");
|
||||||
|
|
||||||
|
BlacklistLogger blacklistLogger = blist.getLogger();
|
||||||
|
|
||||||
|
if (logDatabase) {
|
||||||
|
blacklistLogger.addHandler(new DatabaseLoggerHandler(dsn, user, pass, table, worldName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logConsole) {
|
||||||
|
blacklistLogger.addHandler(new ConsoleLoggerHandler(worldName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (logFile) {
|
||||||
|
FileLoggerHandler handler =
|
||||||
|
new FileLoggerHandler(logFilePattern, logFileCacheSize, worldName);
|
||||||
|
blacklistLogger.addHandler(handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
logger.log(Level.WARNING, "WorldGuard blacklist does not exist.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.log(Level.WARNING, "Could not load WorldGuard blacklist: "
|
||||||
|
+ e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print an overview of settings
|
||||||
|
if (config.getBoolean("summary-on-start", true)) {
|
||||||
|
logger.log(Level.INFO, "=============== WorldGuard configuration for world " + worldName + " ===============");
|
||||||
|
logger.log(Level.INFO, enforceOneSession ? "WorldGuard: Single session is enforced."
|
||||||
|
: "WorldGuard: Single session is NOT ENFORCED.");
|
||||||
|
logger.log(Level.INFO, blockTNT ? "WorldGuard: TNT ignition is blocked."
|
||||||
|
: "WorldGuard: TNT ignition is PERMITTED.");
|
||||||
|
logger.log(Level.INFO, blockLighter ? "WorldGuard: Lighters are blocked."
|
||||||
|
: "WorldGuard: Lighters are PERMITTED.");
|
||||||
|
logger.log(Level.INFO, preventLavaFire ? "WorldGuard: Lava fire is blocked."
|
||||||
|
: "WorldGuard: Lava fire is PERMITTED.");
|
||||||
|
if (disableFireSpread) {
|
||||||
|
logger.log(Level.INFO, "WorldGuard: All fire spread is disabled.");
|
||||||
|
} else {
|
||||||
|
if (disableFireSpreadBlocks.size() > 0) {
|
||||||
|
logger.log(Level.INFO, "WorldGuard: Fire spread is limited to "
|
||||||
|
+ disableFireSpreadBlocks.size() + " block types.");
|
||||||
|
} else {
|
||||||
|
logger.log(Level.INFO, "WorldGuard: Fire spread is UNRESTRICTED.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Blacklist getBlacklist()
|
||||||
|
{
|
||||||
|
return this.blacklist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWorldName()
|
||||||
|
{
|
||||||
|
return this.worldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -20,10 +20,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -31,20 +34,38 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandAllowFire extends WgCommand {
|
public class CommandAllowFire extends WgCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||||
{
|
|
||||||
ch.checkPermission(sender, "/stopfire");
|
|
||||||
ch.checkArgs(args, 0, 0);
|
|
||||||
|
|
||||||
if (wg.fireSpreadDisableToggle) {
|
cfg.checkPermission(sender, "allowfire");
|
||||||
wg.getServer().broadcastMessage(ChatColor.YELLOW
|
|
||||||
+ "Fire spread has been globally re-enabled by " + senderName + ".");
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Fire spread was already globally enabled.");
|
|
||||||
}
|
|
||||||
|
|
||||||
wg.fireSpreadDisableToggle = false;
|
String worldName;
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
CommandHandler.checkArgs(args, 0, 0);
|
||||||
|
worldName = ((Player)sender).getWorld().getName();
|
||||||
|
} else {
|
||||||
|
CommandHandler.checkArgs(args, 1, 1);
|
||||||
|
worldName = args[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
Server server = cfg.getWorldGuardPlugin().getServer();
|
||||||
|
if(server.getWorld(worldName) == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Invalid world specified.");
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||||
|
|
||||||
|
if (wcfg.fireSpreadDisableToggle) {
|
||||||
|
server.broadcastMessage(ChatColor.YELLOW
|
||||||
|
+ "Fire spread has been globally re-enabled by " + senderName + ".");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Fire spread was already globally enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
wcfg.fireSpreadDisableToggle = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -32,46 +32,37 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandGod extends WgCommand {
|
public class CommandGod extends WgCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
CommandHandler.checkArgs(args, 0, 1);
|
||||||
sender.sendMessage("Only players may use this command");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
ch.checkPermission(player, "/god");
|
|
||||||
ch.checkArgs(args, 0, 1);
|
|
||||||
|
|
||||||
// Allow setting other people invincible
|
// Allow setting other people invincible
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (!wg.hasPermission(player, "/godother")) {
|
cfg.checkPermission(sender, "god.other");
|
||||||
player.sendMessage(ChatColor.RED + "You don't have permission to make others invincible.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player other = matchSinglePlayer(wg.getServer(), args[0]);
|
Player other = matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
player.sendMessage(ChatColor.RED + "Player not found.");
|
sender.sendMessage(ChatColor.RED + "Player not found.");
|
||||||
} else {
|
} else {
|
||||||
if (!wg.invinciblePlayers.contains(other.getName())) {
|
if (!cfg.isInvinciblePlayer(other.getName())) {
|
||||||
wg.invinciblePlayers.add(other.getName());
|
cfg.addInvinciblePlayer(other.getName());
|
||||||
player.sendMessage(ChatColor.YELLOW + other.getName() + " is now invincible!");
|
sender.sendMessage(ChatColor.YELLOW + other.getName() + " is now invincible!");
|
||||||
other.sendMessage(ChatColor.YELLOW + player.getName() + " has made you invincible!");
|
other.sendMessage(ChatColor.YELLOW + senderName + " has made you invincible!");
|
||||||
} else {
|
} else {
|
||||||
wg.invinciblePlayers.remove(other.getName());
|
cfg.removeInvinciblePlayer(other.getName());
|
||||||
player.sendMessage(ChatColor.YELLOW + other.getName() + " is no longer invincible.");
|
sender.sendMessage(ChatColor.YELLOW + other.getName() + " is no longer invincible.");
|
||||||
other.sendMessage(ChatColor.YELLOW + player.getName() + " has taken away your invincibility.");
|
other.sendMessage(ChatColor.YELLOW + senderName + " has taken away your invincibility.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Invincibility for one's self
|
// Invincibility for one's self
|
||||||
} else {
|
} else if(sender instanceof Player) {
|
||||||
if (!wg.invinciblePlayers.contains(player.getName())) {
|
cfg.checkPermission(sender, "god.self");
|
||||||
wg.invinciblePlayers.add(player.getName());
|
Player player = (Player)sender;
|
||||||
|
if (!cfg.isInvinciblePlayer(player.getName())) {
|
||||||
|
cfg.addInvinciblePlayer(player.getName());
|
||||||
player.sendMessage(ChatColor.YELLOW + "You are now invincible!");
|
player.sendMessage(ChatColor.YELLOW + "You are now invincible!");
|
||||||
} else {
|
} else {
|
||||||
wg.invinciblePlayers.remove(player.getName());
|
cfg.removeInvinciblePlayer(player.getName());
|
||||||
player.sendMessage(ChatColor.YELLOW + "You are no longer invincible.");
|
player.sendMessage(ChatColor.YELLOW + "You are no longer invincible.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -40,7 +37,6 @@ public class CommandHandler {
|
|||||||
private WorldGuardPlugin wg;
|
private WorldGuardPlugin wg;
|
||||||
private Map<String, WgCommand> commandMap;
|
private Map<String, WgCommand> commandMap;
|
||||||
|
|
||||||
private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$");
|
|
||||||
public static int CMD_LIST_SIZE = 9;
|
public static int CMD_LIST_SIZE = 9;
|
||||||
|
|
||||||
public CommandHandler(WorldGuardPlugin wg)
|
public CommandHandler(WorldGuardPlugin wg)
|
||||||
@ -48,17 +44,18 @@ public CommandHandler(WorldGuardPlugin wg)
|
|||||||
this.wg = wg;
|
this.wg = wg;
|
||||||
this.commandMap = new HashMap<String, WgCommand>();
|
this.commandMap = new HashMap<String, WgCommand>();
|
||||||
|
|
||||||
|
// commands that DO support console as sender
|
||||||
this.commandMap.put("allowfire", new CommandAllowFire());
|
this.commandMap.put("allowfire", new CommandAllowFire());
|
||||||
this.commandMap.put("god", new CommandGod());
|
this.commandMap.put("god", new CommandGod());
|
||||||
this.commandMap.put("heal", new CommandHeal());
|
this.commandMap.put("heal", new CommandHeal());
|
||||||
this.commandMap.put("locate", new CommandLocate());
|
|
||||||
this.commandMap.put("region", new RegionCommandHandler());
|
this.commandMap.put("region", new RegionCommandHandler());
|
||||||
this.commandMap.put("reloadwg", new CommandReloadWG());
|
this.commandMap.put("reloadwg", new CommandReloadWG());
|
||||||
this.commandMap.put("slay", new CommandSlay());
|
this.commandMap.put("slay", new CommandSlay());
|
||||||
this.commandMap.put("stack", new CommandStack());
|
|
||||||
this.commandMap.put("stopfire", new CommandStopFire());
|
this.commandMap.put("stopfire", new CommandStopFire());
|
||||||
this.commandMap.put("tpregrion", new CommandTpRegion());
|
|
||||||
this.commandMap.put("buyregion", new CommandBuyRegion());
|
// commands that DO NOT support console as sender
|
||||||
|
this.commandMap.put("stack", new CommandStack());
|
||||||
|
this.commandMap.put("locate", new CommandLocate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +71,7 @@ public boolean handleCommand(CommandSender sender, Command cmd, String commandLa
|
|||||||
|
|
||||||
String senderName = sender instanceof Player ? ((Player)sender).getName() : "Console";
|
String senderName = sender instanceof Player ? ((Player)sender).getName() : "Console";
|
||||||
|
|
||||||
wgcmd.handle(sender, senderName, cmdName, args, this, wg);
|
wgcmd.handle(sender, senderName, cmdName, args, wg.getWgConfiguration());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (InsufficientArgumentsException e) {
|
} catch (InsufficientArgumentsException e) {
|
||||||
@ -168,113 +165,6 @@ public String getHelp() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks for the command or /region.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param cmd
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean canUseRegionCommand(Player player, String cmd) {
|
|
||||||
return wg.hasPermission(player, "/region")
|
|
||||||
|| wg.hasPermission(player, cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if there are sufficient permissions, otherwise an exception
|
|
||||||
* is raised in that case.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param permission
|
|
||||||
* @throws InsufficientPermissionsException
|
|
||||||
*/
|
|
||||||
public void checkRegionPermission(Player player, String permission)
|
|
||||||
throws InsufficientPermissionsException {
|
|
||||||
if (!wg.hasPermission(player, "/region") && !wg.hasPermission(player, permission)) {
|
|
||||||
throw new InsufficientPermissionsException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if there are sufficient permissions, otherwise an exception
|
|
||||||
* is raised in that case.
|
|
||||||
*
|
|
||||||
* @param sender
|
|
||||||
* @param permission
|
|
||||||
* @throws InsufficientPermissionsException
|
|
||||||
*/
|
|
||||||
public void checkPermission(CommandSender sender, String permission)
|
|
||||||
throws InsufficientPermissionsException {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!wg.hasPermission((Player)sender, permission)) {
|
|
||||||
throw new InsufficientPermissionsException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a group/player DefaultDomain specification for areas.
|
|
||||||
*
|
|
||||||
* @param domain
|
|
||||||
* @param split
|
|
||||||
* @param startIndex
|
|
||||||
*/
|
|
||||||
public static void addToDomain(DefaultDomain domain,
|
|
||||||
String[] split, int startIndex) {
|
|
||||||
for (int i = startIndex; i < split.length; i++) {
|
|
||||||
String s = split[i];
|
|
||||||
Matcher m = groupPattern.matcher(s);
|
|
||||||
if (m.matches()) {
|
|
||||||
domain.addGroup(m.group(1));
|
|
||||||
} else {
|
|
||||||
domain.addPlayer(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a group/player DefaultDomain specification for areas.
|
|
||||||
*
|
|
||||||
* @param domain
|
|
||||||
* @param split
|
|
||||||
* @param startIndex
|
|
||||||
*/
|
|
||||||
public static void removeFromDomain(DefaultDomain domain,
|
|
||||||
String[] split, int startIndex) {
|
|
||||||
for (int i = startIndex; i < split.length; i++) {
|
|
||||||
String s = split[i];
|
|
||||||
Matcher m = groupPattern.matcher(s);
|
|
||||||
if (m.matches()) {
|
|
||||||
domain.removeGroup(m.group(1));
|
|
||||||
} else {
|
|
||||||
domain.removePlayer(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse a group/player DefaultDomain specification for areas.
|
|
||||||
*
|
|
||||||
* @param split
|
|
||||||
* @param startIndex
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static DefaultDomain parseDomainString(String[] split, int startIndex) {
|
|
||||||
DefaultDomain domain = new DefaultDomain();
|
|
||||||
|
|
||||||
for (int i = startIndex; i < split.length; i++) {
|
|
||||||
String s = split[i];
|
|
||||||
Matcher m = groupPattern.matcher(s);
|
|
||||||
if (m.matches()) {
|
|
||||||
domain.addGroup(m.group(1));
|
|
||||||
} else {
|
|
||||||
domain.addPlayer(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -32,32 +32,25 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandHeal extends WgCommand {
|
public class CommandHeal extends WgCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
CommandHandler.checkArgs(args, 0, 1);
|
||||||
sender.sendMessage("Only players may use this command");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
ch.checkPermission(player, "/heal");
|
|
||||||
ch.checkArgs(args, 0, 1);
|
|
||||||
|
|
||||||
// Allow healing other people
|
// Allow healing other people
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (!wg.hasPermission(player, "/healother")) {
|
cfg.checkPermission(sender, "heal.other");
|
||||||
player.sendMessage(ChatColor.RED + "You don't have permission to heal others.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player other = matchSinglePlayer(wg.getServer(), args[0]);
|
Player other = matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
player.sendMessage(ChatColor.RED + "Player not found.");
|
sender.sendMessage(ChatColor.RED + "Player not found.");
|
||||||
} else {
|
} else {
|
||||||
other.setHealth(20);
|
other.setHealth(20);
|
||||||
player.sendMessage(ChatColor.YELLOW + other.getName() + " has been healed!");
|
sender.sendMessage(ChatColor.YELLOW + other.getName() + " has been healed!");
|
||||||
other.sendMessage(ChatColor.YELLOW + player.getName() + " has healed you!");
|
other.sendMessage(ChatColor.YELLOW + senderName + " has healed you!");
|
||||||
}
|
}
|
||||||
} else {
|
} else if (sender instanceof Player){
|
||||||
|
cfg.checkPermission(sender, "heal.self");
|
||||||
|
Player player = (Player)sender;
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
player.sendMessage(ChatColor.YELLOW + "You have been healed!");
|
player.sendMessage(ChatColor.YELLOW + "You have been healed!");
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -33,19 +33,20 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandLocate extends WgCommand {
|
public class CommandLocate extends WgCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
sender.sendMessage("Only players may use this command");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
ch.checkPermission(player, "/locate");
|
cfg.checkPermission(player, "locate");
|
||||||
ch.checkArgs(args, 0, 3);
|
CommandHandler.checkArgs(args, 0, 3);
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
String name = args[0];
|
String name = args[0];
|
||||||
Player target = BukkitUtil.matchSinglePlayer(wg.getServer(), name);
|
Player target = BukkitUtil.matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), name);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
player.setCompassTarget(target.getLocation());
|
player.setCompassTarget(target.getLocation());
|
||||||
player.sendMessage(ChatColor.YELLOW + "Compass target set to " + target.getName() + ".");
|
player.sendMessage(ChatColor.YELLOW + "Compass target set to " + target.getName() + ".");
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -33,59 +33,70 @@
|
|||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionAddMember extends WgCommand {
|
public class CommandRegionAddMember extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage("Only players may use this command");
|
boolean cmdIsOwner = command.equalsIgnoreCase("addowner");
|
||||||
|
|
||||||
|
String permOwn;
|
||||||
|
String permAll;
|
||||||
|
|
||||||
|
if (cmdIsOwner) {
|
||||||
|
CommandHandler.checkArgs(args, 2, -1, "/region addowner <id> [player1 [group1 [players/groups...]]]");
|
||||||
|
permOwn = "region.addowner.own";
|
||||||
|
permAll = "region.addowner.all";
|
||||||
|
} else {
|
||||||
|
CommandHandler.checkArgs(args, 2, -1, "/region addmember <id> [player1 [group1 [players/groups...]]]");
|
||||||
|
permOwn = "region.addmember.own";
|
||||||
|
permAll = "region.addmember.all";
|
||||||
|
}
|
||||||
|
|
||||||
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
|
|
||||||
|
String id = args[0].toLowerCase();
|
||||||
|
if (!mgr.hasRegion(id)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "A region with ID '"
|
||||||
|
+ id + "' doesn't exist.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (!wg.hasPermission(player, "/regionclaim") && !wg.hasPermission(player, "/regionmembership")) {
|
ProtectedRegion existing = mgr.getRegion(id);
|
||||||
ch.checkRegionPermission(player, "/regiondefine");
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
|
cfg.checkRegionPermission(sender, permOwn);
|
||||||
}
|
}
|
||||||
ch.checkArgs(args, 2, -1, "/region add[member|owner] <id> [player1 [group1 [players/groups...]]]");
|
else {
|
||||||
|
cfg.checkRegionPermission(sender, permAll);
|
||||||
String action = command;
|
|
||||||
|
|
||||||
boolean isOwner = action.equalsIgnoreCase("addowner");
|
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
|
||||||
|
|
||||||
String id = args[0].toLowerCase();
|
|
||||||
if (!mgr.hasRegion(id)) {
|
|
||||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
|
||||||
+ id + "' doesn't exist.");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtectedRegion existing = mgr.getRegion(id);
|
|
||||||
|
|
||||||
if (!ch.canUseRegionCommand(player, "/regiondefine")
|
|
||||||
&& !existing.isOwner(wg.wrapPlayer(player))) {
|
|
||||||
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isOwner) {
|
|
||||||
ch.addToDomain(existing.getOwners(), args, 1);
|
|
||||||
} else {
|
|
||||||
ch.addToDomain(existing.getMembers(), args, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
mgr.save();
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg.checkRegionPermission(sender, permAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmdIsOwner) {
|
||||||
|
WorldGuardConfiguration.addToDomain(existing.getOwners(), args, 1);
|
||||||
|
} else {
|
||||||
|
WorldGuardConfiguration.addToDomain(existing.getMembers(), args, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
mgr.save();
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Region updated!");
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Current owners: "
|
||||||
|
+ existing.getOwners().toUserFriendlyString());
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Current members: "
|
||||||
|
+ existing.getMembers().toUserFriendlyString());
|
||||||
|
} catch (IOException e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||||
|
+ e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
@ -35,8 +37,6 @@
|
|||||||
import com.nijikokun.bukkit.iConomy.Account;
|
import com.nijikokun.bukkit.iConomy.Account;
|
||||||
import com.nijikokun.bukkit.iConomy.iConomy;
|
import com.nijikokun.bukkit.iConomy.iConomy;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -46,9 +46,9 @@
|
|||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionClaim extends WgCommand {
|
public class CommandRegionClaim extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
sender.sendMessage("Only players may use this command");
|
||||||
@ -56,23 +56,23 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
Plugin wePlugin = wg.getServer().getPluginManager().getPlugin("WorldEdit");
|
Plugin wePlugin = cfg.getWorldGuardPlugin().getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
if (wePlugin == null) {
|
if (wePlugin == null) {
|
||||||
player.sendMessage(ChatColor.RED + "WorldEdit must be installed and enabled!");
|
player.sendMessage(ChatColor.RED + "WorldEdit must be installed and enabled!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ch.checkRegionPermission(player, "/regionclaim");
|
cfg.checkRegionPermission(player, "region.claim");
|
||||||
ch.checkArgs(args, 1, 1, "/region claim <id>");
|
CommandHandler.checkArgs(args, 1, 1, "/region claim <id>");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String id = args[0].toLowerCase();
|
String id = args[0].toLowerCase();
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
|
|
||||||
ProtectedRegion existing = mgr.getRegion(id);
|
ProtectedRegion existing = mgr.getRegion(id);
|
||||||
|
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
if (!existing.getOwners().contains(wg.wrapPlayer(player))) {
|
if (!existing.getOwners().contains(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
region = new ProtectedCuboidRegion(id, min, max);
|
region = new ProtectedCuboidRegion(id, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mgr.overlapsUnownedRegion(region, wg.wrapPlayer(player))) {
|
if (mgr.overlapsUnownedRegion(region, BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
player.sendMessage(ChatColor.RED + "This region overlaps with someone else's region.");
|
player.sendMessage(ChatColor.RED + "This region overlaps with someone else's region.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
@ -43,23 +44,23 @@
|
|||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionDefine extends WgCommand {
|
public class CommandRegionDefine extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
sender.sendMessage("Only players may use this command");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
Plugin wePlugin = wg.getServer().getPluginManager().getPlugin("WorldEdit");
|
Plugin wePlugin = cfg.getWorldGuardPlugin().getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
if (wePlugin == null) {
|
if (wePlugin == null) {
|
||||||
player.sendMessage(ChatColor.RED + "WorldEdit must be installed and enabled!");
|
sender.sendMessage(ChatColor.RED + "WorldEdit must be installed and enabled!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ch.checkRegionPermission(player, "/regiondefine");
|
cfg.checkRegionPermission(sender, "region.define");
|
||||||
ch.checkArgs(args, 1, -1, "/region define <id> [owner1 [owner2 [owners...]]]");
|
CommandHandler.checkArgs(args, 1, -1, "/region define <id> [owner1 [owner2 [owners...]]]");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String id = args[0].toLowerCase();
|
String id = args[0].toLowerCase();
|
||||||
@ -84,16 +85,16 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
region.setOwners(ch.parseDomainString(args, 1));
|
region.setOwners(WorldGuardConfiguration.parseDomainString(args, 1));
|
||||||
}
|
}
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(w.getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(w.getName());
|
||||||
mgr.addRegion(region);
|
mgr.addRegion(region);
|
||||||
mgr.save();
|
mgr.save();
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
|
sender.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
|
||||||
} catch (IncompleteRegionException e) {
|
} catch (IncompleteRegionException e) {
|
||||||
player.sendMessage(ChatColor.RED + "You must first define an area in WorldEdit.");
|
sender.sendMessage(ChatColor.RED + "You must first define an area in WorldEdit.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
sender.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -32,45 +33,41 @@
|
|||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionDelete extends WgCommand {
|
public class CommandRegionDelete extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
CommandHandler.checkArgs(args, 0, 1, "/region delete <id>");
|
||||||
sender.sendMessage("Only players may use this command");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
|
|
||||||
if (!wg.hasPermission(player, "/regionclaim")) {
|
|
||||||
ch.checkRegionPermission(player, "/regiondelete");
|
|
||||||
}
|
|
||||||
ch.checkArgs(args, 0, 1, "/region delete <id>");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String id = args[0].toLowerCase();
|
String id = args[0].toLowerCase();
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
|
|
||||||
if (!mgr.hasRegion(id)) {
|
if (!mgr.hasRegion(id)) {
|
||||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
sender.sendMessage(ChatColor.RED + "A region with ID '"
|
||||||
+ id + "' doesn't exist.");
|
+ id + "' doesn't exist.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtectedRegion existing = mgr.getRegion(id);
|
ProtectedRegion existing = mgr.getRegion(id);
|
||||||
|
|
||||||
if (!ch.canUseRegionCommand(player, "/regiondelete")
|
if (sender instanceof Player) {
|
||||||
&& !existing.isOwner(wg.wrapPlayer(player))) {
|
Player player = (Player) sender;
|
||||||
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
|
||||||
return true;
|
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
|
cfg.checkRegionPermission(sender, "region.delete.own");
|
||||||
|
} else {
|
||||||
|
cfg.checkRegionPermission(sender, "region.delete.all");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cfg.checkRegionPermission(sender, "region.delete.all");
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr.removeRegion(id);
|
mgr.removeRegion(id);
|
||||||
mgr.save();
|
mgr.save();
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region removed!");
|
sender.sendMessage(ChatColor.YELLOW + "Region removed!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
sender.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.AreaFlags;
|
import com.sk89q.worldguard.protection.regions.AreaFlags;
|
||||||
@ -34,17 +37,12 @@
|
|||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionFlag extends WgCommand {
|
public class CommandRegionFlag extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
// to-do only allow owners to change flags
|
||||||
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
CommandHandler.checkArgs(args, 3, 4, "/region flag <regionid> <name> (<subname>) <value>");
|
||||||
sender.sendMessage("Only players may use this command");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
ch.checkRegionPermission(player, "/regiondefine");
|
|
||||||
ch.checkArgs(args, 3, 4, "/region flag <regionid> <name> (<subname>) <value>");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String id = args[0].toLowerCase();
|
String id = args[0].toLowerCase();
|
||||||
@ -58,34 +56,57 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
valueStr = args[3];
|
valueStr = args[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
ProtectedRegion region = mgr.getRegion(id);
|
ProtectedRegion region = mgr.getRegion(id);
|
||||||
|
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
player.sendMessage(ChatColor.RED + "Could not find a region by that ID.");
|
sender.sendMessage(ChatColor.RED + "Could not find a region by that ID.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
|
cfg.checkRegionPermission(sender, "region.flag.ownregions");
|
||||||
|
}
|
||||||
|
else if(region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
|
cfg.checkRegionPermission(sender, "region.flag.memberregions");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cfg.checkRegionPermission(sender, "region.flag.foreignregions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg.checkRegionPermission(sender, "region.flag.foreignregions");
|
||||||
|
}
|
||||||
|
|
||||||
FlagInfo nfo = FlagInfo.getFlagInfo(nameStr, subnameStr);
|
FlagInfo nfo = FlagInfo.getFlagInfo(nameStr, subnameStr);
|
||||||
|
|
||||||
if (nfo == null) {
|
if (nfo == null) {
|
||||||
|
|
||||||
|
if(!(sender instanceof Player))
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "Unknown flag, or not supported in console mode.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player player = (Player)sender;
|
||||||
|
|
||||||
if(nameStr.equals("spawn"))
|
if(nameStr.equals("spawn"))
|
||||||
{
|
{
|
||||||
if (valueStr.equals("set")) {
|
if (valueStr.equals("set")) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn set to current location");
|
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn set to current location");
|
||||||
AreaFlags flags = region.getFlags();
|
AreaFlags flags = region.getFlags();
|
||||||
Location l = player.getLocation();
|
Location l = player.getLocation();
|
||||||
if(region.contains(BukkitUtil.toVector(l))){
|
|
||||||
flags.setFlag("spawn", "x", l.getX());
|
flags.setFlag("spawn", "x", l.getX());
|
||||||
flags.setFlag("spawn", "y", l.getY());
|
flags.setFlag("spawn", "y", l.getY());
|
||||||
flags.setFlag("spawn", "z", l.getZ());
|
flags.setFlag("spawn", "z", l.getZ());
|
||||||
flags.setFlag("spawn", "yaw", l.getYaw());
|
flags.setFlag("spawn", "yaw", l.getYaw());
|
||||||
flags.setFlag("spawn", "pitch", l.getPitch());
|
flags.setFlag("spawn", "pitch", l.getPitch());
|
||||||
flags.setFlag("spawn", "world", l.getWorld().getName());
|
flags.setFlag("spawn", "world", l.getWorld().getName());
|
||||||
}else{
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + "You must set the spawn location inside the region it belongs to.");
|
|
||||||
}
|
|
||||||
} else if (nameStr.equals("delete")){
|
|
||||||
AreaFlags flags = region.getFlags();
|
AreaFlags flags = region.getFlags();
|
||||||
flags.setFlag("spawn", "x", (String)null);
|
flags.setFlag("spawn", "x", (String)null);
|
||||||
flags.setFlag("spawn", "y", (String)null);
|
flags.setFlag("spawn", "y", (String)null);
|
||||||
@ -93,37 +114,13 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
flags.setFlag("spawn", "yaw", (String)null);
|
flags.setFlag("spawn", "yaw", (String)null);
|
||||||
flags.setFlag("spawn", "pitch", (String)null);
|
flags.setFlag("spawn", "pitch", (String)null);
|
||||||
flags.setFlag("spawn", "world", (String)null);
|
flags.setFlag("spawn", "world", (String)null);
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn removed.");
|
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn removed.");
|
||||||
}else{
|
}else{
|
||||||
player.sendMessage(ChatColor.RED + "Usage: /region flag <regionid> spawn <set|delete>");
|
player.sendMessage(ChatColor.RED + "Usage: /region flag <regionid> spawn <set|delete>");
|
||||||
}
|
}
|
||||||
}else if(nameStr.equals("teleport"))
|
}else if(nameStr.equals("teleport"))
|
||||||
{
|
{
|
||||||
if (valueStr.equals("set")){
|
sender.sendMessage(ChatColor.RED + "Unknown flag specified.");
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag teleport set to current location");
|
|
||||||
AreaFlags flags = region.getFlags();
|
|
||||||
Location l = player.getLocation();
|
|
||||||
if(region.contains(BukkitUtil.toVector(l))){
|
|
||||||
flags.setFlag("teleport", "x", l.getX());
|
|
||||||
flags.setFlag("teleport", "y", l.getY());
|
|
||||||
flags.setFlag("teleport", "z", l.getZ());
|
|
||||||
flags.setFlag("teleport", "world", l.getWorld().getName());
|
|
||||||
}else{
|
|
||||||
player.sendMessage(ChatColor.RED + "You must set the teleport location inside the region it belongs to.");
|
|
||||||
}
|
|
||||||
}else if (valueStr.equals("delete")){
|
|
||||||
AreaFlags flags = region.getFlags();
|
|
||||||
flags.setFlag("teleport", "x", (String)null);
|
|
||||||
flags.setFlag("teleport", "y", (String)null);
|
|
||||||
flags.setFlag("teleport", "z", (String)null);
|
|
||||||
flags.setFlag("teleport", "world", (String)null);
|
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag teleport removed.");
|
|
||||||
}else{
|
|
||||||
player.sendMessage(ChatColor.RED + "Usage: /region flag <regionid> teleport <set|delete>");
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
player.sendMessage(ChatColor.RED + "Unknown flag specified.");
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -197,16 +194,16 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!validValue) {
|
if (!validValue) {
|
||||||
player.sendMessage(ChatColor.RED + "Invalid value '" + valueStr + "' for flag " + fullFlagname);
|
sender.sendMessage(ChatColor.RED + "Invalid value '" + valueStr + "' for flag " + fullFlagname);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
region.getFlags().setFlag(nfo.flagName, nfo.flagSubName, valueStr);
|
region.getFlags().setFlag(nfo.flagName, nfo.flagSubName, valueStr);
|
||||||
mgr.save();
|
mgr.save();
|
||||||
|
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag " + fullFlagname + " set to " + valueStr);
|
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag " + fullFlagname + " set to " + valueStr);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
sender.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,14 +19,14 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.AreaFlags;
|
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;
|
||||||
import java.util.Map;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -35,36 +35,47 @@
|
|||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionInfo extends WgCommand {
|
public class CommandRegionInfo extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
CommandHandler.checkArgs(args, 1, 1, "/region info <id>");
|
||||||
sender.sendMessage("Only players may use this command");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
ch.checkRegionPermission(player, "/regioninfo");
|
|
||||||
ch.checkArgs(args, 1, 1, "/region info <id>");
|
|
||||||
|
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
|
||||||
String id = args[0].toLowerCase();
|
String id = args[0].toLowerCase();
|
||||||
if (!mgr.hasRegion(id)) {
|
if (!mgr.hasRegion(id)) {
|
||||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
sender.sendMessage(ChatColor.RED + "A region with ID '"
|
||||||
+ id + "' doesn't exist.");
|
+ id + "' doesn't exist.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtectedRegion region = mgr.getRegion(id);
|
ProtectedRegion region = mgr.getRegion(id);
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
|
cfg.checkRegionPermission(sender, "region.info.ownregions");
|
||||||
|
}
|
||||||
|
else if(region.isMember(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
|
cfg.checkRegionPermission(sender, "region.info.memberregions");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cfg.checkRegionPermission(sender, "region.info.foreignregions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg.checkRegionPermission(sender, "region.info.foreignregions");
|
||||||
|
}
|
||||||
|
|
||||||
AreaFlags flags = region.getFlags();
|
AreaFlags flags = region.getFlags();
|
||||||
DefaultDomain owners = region.getOwners();
|
DefaultDomain owners = region.getOwners();
|
||||||
DefaultDomain members = region.getMembers();
|
DefaultDomain members = region.getMembers();
|
||||||
|
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region: " + id
|
sender.sendMessage(ChatColor.YELLOW + "Region: " + id
|
||||||
+ ChatColor.GRAY + " (type: " + region.getTypeName() + ")");
|
+ ChatColor.GRAY + " (type: " + region.getTypeName() + ")");
|
||||||
player.sendMessage(ChatColor.BLUE + "Priority: " + region.getPriority());
|
sender.sendMessage(ChatColor.BLUE + "Priority: " + region.getPriority());
|
||||||
|
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
for (FlagInfo nfo : FlagInfo.getFlagInfoList()) {
|
for (FlagInfo nfo : FlagInfo.getFlagInfoList()) {
|
||||||
@ -89,12 +100,12 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
s.append("spawn: not set");
|
s.append("spawn: not set");
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(ChatColor.BLUE + "Flags: " + s.toString());
|
sender.sendMessage(ChatColor.BLUE + "Flags: " + s.toString());
|
||||||
player.sendMessage(ChatColor.BLUE + "Parent: "
|
sender.sendMessage(ChatColor.BLUE + "Parent: "
|
||||||
+ (region.getParent() == null ? "(none)" : region.getParent().getId()));
|
+ (region.getParent() == null ? "(none)" : region.getParent().getId()));
|
||||||
player.sendMessage(ChatColor.LIGHT_PURPLE + "Owners: "
|
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Owners: "
|
||||||
+ owners.toUserFriendlyString());
|
+ owners.toUserFriendlyString());
|
||||||
player.sendMessage(ChatColor.LIGHT_PURPLE + "Members: "
|
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Members: "
|
||||||
+ members.toUserFriendlyString());
|
+ members.toUserFriendlyString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -27,23 +28,17 @@
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionList extends WgCommand {
|
public class CommandRegionList extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
cfg.checkRegionPermission(sender, "region.list");
|
||||||
sender.sendMessage("Only players may use this command");
|
CommandHandler.checkArgs(args, 0, 1, "/region list [page]");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
ch.checkRegionPermission(player, "/regionlist");
|
|
||||||
ch.checkArgs(args, 0, 1, "/region list [page]");
|
|
||||||
|
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
|
||||||
@ -55,10 +50,10 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
Map<String, ProtectedRegion> regions = mgr.getRegions();
|
Map<String, ProtectedRegion> regions = mgr.getRegions();
|
||||||
int size = regions.size();
|
int size = regions.size();
|
||||||
int pages = (int) Math.ceil(size / (float) ch.CMD_LIST_SIZE);
|
int pages = (int) Math.ceil(size / (float) CommandHandler.CMD_LIST_SIZE);
|
||||||
|
|
||||||
String[] regionIDList = new String[size];
|
String[] regionIDList = new String[size];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -68,16 +63,15 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
}
|
}
|
||||||
Arrays.sort(regionIDList);
|
Arrays.sort(regionIDList);
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.RED + "Regions (page "
|
||||||
player.sendMessage(ChatColor.RED + "Regions (page "
|
|
||||||
+ (page + 1) + " of " + pages + "):");
|
+ (page + 1) + " of " + pages + "):");
|
||||||
|
|
||||||
if (page < pages) {
|
if (page < pages) {
|
||||||
for (int i = page * ch.CMD_LIST_SIZE; i < page * ch.CMD_LIST_SIZE + ch.CMD_LIST_SIZE; i++) {
|
for (int i = page * CommandHandler.CMD_LIST_SIZE; i < page * CommandHandler.CMD_LIST_SIZE + CommandHandler.CMD_LIST_SIZE; i++) {
|
||||||
if (i >= size) {
|
if (i >= size) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.YELLOW.toString() + (i + 1) + ". " + regionIDList[i]);
|
sender.sendMessage(ChatColor.YELLOW.toString() + (i + 1) + ". " + regionIDList[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,36 +19,30 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionLoad extends WgCommand {
|
public class CommandRegionLoad extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
cfg.checkRegionPermission(sender, "region.load");
|
||||||
sender.sendMessage("Only players may use this command");
|
CommandHandler.checkArgs(args, 0, 0, "/region load");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
ch.checkRegionPermission(player, "/regionload");
|
|
||||||
ch.checkArgs(args, 0, 0, "/region load");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
mgr.load();
|
mgr.load();
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region database loaded from file!");
|
sender.sendMessage(ChatColor.YELLOW + "Region database loaded from file!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.sendMessage(ChatColor.RED + "Region database failed to load: "
|
sender.sendMessage(ChatColor.RED + "Region database failed to load: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -32,54 +34,66 @@
|
|||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionRemoveMember extends WgCommand {
|
public class CommandRegionRemoveMember extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
boolean cmdIsOwner = command.equalsIgnoreCase("removeowner");
|
||||||
sender.sendMessage("Only players may use this command");
|
String permOwn;
|
||||||
return true;
|
String permAll;
|
||||||
|
|
||||||
|
if (cmdIsOwner) {
|
||||||
|
CommandHandler.checkArgs(args, 2, -1, "/region removeowner <id> [player1 [group1 [players/groups...]]]");
|
||||||
|
permOwn = "region.removeowner.own";
|
||||||
|
permAll = "region.removeowner.all";
|
||||||
|
} else {
|
||||||
|
CommandHandler.checkArgs(args, 2, -1, "/region removemember <id> [player1 [group1 [players/groups...]]]");
|
||||||
|
permOwn = "region.removemember.own";
|
||||||
|
permAll = "region.removemember.all";
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
|
||||||
if (!wg.hasPermission(player, "/regionclaim") && !wg.hasPermission(player, "/regionmembership")) {
|
|
||||||
ch.checkRegionPermission(player, "/regiondefine");
|
|
||||||
}
|
|
||||||
ch.checkArgs(args, 2, -1, "/region removeowner <id> [owner1 [owner2 [owners...]]]");
|
|
||||||
|
|
||||||
String action = command;
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
boolean isOwner = action.equalsIgnoreCase("removeowner");
|
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
|
||||||
|
|
||||||
String id = args[0].toLowerCase();
|
String id = args[0].toLowerCase();
|
||||||
if (!mgr.hasRegion(id)) {
|
if (!mgr.hasRegion(id)) {
|
||||||
player.sendMessage(ChatColor.RED + "A region with ID '"
|
sender.sendMessage(ChatColor.RED + "A region with ID '"
|
||||||
+ id + "' doesn't exist.");
|
+ id + "' doesn't exist.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtectedRegion existing = mgr.getRegion(id);
|
ProtectedRegion existing = mgr.getRegion(id);
|
||||||
|
|
||||||
if (!ch.canUseRegionCommand(player, "/regiondefine")
|
if (sender instanceof Player) {
|
||||||
&& !existing.isOwner(wg.wrapPlayer(player))) {
|
Player player = (Player) sender;
|
||||||
player.sendMessage(ChatColor.RED + "You don't own this region.");
|
|
||||||
return true;
|
if (existing.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
|
cfg.checkRegionPermission(sender, permOwn);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cfg.checkRegionPermission(sender, permAll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cfg.checkRegionPermission(sender, permAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOwner) {
|
|
||||||
ch.removeFromDomain(existing.getOwners(), args, 1);
|
if (cmdIsOwner) {
|
||||||
|
WorldGuardConfiguration.removeFromDomain(existing.getOwners(), args, 1);
|
||||||
} else {
|
} else {
|
||||||
ch.removeFromDomain(existing.getMembers(), args, 1);
|
WorldGuardConfiguration.removeFromDomain(existing.getMembers(), args, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mgr.save();
|
mgr.save();
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region updated!");
|
sender.sendMessage(ChatColor.YELLOW + "Region updated!");
|
||||||
player.sendMessage(ChatColor.GRAY + "Current owners: "
|
sender.sendMessage(ChatColor.GRAY + "Current owners: "
|
||||||
+ existing.getOwners().toUserFriendlyString());
|
+ existing.getOwners().toUserFriendlyString());
|
||||||
player.sendMessage(ChatColor.GRAY + "Current members: "
|
sender.sendMessage(ChatColor.GRAY + "Current members: "
|
||||||
+ existing.getMembers().toUserFriendlyString());
|
+ existing.getMembers().toUserFriendlyString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
sender.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,36 +19,31 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionSave extends WgCommand {
|
public class CommandRegionSave extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
cfg.checkRegionPermission(sender, "region.save");
|
||||||
sender.sendMessage("Only players may use this command");
|
CommandHandler.checkArgs(args, 0, 0, "/region save");
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
ch.checkRegionPermission(player, "/regionsave");
|
|
||||||
ch.checkArgs(args, 0, 0, "/region save");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
mgr.save();
|
mgr.save();
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region database saved to file!");
|
sender.sendMessage(ChatColor.YELLOW + "Region database saved to file!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
sender.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.BukkitPlayer;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
@ -33,35 +34,33 @@
|
|||||||
*
|
*
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
public class CommandRegionSetParent extends WgCommand {
|
public class CommandRegionSetParent extends WgRegionCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
CommandHandler.checkArgs(args, 1, 2, "/region setparent <id> <parent-id>");
|
||||||
sender.sendMessage("Only players may use this command");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (!wg.hasPermission(player, "/regionclaim")) {
|
|
||||||
ch.checkRegionPermission(player, "/regiondefine");
|
|
||||||
}
|
|
||||||
ch.checkArgs(args, 1, 2, "/region setparent <id> <parent-id>");
|
|
||||||
|
|
||||||
String id = args[0].toLowerCase();
|
String id = args[0].toLowerCase();
|
||||||
String parentId = args.length > 1 ? args[1].toLowerCase() : null;
|
String parentId = args.length > 1 ? args[1].toLowerCase() : null;
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(wcfg.getWorldName());
|
||||||
|
|
||||||
ProtectedRegion region = mgr.getRegion(id);
|
ProtectedRegion region = mgr.getRegion(id);
|
||||||
|
|
||||||
if (region == null) {
|
if (region == null) {
|
||||||
player.sendMessage(ChatColor.RED + "Could not find a region with ID: " + id);
|
sender.sendMessage(ChatColor.RED + "Could not find a region with ID: " + id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ch.canUseRegionCommand(player, "/regiondefine")
|
if (sender instanceof Player) {
|
||||||
&& !region.isOwner(wg.wrapPlayer(player))) {
|
Player player = (Player) sender;
|
||||||
player.sendMessage(ChatColor.RED + "You need to own the target regions");
|
|
||||||
return true;
|
if (region.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
|
cfg.checkRegionPermission(sender, "region.setparent.own");
|
||||||
|
} else {
|
||||||
|
cfg.checkRegionPermission(sender, "region.setparent.all");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cfg.checkRegionPermission(sender, "region.setparent.all");
|
||||||
}
|
}
|
||||||
|
|
||||||
ProtectedRegion parent = null;
|
ProtectedRegion parent = null;
|
||||||
@ -71,14 +70,20 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
parent = mgr.getRegion(parentId);
|
parent = mgr.getRegion(parentId);
|
||||||
|
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
player.sendMessage(ChatColor.RED + "Could not find a region with ID: " + parentId);
|
sender.sendMessage(ChatColor.RED + "Could not find a region with ID: " + parentId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ch.canUseRegionCommand(player, "/regiondefine")
|
if (sender instanceof Player) {
|
||||||
&& !parent.isOwner(wg.wrapPlayer(player))) {
|
Player player = (Player) sender;
|
||||||
player.sendMessage(ChatColor.RED + "You need to own the parent region.");
|
|
||||||
return true;
|
if (parent.isOwner(BukkitPlayer.wrapPlayer(cfg, player))) {
|
||||||
|
cfg.checkRegionPermission(sender, "region.setparent.own");
|
||||||
|
} else {
|
||||||
|
cfg.checkRegionPermission(sender, "region.setparent.all");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cfg.checkRegionPermission(sender, "region.setparent.all");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,11 +91,11 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
region.setParent(parent);
|
region.setParent(parent);
|
||||||
|
|
||||||
mgr.save();
|
mgr.save();
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated.");
|
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated.");
|
||||||
} catch (CircularInheritanceException e) {
|
} catch (CircularInheritanceException e) {
|
||||||
player.sendMessage(ChatColor.RED + "Circular inheritance detected. The operation failed.");
|
sender.sendMessage(ChatColor.RED + "Circular inheritance detected. The operation failed.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.sendMessage(ChatColor.RED + "Region database failed to save: "
|
sender.sendMessage(ChatColor.RED + "Region database failed to save: "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,12 +15,11 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.LoggerToChatHandler;
|
import com.sk89q.worldguard.bukkit.LoggerToChatHandler;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -33,31 +32,33 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandReloadWG extends WgCommand {
|
public class CommandReloadWG extends WgCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
cfg.checkPermission(sender, "reloadwg");
|
||||||
sender.sendMessage("Only players may use this command");
|
CommandHandler.checkArgs(args, 0, 0);
|
||||||
return true;
|
|
||||||
|
LoggerToChatHandler handler = null;
|
||||||
|
Logger minecraftLogger = null;
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
handler = new LoggerToChatHandler(player);
|
||||||
|
handler.setLevel(Level.ALL);
|
||||||
|
minecraftLogger = Logger.getLogger("Minecraft");
|
||||||
|
minecraftLogger.addHandler(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
|
||||||
ch.checkPermission(player, "/reloadwg");
|
|
||||||
ch.checkArgs(args, 0, 0);
|
|
||||||
|
|
||||||
LoggerToChatHandler handler = new LoggerToChatHandler(player);
|
|
||||||
handler.setLevel(Level.ALL);
|
|
||||||
Logger minecraftLogger = Logger.getLogger("Minecraft");
|
|
||||||
minecraftLogger.addHandler(handler);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
wg.loadConfiguration();
|
cfg.onDisable();
|
||||||
wg.postReload();
|
cfg.onEnable();
|
||||||
player.sendMessage("WorldGuard configuration reloaded.");
|
|
||||||
|
sender.sendMessage("WorldGuard configuration reloaded.");
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
player.sendMessage("Error while reloading: "
|
sender.sendMessage("Error while reloading: "
|
||||||
+ t.getMessage());
|
+ t.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
minecraftLogger.removeHandler(handler);
|
if (handler != null) {
|
||||||
|
minecraftLogger.removeHandler(handler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -32,34 +32,26 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandSlay extends WgCommand {
|
public class CommandSlay extends WgCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
CommandHandler.checkArgs(args, 0, 1);
|
||||||
sender.sendMessage("Only players may use this command");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
|
|
||||||
ch.checkPermission(player, "/slay");
|
|
||||||
ch.checkArgs(args, 0, 1);
|
|
||||||
|
|
||||||
// Allow killing other people
|
// Allow killing other people
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (!wg.hasPermission(player, "/slayother")) {
|
cfg.checkPermission(sender, "slay.others");
|
||||||
player.sendMessage(ChatColor.RED + "You don't have permission to kill others.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player other = BukkitUtil.matchSinglePlayer(wg.getServer(), args[0]);
|
Player other = BukkitUtil.matchSinglePlayer(cfg.getWorldGuardPlugin().getServer(), args[0]);
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
player.sendMessage(ChatColor.RED + "Player not found.");
|
sender.sendMessage(ChatColor.RED + "Player not found.");
|
||||||
} else {
|
} else {
|
||||||
other.setHealth(0);
|
other.setHealth(0);
|
||||||
player.sendMessage(ChatColor.YELLOW + other.getName() + " has been killed!");
|
sender.sendMessage(ChatColor.YELLOW + other.getName() + " has been killed!");
|
||||||
other.sendMessage(ChatColor.YELLOW + player.getName() + " has killed you!");
|
other.sendMessage(ChatColor.YELLOW + senderName + " has killed you!");
|
||||||
}
|
}
|
||||||
} else {
|
} else if (sender instanceof Player) {
|
||||||
|
cfg.checkPermission(sender, "slay.self");
|
||||||
|
|
||||||
|
Player player = (Player)sender;
|
||||||
player.setHealth(0);
|
player.setHealth(0);
|
||||||
player.sendMessage(ChatColor.YELLOW + "You have committed suicide!");
|
player.sendMessage(ChatColor.YELLOW + "You have committed suicide!");
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.ItemType;
|
import com.sk89q.worldedit.blocks.ItemType;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -33,15 +33,15 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandStack extends WgCommand {
|
public class CommandStack extends WgCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage("Only players may use this command");
|
sender.sendMessage("Only players may use this command");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
ch.checkPermission(player, "/stack");
|
cfg.checkPermission(player, "stack");
|
||||||
ch.checkArgs(args, 0, 0);
|
CommandHandler.checkArgs(args, 0, 0);
|
||||||
|
|
||||||
ItemStack[] items = player.getInventory().getContents();
|
ItemStack[] items = player.getInventory().getContents();
|
||||||
int len = items.length;
|
int len = items.length;
|
||||||
|
@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -31,25 +33,40 @@
|
|||||||
*/
|
*/
|
||||||
public class CommandStopFire extends WgCommand {
|
public class CommandStopFire extends WgCommand {
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!(sender instanceof Player)) {
|
cfg.checkPermission(sender, "stopfire");
|
||||||
sender.sendMessage("Only players may use this command");
|
CommandHandler.checkArgs(args, 0, 0);
|
||||||
|
|
||||||
|
String worldName;
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
CommandHandler.checkArgs(args, 0, 0);
|
||||||
|
worldName = ((Player)sender).getWorld().getName();
|
||||||
|
} else {
|
||||||
|
CommandHandler.checkArgs(args, 1, 1);
|
||||||
|
worldName = args[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
Server server = cfg.getWorldGuardPlugin().getServer();
|
||||||
|
if(server.getWorld(worldName) == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Invalid world specified.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||||
ch.checkPermission(sender, "/stopfire");
|
|
||||||
ch.checkArgs(args, 0, 0);
|
|
||||||
|
|
||||||
if (!wg.fireSpreadDisableToggle) {
|
|
||||||
wg.getServer().broadcastMessage(ChatColor.YELLOW
|
|
||||||
|
if (!wcfg.fireSpreadDisableToggle) {
|
||||||
|
cfg.getWorldGuardPlugin().getServer().broadcastMessage(ChatColor.YELLOW
|
||||||
+ "Fire spread has been globally disabled by " + senderName + ".");
|
+ "Fire spread has been globally disabled by " + senderName + ".");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Fire spread was already globally disabled.");
|
sender.sendMessage(ChatColor.YELLOW + "Fire spread was already globally disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
wg.fireSpreadDisableToggle = true;
|
wcfg.fireSpreadDisableToggle = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,18 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -32,47 +34,76 @@
|
|||||||
*/
|
*/
|
||||||
public class RegionCommandHandler extends WgCommand {
|
public class RegionCommandHandler extends WgCommand {
|
||||||
|
|
||||||
private Map<String, WgCommand> commandMap;
|
private Map<String, WgRegionCommand> commandMap;
|
||||||
|
|
||||||
public RegionCommandHandler()
|
public RegionCommandHandler() {
|
||||||
{
|
this.commandMap = new HashMap<String, WgRegionCommand>();
|
||||||
this.commandMap = new HashMap<String, WgCommand>();
|
|
||||||
|
|
||||||
this.commandMap.put("addmember", new CommandRegionAddMember());
|
WgRegionCommand addmember = new CommandRegionAddMember();
|
||||||
this.commandMap.put("addowner", new CommandRegionAddMember());
|
WgRegionCommand removemember = new CommandRegionRemoveMember();
|
||||||
this.commandMap.put("claim", new CommandRegionClaim());
|
|
||||||
this.commandMap.put("define", new CommandRegionDefine());
|
// commands that DO support console as sender
|
||||||
this.commandMap.put("delete", new CommandRegionDelete());
|
|
||||||
this.commandMap.put("flag", new CommandRegionFlag());
|
|
||||||
this.commandMap.put("info", new CommandRegionInfo());
|
|
||||||
this.commandMap.put("list", new CommandRegionList());
|
|
||||||
this.commandMap.put("load", new CommandRegionLoad());
|
|
||||||
this.commandMap.put("removemember", new CommandRegionRemoveMember());
|
|
||||||
this.commandMap.put("removeowner", new CommandRegionRemoveMember());
|
|
||||||
this.commandMap.put("save", new CommandRegionSave());
|
this.commandMap.put("save", new CommandRegionSave());
|
||||||
|
this.commandMap.put("load", new CommandRegionLoad());
|
||||||
|
this.commandMap.put("list", new CommandRegionList());
|
||||||
|
this.commandMap.put("info", new CommandRegionInfo());
|
||||||
|
this.commandMap.put("flag", new CommandRegionFlag());
|
||||||
|
this.commandMap.put("removemember", removemember);
|
||||||
|
this.commandMap.put("removeowner", removemember);
|
||||||
this.commandMap.put("setparent", new CommandRegionSetParent());
|
this.commandMap.put("setparent", new CommandRegionSetParent());
|
||||||
|
this.commandMap.put("delete", new CommandRegionDelete());
|
||||||
|
this.commandMap.put("addmember", addmember);
|
||||||
|
this.commandMap.put("addowner", addmember);
|
||||||
|
|
||||||
|
// commands that DO NOT support console as sender
|
||||||
|
this.commandMap.put("define", new CommandRegionDefine());
|
||||||
|
this.commandMap.put("claim", new CommandRegionClaim());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException {
|
public boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException {
|
||||||
|
|
||||||
if (!wg.useRegions) {
|
String worldName;
|
||||||
sender.sendMessage(ChatColor.RED + "Regions are disabled.");
|
String subCommand;
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
CommandHandler.checkArgs(args, 1, -1);
|
||||||
|
worldName = ((Player) sender).getWorld().getName();
|
||||||
|
subCommand = args[0].toLowerCase();
|
||||||
|
} else {
|
||||||
|
CommandHandler.checkArgs(args, 2, -1);
|
||||||
|
worldName = args[0];
|
||||||
|
subCommand = args[1].toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
Server server = cfg.getWorldGuardPlugin().getServer();
|
||||||
|
if (server.getWorld(worldName) == null) {
|
||||||
|
sender.sendMessage("Invalid world specified.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ch.checkArgs(args, 1, -1);
|
WorldGuardWorldConfiguration wcfg = cfg.getWorldConfig(worldName);
|
||||||
|
|
||||||
String subCommand = args[0].toLowerCase();
|
if (!wcfg.useRegions) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Regions are disabled in this world.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
WgCommand wgcmd = commandMap.get(subCommand);
|
WgRegionCommand wgcmd = commandMap.get(subCommand);
|
||||||
if (wgcmd == null) {
|
if (wgcmd == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] subArgs = new String[args.length - 1];
|
String[] subArgs;
|
||||||
System.arraycopy(args, 1, subArgs, 0, args.length - 1);
|
if (sender instanceof Player) {
|
||||||
|
subArgs = new String[args.length - 1];
|
||||||
|
System.arraycopy(args, 1, subArgs, 0, args.length - 1);
|
||||||
|
} else {
|
||||||
|
subArgs = new String[args.length - 2];
|
||||||
|
System.arraycopy(args, 2, subArgs, 0, args.length - 2);
|
||||||
|
}
|
||||||
|
|
||||||
wgcmd.handle(sender, senderName, subCommand, subArgs, ch, wg);
|
wgcmd.handle(sender, senderName, subCommand, subArgs, cfg, wcfg);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldguard.bukkit.commands;
|
package com.sk89q.worldguard.bukkit.commands;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.InsufficientArgumentsException;
|
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.InsufficientPermissionsException;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,7 +30,6 @@
|
|||||||
*/
|
*/
|
||||||
public abstract class WgCommand {
|
public abstract class WgCommand {
|
||||||
|
|
||||||
|
public abstract boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg) throws CommandHandlingException;
|
||||||
public abstract boolean handle(CommandSender sender, String senderName, String command, String[] args, CommandHandler ch, WorldGuardPlugin wg) throws CommandHandlingException;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
// $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.bukkit.commands;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardWorldConfiguration;
|
||||||
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Michael
|
||||||
|
*/
|
||||||
|
public abstract class WgRegionCommand {
|
||||||
|
|
||||||
|
public abstract boolean handle(CommandSender sender, String senderName, String command, String[] args, WorldGuardConfiguration cfg, WorldGuardWorldConfiguration wcfg) throws CommandHandlingException;
|
||||||
|
|
||||||
|
}
|
@ -37,25 +37,35 @@ public class GlobalRegionManager {
|
|||||||
|
|
||||||
private WorldGuardPlugin wg;
|
private WorldGuardPlugin wg;
|
||||||
private HashMap<String, RegionManager> managers;
|
private HashMap<String, RegionManager> managers;
|
||||||
private GlobalFlags globalFlags;
|
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
|
||||||
|
|
||||||
public GlobalRegionManager(WorldGuardPlugin wg) {
|
public GlobalRegionManager(WorldGuardPlugin wg) {
|
||||||
|
|
||||||
this.wg = wg;
|
this.wg = wg;
|
||||||
this.managers = new HashMap<String, RegionManager>();
|
this.managers = new HashMap<String, RegionManager>();
|
||||||
this.globalFlags = new GlobalFlags();
|
}
|
||||||
|
|
||||||
|
public void onEnable() {
|
||||||
|
|
||||||
|
this.managers.clear();
|
||||||
|
|
||||||
for (World w : wg.getServer().getWorlds()) {
|
for (World w : wg.getServer().getWorlds()) {
|
||||||
loadWorld(w.getName());
|
loadWorld(w.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.getWgConfiguration().onEnable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
wg.getWgConfiguration().onDisable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadWorld(String name) {
|
private void loadWorld(String name) {
|
||||||
|
|
||||||
String filename = name + ".regions.json";
|
String filename = name + ".regions.json";
|
||||||
try {
|
try {
|
||||||
managers.put(name, new FlatRegionManager(globalFlags, new JSONDatabase(new File(wg.getDataFolder(), filename))));
|
managers.put(name, new FlatRegionManager(new GlobalFlags(), new JSONDatabase(new File(wg.getDataFolder(), filename))));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warning("WorldGuard: Failed to load regions from file " + filename + " : "
|
logger.warning("WorldGuard: Failed to load regions from file " + filename + " : "
|
||||||
@ -76,12 +86,14 @@ public RegionManager getRegionManager(String worldName) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGlobalFlags(GlobalFlags globalflags) {
|
|
||||||
|
public void setGlobalFlags(String worldName, GlobalFlags globalflags) {
|
||||||
|
|
||||||
if (globalflags != null) {
|
if (globalflags != null) {
|
||||||
this.globalFlags = globalflags;
|
RegionManager ret = this.managers.get(worldName);
|
||||||
for (Map.Entry<String, RegionManager> entry : managers.entrySet()) {
|
|
||||||
entry.getValue().setGlobalFlags(globalflags);
|
if (ret == null) {
|
||||||
|
ret.setGlobalFlags(globalflags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user