Compare commits

...
30 Commits
Author SHA1 Message Date
sk89q abbced0530 Updated changelog. 2011-01-20 02:09:04 -08:00
sk89q 200e07023f Fixed /locate printing the name of the wrong person. 2011-01-20 02:03:43 -08:00
sk89q 5fdd26b53f Fixed CSVDatabase spitting an error if the owners list was empty. 2011-01-20 02:01:50 -08:00
sk89q 61896ea760 Updated example config.yml. 2011-01-20 01:56:42 -08:00
sk89q b43881c299 Added /locate. 2011-01-20 01:54:47 -08:00
sk89q 6046f4defc Fixed teleport-on-suffocation setting. 2011-01-20 01:07:39 -08:00
sk89q 69ccb9f12b Implemented contact damage and fixed other damage protection. 2011-01-20 00:55:20 -08:00
sk89q 430f2f57e9 Made TNT blocking work. 2011-01-19 23:38:16 -08:00
sk89q c3f0bbb41c Added /heal and /slay. 2011-01-19 23:31:20 -08:00
sk89q 7e481e6a9a Moved commands handling to be Bukkit-compliant. 2011-01-19 23:27:35 -08:00
sk89q 627de1aebd Changed how the player item event was handled. 2011-01-19 22:09:15 -08:00
sk89q 194108336b Updated CHANGELOG.txt. 2011-01-17 19:47:24 -08:00
sk89q eade612981 Fixed WorldGuard not getting group lists for permissions correctly. 2011-01-17 19:45:53 -08:00
sk89q 733163cc4c Updated changelog, readme. 2011-01-17 19:22:04 -08:00
sk89q 86a917ddd1 Added creeper block support. 2011-01-17 18:38:12 -08:00
sk89q e8503aa0b9 Now supports GroupUsers (through WorldEdit). 2011-01-17 17:55:56 -08:00
sk89q 01bf9e8406 Fixed issue where the build process did not make sure that plugin.yml would be updated. 2011-01-17 17:47:07 -08:00
sk89q 0bdadf63b3 Fixed errors in tests. 2011-01-17 17:45:51 -08:00
sk89q 5b1c35bf06 Fixed build file not replacing version macro correctly. 2011-01-17 16:51:04 -08:00
sk89q c467acdfac Updated CHANGELOG.txt for 2.1.1. 2011-01-17 02:55:18 -08:00
sk89q 22167a0a07 Allowed placing WorldEdit.jar as a dependency in WorldGuard/. 2011-01-17 02:53:13 -08:00
sk89q 251647c7a2 Added some priority support. 2011-01-17 02:31:32 -08:00
sk89q 80e9799579 Fixed typo in README.txt. 2011-01-17 00:23:17 -08:00
sk89q 95f49f34d0 Cleaned up code. 2011-01-17 00:19:23 -08:00
sk89q b01b67f64c Cleaned up code. 2011-01-17 00:16:02 -08:00
sk89q 603fb5d2b8 Made /reload WorldGuard work for everyone by default. 2011-01-17 00:13:27 -08:00
sk89q 22f7c347ab Simplified release ZIP. 2011-01-17 00:10:32 -08:00
sk89q 08229ed4f9 Made WorldGuard write default configuration files, more friendly. Removed hMod configuration files. 2011-01-17 00:05:35 -08:00
sk89q a942fd08f5 Fixed NullPointerException related to the player item event. 2011-01-16 23:15:30 -08:00
sk89q c96d534c26 Fixed fire spread disable preventing flint and steel too. 2011-01-16 19:38:29 -08:00
32 changed files with 1519 additions and 1261 deletions

No files matched your search

+24
View File
@@ -1,3 +1,27 @@
2.3:
- /god now works very well.
- Item (TNT, flint and steel, etc.) blocking should now work.
- The TNT blocking configuration variable should now work.
- Re-added /heal (not sure where that went), added /slay.
- Implemented contact damage disable toggle.
- Made all player damage disabling configuration parameters work.
- Fixed teleport-on-suffocation setting.
- Added /locate <name>, /locate <x> <y> <z>, and /locate that lets you
program/change your compass bearing to point to a player's position
(not yet live), a position, or back to spawn.
- Fixed CSVDatabase spitting an error if the owners list was empty.
2.2:
- Now supports GroupUsers.
- Added support for blocking creeper explosions.
- Fixed a bug where a player's groups were not being loaded correctly,
causing the blacklist group ignore option to not work.
2.1.1:
- Fixed fire spread disable preventing flint and steel too.
- Fixed NullPointerException related to the player item event.
- Made setup simpler.
2.1:
- Improved Bukkit support.
-28
View File
@@ -1,28 +0,0 @@
Installation
------------
Bukkit:
** Make sure you first install the WorldEdit plugin. **
1. Create a "plugins" folder inside your server folder.
2. Copy WorldGuard.jar into "plugins".
3. Restart your server.
You may want to copy config.yml into plugins/WorldGuard/config.yml
(you will have to create that folder). Edit it to fit your needs.
hMod:
1. Create a "plugins" folder inside your "bin" folder.
2. Copy WorldGuard.jar into "plugins".
3. Add "WorldGuard" to the "plugins" line of your server.properties file.
If it's not already there, add the line. The line should look like this:
plugins=WorldGuard
If you have multiple plugins, separate plugin names with commas.
+4 -232
View File
@@ -1,242 +1,14 @@
WorldGuard
Copyright (c) 2010 sk89q <http://www.sk89q.com>
Copyright (c) 2010, 2011 sk89q <http://www.sk89q.com>
Licensed under the GNU Lesser General Public License v3
Introduction
------------
WorldGuard has a number of features, any of which you can choose to
use or not:
WorldGuard protects your server!
- Enforce only one session for a player on a server (can't login twice).
- Block creeper explosions.
- Block TNT explosions.
- Block lighters from setting fires.
- Block all fires.
- Disable fall damage, lava damage, fire damage, and/or water damage.
- Allow fire but prevent it from burning certain blocks.
- Prevent lava from starting fires.
- Restrict lava spreading to only some block types.
- Simulate classic-esque water by letting water infinitely expand in
area (only if there is a block underneath).
- Prevent water from destroying blocks like Redstone wire and flowers.
- Simulate the function of the sponge from Minecraft Classic.
- Notify admins, block, log, kick or ban for the use of certain block types
or items.
- Temporarily stop fire globally with some commands.
- Destroy tools on drop to alleviate the durability cheat.
- Prevent gravel and sand from falling.
- Allow portal blocks to be placed anywhere.
hMod is required as WorldGuard is a plugin for hMod.
Configuration
-------------
A "worldguard.properties" will be created the first the time that you load
WorldGuard on your server. You can either restart your server or use
/reloadplugin WorldGuard to reload the configuraton file after editing it.
NOTE: Some features may require a custom version of hMod. When the server
is loaded with the plugin, WorldGuard will tell you the features
unsupported by your version of hMod.
- summary-on-start (def. true)
Print a summary of WorldGuard's protection settings at-a-glance when
the plugin is loaded.
- item-durability (def. false)
**Requires special version of hMod
Enables item durability.
- classic-water (def. false)
Toggle use of classic water. Be foreward that your world may be
flooded if you are not careful. If you have WorldEdit, you can use
//drain in such an event, although that will drain the entire pool
as well. This classic-esque water will only spread infinitely over
ground, but if there are air blocks underneath, the water will not
spread (preventing waterfalls from becoming tsunamis).
- simulate-sponge (def. true)
Toggle simulation of the sponge from Classic. It blocks water from
flowing near the sponge.
- sponge-radius (def. 3)
The radius of the sponge's effect. The default is that of Classic,
creating a 5x5x5 cuboid free of water. Increasing the number will
increase server load exponentially, although 3-5 has fairly low impact.
- no-physics-gravel (def. false)
**Requires special version of hMod
Prevents gravel from falling due to gravity.
- no-physics-sand (def. false)
**Requires special version of hMod
Prevents sand from falling due to gravity.
- allow-portal-anywhere (def. false)
**Requires special version of hMod
Allows you to place portal blocks anywhere.
- enforce-single-session (def. true)
Enforce single sessions. If the player is already found to be on
the server when s/he logs in, the other player will be kicked with
an informative message. The inventory will have been saved before
the new session starts.
- block-tnt (def. false)
Block TNT explosions. TNT will still explode client-side but the blocks
will be "restored" in a few seconds afterwards.
- block-lighter (def. false)
Block flint and steel fires. Those with access to the commands
/uselighter or /lighter can bypass this. /uselighter is not a real
command; it is only used for permissions.
- block-creepers (def. false)
Block creeper explosions from destroying terrain (and possibly from
causing damage).
- disable-lava-fire (def. true)
Prevent lava from starting fires.
- allowed-lava-spread-blocks (no default)
List of block names/IDs to allow lava to spread to. Leave blank
to disable this feature.
- disable-all-fire-spread (def. false)
Disable all fire from spreading.
- disallowed-fire-spread-blocks (no default)
List of block names/IDs to prevent fire from spreading to. Leave blank
to disable this feature. Enabling disable-all-fire-spread will
override this function.
- disable-water-damage-blocks (no default)
List of blocks that should not be destroyed by water (Redstone wire,
minecart tracks, flowers, etc.).
- item-drop-blacklist (no default)
List of block names/IDs to destroy on drop. This can alleviate the
durability cheat that allows you to drop your tools to fix their
durability. You can also enforce this with the blacklist but
this is an easier way to do it (this way also prints a more
friendly message than if you used the 'tell' action of the blacklist).
- login-protection (def. 3)
Number of seconds to keep a player invincible when the player joins.
- spawn-protection (def. 0)
Number of seconds to keep a player invincible when the player spawns.
This does not apply to players joining the server.
- kick-on-death (def. false)
Kick players when they die (and respawn). This is to work around the
issues of invisible players when players die.
- disable-fall-damage (def. false)
- disable-lava-damage (def. false)
- disable-fire-damage (def. false)
- disable-water-damage (def. false)
Disable various types of damage.
- log-console (def. true)
For blacklist log actions, print to console.
- log-file (def. false)
For blacklist log actions, log to file.
- log-file-path (def. "worldguard/logs/%Y-%m-%d.log")
Log blacklist events to file. You can use these patterns in the path:
%Y the year (YYYY)
%m the month (MM)
%d the day (DD)
%W the week of the year (00-52)
%H 24-hour time (HH)
%h 12-hour time (HH)
%i the minute (mm)
%s the second (ss)
%u the user's name
%% translates to a single percent sign "%"
The files are not automatically rotated if they get large so you should
perhaps put a week in the filename at least.
Escape backslashes with another backslash, like so:
C:\path\to\log.txt -> C:\\path\\to\\log.txt
- log-file-open-files (def. 10)
The number of log files to keep open at once. Unless you use dynamic
patterns in the path, the value of this variable won't matter. However,
if, for example, you use a player's username in the filename and you
have many users who cause logged events to occur, files would have
to be opened for each user and this parameter would matter.
- log-database (def. false)
Log blacklist events to database.
- log-database-dsn (def. "jdbc:mysql://localhost:3306/minecraft")
Connection string. A string to use for MySQL would be:
jdbc:mysql://localhost:3306/minecraft
The "minecraft" part at the end is the database name.
Escape colons with a backslash, like so:
jdbc:mysql://localhost:3306/minecraft
->
jdbc\:mysql\://localhost\:3306/minecraft
- log-database-user (def. "root")
Database username.
- log-database-pass (def. "")
Database password.
- log-database-table (def. "blacklist_events")
Database table to use.
Commands
--------
- /stopfire and /allowfire
Disables and enables fire spread globally. Both commands require the
permission to use only "/stopfire. Re-enabling fire spread with this
command will not override other fire spread control features of
WorldGuard. Note that disabling fire does not disable fire damage
but fire at least won't spread.
- /god
Toggles your invincibility. Players must have permission to use "/god"
to be able to use this command. You can also use this command to
toggle the invincibility of others although you must have the
"/godother" permission.
Server Commands
---------------
- fire-stop and fire-allow
Disables and enables fire spread globally. Re-enabling fire spread
with this command will not override other fire spread control features
of WorldGuard. Note that disabling fire does not disable fire damage
but fire at least won't spread.
Blacklists
----------
Blacklists let you control the use of blocks and items. You can have
certain rules apply to only some groups.
Edit the included worldguard-blacklist.txt file and follow the
instructions inside. The file comes with the download for WorldGuard.
Other Features
--------------
To give someone invincibility every time s/he joins the server, create
a wg-invincible group and add the group to the user or have the user's
group inherit this group.
To give someone the ability to breathe under water, create
a wg-amphibious group and add the group to the user or have the user's
group inherit this group.
Documentation can be found at:
http://wiki.sk89q.com/wiki/WorldGuard
Thanks
------
+84
View File
@@ -0,0 +1,84 @@
#
# This is the blacklist for WorldGuard. The blacklist allows you to perform
# actions depending on an item or block ID. Comments start with # and they
# are ignored so you can put your own notes.
#
# --------------------------------------------------------------------------
#
# WARNING:
# Remember to check the compatibility spreadsheet for WorldGuard to see
# if any events or actions are currently broken in your version of Bukkit.
#
# --------------------------------------------------------------------------
#
# Format:
# [item1,item2]
# option1=options
# event1=whatToDo1,whatToDo2,whatToDo3
# event2=whatToDo1,whatToDo2
#
# Example to block some ore mining and placement:
# [coalore,goldore,ironore]
# on-break=deny,log,kick
# on-place=deny,tell
#
# Options:
# - ignore-groups (comma-separated list of groups to not affect)
# - comment (message for yourself that is printed with 'log' and 'notify')
# - message (optional message to show the user instead; %s is the item name)
#
# Events:
# - on-break (when a block of this type is about to be broken)
# - on-destroy-with (the item/block held by the user while destroying)
# - on-place (a block is being placed)
# - on-use (an item like flint and steel or a bucket is being used)
# - on-interact (when a block in used (doors, chests, etc.))
# - on-drop (an item is being dropped from the player's inventory)
# - on-acquire (an item enters a player's inventory via some method)
#
# Actions (for events):
# - deny (deny completely)
# - notify (notify admins)
# - log (log to console/file/database)
# - tell (tell a player that that's not allowed)
# - kick (kick player)
# - ban (ban player)
#
# Users with the /worldguardnotify permission will receive notifications.
#
# -------------
#
# You can have the same block or item used in two different sections and
# they will both apply:
#
# [goldblock]
# ignore-groups=vip
# on-break=deny
# [goldblock]
# ignore-groups=admins
# on-break=tell
#
# However, some events override others. For example, if you disable both
# usage of the diamond pickaxe (with the on-destroy-with event) and
# destruction of gold blocks (with the on-break event) and a player tries
# to destroy a gold block with a diamond pickaxe, because the
# on-destroy-with event comes first, the rules for the gold block
# will not be applied (but the player will be denied nevertheless).
#
# --------------------------------------------------------------------------
#
# Some examples follow.
#
# REMEMBER: If a line has # in front, it will be ignored.
#
# --------------------------------------------------------------------------
# Deny lava buckets
#[lavabucket]
#ignore-groups=admins,mods
#on-use=deny,tell
# Deny some ore
#[coalore,goldore,ironore]
#ignore-groups=admins,mods
#on-break=notify,deny,log
+10 -11
View File
@@ -30,9 +30,14 @@
<attribute name="Implementation-Title" value="WorldGuard"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="WorldGuard-Version" value="${version}"/>
<attribute name="Class-Path" value="WorldEdit.jar"/>
<attribute name="Class-Path" value="WorldEdit.jar WorldGuard/WorldEdit.jar"/>
</manifest>
<delete file="${build.dir}/plugin.yml"/>
<copy tofile="${build.dir}/plugin.yml" file="plugin.yml"/>
<replace file="${build.dir}/plugin.yml" token="WGVERSIONMACRO" value="${version}"/>
<mkdir dir="${build.dir}/defaults"/>
<copy tofile="${build.dir}/defaults/config.yml" file="config.yml"/>
<copy tofile="${build.dir}/defaults/blacklist.txt" file="blacklist.txt"/>
<jar jarfile="${dist.dir}/WorldGuard.jar" basedir="${build.dir}" manifest="manifest.mf"/>
</target>
@@ -48,16 +53,10 @@
<antcall target="jar"/>
<delete dir="${release.dir}"/>
<mkdir dir="${release.dir}"/>
<copy todir="${release.dir}">
<fileset dir="."/>
<globmapper from="*.txt" to="*.txt"/>
</copy>
<copy tofile="${release.dir}/worldguard.updatr" file="worldguard.updatr"/>
<replace file="${release.dir}/worldguard.updatr" token="%version%" value="${version}"/>
<copy tofile="${release.dir}/plugin.yml" file="plugin.yml"/>
<copy tofile="${release.dir}/config.yml" file="config.yml"/>
<replace file="${release.dir}/plugin.yml" token="WGVERSIONMACRO" value="${version}"/>
<copy file="worldguard.properties" todir="${release.dir}"/>
<copy tofile="${release.dir}/README.txt" file="README.txt"/>
<copy tofile="${release.dir}/LICENSE.txt" file="LICENSE.txt"/>
<copy tofile="${release.dir}/CHANGELOG.txt" file="CHANGELOG.txt"/>
<copy tofile="${release.dir}/blacklist_table.sql" file="blacklist_table.sql"/>
<copy tofile="${release.dir}/WorldGuard.jar" file="${dist.dir}/WorldGuard.jar"/>
<zip destfile="${release.dir}/worldguard-${version}.zip" basedir="${release.dir}" excludes="*.zip plugin.yml"/>
<mkdir dir="${release.dir}/src"/>
+65 -33
View File
@@ -1,63 +1,95 @@
summary-on-start: true
#
# WorldGuard's configuration file
#
# About editing this file:
# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If
# you use an editor like Notepad++ (recommended for Windows users), you
# must configure it to "replace tabs with spaces." In Notepad++, this can
# be changed in Settings > Preferences > Language Menu.
# - Don't get rid of the indents. They are indented so some entries are
# in categories (like "enforce-single-session" is in the "protection"
# category.
# - If you want to check the format of this file before putting it
# into WorldGuard, paste it into http://yaml-online-parser.appspot.com/
# and see if it gives "ERROR:".
# - Lines starting with # are commentsand so they are ignored.
#
# WARNING:
# Remember to check the compatibility spreadsheet for WorldGuard to see
# if any features are currently broken in your version of Bukkit.
#
summary-on-start: on
protection:
enforce-single-session: true
item-durability: true
enforce-single-session: on
item-durability: on
simulation:
classic-water: false
classic-water: off
sponge:
enable: true
enable: on
radius: 3
physics:
# Doesn't work in Bukkit yet
no-physics-gravel: false
no-physics-sand: false
allow-portal-anywhere: false
no-physics-gravel: off
no-physics-sand: off
allow-portal-anywhere: off
disable-water-damage-blocks: []
ignition:
block-tnt: false
block-lighter: false
block-tnt: off
block-lighter: off
fire:
disable-all-fire-spread: false
disable-all-fire-spread: off
disable-fire-spread-blocks: []
disable-lava-fire-spread: true
disable-lava-fire-spread: on
lava-spread-blocks: []
mobs:
# Doesn't work in Bukkit yet
block-creeper-explosions: false
block-creeper-explosions: off
block-creeper-block-damage: off
spawn:
# Doesn't work in Bukkit yet
login-protection: 3
spawn-protection: 0
kick-on-death: false
exact-respawn: false
teleport-to-home-on-death: false
kick-on-death: off
exact-respawn: off
teleport-to-home-on-death: off
player-damage:
# Doesn't work in Bukkit yet
disable-fall-damage: true
disable-lava-damage: true
disable-fire-damage: true
disable-drowning-damage: true
disable-suffocation-damage: true
teleport-on-suffocation: true
disable-fall-damage: off
disable-lava-damage: off
disable-fire-damage: off
disable-drowning-damage: off
disable-suffocation-damage: off
disable-contact-damage: off
teleport-on-suffocation: off
regions:
enable: true
enable: on
wand: 287
blacklist:
logging:
console:
enable: true
enable: on
database:
enable: false
enable: off
dsn: jdbc:mysql://localhost:3306/minecraft
user: root
password: pass
table: blacklist_events
file:
enable: true
enable: on
path: worldguard/logs/%Y-%m-%d.log
open-files: 10
# See http://wiki.sk89q.com/wiki/WorldGuard/Permissions/Bukkit
permissions:
groups:
default:
users:
sk89q:
permissions:
users:
- /region
- /reloadwg
+31 -1
View File
@@ -1,3 +1,33 @@
name: WorldGuard
main: com.sk89q.worldguard.bukkit.WorldGuardPlugin
version: WGVERSIONMACRO
version: WGVERSIONMACRO
commands:
stopfire:
description: Halts all fire spread until it is disabled or the server is restarted
usage: /<command>
allowfire:
description: Re-enables fire spread if he has been disabled with /stopfire
usage: /<command>
god:
description: Toggles god mode
usage: /<command> [other player]
heal:
description: Heal yourself or another
usage: /<command> [other player]
slay:
description: Slay yourself or another
usage: /<command> [other player]
stack:
description: Stacks items in the player's inventory
usage: /<command>
aliases: ;
region:
description: Adjust protected regions
usage: /<command> <define|claim|flag|delete|info|addowner|removeowner|list|save|load> ...
aliases: rg, regions
locate:
description: Set your compass towards a person
usage: /<command> <target>
reloadwg:
description: Reload WorldGuard's configuration
usage: /<command>
+2 -2
View File
@@ -1,5 +1,3 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
@@ -16,6 +14,8 @@ package au.com.bytecode.opencsv;
limitations under the License.
*/
package au.com.bytecode.opencsv;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+2 -2
View File
@@ -1,5 +1,3 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
@@ -16,6 +14,8 @@ package au.com.bytecode.opencsv;
limitations under the License.
*/
package au.com.bytecode.opencsv;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
+2 -2
View File
@@ -1,5 +1,3 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
@@ -16,6 +14,8 @@ package au.com.bytecode.opencsv;
limitations under the License.
*/
package au.com.bytecode.opencsv;
import java.io.Closeable;
import java.io.IOException;
import java.io.PrintWriter;
@@ -1,4 +1,3 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
@@ -15,6 +14,8 @@ package au.com.bytecode.opencsv;
limitations under the License.
*/
package au.com.bytecode.opencsv;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -1,4 +1,3 @@
package au.com.bytecode.opencsv;
/**
Copyright 2005 Bytecode Pty Ltd.
@@ -14,6 +13,9 @@ package au.com.bytecode.opencsv;
See the License for the specific language governing permissions and
limitations under the License.
*/
package au.com.bytecode.opencsv;
import java.io.IOException;
import java.io.Reader;
import java.math.BigDecimal;
+1 -1
View File
@@ -71,7 +71,7 @@ public abstract class LocalPlayer {
*
* @return
*/
public abstract List<String> getGroups();
public abstract String[] getGroups();
@Override
public boolean equals(Object obj) {
@@ -21,8 +21,6 @@ package com.sk89q.worldguard.blacklist;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
import org.bukkit.ChatColor;
import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldguard.LocalPlayer;
@@ -1,6 +1,3 @@
package com.sk89q.worldguard.blacklist;
import com.sk89q.worldguard.blacklist.events.BlacklistEvent;
// $Id$
/*
* WorldGuard
@@ -20,6 +17,10 @@ import com.sk89q.worldguard.blacklist.events.BlacklistEvent;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.blacklist;
import com.sk89q.worldguard.blacklist.events.BlacklistEvent;
/**
*
* @author sk89q
@@ -1,4 +1,3 @@
package com.sk89q.worldguard.blacklist.loggers;
// $Id$
/*
* WorldGuard
@@ -18,6 +17,8 @@ package com.sk89q.worldguard.blacklist.loggers;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.blacklist.loggers;
import java.util.logging.Logger;
import java.util.logging.Level;
import com.sk89q.worldedit.blocks.ItemType;
@@ -19,7 +19,6 @@
package com.sk89q.worldguard.bukkit;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.sk89q.worldedit.Vector;
@@ -61,7 +60,7 @@ public class BukkitPlayer extends LocalPlayer {
}
@Override
public List<String> getGroups() {
public String[] getGroups() {
return plugin.getGroups(player);
}
@@ -1,4 +1,3 @@
package com.sk89q.worldguard.bukkit;
// $Id$
/*
* WorldGuard
@@ -18,6 +17,8 @@ package com.sk89q.worldguard.bukkit;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.bukkit;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import org.bukkit.ChatColor;
@@ -176,7 +176,7 @@ public class WorldGuardBlockListener extends BlockListener {
return;
}
if (plugin.disableFireSpread) {
if (plugin.disableFireSpread && isFireSpread) {
event.setCancelled(true);
return;
}
@@ -20,11 +20,15 @@
package com.sk89q.worldguard.bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockType;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
public class WorldGuardEntityListener extends EntityListener {
@@ -47,40 +51,18 @@ public class WorldGuardEntityListener extends EntityListener {
Entity defender = event.getEntity();
DamageCause type = event.getCause();
if (defender instanceof Player) {
if (defender instanceof Player) {
Player player = (Player)defender;
if (plugin.invinciblePlayers.contains(player.getName())) {
event.setCancelled(true);
return;
}
if (plugin.disableFallDamage && type == DamageCause.FALL) {
event.setCancelled(true);
return;
}
if (plugin.disableLavaDamage && type == DamageCause.LAVA) {
event.setCancelled(true);
return;
}
if (plugin.disableFireDamage && (type == DamageCause.FIRE
|| type == DamageCause.FIRE_TICK)) {
event.setCancelled(true);
return;
}
if (plugin.disableDrowningDamage && type == DamageCause.DROWNING) {
event.setCancelled(true);
return;
}
if (type == DamageCause.DROWNING
&& plugin.amphibiousPlayers.contains(player.getName())) {
event.setCancelled(true);
return;
}
}
}
@@ -110,4 +92,148 @@ public class WorldGuardEntityListener extends EntityListener {
}
}
}
public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
Entity defender = event.getEntity();
if (defender instanceof Player) {
Player player = (Player)defender;
if (plugin.invinciblePlayers.contains(player.getName())) {
event.setCancelled(true);
return;
}
}
}
public void onEntityDamage(EntityDamageEvent event) {
Entity defender = event.getEntity();
DamageCause type = event.getCause();
if (defender instanceof Player) {
Player player = (Player)defender;
if (plugin.invinciblePlayers.contains(player.getName())) {
event.setCancelled(true);
return;
}
if (plugin.disableFallDamage && type == DamageCause.FALL) {
event.setCancelled(true);
return;
}
if (plugin.disableFireDamage && (type == DamageCause.FIRE
|| type == DamageCause.FIRE_TICK)) {
event.setCancelled(true);
return;
}
if (plugin.disableDrowningDamage && type == DamageCause.DROWNING) {
event.setCancelled(true);
return;
}
if (plugin.teleportOnSuffocation && type == DamageCause.SUFFOCATION) {
findFreePosition(player);
event.setCancelled(true);
return;
}
if (plugin.disableSuffocationDamage && type == DamageCause.SUFFOCATION) {
event.setCancelled(true);
return;
}
if (plugin.disableContactDamage && type == DamageCause.CONTACT) {
event.setCancelled(true);
return;
}
if (type == DamageCause.DROWNING
&& plugin.amphibiousPlayers.contains(player.getName())) {
event.setCancelled(true);
return;
}
}
}
@Override
public void onEntityExplode(EntityExplodeEvent event) {
if (event.getEntity() instanceof LivingEntity) {
if (plugin.blockCreeperBlockDamage) {
event.setCancelled(true);
return;
}
if (plugin.blockCreeperExplosions) {
event.setCancelled(true);
return;
}
if (plugin.useRegions) {
Vector pt = toVector(event.getEntity().getLocation());
if (!plugin.regionManager.getApplicableRegions(pt).allowsCreeperExplosions()) {
event.setCancelled(true);
return;
}
}
} else { // Shall assume that this is TNT
if (plugin.blockTNT) {
event.setCancelled(true);
return;
}
if (plugin.useRegions) {
Vector pt = toVector(event.getEntity().getLocation());
if (!plugin.regionManager.getApplicableRegions(pt).allowsTNT()) {
event.setCancelled(true);
return;
}
}
}
}
/**
* Find a position for the player to stand that is not inside a block.
* Blocks above the player will be iteratively tested until there is
* a series of two free blocks. The player will be teleported to
* that free position.
*
* @param player
*/
public void findFreePosition(Player player) {
Location loc = player.getLocation();
int x = loc.getBlockX();
int y = Math.max(0, loc.getBlockY());
int origY = y;
int z = loc.getBlockZ();
World world = player.getWorld();
byte free = 0;
while (y <= 129) {
if (BlockType.canPassThrough(world.getBlockTypeIdAt(x, y, z))) {
free++;
} else {
free = 0;
}
if (free == 2) {
if (y - 1 != origY) {
loc.setX(x + 0.5);
loc.setY(y);
loc.setZ(z + 0.5);
player.teleportTo(loc);
}
return;
}
y++;
}
}
}
@@ -19,31 +19,16 @@
package com.sk89q.worldguard.bukkit;
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.blocks.ItemType;
import com.sk89q.worldedit.bukkit.WorldEditAPI;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.*;
import com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent;
import com.sk89q.worldguard.domains.*;
import com.sk89q.worldguard.protection.*;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
/**
@@ -54,12 +39,6 @@ public class WorldGuardPlayerListener extends PlayerListener {
* Plugin.
*/
private WorldGuardPlugin plugin;
/**
* Group pattern used to specify groups for the region command.
*/
private static Pattern groupPattern = Pattern.compile("^[gG]:(.+)$");
private static int CMD_LIST_SIZE = 9;
/**
* Construct the object;
@@ -117,8 +96,9 @@ public class WorldGuardPlayerListener extends PlayerListener {
public void onPlayerItem(PlayerItemEvent event) {
Player player = event.getPlayer();
Block block = event.getBlockClicked();
ItemStack item = event.getItem();
if (plugin.useRegions && !event.isBlock() && event.getBlockClicked() != null) {
if (plugin.useRegions && !event.isBlock() && block != null) {
Vector pt = toVector(block.getRelative(event.getBlockFace()));
LocalPlayer localPlayer = plugin.wrapPlayer(player);
@@ -131,10 +111,11 @@ public class WorldGuardPlayerListener extends PlayerListener {
}
}
if (plugin.blacklist != null) {
if (item != null && plugin.blacklist != null && block != null) {
if (!plugin.blacklist.check(
new ItemUseBlacklistEvent(plugin.wrapPlayer(player), toVector(block),
block.getTypeId()), false, false)) {
new ItemUseBlacklistEvent(plugin.wrapPlayer(player),
toVector(block.getRelative(event.getBlockFace())),
item.getTypeId()), false, false)) {
event.setCancelled(true);
return;
}
@@ -160,629 +141,4 @@ public class WorldGuardPlayerListener extends PlayerListener {
}
}
}
/**
* Called when a player attempts to use a command
*
* @param event Relevant event details
*/
@Override
public void onPlayerCommand(PlayerChatEvent event) {
if (handleCommand(event)) {
event.setCancelled(true);
}
}
/**
* Called when a player attempts to use a command
*
* @param event Relevant event details
*/
public boolean handleCommand(PlayerChatEvent event) {
Player player = event.getPlayer();
String[] split = event.getMessage().split(" ");
if (split[0].equalsIgnoreCase("/stopfire") &&
plugin.hasPermission(player, "/stopfire")) {
if (!plugin.fireSpreadDisableToggle) {
plugin.getServer().broadcastMessage(ChatColor.YELLOW
+ "Fire spread has been globally disabled by " + player.getName() + ".");
} else {
player.sendMessage(ChatColor.YELLOW + "Fire spread was already globally disabled.");
}
plugin.fireSpreadDisableToggle = true;
} else if (split[0].equalsIgnoreCase("/allowfire")
&& plugin.hasPermission(player, "/stopfire")) {
if (plugin.fireSpreadDisableToggle) {
plugin.getServer().broadcastMessage(ChatColor.YELLOW
+ "Fire spread has been globally re-enabled by " + player.getName() + ".");
} else {
player.sendMessage(ChatColor.YELLOW + "Fire spread was already globally enabled.");
}
plugin.fireSpreadDisableToggle = false;
} else if (split[0].equalsIgnoreCase("/god")
&& plugin.hasPermission(player, "/god")) {
// Allow setting other people invincible
if (split.length > 1) {
if (!plugin.hasPermission(player, "/godother")) {
player.sendMessage(ChatColor.RED + "You don't have permission to make others invincible.");
return true;
}
Player other = matchSinglePlayer(plugin.getServer(), split[1]);
if (other == null) {
player.sendMessage(ChatColor.RED + "Player not found.");
} else {
if (!plugin.invinciblePlayers.contains(other.getName())) {
plugin.invinciblePlayers.add(other.getName());
player.sendMessage(ChatColor.YELLOW + other.getName() + " is now invincible!");
other.sendMessage(ChatColor.YELLOW + player.getName() + " has made you invincible!");
} else {
plugin.invinciblePlayers.remove(other.getName());
player.sendMessage(ChatColor.YELLOW + other.getName() + " is no longer invincible.");
other.sendMessage(ChatColor.YELLOW + player.getName() + " has taken away your invincibility.");
}
}
// Invincibility for one's self
} else {
if (!plugin.invinciblePlayers.contains(player.getName())) {
plugin.invinciblePlayers.add(player.getName());
player.sendMessage(ChatColor.YELLOW + "You are now invincible!");
} else {
plugin.invinciblePlayers.remove(player.getName());
player.sendMessage(ChatColor.YELLOW + "You are no longer invincible.");
}
}
} else if ((split[0].equalsIgnoreCase("/stack")
|| split[0].equalsIgnoreCase("/;"))
&& plugin.hasPermission(player, "/stack")) {
ItemStack[] items = player.getInventory().getContents();
int len = items.length;
int affected = 0;
for (int i = 0; i < len; i++) {
ItemStack item = items[i];
// Avoid infinite stacks and stacks with durability
if (item == null || item.getAmount() <= 0
|| ItemType.shouldNotStack(item.getTypeId())) {
continue;
}
// Ignore buckets
if (item.getTypeId() >= 325 && item.getTypeId() <= 327) {
continue;
}
if (item.getAmount() < 64) {
int needed = 64 - item.getAmount(); // Number of needed items until 64
// Find another stack of the same type
for (int j = i + 1; j < len; j++) {
ItemStack item2 = items[j];
// Avoid infinite stacks and stacks with durability
if (item2 == null || item2.getAmount() <= 0
|| ItemType.shouldNotStack(item.getTypeId())) {
continue;
}
// Same type?
// Blocks store their color in the damage value
if (item2.getTypeId() == item.getTypeId() &&
(!ItemType.usesDamageValue(item.getTypeId())
|| item.getDamage() == item2.getDamage())) {
// This stack won't fit in the parent stack
if (item2.getAmount() > needed) {
item.setAmount(64);
item2.setAmount(item2.getAmount() - needed);
break;
// This stack will
} else {
items[j] = null;
item.setAmount(item.getAmount() + item2.getAmount());
needed = 64 - item.getAmount();
}
affected++;
}
}
}
}
if (affected > 0) {
player.getInventory().setContents(items);
}
player.sendMessage(ChatColor.YELLOW + "Items compacted into stacks!");
} else if (split[0].equalsIgnoreCase("/rg")
|| split[0].equalsIgnoreCase("/region")) {
if (split.length < 2) {
player.sendMessage(ChatColor.RED + "/region <define|flag|delete|info|add|remove|list|save|load> ...");
return true;
}
String action = split[1];
String[] args = new String[split.length - 1];
System.arraycopy(split, 1, args, 0, split.length - 1);
handleRegionCommand(player, action, args);
} else if (split[0].equalsIgnoreCase("/reload")
&& plugin.hasPermission(player, "/reload")
&& split.length > 1) {
if (split[1].equalsIgnoreCase("WorldGuard")) {
LoggerToChatHandler handler = new LoggerToChatHandler(player);
handler.setLevel(Level.ALL);
Logger minecraftLogger = Logger.getLogger("Minecraft");
minecraftLogger.addHandler(handler);
try {
plugin.loadConfiguration();
plugin.postReload();
player.sendMessage("WorldGuard configuration reloaded.");
} catch (Throwable t) {
player.sendMessage("Error while reloading: "
+ t.getMessage());
} finally {
minecraftLogger.removeHandler(handler);
}
return true;
}
} else {
return false;
}
return true;
}
/**
* Handles a region command.
*
* @param player
* @param action
* @param args
*/
private void handleRegionCommand(Player player, String action, String[] args) {
if (!plugin.useRegions) {
player.sendMessage(ChatColor.RED + "Regions are disabled.");
return;
}
if (action.equalsIgnoreCase("define")) {
if (!canUseRegionCommand(player, "/regiondefine")) {
player.sendMessage(ChatColor.RED + "You don't have the /regiondefine permission.");
return;
}
if (args.length < 2) {
player.sendMessage(ChatColor.RED + "/region define <id> [owner1 [owner2 [owners...]]]");
return;
}
try {
String id = args[1].toLowerCase();
Plugin wePlugin = plugin.getServer().getPluginManager().getPlugin("WorldEdit");
if (plugin == null) {
player.sendMessage(ChatColor.RED + "WorldEdit must be installed and enabled as a plugin.");
return;
}
WorldEditPlugin worldEdit = (WorldEditPlugin)wePlugin;
WorldEditAPI api = worldEdit.getAPI();
LocalSession session = api.getSession(player);
Region weRegion = session.getRegion();
BlockVector min = weRegion.getMinimumPoint().toBlockVector();
BlockVector max = weRegion.getMaximumPoint().toBlockVector();
ProtectedRegion region = new ProtectedCuboidRegion(min, max);
if (args.length >= 3) {
region.setOwners(parseDomainString(args, 2));
}
plugin.regionManager.addRegion(id, region);
plugin.regionLoader.save(plugin.regionManager);
player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
} catch (IncompleteRegionException e) {
player.sendMessage(ChatColor.RED + "You must first define an area in WorldEdit.");
} catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: "
+ e.getMessage());
}
} else if (action.equalsIgnoreCase("claim")) {
if (!canUseRegionCommand(player, "/regionclaim")) {
player.sendMessage(ChatColor.RED + "You don't have the /regionclaim permission.");
return;
}
if (args.length < 1) {
player.sendMessage(ChatColor.RED + "/region claim <id>");
return;
}
try {
String id = args[1].toLowerCase();
Plugin wePlugin = plugin.getServer().getPluginManager().getPlugin("WorldEdit");
if (plugin == null) {
player.sendMessage(ChatColor.RED + "WorldEdit must be installed and enabled as a plugin.");
return;
}
ProtectedRegion existing = plugin.regionManager.getRegion(id);
if (existing != null) {
if (!existing.getOwners().contains(plugin.wrapPlayer(player))) {
player.sendMessage(ChatColor.RED + "You don't own this region.");
return;
}
}
WorldEditPlugin worldEdit = (WorldEditPlugin)wePlugin;
WorldEditAPI api = worldEdit.getAPI();
LocalSession session = api.getSession(player);
Region weRegion = session.getRegion();
BlockVector min = weRegion.getMinimumPoint().toBlockVector();
BlockVector max = weRegion.getMaximumPoint().toBlockVector();
ProtectedRegion region = new ProtectedCuboidRegion(min, max);
if (plugin.regionManager.overlapsUnownedRegion(region, plugin.wrapPlayer(player))) {
player.sendMessage(ChatColor.RED + "This region overlaps with someone else's region.");
return;
}
region.getOwners().addPlayer(player.getName());
plugin.regionManager.addRegion(id, region);
plugin.regionLoader.save(plugin.regionManager);
player.sendMessage(ChatColor.YELLOW + "Region saved as " + id + ".");
} catch (IncompleteRegionException e) {
player.sendMessage(ChatColor.RED + "You must first define an area in WorldEdit.");
} catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: "
+ e.getMessage());
}
} else if (action.equalsIgnoreCase("flag")) {
if (!canUseRegionCommand(player, "/regiondefine")) {
player.sendMessage(ChatColor.RED + "You don't have the /regiondefine permission.");
return;
}
if (args.length < 4) {
player.sendMessage(ChatColor.RED + "/region flag <id> <lighter> <none|allow|deny>");
player.sendMessage(ChatColor.RED + "Other flags not supported in Bukkit at the moment.");
return;
}
try {
String id = args[1].toLowerCase();
String flagStr = args[2];
String stateStr = args[3];
ProtectedRegion region = plugin.regionManager.getRegion(id);
if (region == null) {
player.sendMessage(ChatColor.RED + "Could not find a region by that ID.");
return;
}
AreaFlags.State state = null;
if (stateStr.equalsIgnoreCase("allow")) {
state = AreaFlags.State.ALLOW;
} else if (stateStr.equalsIgnoreCase("deny")) {
state = AreaFlags.State.DENY;
} else if (stateStr.equalsIgnoreCase("none")) {
state = AreaFlags.State.NONE;
} else {
player.sendMessage(ChatColor.RED + "Acceptable states: allow, deny, none");
return;
}
AreaFlags flags = region.getFlags();
/*if (flagStr.equalsIgnoreCase("build")) {
flags.allowBuild = state;
} else if (flagStr.equalsIgnoreCase("pvp")) {
flags.allowPvP = state;
} else if (flagStr.equalsIgnoreCase("tnt")) {
flags.allowTNT = state;
} else*/ if (flagStr.equalsIgnoreCase("lighter")) {
flags.allowLighter = state;
} else {
player.sendMessage(ChatColor.RED + "Acceptable flags: build, pvp, tnt, lighter");
return;
}
plugin.regionLoader.save(plugin.regionManager);
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated.");
} catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: "
+ e.getMessage());
}
} else if (action.equalsIgnoreCase("info")) {
if (!canUseRegionCommand(player, "/regioninfo")) {
player.sendMessage(ChatColor.RED + "You don't have the /regioninfo permission.");
return;
}
if (args.length < 2) {
player.sendMessage(ChatColor.RED + "/region info <id>");
return;
}
String id = args[1].toLowerCase();
if (!plugin.regionManager.hasRegion(id)) {
player.sendMessage(ChatColor.RED + "A region with ID '"
+ id + "' doesn't exist.");
return;
}
ProtectedRegion region = plugin.regionManager.getRegion(id);
AreaFlags flags = region.getFlags();
DefaultDomain domain = region.getOwners();
player.sendMessage(ChatColor.YELLOW + "Region ID: " + id);
player.sendMessage(ChatColor.GRAY + "Type: " + region.getClass().getCanonicalName());
player.sendMessage(ChatColor.BLUE + "Build: " + flags.allowBuild.name());
player.sendMessage(ChatColor.BLUE + "PvP: " + flags.allowPvP.name());
player.sendMessage(ChatColor.BLUE + "TNT: " + flags.allowTNT.name());
player.sendMessage(ChatColor.BLUE + "Lighter: " + flags.allowLighter.name());
player.sendMessage(ChatColor.LIGHT_PURPLE + "Players: " + domain.toPlayersString());
player.sendMessage(ChatColor.LIGHT_PURPLE + "Groups: " + domain.toGroupsString());
} else if (action.equalsIgnoreCase("addowner")) {
if (!canUseRegionCommand(player, "/regiondefine")
&& !canUseRegionCommand(player, "/regionclaim")) {
player.sendMessage(ChatColor.RED + "You don't have the /regiondefine permission.");
return;
}
if (args.length < 2) {
player.sendMessage(ChatColor.RED + "/region addowner <id>");
return;
}
try {
String id = args[1].toLowerCase();
if (!plugin.regionManager.hasRegion(id)) {
player.sendMessage(ChatColor.RED + "A region with ID '"
+ id + "' doesn't exist.");
return;
}
ProtectedRegion existing = plugin.regionManager.getRegion(id);
if (!canUseRegionCommand(player, "/regiondefine")
&& !existing.getOwners().contains(plugin.wrapPlayer(player))) {
player.sendMessage(ChatColor.RED + "You don't own this region.");
return;
}
addToDomain(existing.getOwners(), args, 2);
plugin.regionLoader.save(plugin.regionManager);
player.sendMessage(ChatColor.YELLOW + "Region updated!");
} catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: "
+ e.getMessage());
}
} else if (action.equalsIgnoreCase("removeowner")) {
if (!canUseRegionCommand(player, "/regiondefine")
&& !canUseRegionCommand(player, "/regionclaim")) {
player.sendMessage(ChatColor.RED + "You don't have the /regiondefine permission.");
return;
}
if (args.length < 2) {
player.sendMessage(ChatColor.RED + "/region removeowner <id>");
return;
}
try {
String id = args[1].toLowerCase();
if (!plugin.regionManager.hasRegion(id)) {
player.sendMessage(ChatColor.RED + "A region with ID '"
+ id + "' doesn't exist.");
return;
}
ProtectedRegion existing = plugin.regionManager.getRegion(id);
if (!canUseRegionCommand(player, "/regiondefine")
&& !existing.getOwners().contains(plugin.wrapPlayer(player))) {
player.sendMessage(ChatColor.RED + "You don't own this region.");
return;
}
removeFromDomain(existing.getOwners(), args, 2);
plugin.regionLoader.save(plugin.regionManager);
player.sendMessage(ChatColor.YELLOW + "Region updated!");
} catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: "
+ e.getMessage());
}
} else if (action.equalsIgnoreCase("list")) {
if (!canUseRegionCommand(player, "/regiondefine")) {
player.sendMessage(ChatColor.RED + "You don't have the /regiondefine permission.");
return;
}
int page = 0;
if (args.length >= 2) {
try {
page = Math.max(0, Integer.parseInt(args[1]) - 1);
} catch (NumberFormatException e) {
page = 0;
}
}
Map<String,ProtectedRegion> regions = plugin.regionManager.getRegions();
int size = regions.size();
int pages = (int)Math.ceil(size / (float)CMD_LIST_SIZE);
String[] regionIDList = new String[size];
int index = 0;
for (String id : regions.keySet()) {
regionIDList[index] = id;
index++;
}
Arrays.sort(regionIDList);
player.sendMessage(ChatColor.RED + "Regions (page "
+ (page + 1) + " of " + pages + "):");
if (page < pages) {
for (int i = page * CMD_LIST_SIZE; i < page * CMD_LIST_SIZE + CMD_LIST_SIZE; i++) {
if (i >= size) break;
player.sendMessage(ChatColor.YELLOW.toString() + (i + 1) + ". " + regionIDList[i]);
}
}
} else if (action.equalsIgnoreCase("delete")) {
if (!canUseRegionCommand(player, "/regiondelete")
&& !canUseRegionCommand(player, "/regionclaim")) {
player.sendMessage(ChatColor.RED + "You don't have the /regiondelete permission.");
return;
}
if (args.length < 2) {
player.sendMessage(ChatColor.RED + "/region delete <id>");
return;
}
try {
String id = args[1].toLowerCase();
if (!plugin.regionManager.hasRegion(id)) {
player.sendMessage(ChatColor.RED + "A region with ID '"
+ id + "' doesn't exist.");
return;
}
ProtectedRegion existing = plugin.regionManager.getRegion(id);
if (!canUseRegionCommand(player, "/regiondelete")
&& !existing.getOwners().contains(plugin.wrapPlayer(player))) {
player.sendMessage(ChatColor.RED + "You don't own this region.");
return;
}
plugin.regionManager.removeRegion(id);
plugin.regionLoader.save(plugin.regionManager);
player.sendMessage(ChatColor.YELLOW + "Region removed!");
} catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: "
+ e.getMessage());
}
} else if (action.equalsIgnoreCase("save")) {
if (!canUseRegionCommand(player, "/regionsave")) {
player.sendMessage(ChatColor.RED + "You don't have the /regionsave permission.");
return;
}
try {
plugin.regionLoader.save(plugin.regionManager);
player.sendMessage(ChatColor.YELLOW + "Region database saved to file!");
} catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to save: "
+ e.getMessage());
}
} else if (action.equalsIgnoreCase("load")) {
if (!canUseRegionCommand(player, "/regionload")) {
player.sendMessage(ChatColor.RED + "You don't have the /regionload permission.");
return;
}
try {
plugin.regionLoader.load(plugin.regionManager);
player.sendMessage(ChatColor.YELLOW + "Region database loaded from file!");
} catch (IOException e) {
player.sendMessage(ChatColor.RED + "Region database failed to load: "
+ e.getMessage());
}
} else {
player.sendMessage(ChatColor.RED + "/region <define|claim|flag|delete|info|addowner|removeowner|list|save|load> ...");
}
}
/**
* Checks for the command or /region.
*
* @param player
* @param cmd
* @return
*/
private boolean canUseRegionCommand(Player player, String cmd) {
return plugin.hasPermission(player, "/region")
|| plugin.hasPermission(player, cmd);
}
/**
* Parse a group/player DefaultDomain specification for areas.
*
* @param domain
* @param split
* @param startIndex
*/
private 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
*/
private 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
*/
private 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;
}
}
File diff suppressed because it is too large. Load diff
@@ -19,7 +19,7 @@
package com.sk89q.worldguard.protection;
import java.util.Map;
import java.util.SortedMap;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.AreaFlags.State;
@@ -31,93 +31,172 @@ import com.sk89q.worldguard.protection.AreaFlags.State;
*/
public class ApplicableRegionSet {
private Vector pt;
private Map<String,ProtectedRegion> regions;
private SortedMap<String,ProtectedRegion> regions;
public ApplicableRegionSet(Vector pt, Map<String,ProtectedRegion> regions) {
public ApplicableRegionSet(Vector pt, SortedMap<String,ProtectedRegion> regions) {
this.pt = pt;
this.regions = regions;
}
public boolean canBuild(LocalPlayer player) {
boolean allowed = false;
boolean found = false;
int lastPriority = 0;
for (ProtectedRegion region : regions.values()) {
if (region.getFlags().allowBuild == State.ALLOW) continue;
if (!region.contains(pt)) continue;
if (region.getFlags().allowBuild == State.DENY) return false;
// Ignore lower priority regions
if (found && region.getPriority() < lastPriority) {
break;
}
if (!region.getOwners().contains(player)) {
return false;
}
found = true;
if (!allowed && region.getFlags().allowBuild == State.ALLOW) {
allowed = true;
}
if (!allowed && region.getOwners().contains(player)) {
allowed = true;
}
lastPriority = region.getPriority();
}
return found ? allowed : true;
return true;
}
public boolean allowsPvP() {
boolean found = false;
int lastPriority = 0;
for (ProtectedRegion region : regions.values()) {
if (!region.contains(pt)) continue;
if (region.getFlags().allowBuild == State.DENY) return false;
if (region.getFlags().allowPvP == State.DENY) return false;
// Ignore lower priority regions
if (found && region.getPriority() < lastPriority) {
break;
}
found = true;
lastPriority = region.getPriority();
}
return true;
}
public boolean allowsMobDamage() {
boolean found = false;
int lastPriority = 0;
for (ProtectedRegion region : regions.values()) {
if (!region.contains(pt)) continue;
if (region.getFlags().allowMobDamage == State.DENY) return false;
// Ignore lower priority regions
if (found && region.getPriority() < lastPriority) {
break;
}
found = true;
lastPriority = region.getPriority();
}
return true;
}
public boolean allowsCreeperExplosions() {
boolean found = false;
int lastPriority = 0;
for (ProtectedRegion region : regions.values()) {
if (!region.contains(pt)) continue;
if (region.getFlags().allowCreeperExplosions == State.DENY) return false;
// Ignore lower priority regions
if (found && region.getPriority() < lastPriority) {
break;
}
found = true;
lastPriority = region.getPriority();
}
return true;
}
public boolean allowsTNT() {
boolean found = false;
int lastPriority = 0;
for (ProtectedRegion region : regions.values()) {
if (!region.contains(pt)) continue;
if (region.getFlags().allowTNT == State.DENY) return false;
// Ignore lower priority regions
if (found && region.getPriority() < lastPriority) {
break;
}
found = true;
lastPriority = region.getPriority();
}
return true;
}
public boolean allowsLighter() {
boolean found = false;
int lastPriority = 0;
for (ProtectedRegion region : regions.values()) {
if (!region.contains(pt)) continue;
if (region.getFlags().allowLighter == State.DENY) return false;
// Ignore lower priority regions
if (found && region.getPriority() < lastPriority) {
break;
}
found = true;
lastPriority = region.getPriority();
}
return true;
}
public boolean allowsFireSpread() {
boolean found = false;
int lastPriority = 0;
for (ProtectedRegion region : regions.values()) {
if (!region.contains(pt)) continue;
if (region.getFlags().allowFireSpread == State.DENY) return false;
// Ignore lower priority regions
if (found && region.getPriority() < lastPriority) {
break;
}
found = true;
lastPriority = region.getPriority();
}
return true;
}
public boolean allowsLavaFire() {
boolean found = false;
int lastPriority = 0;
for (ProtectedRegion region : regions.values()) {
if (!region.contains(pt)) continue;
if (region.getFlags().allowLavaFire == State.DENY) return false;
// Ignore lower priority regions
if (found && region.getPriority() < lastPriority) {
break;
}
found = true;
lastPriority = region.getPriority();
}
return true;
@@ -25,10 +25,10 @@ import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.*;
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.AreaFlags.State;
@@ -127,14 +127,18 @@ public class CSVDatabase implements ProtectionDatabase {
}
String id = line[0];
BlockVector min = new BlockVector(
Vector pt1 = new Vector(
Integer.parseInt(line[2]),
Integer.parseInt(line[3]),
Integer.parseInt(line[4]));
BlockVector max = new BlockVector(
Vector pt2 = new Vector(
Integer.parseInt(line[5]),
Integer.parseInt(line[6]),
Integer.parseInt(line[7]));
BlockVector min = Vector.getMinimum(pt1, pt2).toBlockVector();
BlockVector max = Vector.getMaximum(pt1, pt2).toBlockVector();
int priority = Integer.parseInt(line[8]);
String ownersData = line[9];
String flagsData = line[10];
@@ -147,7 +151,7 @@ public class CSVDatabase implements ProtectionDatabase {
region.setFlags(parseFlags(flagsData));
regions.put(id, region);
} else {
logger.warning("Line has invalid: " + line);
logger.warning("Line is invalid: " + line);
}
}
} finally {
@@ -193,6 +197,10 @@ public class CSVDatabase implements ProtectionDatabase {
String[] parts = data.split(",");
for (String part : parts) {
if (part.trim().length() == 0) {
continue;
}
Matcher matcher = pattern.matcher(part);
if (!matcher.matches()) {
@@ -19,23 +19,22 @@
package com.sk89q.worldguard.protection;
/**
* Caches the results of the protection to prevent necessary lookups.
*
* @author sk89q
*/
public class CacheManager {
import java.util.Comparator;
class DescendingPriorityComparator implements Comparator<ProtectedRegion> {
/**
* Region manager.
*/
private RegionManager manager;
/**
* Construct the object.
* Compares two regions.
*
* @param manager
* @param other
* @return
*/
public CacheManager(RegionManager manager) {
this.manager = manager;
public int compare(ProtectedRegion r1, ProtectedRegion r2) {
if (r1.getPriority() == r2.getPriority()) {
return 0;
} else if (r1.getPriority() > r2.getPriority()) {
return -1;
} else {
return 1;
}
}
}
@@ -22,7 +22,8 @@ package com.sk89q.worldguard.protection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.LinkedHashMap;
import java.util.SortedMap;
import java.util.TreeMap;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer;
@@ -37,13 +38,13 @@ public class FlatRegionManager implements RegionManager {
/**
* List of protected regions.
*/
private Map<String,ProtectedRegion> regions;
private SortedMap<String,ProtectedRegion> regions;
/**
* Construct the manager.
*/
public FlatRegionManager() {
regions = new LinkedHashMap<String,ProtectedRegion>();
regions = new TreeMap<String,ProtectedRegion>();
}
/**
@@ -54,7 +55,16 @@ public class FlatRegionManager implements RegionManager {
public Map<String,ProtectedRegion> getRegions() {
return regions;
}
/**
* Set a list of protected regions.
*
* @return
*/
public void setRegions(Map<String,ProtectedRegion> regions) {
this.regions = new TreeMap<String,ProtectedRegion>(regions);
}
/**
* Adds a region.
*
@@ -93,15 +103,6 @@ public class FlatRegionManager implements RegionManager {
return regions.get(id);
}
/**
* Set a list of protected regions.
*
* @return
*/
public void setRegions(Map<String,ProtectedRegion> regions) {
this.regions = regions;
}
/**
* Get an object for a point for rules to be applied with.
*
@@ -28,7 +28,7 @@ import com.sk89q.worldguard.domains.DefaultDomain;
*
* @author sk89q
*/
public abstract class ProtectedRegion {
public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
/**
* Area message.
*/
@@ -47,7 +47,7 @@ public abstract class ProtectedRegion {
private AreaFlags flags = new AreaFlags();
/**
* Construct a new instance of this cuboid region.
* Construct a new instance of this region.
*
* @param id
* @param priority
@@ -127,6 +127,22 @@ public abstract class ProtectedRegion {
*/
public abstract boolean contains(Vector pt);
/**
* Compares to another region.
*
* @param other
* @return
*/
public int compareTo(ProtectedRegion other) {
if (priority == other.priority) {
return 0;
} else if (priority > other.priority) {
return -1;
} else {
return 1;
}
}
/**
* Checks if two region intersects.
*
@@ -38,7 +38,7 @@ public interface RegionManager {
*
* @return
*/
public Map<String,ProtectedRegion> getRegions();
public Map<String, ProtectedRegion> getRegions();
/**
* Set a list of protected regions.
@@ -19,8 +19,10 @@
package com.sk89q.worldguard;
import java.util.List;
import java.util.Set;
import java.util.HashSet;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.LocalPlayer;
public class TestPlayer extends LocalPlayer {
@@ -44,4 +46,34 @@ public class TestPlayer extends LocalPlayer {
public boolean hasGroup(String group) {
return groups.contains(group.toLowerCase());
}
@Override
public Vector getPosition() {
// TODO Auto-generated method stub
return null;
}
@Override
public void kick(String msg) {
// TODO Auto-generated method stub
}
@Override
public void ban(String msg) {
// TODO Auto-generated method stub
}
@Override
public void printRaw(String msg) {
// TODO Auto-generated method stub
}
@Override
public List<String> getGroups() {
// TODO Auto-generated method stub
return null;
}
}
-90
View File
@@ -1,90 +0,0 @@
#
# This is the blacklist for WorldGuard. Comments start with # and they
# are ignored so you can put your own notes.
#
# Format:
# [item1,item2]
# option1=options
# event1=whatToDo1,whatToDo2,whatToDo3
# event2=whatToDo1,whatToDo2
#
# Example to block ore and catch some events:
# [coalore,goldore,ironore]
# on-destroy-with=deny,log,kick
# on-place=deny,tell
#
# Options:
# - ignore-groups (comma-delimited list of groups to not affect)
# - comment (message for yourself that is printed with 'log' and 'notify')
# - message (optional message to show the user instead; %s is the item name)
#
# Events:
# - on-destroy (when a block of this type is being destroyed)
# - on-break (when a block of this type is about to be broken)
# - on-destroy-with (the item/block held by the user while destroying)
# - on-place (a block is being placed)
# - on-use (an item like a lighter is being used)
# - on-right-click (the block is right clicked -- curently INEFFECTIVE)
# - on-drop (the item is being dropped from the player's inventory)
# - on-acquire (the item enters a player's inventory via some method)
#
# Actions (for events):
# - deny (deny completely)
# - notify (notify admins)
# - log (log to console/file/database)
# - tell (tell a player that that's not allowed)
# - kick (kick player)
# - ban (ban player)
#
# With the on-acquire event, it will completely block item pick ups
# (the item will still be on the ground) if you use 'deny' but the other
# actions (notify, log, etc.) won't do anything. However, if the player
# receives the item via a different method (i.e. from a chest), all actions
# will work although the item is removed after a short delay rather than
# blocked from the beginning (as it is part client-side).
#
# Users with the /worldguardnotify permission will be receive notifications.
#
# -------------
#
# You can have the same block or item used in two different sections and
# they will both apply:
#
# [goldblock]
# ignore-groups=vip
# on-destroy=deny
# [goldblock]
# ignore-groups=admins
# on-destroy=tell
#
# However, some events override others. For example, if you disable both
# usage of the diamond pickaxe (with the on-destroy-with event) and
# destruction of gold blocks (with the on-destroy event) and a player tries
# to destroy a gold block with a diamond pickaxe, because the
# on-destroy-with event comes first, the rules for the gold block
# will not be applied (but the player will be denied nevertheless).
#
# -------------
#
# Some examples follow. Remember to remove # in front if you want them
# to work for you!
# Deny lava buckets
#[lavabucket]
#ignore-groups=admins,mods
#on-use=deny,tell
# Deny lighter usage
#[259]
#on-use=deny,tell
# Deny some ore
#[coalore,goldore,ironore]
#ignore-groups=admins,mods
#on-destroy=notify,deny,log
#[cobblestone]
#on-place=deny,tell,log
#[lever]
#on-break=deny,tell
-108
View File
@@ -1,108 +0,0 @@
#
# WorldGuard configuration
#
# This is a starter copy of WorldGuard's configuration so you can configure
# WorldGuard right from the beginning. Copy it into your server folder
# (into where server.properties resides) and edit the file as your desire.
#
# Display a summary of WorldGuard's core protection features (lava fire
# disable and others) when Worldguard starts up.
summary-on-start=true
# Toggle the item durabiltiy fix
item-durability=true
# Simulate the sponge from Classic. It removes water and prevents water from
# flowing into an area containing sponges. Use this to protect circuits
# or to assist in underwater projects.
simulate-sponge=false
sponge-radius=3
# Simulate classic water. Water will spread infinitely. Be aware that this
# may likely flood your server.
classic-water=false
# Allow the placement of portal blocks anyway.
allow-portal-anywhere=false
# Prevent gravel from falling.
no-physics-gravel=false
# Prevent sand from falling.
no-physics-sand=false
# Kick the older player if a player attempts to join again without first
# logging out the first instance.
enforce-single-session=true
# List of items to destroy on drop. You can also accomplish this using
# the blacklist.
item-drop-blacklist=
# Simple prevention
block-creepers=false
block-lighter=false
block-tnt=false
# Login protection prevents players from getting any damage for a few
# seconds after joining the server.
login-protection=3
# Spawn protection prevents players from getting any damage after spawning
# (after dying).
spawn-protection=0
# This is an deprecated feature to fix a bug. This kicks a user once the
# player dies and attemtps to respawn. The player can then still rejoin
# and be alive.
kick-on-death=false
# Disable various ways of damage. If you want to give someone invincibility
# or the ability to breathe under water, create the groups wg-invincible
# and wg-amphibious respectively and apply them to users as needed.
disable-fall-damage=false
disable-lava-damage=false
disable-fire-damage=false
disable-water-damage=false
disable-suffocation-damage=false
# Teleports player when s/he is suffocating. This can be abused to get
# through ceilings.
teleport-on-suffocation=false
# Disable fire spreading between blocks. Note that this does not prevent
# fire damage -- it only prevents fire spread.
disable-all-fire-spread=false
# List blocks that fire should not spread to or between. Cloth and wood
# are some good examples.
disallowed-fire-spread-blocks=
# Prevent lava from starting fires.
disable-lava-fire=true
# List of blocks that lava is allowed to spread onto.
allowed-lava-spread-blocks=
# List of blocks that should not be destroyed by water (Redstone wire,
# minecart tracks, flowers, etc.).
disable-water-damage-blocks=
# Control where to log blacklist events to. You can use multiple log
# methods as you please.
log-console=true
log-database-dsn=jdbc\:mysql\://localhost\:3306/minecraft
log-database-pass=
log-database-table=blacklist_events
log-database-user=root
log-database=false
log-file-open-files=10
log-file-path=worldguard/logs/%Y-%m-%d.log
log-file=false
# On death options.
teleport-to-home-on-death=false
exact-respawn=false
#EOF
-5
View File
@@ -1,5 +0,0 @@
name = WorldGuard
version = %version%
url = updatr.update.sk89q.com/worldguard.updatr
file = cloud.github.com/downloads/sk89q/worldguard/worldguard-%version%.zip
notes =