Compare commits

...
23 Commits
Author SHA1 Message Date
sk89q 1f214aadee [maven-release-plugin] prepare release 5.8 2013-07-16 11:07:06 -07:00
sk89q 174b3fad15 Updated Maven release plugin to 2.4.1. 2013-07-16 10:45:44 -07:00
sk89q 07531f67d4 Updated org.bukkit:bukkit dependency to 1.6.2-R0.1-SNAPSHOT. 2013-07-16 10:35:30 -07:00
sk89q 291c45064a Bumped version to 5.8-SNAPSHOT, updated CHANGELOG.txt. 2013-07-07 12:28:57 -07:00
sk89q 6f56cb29a5 Fixed -w flag for /rg load and /rg save. 2013-07-07 12:14:41 -07:00
sk89q 977c7d2f29 Changed DoubleFlag and IntegerFlag to take java.lang.Number objects in unmarshal(). 2013-07-07 11:45:22 -07:00
sk89q ecb87efe8d Update Bukkit dependency to version 1.6.1-R0.1-SNAPSHOT. 2013-07-07 11:42:24 -07:00
sk89q a57c162cd8 Convert heal flags datatype from integer to double.
Existing data should be cast with no data loss.
2013-07-07 11:38:03 -07:00
wizjany 60c3ed4f6b Polish the fix from the last commit and straighten some other multiworld issues in the move handler. 2013-06-23 20:17:20 -04:00
wizjany 714e75eb95 Potential fix for broken multiworld states. 2013-06-23 16:35:57 -04:00
Wizjany 636819c801 Revert change to permissions node for flags.
region.flag.own/member/etc was region.flag.regions.own/member/etc
This shouldn't be changed in between, especially if we maintain compatibility with the other flag node (flag.flags).
2013-06-20 00:52:59 -03:00
wizjany 9a6c2e0685 Finish reverting changes from earlier 2013-06-10 23:12:06 -04:00
wizjany 736eecc13b Add config option to use player teleports for move events.
Additionally removed code duplication in Vehicle listener.
2013-06-08 12:04:58 -04:00
TomyLobo 4718c5dab0 Removed unused imports. 2013-06-07 14:06:07 +02:00
Albert Pham 7e9bd49da2 Added mobs.disable-snowman-trails. 2013-06-02 13:23:01 -07:00
wizjany a0d0ff0b92 Lighter changes in BlockIgnite as well 2013-06-02 11:19:12 -04:00
wizjany b41be0c319 Added a static WorldGuardPlugin instance and made the utility methods in RegionCommands static. 2013-06-01 18:14:59 -04:00
wizjany 17a466059e A few changes in the new region commands.
- Allow setting flags on the global region (bugfix)
- Don't throw permissions errors when listing available flags (bugfix)
- Info command defaults to global region if no others are present (enhancement)
- A few typo and spacing fixes (enhancement)
2013-06-01 17:39:49 -04:00
wizjany 2d9e95a63e Revert lighter changes for now. This brings back the odd behaviors between flint & steel and fire charges, but makes it more intuitive for protection. 2013-06-01 10:14:56 -04:00
Albert Pham 532a45f9e7 Offering a sacrifice to the gods of pedantry. canX() -> mayX() for permissions. 2013-05-31 22:06:37 -07:00
Albert Pham d61e32ebb5 Cleaned up RegionCommands, abstracted region permissions. 2013-05-31 21:56:32 -07:00
Albert Pham b7d38e94c8 Added -a flag to region remove owner/member commands to remove all. 2013-05-29 13:24:40 -07:00
wizjany ae158742f6 [maven-release-plugin] prepare for next development iteration 2013-05-26 17:20:00 -04:00
26 changed files with 1910 additions and 1325 deletions

No files matched your search

+17
View File
@@ -1,3 +1,20 @@
5.8:
- BREAKING CHANGE: This version has been built for versions of Bukkit for MC 1.6.1 and
newer. Do not try to use this version of WG on an older Bukkit version.
- Added support for Minecraft 1.6+. Actual support of new 1.6 additions is dependant on
Bukkit. Please use a newer build of Bukkit if, for example, you seem to be unable to
add "Horses" to your lists of entities.
- Added mobs.disable-snowman-trails to disable the trails left by walking snowmen.
- Added -a flag to /region removeowner and /region removemember to remove all objects.
- Teleporting is now handled by entry/exit flags. If this is causing people to get
entirely stuck inside entry/exit deny regions, set the new setting
'use-player-teleports' to 'false' in your configuration.
- Updated formatting for region commands, especially /region info.
- Changed permissions checking for /region commands to be more consistent, checking for
region IDs as a sub-node. This means that if some permissions for some region
commands no longer work, add '.*' to the end of permission lines for WG in your
permission plugin.
5.7.5:
- Refixed a few issues from 5.7.4.
+319 -319
View File
@@ -1,319 +1,319 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>5.7.5</version>
<packaging>jar</packaging>
<!-- Project information -->
<name>WorldGuard</name>
<description>WorldGuard protects your Minecraft servers.</description>
<licenses>
<license>
<name>GNU General Public License 2.0</name>
<url>LICENSE.txt</url>
<distribution>repo</distribution>
<comments>License on all contributions</comments>
</license>
</licenses>
<issueManagement>
<system>YouTrack</system>
<url>http://youtrack.sk89q.com</url>
</issueManagement>
<ciManagement>
<system>Jenkins</system>
<url>http://build.sk89q.com</url>
</ciManagement>
<scm>
<connection>scm:git:git://github.com/sk89q/worldguard.git</connection>
<developerConnection>scm:git:git@github.com:sk89q/worldguard.git</developerConnection>
<url>https://github.com/sk89q/worldguard</url>
<tag>master</tag>
</scm>
<mailingLists>
<mailingList>
<name>Developer Discussion</name>
<archive>https://groups.google.com/d/forum/sk-dev-discuss</archive>
</mailingList>
</mailingLists>
<distributionManagement>
<site>
<id>sk89q-docs-upload</id>
<url>ftp://sk89q-maven-deploy/worldguard/</url>
</site>
</distributionManagement>
<properties> <!-- Fix encoding warnings -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
<repository>
<id>zml-repo</id>
<url>http://files.zachsthings.com/repo</url>
</repository>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>5.5.3</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.5-R0.1-SNAPSHOT</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>commandbook</artifactId>
<version>2.1</version>
<scope>compile</scope>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>com.zachsthings.libcomponents</groupId>
<artifactId>libcomponents-bukkit</artifactId>
</exclusion>
<exclusion>
<groupId>org.spout</groupId>
<artifactId>spoutapi</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.nijikokun</groupId>
<artifactId>iconomy</artifactId>
<version>5.0</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.khelekore</groupId>
<artifactId>prtree</artifactId>
<version>1.5.0</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.0</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
<type>jar</type>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<extensions> <!-- Used for uploading the docs -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/</directory>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
<resource>
<targetPath>defaults/</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/</directory>
<includes>
<include>config.yml</include>
<include>config_world.yml</include>
<include>blacklist.txt</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<addMavenDescriptor>true</addMavenDescriptor>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Class-Path>WorldGuard/WorldEdit.jar lib/WorldEdit.jar ../lib/WorldEdit.jar ../WorldEdit.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>net.sf.opencsv:opencsv</include>
<include>org.khelekore:prtree</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-2</version>
<configuration>
<descriptor>${basedir}/src/main/assembly/default.xml</descriptor>
</configuration>
<executions>
<execution>
<id>release</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<preparationGoals>assembly:assembly</preparationGoals>
<goals>assembly:assembly</goals>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.5</version>
<reportSets>
<reportSet>
<reports>
<report>license</report>
<report>index</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<!-- Attach javadocs and source .jars -->
<profile>
<id>attach-docs</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>5.8</version>
<packaging>jar</packaging>
<!-- Project information -->
<name>WorldGuard</name>
<description>WorldGuard protects your Minecraft servers.</description>
<licenses>
<license>
<name>GNU General Public License 2.0</name>
<url>LICENSE.txt</url>
<distribution>repo</distribution>
<comments>License on all contributions</comments>
</license>
</licenses>
<issueManagement>
<system>YouTrack</system>
<url>http://youtrack.sk89q.com</url>
</issueManagement>
<ciManagement>
<system>Jenkins</system>
<url>http://build.sk89q.com</url>
</ciManagement>
<scm>
<connection>scm:git:git://github.com/sk89q/worldguard.git</connection>
<developerConnection>scm:git:git@github.com:sk89q/worldguard.git</developerConnection>
<url>https://github.com/sk89q/worldguard</url>
<tag>5.8</tag>
</scm>
<mailingLists>
<mailingList>
<name>Developer Discussion</name>
<archive>https://groups.google.com/d/forum/sk-dev-discuss</archive>
</mailingList>
</mailingLists>
<distributionManagement>
<site>
<id>sk89q-docs-upload</id>
<url>ftp://sk89q-maven-deploy/worldguard/</url>
</site>
</distributionManagement>
<properties> <!-- Fix encoding warnings -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
<repository>
<id>zml-repo</id>
<url>http://files.zachsthings.com/repo</url>
</repository>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>5.5.3</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.6.2-R0.1-SNAPSHOT</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>commandbook</artifactId>
<version>2.1</version>
<scope>compile</scope>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>com.zachsthings.libcomponents</groupId>
<artifactId>libcomponents-bukkit</artifactId>
</exclusion>
<exclusion>
<groupId>org.spout</groupId>
<artifactId>spoutapi</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.nijikokun</groupId>
<artifactId>iconomy</artifactId>
<version>5.0</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.khelekore</groupId>
<artifactId>prtree</artifactId>
<version>1.5.0</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.0</version>
<scope>compile</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
<type>jar</type>
</dependency>
</dependencies>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<extensions> <!-- Used for uploading the docs -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/</directory>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
<resource>
<targetPath>defaults/</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/</directory>
<includes>
<include>config.yml</include>
<include>config_world.yml</include>
<include>blacklist.txt</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<addMavenDescriptor>true</addMavenDescriptor>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Class-Path>WorldGuard/WorldEdit.jar lib/WorldEdit.jar ../lib/WorldEdit.jar ../WorldEdit.jar</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>net.sf.opencsv:opencsv</include>
<include>org.khelekore:prtree</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-2</version>
<configuration>
<descriptor>${basedir}/src/main/assembly/default.xml</descriptor>
</configuration>
<executions>
<execution>
<id>release</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<preparationGoals>assembly:assembly</preparationGoals>
<goals>assembly:assembly</goals>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.5</version>
<reportSets>
<reportSet>
<reports>
<report>license</report>
<report>index</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<!-- Attach javadocs and source .jars -->
<profile>
<id>attach-docs</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -0,0 +1,46 @@
// $Id$
/*
* This file is a part of WorldGuard.
* Copyright (c) sk89q <http://www.sk89q.com>
* Copyright (c) the WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* (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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.bukkit;
import org.bukkit.command.CommandSender;
import org.enginehub.util.PermissionModel;
abstract class AbstractPermissionModel implements PermissionModel {
private final WorldGuardPlugin plugin;
private final CommandSender sender;
public AbstractPermissionModel(WorldGuardPlugin plugin, CommandSender sender) {
this.plugin = plugin;
this.sender = sender;
}
protected WorldGuardPlugin getPlugin() {
return plugin;
}
public CommandSender getSender() {
return sender;
}
protected boolean hasPluginPermission(String permission) {
return plugin.hasPermission(getSender(), "worldguard." + permission);
}
}
@@ -99,6 +99,7 @@ public class ConfigurationManager {
public boolean activityHaltToggle = false;
public boolean autoGodMode;
public boolean usePlayerMove;
public boolean usePlayerTeleports;
public boolean deopOnJoin;
public boolean blockInGameOp;
public Map<String, String> hostKeys = new HashMap<String, String>();
@@ -144,6 +145,7 @@ public class ConfigurationManager {
autoGodMode = config.getBoolean("auto-invincible", config.getBoolean("auto-invincible-permission", false));
config.removeProperty("auto-invincible-permission");
usePlayerMove = config.getBoolean("use-player-move-event", true);
usePlayerTeleports = config.getBoolean("use-player-teleports", true);
deopOnJoin = config.getBoolean("security.deop-everyone-on-join", false);
blockInGameOp = config.getBoolean("security.block-in-game-op-command", false);
@@ -19,18 +19,19 @@
package com.sk89q.worldguard.bukkit;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import org.bukkit.GameMode;
import org.bukkit.World;
import org.bukkit.entity.Player;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
import java.util.HashMap;
import java.util.Map;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
import org.bukkit.GameMode;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
/**
* This processes per-player state information and is also meant to be used
@@ -59,7 +60,8 @@ public class FlagStateManager implements Runnable {
/**
* Run the task.
*/
public void run() {
@Override
public void run() {
Player[] players = plugin.getServer().getOnlinePlayers();
ConfigurationManager config = plugin.getGlobalStateManager();
@@ -112,14 +114,18 @@ public class FlagStateManager implements Runnable {
Integer healAmount = applicable.getFlag(DefaultFlag.HEAL_AMOUNT);
Integer healDelay = applicable.getFlag(DefaultFlag.HEAL_DELAY);
Integer minHealth = applicable.getFlag(DefaultFlag.MIN_HEAL);
Integer maxHealth = applicable.getFlag(DefaultFlag.MAX_HEAL);
Double minHealth = applicable.getFlag(DefaultFlag.MIN_HEAL);
Double maxHealth = applicable.getFlag(DefaultFlag.MAX_HEAL);
if (healAmount == null || healDelay == null || healAmount == 0 || healDelay < 0) {
return;
}
if (minHealth == null) minHealth = 0;
if (maxHealth == null) maxHealth = player.getMaxHealth();
if (minHealth == null) {
minHealth = 0.0;
}
if (maxHealth == null) {
maxHealth = player.getMaxHealth();
}
// Apply a cap to prevent possible exceptions
minHealth = Math.min(player.getMaxHealth(), minHealth);
@@ -159,8 +165,12 @@ public class FlagStateManager implements Runnable {
if (feedAmount == null || feedDelay == null || feedAmount == 0 || feedDelay < 0) {
return;
}
if (minHunger == null) minHunger = 0;
if (maxHunger == null) maxHunger = 20;
if (minHunger == null) {
minHunger = 0;
}
if (maxHunger == null) {
maxHunger = 20;
}
// Apply a cap to prevent possible exceptions
minHunger = Math.min(20, minHunger);
@@ -0,0 +1,145 @@
// $Id$
/*
* This file is a part of WorldGuard.
* Copyright (c) sk89q <http://www.sk89q.com>
* Copyright (c) the WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* (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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
/**
* Used for querying region-related permissions.
*/
public class RegionPermissionModel extends AbstractPermissionModel {
public RegionPermissionModel(WorldGuardPlugin plugin, CommandSender sender) {
super(plugin, sender);
}
public boolean mayForceLoadRegions() {
return hasPluginPermission("region.load");
}
public boolean mayForceSaveRegions() {
return hasPluginPermission("region.save");
}
public boolean mayMigrateRegionStore() {
return hasPluginPermission("region.migratedb");
}
public boolean mayDefine() {
return hasPluginPermission("region.define");
}
public boolean mayRedefine(ProtectedRegion region) {
return hasPatternPermission("redefine", region);
}
public boolean mayClaim() {
return hasPluginPermission("region.claim");
}
public boolean mayClaimRegionsUnbounded() {
return hasPluginPermission("region.unlimited");
}
public boolean mayDelete(ProtectedRegion region) {
return hasPatternPermission("remove", region);
}
public boolean maySetPriority(ProtectedRegion region) {
return hasPatternPermission("setpriority", region);
}
public boolean maySetParent(ProtectedRegion child, ProtectedRegion parent) {
return hasPatternPermission("setparent", child) &&
(parent == null ||
hasPatternPermission("setparent", parent));
}
public boolean maySelect(ProtectedRegion region) {
return hasPatternPermission("select", region);
}
public boolean mayLookup(ProtectedRegion region) {
return hasPatternPermission("info", region);
}
public boolean mayTeleportTo(ProtectedRegion region) {
return hasPatternPermission("teleport", region);
}
public boolean mayList() {
return hasPluginPermission("region.list");
}
public boolean mayList(String targetPlayer) {
if (targetPlayer == null) {
return mayList();
}
if (targetPlayer.equalsIgnoreCase(getSender().getName())) {
return hasPluginPermission("region.list.own");
} else {
return mayList();
}
}
public boolean maySetFlag(ProtectedRegion region) {
return hasPatternPermission("flag.regions", region);
}
public boolean maySetFlag(ProtectedRegion region, Flag<?> flag) {
// This is a WTF permission
return hasPatternPermission(
"flag.flags." + flag.getName().toLowerCase(), region);
}
/**
* Checks to see if the given sender has permission to modify the given region
* using the region permission pattern.
*
* @param perm the name of the node
* @param region the region
*/
private boolean hasPatternPermission(String perm, ProtectedRegion region) {
if (!(getSender() instanceof Player)) {
return true; // Non-players (i.e. console, command blocks, etc.) have full power
}
LocalPlayer localPlayer = getPlugin().wrapPlayer((Player) getSender());
String idLower = region.getId().toLowerCase();
String effectivePerm;
if (region.isOwner(localPlayer)) {
return hasPluginPermission("region." + perm + ".own." + idLower) ||
hasPluginPermission("region." + perm + ".member." + idLower);
} else if (region.isMember(localPlayer)) {
return hasPluginPermission("region." + perm + ".member." + idLower);
} else {
effectivePerm = "region." + perm + "." + idLower;
}
return hasPluginPermission(effectivePerm);
}
}
@@ -18,7 +18,6 @@
package com.sk89q.worldguard.bukkit;
import org.bukkit.Bukkit;
import org.bukkit.World;
import com.sk89q.worldguard.protection.managers.RegionManager;
@@ -27,7 +26,6 @@ import com.sk89q.worldguard.protection.managers.RegionManager;
* Helper class to get a reference to WorldGuard and its components.
*/
public class WGBukkit {
private static WorldGuardPlugin cachedPlugin = null;
private WGBukkit() {
}
@@ -43,17 +41,16 @@ public class WGBukkit {
* @return the WorldGuard plugin or null
*/
public static WorldGuardPlugin getPlugin() {
if (cachedPlugin == null) {
cachedPlugin = (WorldGuardPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
}
return cachedPlugin;
return WorldGuardPlugin.inst();
}
/**
* Set cache to null for reload WorldGuardPlugin
* @deprecated instance is now stored directly in {@link WorldGuardPlugin}
*/
@Deprecated
public static void cleanCache() {
cachedPlugin = null;
// do nothing - plugin instance is stored in plugin class now
}
/**
@@ -67,7 +64,7 @@ public class WGBukkit {
if (getPlugin() == null) {
return null;
}
return cachedPlugin.getRegionManager(world);
return WorldGuardPlugin.inst().getRegionManager(world);
}
}
@@ -161,6 +161,7 @@ public class WorldConfiguration {
public boolean disableMyceliumSpread;
public boolean disableVineGrowth;
public boolean disableEndermanGriefing;
public boolean disableSnowmanTrails;
public boolean regionInvinciblityRemovesMobs;
public boolean disableDeathMessages;
public boolean disableObsidianGenerators;
@@ -353,6 +354,7 @@ public class WorldConfiguration {
blockFireballBlockDamage = getBoolean("mobs.block-fireball-block-damage", false);
antiWolfDumbness = getBoolean("mobs.anti-wolf-dumbness", false);
disableEndermanGriefing = getBoolean("mobs.disable-enderman-griefing", false);
disableSnowmanTrails = getBoolean("mobs.disable-snowman-trails", false);
blockEntityPaintingDestroy = getBoolean("mobs.block-painting-destroy", false);
blockEntityItemFrameDestroy = getBoolean("mobs.block-item-frame-destroy", false);
blockPluginSpawning = getBoolean("mobs.block-plugin-spawning", true);
@@ -583,7 +585,9 @@ public class WorldConfiguration {
for (String group : plugin.getGroups(player)) {
if (maxRegionCounts.containsKey(group)) {
int groupMax = maxRegionCounts.get(group);
if (max < groupMax) max = groupMax;
if (max < groupMax) {
max = groupMax;
}
}
}
if (max <= -1) {
@@ -18,7 +18,7 @@
*/
package com.sk89q.worldguard.bukkit;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -26,6 +26,7 @@ import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowman;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -45,6 +46,7 @@ import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.EntityBlockFormEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.inventory.ItemStack;
@@ -339,8 +341,11 @@ public class WorldGuardBlockListener implements Listener {
if (player != null && !plugin.getGlobalRegionManager().hasBypass(player, world)) {
LocalPlayer localPlayer = plugin.wrapPlayer(player);
// this is preliminarily handled in the player listener under handleBlockRightClick
// why it's handled here too, no one knows
if (cause == IgniteCause.FLINT_AND_STEEL || cause == IgniteCause.FIREBALL) {
if (!set.allows(DefaultFlag.LIGHTER, localPlayer)
if (!set.allows(DefaultFlag.LIGHTER)
&& !set.canBuild(localPlayer)
&& !plugin.hasPermission(player, "worldguard.override.lighter")) {
event.setCancelled(true);
return;
@@ -705,6 +710,27 @@ public class WorldGuardBlockListener implements Listener {
}
}
/*
* Called when a block is formed by an entity.
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEntityBlockForm(EntityBlockFormEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
if (cfg.activityHaltToggle) {
event.setCancelled(true);
return;
}
if (event.getEntity() instanceof Snowman) {
if (wcfg.disableSnowmanTrails) {
event.setCancelled(true);
return;
}
}
}
/*
* Called when a block spreads based on world conditions.
*/
@@ -26,7 +26,6 @@ import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.EnderPearl;
@@ -35,7 +34,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
@@ -108,6 +108,11 @@ public class WorldGuardPlayerListener implements Listener {
}
}
// unsure if anyone actually started using this yet, but just in case...
public static boolean checkMove(WorldGuardPlugin plugin, Player player, World world, Location from, Location to) {
return checkMove(plugin, player, from, to); // drop world since it used to be mishandled
}
/**
* Handles movement related events, including changing gamemode, sending
* greeting/farewell messages, etc.
@@ -115,19 +120,23 @@ public class WorldGuardPlayerListener implements Listener {
* although WGBukkit.getPlugin() may be used.
* @return true if the movement should not be allowed
*/
public static boolean checkMove(WorldGuardPlugin plugin, Player player, World world, Location from, Location to) {
public static boolean checkMove(WorldGuardPlugin plugin, Player player, Location from, Location to) {
PlayerFlagState state = plugin.getFlagStateManager().getState(player);
//Flush states in multiworld scenario
if (state.lastWorld != null && !state.lastWorld.equals(world)) {
if (state.lastWorld != null && !state.lastWorld.equals(to.getWorld())) {
plugin.getFlagStateManager().forget(player);
state = plugin.getFlagStateManager().getState(player);
}
World world = from.getWorld();
World toWorld = to.getWorld();
LocalPlayer localPlayer = plugin.wrapPlayer(player);
boolean hasBypass = plugin.getGlobalRegionManager().hasBypass(player, world);
boolean hasRemoteBypass = plugin.getGlobalRegionManager().hasBypass(player, toWorld);
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
RegionManager mgr = plugin.getGlobalRegionManager().get(toWorld);
Vector pt = new Vector(to.getBlockX(), to.getBlockY(), to.getBlockZ());
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
@@ -170,7 +179,7 @@ public class WorldGuardPlayerListener implements Listener {
*/
boolean entryAllowed = set.allows(DefaultFlag.ENTRY, localPlayer);
if (!hasBypass && (!entryAllowed /*|| regionFull*/)) {
if (!hasRemoteBypass && (!entryAllowed /*|| regionFull*/)) {
String message = /*maxPlayerMessage != null ? maxPlayerMessage :*/ "You are not permitted to enter this area.";
player.sendMessage(ChatColor.DARK_RED + message);
@@ -179,8 +188,9 @@ public class WorldGuardPlayerListener implements Listener {
// Have to set this state
if (state.lastExitAllowed == null) {
state.lastExitAllowed = mgr.getApplicableRegions(toVector(from))
.allows(DefaultFlag.EXIT, localPlayer);
state.lastExitAllowed = plugin.getGlobalRegionManager().get(world)
.getApplicableRegions(toVector(from))
.allows(DefaultFlag.EXIT, localPlayer);
}
boolean exitAllowed = set.allows(DefaultFlag.EXIT, localPlayer);
@@ -285,7 +295,7 @@ public class WorldGuardPlayerListener implements Listener {
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
|| event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
boolean result = checkMove(plugin, player, world, event.getFrom(), event.getTo());
boolean result = checkMove(plugin, player, event.getFrom(), event.getTo());
if (result) {
Location newLoc = event.getFrom();
newLoc.setX(newLoc.getBlockX() + 0.5);
@@ -781,7 +791,8 @@ public class WorldGuardPlayerListener implements Listener {
if (item.getTypeId() == ItemID.FIRE_CHARGE || item.getTypeId() == ItemID.FLINT_AND_TINDER) {
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
&& !placedInSet.allows(DefaultFlag.LIGHTER, localPlayer)) {
&& !plugin.canBuild(player, placedIn)
&& !placedInSet.allows(DefaultFlag.LIGHTER)) {
event.setCancelled(true);
event.setUseItemInHand(Result.DENY);
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to use that here.");
@@ -1375,10 +1386,12 @@ public class WorldGuardPlayerListener implements Listener {
ApplicableRegionSet setFrom = mgr.getApplicableRegions(ptFrom);
LocalPlayer localPlayer = plugin.wrapPlayer(event.getPlayer());
boolean result = checkMove(plugin, event.getPlayer(), event.getPlayer().getWorld(), event.getFrom(), event.getTo());
if (result) {
event.setCancelled(true);
return;
if (cfg.usePlayerTeleports) {
boolean result = checkMove(plugin, event.getPlayer(), event.getFrom(), event.getTo());
if (result) {
event.setCancelled(true);
return;
}
}
if (event.getCause() == TeleportCause.ENDER_PEARL) {
@@ -72,6 +72,11 @@ import com.sk89q.worldguard.util.FatalConfigurationLoadingException;
*/
public class WorldGuardPlugin extends JavaPlugin {
/**
* Current instance of this plugin.
*/
private static WorldGuardPlugin inst;
/**
* Manager for commands. This automatically handles nested commands,
* permissions checking, and a number of other fancy command things.
@@ -102,7 +107,7 @@ public class WorldGuardPlugin extends JavaPlugin {
configuration = new ConfigurationManager(this);
globalRegionManager = new GlobalRegionManager(this);
final WorldGuardPlugin plugin = this;
final WorldGuardPlugin plugin = inst = this;
commands = new CommandsManager<CommandSender>() {
@Override
public boolean hasPermission(CommandSender player, String perm) {
@@ -111,6 +116,14 @@ public class WorldGuardPlugin extends JavaPlugin {
};
}
/**
* Get the current instance of WorldGuard
* @return WorldGuardPlugin instance
*/
public static WorldGuardPlugin inst() {
return inst;
}
/**
* Called on plugin enable.
*/
@@ -82,96 +82,16 @@ public class WorldGuardVehicleListener implements Listener {
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(world);
// unfortunate code duplication
if (wcfg.useRegions) {
// Did we move a block?
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
|| event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
PlayerFlagState state = plugin.getFlagStateManager().getState(player);
LocalPlayer localPlayer = plugin.wrapPlayer(player);
boolean hasBypass = plugin.getGlobalRegionManager().hasBypass(player, world);
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
Vector pt = new Vector(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
boolean entryAllowed = set.allows(DefaultFlag.ENTRY, localPlayer);
if (!hasBypass && !entryAllowed) {
boolean result = WorldGuardPlayerListener.checkMove(plugin, player, event.getFrom(), event.getTo());
if (result) {
vehicle.setVelocity(new org.bukkit.util.Vector(0,0,0));
vehicle.teleport(event.getFrom());
return;
}
// Have to set this state
if (state.lastExitAllowed == null) {
state.lastExitAllowed = mgr.getApplicableRegions(toVector(event.getFrom()))
.allows(DefaultFlag.EXIT, localPlayer);
}
boolean exitAllowed = set.allows(DefaultFlag.EXIT, localPlayer);
if (!hasBypass && exitAllowed && !state.lastExitAllowed) {
player.sendMessage(ChatColor.DARK_RED + "You are not permitted to leave this area.");
vehicle.setVelocity(new org.bukkit.util.Vector(0,0,0));
vehicle.teleport(event.getFrom());
return;
}
String greeting = set.getFlag(DefaultFlag.GREET_MESSAGE, localPlayer);
String farewell = set.getFlag(DefaultFlag.FAREWELL_MESSAGE, localPlayer);
Boolean notifyEnter = set.getFlag(DefaultFlag.NOTIFY_ENTER, localPlayer);
Boolean notifyLeave = set.getFlag(DefaultFlag.NOTIFY_LEAVE, localPlayer);
if (state.lastFarewell != null && (farewell == null
|| !state.lastFarewell.equals(farewell))) {
String replacedFarewell = plugin.replaceMacros(
player, BukkitUtil.replaceColorMacros(state.lastFarewell));
player.sendMessage(ChatColor.AQUA + " ** " + replacedFarewell);
}
if (greeting != null && (state.lastGreeting == null
|| !state.lastGreeting.equals(greeting))) {
String replacedGreeting = plugin.replaceMacros(
player, BukkitUtil.replaceColorMacros(greeting));
player.sendMessage(ChatColor.AQUA + " ** " + replacedGreeting);
}
if ((notifyLeave == null || !notifyLeave)
&& state.notifiedForLeave != null && state.notifiedForLeave) {
plugin.broadcastNotification(ChatColor.GRAY + "WG: "
+ ChatColor.LIGHT_PURPLE + player.getName()
+ ChatColor.GOLD + " left NOTIFY region");
}
if (notifyEnter != null && notifyEnter && (state.notifiedForEnter == null
|| !state.notifiedForEnter)) {
StringBuilder regionList = new StringBuilder();
for (ProtectedRegion region : set) {
if (regionList.length() != 0) {
regionList.append(", ");
}
regionList.append(region.getId());
}
plugin.broadcastNotification(ChatColor.GRAY + "WG: "
+ ChatColor.LIGHT_PURPLE + player.getName()
+ ChatColor.GOLD + " entered NOTIFY region: "
+ ChatColor.WHITE
+ regionList);
}
state.lastGreeting = greeting;
state.lastFarewell = farewell;
state.notifiedForEnter = notifyEnter;
state.notifiedForLeave = notifyLeave;
state.lastExitAllowed = exitAllowed;
state.lastWorld = event.getTo().getWorld();
state.lastBlockX = event.getTo().getBlockX();
state.lastBlockY = event.getTo().getBlockY();
state.lastBlockZ = event.getTo().getBlockZ();
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,58 @@
// $Id$
/*
* This file is a part of WorldGuard.
* Copyright (c) sk89q <http://www.sk89q.com>
* Copyright (c) the WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* (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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.bukkit.commands;
/**
* Used for /rg list.
*/
class RegionListEntry implements Comparable<RegionListEntry> {
private final String id;
private final int index;
boolean isOwner;
boolean isMember;
public RegionListEntry(String id, int index) {
this.id = id;
this.index = index;
}
@Override
public int compareTo(RegionListEntry o) {
if (isOwner != o.isOwner) {
return isOwner ? 1 : -1;
}
if (isMember != o.isMember) {
return isMember ? 1 : -1;
}
return id.compareTo(o.id);
}
@Override
public String toString() {
if (isOwner) {
return (index + 1) + ". +" + id;
} else if (isMember) {
return (index + 1) + ". -" + id;
} else {
return (index + 1) + ". " + id;
}
}
}
@@ -174,9 +174,9 @@ public class RegionMemberCommands {
@Command(aliases = {"removemember", "remmember", "removemem", "remmem"},
usage = "<id> <owners...>",
flags = "w:",
flags = "aw:",
desc = "Remove an owner to a region",
min = 2)
min = 1)
public void removeMember(CommandContext args, CommandSender sender) throws CommandException {
final World world;
Player player = null;
@@ -216,7 +216,14 @@ public class RegionMemberCommands {
}
}
RegionDBUtil.removeFromDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
if (args.hasFlag('a')) {
region.getMembers().removaAll();
} else {
if (args.argsLength() < 2) {
throw new CommandException("List some names to remove, or use -a to remove all.");
}
RegionDBUtil.removeFromDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
}
sender.sendMessage(ChatColor.YELLOW
+ "Region '" + id + "' updated.");
@@ -231,9 +238,9 @@ public class RegionMemberCommands {
@Command(aliases = {"removeowner", "remowner"},
usage = "<id> <owners...>",
flags = "w:",
flags = "aw:",
desc = "Remove an owner to a region",
min = 2)
min = 1)
public void removeOwner(CommandContext args,
CommandSender sender) throws CommandException {
final World world;
@@ -274,7 +281,14 @@ public class RegionMemberCommands {
}
}
RegionDBUtil.removeFromDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
if (args.hasFlag('a')) {
region.getOwners().removaAll();
} else {
if (args.argsLength() < 2) {
throw new CommandException("List some names to remove, or use -a to remove all.");
}
RegionDBUtil.removeFromDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
}
sender.sendMessage(ChatColor.YELLOW
+ "Region '" + id + "' updated.");
@@ -0,0 +1,334 @@
// $Id$
/*
* This file is a part of WorldGuard.
* Copyright (c) sk89q <http://www.sk89q.com>
* Copyright (c) the WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* (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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldguard.bukkit.commands;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
/**
* Create a region printout, as used in /region info to show information about
* a region.
*/
public class RegionPrintoutBuilder {
private final ProtectedRegion region;
private final StringBuilder builder = new StringBuilder();
/**
* Create a new instance with a region to report on.
*
* @param region the region
*/
public RegionPrintoutBuilder(ProtectedRegion region) {
this.region = region;
}
/**
* Add a new line.
*/
private void newLine() {
builder.append("\n");
}
/**
* Add region name, type, and priority.
*/
public void appendBasics() {
builder.append(ChatColor.BLUE);
builder.append("Region: ");
builder.append(ChatColor.YELLOW);
builder.append(region.getId());
builder.append(ChatColor.GRAY);
builder.append(" (type=");
builder.append(region.getTypeName());
builder.append(ChatColor.GRAY);
builder.append(", priority=");
builder.append(region.getPriority());
builder.append(")");
newLine();
}
/**
* Add information about flags.
*/
public void appendFlags() {
builder.append(ChatColor.BLUE);
builder.append("Flags: ");
appendFlagsList(true);
newLine();
}
/**
* Append just the list of flags (without "Flags:"), including colors.
*
* @param useColors true to use colors
*/
public void appendFlagsList(boolean useColors) {
boolean hasFlags = false;
for (Flag<?> flag : DefaultFlag.getFlags()) {
Object val = region.getFlag(flag), group = null;
// No value
if (val == null) {
continue;
}
if (hasFlags) {
builder.append(", ");
} else {
if (useColors) {
builder.append(ChatColor.YELLOW);
}
}
RegionGroupFlag groupFlag = flag.getRegionGroupFlag();
if (groupFlag != null) {
group = region.getFlag(groupFlag);
}
if(group == null) {
builder.append(flag.getName()).append(": ")
.append(String.valueOf(val));
} else {
builder.append(flag.getName()).append(" -g ")
.append(String.valueOf(group)).append(": ")
.append(String.valueOf(val));
}
hasFlags = true;
}
if (!hasFlags) {
if (useColors) {
builder.append(ChatColor.RED);
}
builder.append("(none)");
}
}
/**
* Add information about parents.
*/
public void appendParents() {
appendParentTree(true);
}
/**
* Add information about parents.
*
* @param useColors true to use colors
*/
public void appendParentTree(boolean useColors) {
if (region.getParent() == null) {
return;
}
List<ProtectedRegion> inheritance = new ArrayList<ProtectedRegion>();
ProtectedRegion r = region;
inheritance.add(r);
while (r.getParent() != null) {
r = r.getParent();
inheritance.add(r);
}
ListIterator<ProtectedRegion> it = inheritance.listIterator(
inheritance.size());
int indent = 0;
while (it.hasPrevious()) {
ProtectedRegion cur = it.previous();
if (useColors) {
builder.append(ChatColor.GREEN);
}
// Put symbol for child
if (indent != 0) {
for (int i = 0; i < indent; i++) {
builder.append(" ");
}
builder.append("\u2517");
}
// Put name
builder.append(cur.getId());
// Put (parent)
if (!cur.equals(region)) {
if (useColors) {
builder.append(ChatColor.GRAY);
}
builder.append(" (parent, priority=" + cur.getPriority() + ")");
}
indent++;
newLine();
}
}
/**
* Add information about members.
*/
public void appendDomain() {
builder.append(ChatColor.BLUE);
builder.append("Owners: ");
DefaultDomain owners = region.getOwners();
if (owners.size() != 0) {
builder.append(ChatColor.YELLOW);
builder.append(owners.toUserFriendlyString());
} else {
builder.append(ChatColor.RED);
builder.append("(no owners)");
}
newLine();
builder.append(ChatColor.BLUE);
builder.append("Members: ");
DefaultDomain members = region.getMembers();
if (members.size() != 0) {
builder.append(ChatColor.YELLOW);
builder.append(members.toUserFriendlyString());
} else {
builder.append(ChatColor.RED);
builder.append("(no members)");
}
newLine();
}
/**
* Add information about coordinates.
*/
public void appendBounds() {
BlockVector min = region.getMinimumPoint();
BlockVector max = region.getMaximumPoint();
builder.append(ChatColor.BLUE);
builder.append("Bounds:");
builder.append(ChatColor.YELLOW);
builder.append(" (" + min.getBlockX() + "," + min.getBlockY() + "," + min.getBlockZ() + ")");
builder.append(" -> (" + max.getBlockX() + "," + max.getBlockY() + "," + max.getBlockZ() + ")");
newLine();
}
/**
* Append all the default fields used for /rg info.
*/
public void appendRegionInfo() {
builder.append(ChatColor.GRAY);
builder.append("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
builder.append(" Region Info ");
builder.append("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
newLine();
appendBasics();
appendFlags();
appendParents();
appendDomain();
appendBounds();
}
/**
* Send the report to a {@link CommandSender}.
*
* @param sender the recepient
*/
public void send(CommandSender sender) {
sender.sendMessage(toString());
}
public StringBuilder append(boolean b) {
return builder.append(b);
}
public StringBuilder append(char c) {
return builder.append(c);
}
public StringBuilder append(char[] str, int offset, int len) {
return builder.append(str, offset, len);
}
public StringBuilder append(char[] str) {
return builder.append(str);
}
public StringBuilder append(CharSequence s, int start, int end) {
return builder.append(s, start, end);
}
public StringBuilder append(CharSequence s) {
return builder.append(s);
}
public StringBuilder append(double d) {
return builder.append(d);
}
public StringBuilder append(float f) {
return builder.append(f);
}
public StringBuilder append(int i) {
return builder.append(i);
}
public StringBuilder append(long lng) {
return builder.append(lng);
}
public StringBuilder append(Object obj) {
return builder.append(obj);
}
public StringBuilder append(String str) {
return builder.append(str);
}
public StringBuilder append(StringBuffer sb) {
return builder.append(sb);
}
public StringBuilder appendCodePoint(int codePoint) {
return builder.appendCodePoint(codePoint);
}
@Override
public String toString() {
return builder.toString().trim();
}
}
@@ -34,7 +34,6 @@ import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldguard.bukkit.LoggerToChatHandler;
import com.sk89q.worldguard.bukkit.ReportWriter;
import com.sk89q.worldguard.bukkit.WGBukkit;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.util.PastebinPoster;
import com.sk89q.worldguard.util.PastebinPoster.PasteCallback;
@@ -73,7 +72,7 @@ public class WorldGuardCommands {
plugin.getGlobalRegionManager().unload();
plugin.getGlobalStateManager().load();
plugin.getGlobalRegionManager().preload();
WGBukkit.cleanCache();
// WGBukkit.cleanCache();
sender.sendMessage("WorldGuard configuration reloaded.");
} catch (Throwable t) {
sender.sendMessage("Error while reloading: "
@@ -30,8 +30,8 @@ import java.util.Set;
import com.sk89q.worldguard.LocalPlayer;
public class DefaultDomain implements Domain {
private Set<String> groups;
private Set<String> players;
private final Set<String> groups;
private final Set<String> players;
public DefaultDomain() {
this.groups = new LinkedHashSet<String>();
@@ -135,4 +135,9 @@ public class DefaultDomain implements Domain {
return str.toString();
}
public void removaAll() {
groups.clear();
players.clear();
}
}
@@ -40,7 +40,7 @@ public final class DefaultFlag {
public static final StateFlag OTHER_EXPLOSION = new StateFlag("other-explosion", true);
public static final StateFlag SLEEP = new StateFlag("sleep", true);
public static final StateFlag TNT = new StateFlag("tnt", true, RegionGroup.ALL);
public static final StateFlag LIGHTER = new StateFlag("lighter", false, RegionGroup.NON_MEMBERS);
public static final StateFlag LIGHTER = new StateFlag("lighter", true);
public static final StateFlag FIRE_SPREAD = new StateFlag("fire-spread", true);
public static final StateFlag LAVA_FIRE = new StateFlag("lava-fire", true);
public static final StateFlag LIGHTNING = new StateFlag("lightning", true);
@@ -80,8 +80,8 @@ public final class DefaultFlag {
public static final EnumFlag<GameMode> GAME_MODE = new EnumFlag<GameMode>("game-mode", GameMode.class, RegionGroup.ALL);
public static final IntegerFlag HEAL_DELAY = new IntegerFlag("heal-delay", RegionGroup.ALL);
public static final IntegerFlag HEAL_AMOUNT = new IntegerFlag("heal-amount", RegionGroup.ALL);
public static final IntegerFlag MIN_HEAL = new IntegerFlag("heal-min-health", RegionGroup.ALL);
public static final IntegerFlag MAX_HEAL = new IntegerFlag("heal-max-health", RegionGroup.ALL);
public static final DoubleFlag MIN_HEAL = new DoubleFlag("heal-min-health", RegionGroup.ALL);
public static final DoubleFlag MAX_HEAL = new DoubleFlag("heal-max-health", RegionGroup.ALL);
public static final IntegerFlag FEED_DELAY = new IntegerFlag("feed-delay", RegionGroup.ALL);
public static final IntegerFlag FEED_AMOUNT = new IntegerFlag("feed-amount", RegionGroup.ALL);
public static final IntegerFlag MIN_FOOD = new IntegerFlag("feed-min-hunger", RegionGroup.ALL);
@@ -119,4 +119,20 @@ public final class DefaultFlag {
public static Flag<?>[] getFlags() {
return flagsList;
}
/**
* Try to match the flag with the given ID using a fuzzy name match.
*
* @param id the flag ID
* @return a flag, or null
*/
public static Flag<?> fuzzyMatchFlag(String id) {
for (Flag<?> flag : DefaultFlag.getFlags()) {
if (flag.getName().replace("-", "").equalsIgnoreCase(id.replace("-", ""))) {
return flag;
}
}
return null;
}
}
@@ -52,6 +52,8 @@ public class DoubleFlag extends Flag<Double> {
public Double unmarshal(Object o) {
if (o instanceof Double) {
return (Double) o;
} else if (o instanceof Number) {
return ((Number) o).doubleValue();
} else {
return null;
}
@@ -52,6 +52,8 @@ public class IntegerFlag extends Flag<Integer> {
public Integer unmarshal(Object o) {
if (o instanceof Integer) {
return (Integer) o;
} else if (o instanceof Number) {
return ((Number) o).intValue();
} else {
return null;
}
@@ -0,0 +1,23 @@
// $Id$
/*
* This file is a part of WorldGuard.
* Copyright (c) sk89q <http://www.sk89q.com>
* Copyright (c) the WorldGuard team and contributors
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* (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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.enginehub.util;
public interface PermissionModel {
}
@@ -19,26 +19,8 @@
package com.sk89q.worldguard.protection;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.TestPlayer;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.managers.FlatRegionManager;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashSet;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class FlatRegionManagerTest extends RegionOverlapTest {
protected RegionManager createRegionManager() throws Exception {
@@ -19,26 +19,8 @@
package com.sk89q.worldguard.protection;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.BlockVector2D;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldguard.TestPlayer;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.managers.PRTreeRegionManager;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashSet;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class PRTreeRegionManagerTest extends RegionOverlapTest {
protected RegionManager createRegionManager() throws Exception {
@@ -28,7 +28,6 @@ import com.sk89q.worldguard.TestPlayer;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.managers.FlatRegionManager;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.*;
import org.junit.Test;