Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b707289284 | ||
|
|
43486bda63 | ||
|
|
7086a1d0d2 | ||
|
|
4dd13bd925 | ||
|
|
4ce97bca0e | ||
|
|
ec9712f30e | ||
|
|
0162910964 | ||
|
|
c252a79c1a | ||
|
|
2df3290d38 | ||
|
|
4805df2f03 | ||
|
|
5bc670db8b | ||
|
|
ffda88f193 | ||
|
|
96a69aa2ef | ||
|
|
2d90fddbee | ||
|
|
bbd1a0ef10 | ||
|
|
6b16ed79b3 | ||
|
|
73b9a7fb0d | ||
|
|
4a0ae833f0 | ||
|
|
5f32ebe2de | ||
|
|
723928d239 | ||
|
|
d024ed7b81 | ||
|
|
ec4143d3dc | ||
|
|
071fdaabd3 | ||
|
|
23766f20dd | ||
|
|
31739c647b | ||
|
|
faa016180a | ||
|
|
e26238e814 | ||
|
|
f8ed1a3e3e | ||
|
|
d47c255168 | ||
|
|
d1e7796f81 | ||
|
|
1095064c5e | ||
|
|
a15c9d289b | ||
|
|
c0f95bebf0 | ||
|
|
0a54779fc4 | ||
|
|
ac525958c5 | ||
|
|
458cf64501 | ||
|
|
4acef77623 | ||
|
|
d38d7fc492 | ||
|
|
2510c3eeb5 | ||
|
|
326d53fd09 | ||
|
|
75b3082b12 | ||
|
|
1f214aadee | ||
|
|
174b3fad15 | ||
|
|
07531f67d4 | ||
|
|
291c45064a | ||
|
|
6f56cb29a5 | ||
|
|
977c7d2f29 | ||
|
|
ecb87efe8d | ||
|
|
a57c162cd8 | ||
|
|
60c3ed4f6b | ||
|
|
714e75eb95 | ||
|
|
636819c801 | ||
|
|
9a6c2e0685 | ||
|
|
736eecc13b | ||
|
|
4718c5dab0 | ||
|
|
7e9bd49da2 | ||
|
|
a0d0ff0b92 | ||
|
|
b41be0c319 | ||
|
|
17a466059e | ||
|
|
2d9e95a63e | ||
|
|
532a45f9e7 | ||
|
|
d61e32ebb5 | ||
|
|
b7d38e94c8 | ||
|
|
ae158742f6 | ||
|
|
c35686f8d1 | ||
|
|
a5b6651582 | ||
|
|
54973fdf82 | ||
|
|
0bee631385 | ||
|
|
6283382837 | ||
|
|
39bb522051 | ||
|
|
bf80d57abe | ||
|
|
865b94006a | ||
|
|
874248f8b5 | ||
|
|
cef7d5bb12 | ||
|
|
2a8131780f | ||
|
|
7094f70f4a | ||
|
|
df5af6129c | ||
|
|
a6888c3767 | ||
|
|
1bd367ddde | ||
|
|
0cf87ae561 | ||
|
|
fa80f5f67f | ||
|
|
7f080f920d | ||
|
|
13658323b4 | ||
|
|
2d440ab5ba | ||
|
|
dc55673691 | ||
|
|
92bb3948a6 | ||
|
|
f67ad6478c | ||
|
|
1d984198ce | ||
|
|
f2ca980771 | ||
|
|
b826697aea | ||
|
|
89430c13ec | ||
|
|
f07acea3e1 | ||
|
|
e9402c55e6 | ||
|
|
2eb6c76da8 | ||
|
|
a34e48a145 | ||
|
|
2d50659b48 | ||
|
|
327ae2b807 | ||
|
|
dfb6114584 | ||
|
|
5085841d9d | ||
|
|
7a98944469 | ||
|
|
3d2b455cda | ||
|
|
460d5d0691 | ||
|
|
b5f80351ec | ||
|
|
72a9472a57 | ||
|
|
7eb820c688 | ||
|
|
886b279da6 | ||
|
|
f2d7135fc5 | ||
|
|
d214a859c3 | ||
|
|
d1e221c2b7 | ||
|
|
e0e4207a4d | ||
|
|
4398c781c5 | ||
|
|
3e06000fd9 | ||
|
|
833795ebe1 | ||
|
|
6e270d5ec3 | ||
|
|
09a9bea3a7 | ||
|
|
035ccee2a6 | ||
|
|
17aa2a4153 | ||
|
|
f5bc5c0b47 | ||
|
|
e7a4afde7d | ||
|
|
8758c9b940 | ||
|
|
a569d20779 | ||
|
|
88e01fa083 | ||
|
|
7b435f9283 | ||
|
|
a240e5d128 | ||
|
|
0d0ba31d3a | ||
|
|
e79bb3533d | ||
|
|
f94c4ec831 | ||
|
|
d5afb76105 | ||
|
|
dd7e9ba05e | ||
|
|
ee54698fdb | ||
|
|
955b0e991c | ||
|
|
c1b98b9e40 | ||
|
|
d6939b7916 | ||
|
|
5f0ca37879 | ||
|
|
548bdb7eb5 | ||
|
|
5c85f39228 | ||
|
|
85b2cbc03a | ||
|
|
cc78011da6 | ||
|
|
d016da1895 | ||
|
|
8593f1c80a | ||
|
|
0b3c40dc3e | ||
|
|
2e7ecc59c0 | ||
|
|
942ce95dbf | ||
|
|
03f77d5ab7 | ||
|
|
8dec32fa6a | ||
|
|
8f409d47d9 | ||
|
|
93f062d4e3 | ||
|
|
b8f9ceafbb | ||
|
|
75d07b6dad | ||
|
|
6060a0a430 | ||
|
|
647ba1572c | ||
|
|
051e0cb811 | ||
|
|
b8c9e78910 | ||
|
|
2d7d9c6093 | ||
|
|
0f32f56208 | ||
|
|
5addfd8975 | ||
|
|
7f108ce8f0 | ||
|
|
8c883e1ca8 | ||
|
|
d18fe6ffa0 | ||
|
|
80a8ac9e98 | ||
|
|
671fd58568 | ||
|
|
c4ea3b59f0 | ||
|
|
5d5def206d | ||
|
|
b2ebbb9b55 | ||
|
|
3734c071bf | ||
|
|
b1a419f2a2 | ||
|
|
bf5e292160 | ||
|
|
df57d91270 | ||
|
|
4da1741578 | ||
|
|
7a3774e730 | ||
|
|
e6e21caeea | ||
|
|
200d47ab09 | ||
|
|
ab274151d4 | ||
|
|
aec1e3a529 | ||
|
|
916caa1eb2 |
No files matched your search
@@ -4,3 +4,10 @@
|
||||
target
|
||||
|
||||
.DS_Store
|
||||
*.iml
|
||||
.idea
|
||||
|
||||
/bin
|
||||
/dependency-reduced-pom.xml
|
||||
*-private.sh
|
||||
|
||||
+143
-1
@@ -1,3 +1,145 @@
|
||||
5.9
|
||||
- Added a config option to allow explosion flags to only prevent block damage
|
||||
- Added allow-tamed-spawns setting, on by default. This will stop WorldGuard
|
||||
from culling tamed animals.
|
||||
- Added config option and flag to prevent soil from drying naturally.
|
||||
- Added formatting codes, &k/l/m/n/o and &x (reset).
|
||||
- Added snow-fall-blocks option to config to restrict snow fall to certain blocks
|
||||
- Allow players to add newlines (\n) via command, not just manually in yml.
|
||||
- Allow the console to load/save all region managers with one command.
|
||||
- Changed entity report format slightly.
|
||||
- Check bypass perms for item-drop flag.
|
||||
- Check for entities and projectiles removing items from frames too.
|
||||
- Fix being able to use bonemeal to turn tall grass into double plants.
|
||||
- Fix number of arguments for migratedb command.
|
||||
- Fixed addowner/addmember commands adding command artifacts. Specifically,
|
||||
"-w <world>" will no longer be added when using it.
|
||||
- Fixed milking cows in protected areas due to changes in Bukkit.
|
||||
- Fixed ProtectedCuboidRegion::getPoints() returning points in wrong order.
|
||||
- Fixed snowman trails being treated as snow fall.
|
||||
- Make /rg list default to own regions if the player doesn't have permission otherwise.
|
||||
- Protected items in item frames in protected regions.
|
||||
- Resolved an issue where explosions of type OTHER_EXPLOSION were ignoring the world
|
||||
configuration settings.
|
||||
- Send item-use blacklist event when right-clicking entities.
|
||||
- Transformed the BlockFadeEvent handler into a switch.
|
||||
|
||||
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.
|
||||
|
||||
5.7.4:
|
||||
- BREAKING CHANGE: Removed the cyan "**" in front of greeting
|
||||
and farewell messages to allow more customizability. You can
|
||||
re-add them by adding "&c**" to the flag.
|
||||
- Fixed an issue enderpearling inside exit/entry deny regions.
|
||||
- Added checks to players teleporting in and out of exit/entry regions.
|
||||
- Fix bad matching in blocked and allowed command flags.
|
||||
- Fixed heal flag bugs when player max health was increased.
|
||||
- Add fishing to xp blocker.
|
||||
- Applied other-explosion flag to entity damage as well.
|
||||
- Fixed an issue with interaction that should allow blacklisting item use actions with no block involved (eg fishing rods, potions)
|
||||
- Fix witherskull/fireball settings not being differentiated in one case
|
||||
- Allow cow milking in no-build areas
|
||||
- Fix infinite durability breaking items instantly.
|
||||
|
||||
5.7.3:
|
||||
- Fixed the error caused by Bukkit's change of the TNT minecart API.
|
||||
|
||||
5.7.2:
|
||||
- Updated to MineCraft 1.5.
|
||||
- Added TNT Minecart support. They are handled with the same flags/settings as TNT.
|
||||
- Added mining and smelting xp handling to the xp drops flag and setting.
|
||||
- Fixed a few edge cases for placing items on region borders.
|
||||
- Legacy: Fixed issue with //stack not respecting item metadata.
|
||||
|
||||
5.7.1:
|
||||
- Added a vine growth config option and flag.
|
||||
- Added support for many commands to be used from console.
|
||||
Usage is with -w flag and a world name e.g.
|
||||
/rg addmem <id> <player> -w <worldname>
|
||||
/rg flag <id> <flag> -w <worldname> <flagvalue>
|
||||
- Fixed bug that blocks placing plants in flower pots.
|
||||
- Fixed permissions check for /rg tp
|
||||
- Fixed enderchests not being accessible (they are now part of the USE flag)
|
||||
- Fixed an issue with slabs being placable in protected regions. This was
|
||||
also fixed in CraftBukkit but has been left in for users running other versions.
|
||||
- Fixed wither skulls being handled with other fireballs, despite having their own settings.
|
||||
- Fixed item frames being placable on region borders.
|
||||
- Fixed a bug that made explosions more ineffective than they should have been.
|
||||
- Fixed bonemeal usage in protected regions.
|
||||
- Fixed special minecarts being placable in protected regions.
|
||||
- Fixed bugs being placable on region borders.
|
||||
- Fixed wolves bypassing pvp flags.
|
||||
|
||||
5.7:
|
||||
- Fixed thread sync issue with FlagStateManager.
|
||||
- Fixed dragon egg region protection not working in certain cases.
|
||||
- Added beacon and anvil usage protection in regions.
|
||||
- Add mobs.block-enderdragon-portal-creation to stop enderdragons
|
||||
from making portals on death.
|
||||
- Fix TNT being lethal in some case when damage was disabled.
|
||||
- Fix snowballs and enderpearls being able to knock players back in
|
||||
pvp deny regions.
|
||||
- Add subcommand support for allowed and blocked command flags.
|
||||
- Add max-players-allowed and max-players-reject-message flags to
|
||||
limit the numbers of players in a region.
|
||||
- Fix players being able to plant cocoa beans in protected areas.
|
||||
- Add an enderpearl flag to prevent players from teleporting to and
|
||||
from regions.
|
||||
- Added mobs.block-other-explosions config setting and other-explosion
|
||||
flag to block explosions caused by uncovered things, such as other
|
||||
plugins. (It doesn't actually have to be a mob)
|
||||
- Fix mob damage setting and flag not blocking the DoT wither effect.
|
||||
- Ghast fireball flag will not block blaze fireballs from lighting things
|
||||
on fire.
|
||||
- Fixed players without region permissions being able to trigger tripwires,
|
||||
use enderchests, use wooden buttons, and put plants in flower pots.
|
||||
- Added mobs.block-zombie-door-destruction setting to stop zombies from
|
||||
breaking down doors while difficulty is set to hard.
|
||||
|
||||
Thank you to thvortex, Dilandau, tophathacker, and Dark_arc for their contributions this release.
|
||||
|
||||
5.6.5:
|
||||
- Fixed a regression that caused paintings and item frames to no longer be properly
|
||||
protected.
|
||||
|
||||
5.6.4:
|
||||
- Added mobs.block-above-ground-slimes to block slimes spawning naturally above ground.
|
||||
- Added security.deop-everyone-on-join to de-op all players when they join.
|
||||
- Added security.block-in-game-op-command to prevent usage of /op from in-game.
|
||||
- Fixed a NullPointerException in PlayerInteract involving water potions and
|
||||
potion blocking.
|
||||
- Fixed an issue with snowballs being blocked in regions.
|
||||
- Changed dragon eggs to be checked like it is a broken block in regions.
|
||||
- Moved developer's WGBukkit class to package com.sk89q.worldguard.bukkit.
|
||||
|
||||
5.6.3:
|
||||
- Added helper WGBukkit class to get references to WorldGuard from other plugins.
|
||||
- Added physics.vine-like-rope-ladders to make ladders work like vines. As long as the
|
||||
top ladder block is present, ladder blocks will hold even if they have no block
|
||||
behind them, like a rope ladder.
|
||||
- Fixed NullPointerException in PlayerInteractEvent caused by potion blocking.
|
||||
- Fixed mobs.block-{item-frame,painting}-destroy not working.
|
||||
|
||||
Thank you to def for testing the above fixes and features.
|
||||
|
||||
5.6.2:
|
||||
- Fixed potion blocking not working well for splash potions.
|
||||
|
||||
@@ -469,4 +611,4 @@ EduardBaer, TomyLobo, and halvors
|
||||
- Added block lag fix.
|
||||
|
||||
1.0
|
||||
- Initial release.
|
||||
- Initial release.
|
||||
@@ -26,10 +26,13 @@ must be licensed under the GNU General Public License v3.
|
||||
|
||||
Please read CONTRIBUTING.md for important guidelines to follow.
|
||||
|
||||
We recommend following our [mailing list](https://groups.google.com/d/forum/sk-dev-discuss), especially if you have some big ideas that you want to implement.
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* [Mailing list](https://groups.google.com/d/forum/sk-dev-discuss)
|
||||
* [IRC channel](http://skq.me/irc/irc.esper.net/sk89q/) (#sk89q on irc.esper.net)
|
||||
* [Issue tracker](http://youtrack.sk89q.com/issues/WORLDGUARD)
|
||||
* [Continuous integration](http://build.sk89q.com) [](http://travis-ci.org/sk89q/worldguard)
|
||||
* [End-user documentation](http://wiki.sk89q.com/wiki/WorldGuard)
|
||||
* [Continuous integration](http://builds.enginehub.org) [](http://travis-ci.org/sk89q/worldguard)
|
||||
* [End-user documentation](http://wiki.sk89q.com/wiki/WorldGuard)
|
||||
@@ -2,7 +2,10 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>5.6.2</version>
|
||||
<version>5.9</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<!-- Project information -->
|
||||
<name>WorldGuard</name>
|
||||
<description>WorldGuard protects your Minecraft servers.</description>
|
||||
<licenses>
|
||||
@@ -13,15 +16,50 @@
|
||||
<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>
|
||||
<url>https://github.com/sk89q/worldguard</url>
|
||||
<tag>master</tag>
|
||||
<developerConnection>scm:git:git@github.com:sk89q/worldguard.git</developerConnection>
|
||||
<url>https://github.com/sk89q/worldguard</url>
|
||||
<tag>5.9</tag>
|
||||
</scm>
|
||||
<properties>
|
||||
|
||||
<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>
|
||||
<repository>
|
||||
<id>maven.sk89q.com</id>
|
||||
<url>http://maven.sk89q.com/artifactory/libs-release-local</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>maven.sk89q.com-snapshot</id>
|
||||
<url>http://maven.sk89q.com/artifactory/libs-snapshot-local</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<properties> <!-- Fix encoding warnings -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
@@ -36,24 +74,30 @@
|
||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit</artifactId>
|
||||
<version>5.4.4</version>
|
||||
<version>5.5.8</version>
|
||||
<scope>compile</scope>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.4.2-R0.3-SNAPSHOT</version>
|
||||
<version>1.7.2-R0.3</version>
|
||||
<scope>compile</scope>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>commandbook</artifactId>
|
||||
<version>2.1</version>
|
||||
<version>2.3</version>
|
||||
<scope>compile</scope>
|
||||
<type>jar</type>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.zachsthings.libcomponents</groupId>
|
||||
@@ -65,42 +109,45 @@
|
||||
</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>
|
||||
<distributionManagement>
|
||||
<site>
|
||||
<id>sk89q-docs-upload</id>
|
||||
<url>ftp://sk89q-maven-deploy/worldguard/</url>
|
||||
</site>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
|
||||
<extensions>
|
||||
<extensions> <!-- Used for uploading the docs -->
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ftp</artifactId>
|
||||
@@ -200,33 +247,34 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.2.2</version>
|
||||
<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-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>
|
||||
@@ -237,4 +285,43 @@
|
||||
</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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,9 +29,15 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BukkitUtil {
|
||||
@@ -143,6 +149,27 @@ public class BukkitUtil {
|
||||
return id == 8 || id == 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given potion is a vial of water.
|
||||
*
|
||||
* @param item the item to check
|
||||
* @return true if it's a water vial
|
||||
*/
|
||||
public static boolean isWaterPotion(ItemStack item) {
|
||||
return (item.getDurability() & 0x3F) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get just the potion effect bits. This is to work around bugs with potion
|
||||
* parsing.
|
||||
*
|
||||
* @param item item
|
||||
* @return new bits
|
||||
*/
|
||||
public static int getPotionEffectBits(ItemStack item) {
|
||||
return item.getDurability() & 0x3F;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -222,6 +249,14 @@ public class BukkitUtil {
|
||||
str = str.replace("&2", ChatColor.GRAY.toString());
|
||||
str = str.replace("&w", ChatColor.WHITE.toString());
|
||||
|
||||
str = str.replace("&k", ChatColor.MAGIC.toString());
|
||||
str = str.replace("&l", ChatColor.BOLD.toString());
|
||||
str = str.replace("&m", ChatColor.STRIKETHROUGH.toString());
|
||||
str = str.replace("&n", ChatColor.UNDERLINE.toString());
|
||||
str = str.replace("&o", ChatColor.ITALIC.toString());
|
||||
|
||||
str = str.replace("&x", ChatColor.RESET.toString());
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -235,26 +270,12 @@ public class BukkitUtil {
|
||||
return entity instanceof Item
|
||||
|| entity instanceof TNTPrimed
|
||||
|| entity instanceof ExperienceOrb
|
||||
|| entity instanceof FallingSand
|
||||
|| entity instanceof FallingBlock
|
||||
|| (entity instanceof LivingEntity
|
||||
&& !(entity instanceof Tameable)
|
||||
&& !(entity instanceof Player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether our running CraftBukkit already supports
|
||||
* the HangingEvent instead of the PaintingEvent
|
||||
*
|
||||
* @return true if the hanging event is supported
|
||||
*/
|
||||
public static boolean hasHangingEvent() {
|
||||
Class<?> tmp = null;
|
||||
try {
|
||||
tmp = Class.forName("org.bukkit.event.hanging.HangingEvent");
|
||||
} catch (ClassNotFoundException ignored) { }
|
||||
return (tmp != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search an enum for a value, and return the first one found. Return null if the
|
||||
* enum entry is not found.
|
||||
|
||||
@@ -18,6 +18,15 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.commandbook.CommandBook;
|
||||
import com.sk89q.commandbook.GodComponent;
|
||||
import com.sk89q.util.yaml.YAMLFormat;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
@@ -27,16 +36,6 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import com.sk89q.commandbook.CommandBook;
|
||||
import com.sk89q.commandbook.GodComponent;
|
||||
import com.sk89q.util.yaml.YAMLFormat;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
|
||||
/**
|
||||
* Represents the global configuration and also delegates configuration
|
||||
* for individual worlds.
|
||||
@@ -100,6 +99,9 @@ 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>();
|
||||
|
||||
/**
|
||||
@@ -138,15 +140,15 @@ public class ConfigurationManager {
|
||||
}
|
||||
|
||||
config.removeProperty("suppress-tick-sync-warnings");
|
||||
useRegionsScheduler = config.getBoolean(
|
||||
"regions.use-scheduler", true);
|
||||
useRegionsCreatureSpawnEvent = config.getBoolean(
|
||||
"regions.use-creature-spawn-event", true);
|
||||
autoGodMode = config.getBoolean(
|
||||
"auto-invincible", config.getBoolean("auto-invincible-permission", false));
|
||||
useRegionsScheduler = config.getBoolean("regions.use-scheduler", true);
|
||||
useRegionsCreatureSpawnEvent = config.getBoolean("regions.use-creature-spawn-event", true);
|
||||
autoGodMode = config.getBoolean("auto-invincible", config.getBoolean("auto-invincible-permission", false));
|
||||
config.removeProperty("auto-invincible-permission");
|
||||
usePlayerMove = config.getBoolean(
|
||||
"use-player-move-event", true);
|
||||
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);
|
||||
|
||||
hostKeys = new HashMap<String, String>();
|
||||
Object hostKeysRaw = config.getProperty("host-keys");
|
||||
|
||||
@@ -60,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();
|
||||
|
||||
@@ -83,10 +84,8 @@ public class FlagStateManager implements Runnable {
|
||||
}
|
||||
|
||||
Vector playerLocation = toVector(player.getLocation());
|
||||
RegionManager regionManager = plugin.getGlobalRegionManager()
|
||||
.get(player.getWorld());
|
||||
ApplicableRegionSet applicable = regionManager
|
||||
.getApplicableRegions(playerLocation);
|
||||
RegionManager regionManager = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet applicable = regionManager.getApplicableRegions(playerLocation);
|
||||
|
||||
if (!RegionQueryUtil.isInvincible(plugin, player, applicable)
|
||||
&& !plugin.getGlobalStateManager().hasGodMode(player)
|
||||
@@ -115,14 +114,22 @@ 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 = 20;
|
||||
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);
|
||||
maxHealth = Math.min(player.getMaxHealth(), maxHealth);
|
||||
|
||||
if (player.getHealth() >= maxHealth && healAmount > 0) {
|
||||
return;
|
||||
@@ -158,8 +165,16 @@ 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);
|
||||
maxHunger = Math.min(20, maxHunger);
|
||||
|
||||
if (player.getFoodLevel() >= maxHunger && feedAmount > 0) {
|
||||
return;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -231,7 +231,7 @@ public class ReportWriter {
|
||||
for (Map.Entry<Class<? extends Entity>, Integer> entry
|
||||
: entityCounts.entrySet()) {
|
||||
entitiesLog.put(entry.getKey().getSimpleName(),
|
||||
"%d [%f]",
|
||||
"%d [%f/chunk]",
|
||||
entry.getValue(),
|
||||
(float) (entry.getValue() / (double) loadedChunkCount));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
// $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
|
||||
* GNU 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.World;
|
||||
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
|
||||
/**
|
||||
* Helper class to get a reference to WorldGuard and its components.
|
||||
*/
|
||||
public class WGBukkit {
|
||||
|
||||
private WGBukkit() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WorldGuard plugin. If WorldGuard isn't loaded yet, then this will
|
||||
* return null.
|
||||
* <p>
|
||||
* If you are depending on WorldGuard in your plugin, you should place
|
||||
* <code>softdepend: [WorldGuard]</code> or <code>depend: [WorldGuard]</code>
|
||||
* in your plugin.yml so that this won't return null for you.
|
||||
*
|
||||
* @return the WorldGuard plugin or null
|
||||
*/
|
||||
public static WorldGuardPlugin getPlugin() {
|
||||
return WorldGuardPlugin.inst();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache to null for reload WorldGuardPlugin
|
||||
* @deprecated instance is now stored directly in {@link WorldGuardPlugin}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void cleanCache() {
|
||||
// do nothing - plugin instance is stored in plugin class now
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the region manager for a given world. May return null if WorldGuard
|
||||
* is not loaded or region protection is not enabled for the given world.
|
||||
*
|
||||
* @param world world
|
||||
* @return a region manager or null
|
||||
*/
|
||||
public static RegionManager getRegionManager(World world) {
|
||||
if (getPlugin() == null) {
|
||||
return null;
|
||||
}
|
||||
return WorldGuardPlugin.inst().getRegionManager(world);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,6 +19,22 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLFormat;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldguard.blacklist.Blacklist;
|
||||
@@ -28,16 +44,6 @@ import com.sk89q.worldguard.blacklist.loggers.DatabaseLoggerHandler;
|
||||
import com.sk89q.worldguard.blacklist.loggers.FileLoggerHandler;
|
||||
import com.sk89q.worldguard.chest.ChestProtection;
|
||||
import com.sk89q.worldguard.chest.SignChestProtection;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Holds the configuration for individual worlds.
|
||||
@@ -69,6 +75,7 @@ public class WorldConfiguration {
|
||||
private ChestProtection chestProtection = new SignChestProtection();
|
||||
|
||||
/* Configuration data start */
|
||||
public boolean summaryOnStart;
|
||||
public boolean opPermissions;
|
||||
public boolean fireSpreadDisableToggle;
|
||||
public boolean itemDurability;
|
||||
@@ -81,6 +88,7 @@ public class WorldConfiguration {
|
||||
public boolean redstoneSponges;
|
||||
public boolean noPhysicsGravel;
|
||||
public boolean noPhysicsSand;
|
||||
public boolean ropeLadders;
|
||||
public boolean allowPortalAnywhere;
|
||||
public Set<Integer> preventWaterDamage;
|
||||
public boolean blockLighter;
|
||||
@@ -97,11 +105,15 @@ public class WorldConfiguration {
|
||||
public boolean blockWitherSkullExplosions;
|
||||
public boolean blockWitherSkullBlockDamage;
|
||||
public boolean blockEnderDragonBlockDamage;
|
||||
public boolean blockEnderDragonPortalCreation;
|
||||
public boolean blockFireballExplosions;
|
||||
public boolean blockFireballBlockDamage;
|
||||
public boolean blockOtherExplosions;
|
||||
public boolean blockEntityPaintingDestroy;
|
||||
public boolean blockEntityItemFrameDestroy;
|
||||
public boolean blockPluginSpawning;
|
||||
public boolean blockGroundSlimes;
|
||||
public boolean blockZombieDoorDestruction;
|
||||
public boolean disableContactDamage;
|
||||
public boolean disableFallDamage;
|
||||
public boolean disableLavaDamage;
|
||||
@@ -118,6 +130,7 @@ public class WorldConfiguration {
|
||||
public boolean highFreqFlags;
|
||||
public int regionWand;
|
||||
public Set<EntityType> blockCreatureSpawn;
|
||||
public boolean allowTamedSpawns;
|
||||
// public boolean useiConomy;
|
||||
// public boolean buyOnClaim;
|
||||
// public double buyOnClaimPrice;
|
||||
@@ -147,13 +160,19 @@ public class WorldConfiguration {
|
||||
public boolean disableLeafDecay;
|
||||
public boolean disableGrassGrowth;
|
||||
public boolean disableMyceliumSpread;
|
||||
public boolean disableVineGrowth;
|
||||
public boolean disableEndermanGriefing;
|
||||
public boolean disableSnowmanTrails;
|
||||
public boolean disableSoilDehydration;
|
||||
public Set<Integer> allowedSnowFallOver;
|
||||
public boolean regionInvinciblityRemovesMobs;
|
||||
public boolean explosionFlagCancellation;
|
||||
public boolean disableDeathMessages;
|
||||
public boolean disableObsidianGenerators;
|
||||
|
||||
private Map<String, Integer> maxRegionCounts;
|
||||
|
||||
|
||||
/* Configuration data end */
|
||||
|
||||
/**
|
||||
@@ -178,7 +197,9 @@ public class WorldConfiguration {
|
||||
config = new YAMLProcessor(configFile, true, YAMLFormat.EXTENDED);
|
||||
loadConfiguration();
|
||||
|
||||
plugin.getLogger().info("Loaded configuration for world '" + worldName + "'");
|
||||
if (summaryOnStart) {
|
||||
plugin.getLogger().info("Loaded configuration for world '" + worldName + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getBoolean(String node, boolean def) {
|
||||
@@ -284,6 +305,7 @@ public class WorldConfiguration {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
summaryOnStart = getBoolean("summary-on-start", true);
|
||||
opPermissions = getBoolean("op-permissions", true);
|
||||
|
||||
itemDurability = getBoolean("protection.item-durability", true);
|
||||
@@ -312,6 +334,7 @@ public class WorldConfiguration {
|
||||
|
||||
noPhysicsGravel = getBoolean("physics.no-physics-gravel", false);
|
||||
noPhysicsSand = getBoolean("physics.no-physics-sand", false);
|
||||
ropeLadders = getBoolean("physics.vine-like-rope-ladders", false);
|
||||
allowPortalAnywhere = getBoolean("physics.allow-portal-anywhere", false);
|
||||
preventWaterDamage = new HashSet<Integer>(getIntList("physics.disable-water-damage-blocks", null));
|
||||
|
||||
@@ -331,13 +354,19 @@ public class WorldConfiguration {
|
||||
blockWitherSkullExplosions = getBoolean("mobs.block-wither-skull-explosions", false);
|
||||
blockWitherSkullBlockDamage = getBoolean("mobs.block-wither-skull-block-damage", false);
|
||||
blockEnderDragonBlockDamage = getBoolean("mobs.block-enderdragon-block-damage", false);
|
||||
blockEnderDragonPortalCreation = getBoolean("mobs.block-enderdragon-portal-creation", false);
|
||||
blockFireballExplosions = getBoolean("mobs.block-fireball-explosions", false);
|
||||
blockFireballBlockDamage = getBoolean("mobs.block-fireball-block-damage", false);
|
||||
antiWolfDumbness = getBoolean("mobs.anti-wolf-dumbness", false);
|
||||
allowTamedSpawns = getBoolean("mobs.allow-tamed-spawns", true);
|
||||
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);
|
||||
blockGroundSlimes = getBoolean("mobs.block-above-ground-slimes", false);
|
||||
blockOtherExplosions = getBoolean("mobs.block-other-explosions", false);
|
||||
blockZombieDoorDestruction = getBoolean("mobs.block-zombie-door-destruction", false);
|
||||
|
||||
disableFallDamage = getBoolean("player-damage.disable-fall-damage", false);
|
||||
disableLavaDamage = getBoolean("player-damage.disable-lava-damage", false);
|
||||
@@ -376,9 +405,13 @@ public class WorldConfiguration {
|
||||
disableLeafDecay = getBoolean("dynamics.disable-leaf-decay", false);
|
||||
disableGrassGrowth = getBoolean("dynamics.disable-grass-growth", false);
|
||||
disableMyceliumSpread = getBoolean("dynamics.disable-mycelium-spread", false);
|
||||
disableVineGrowth = getBoolean("dynamics.disable-vine-growth", false);
|
||||
disableSoilDehydration = getBoolean("dynamics.disable-soil-dehydration", false);
|
||||
allowedSnowFallOver = new HashSet<Integer>(getIntList("dynamics.snow-fall-blocks", null));
|
||||
|
||||
useRegions = getBoolean("regions.enable", true);
|
||||
regionInvinciblityRemovesMobs = getBoolean("regions.invincibility-removes-mobs", false);
|
||||
explosionFlagCancellation = getBoolean("regions.explosion-flags-block-entity-damage", true);
|
||||
highFreqFlags = getBoolean("regions.high-frequency-flags", false);
|
||||
regionWand = getInt("regions.wand", 334);
|
||||
maxClaimVolume = getInt("regions.max-claim-volume", 30000);
|
||||
@@ -448,7 +481,9 @@ public class WorldConfiguration {
|
||||
this.blacklist = null;
|
||||
} else {
|
||||
this.blacklist = blist;
|
||||
plugin.getLogger().log(Level.INFO, "Blacklist loaded.");
|
||||
if (summaryOnStart) {
|
||||
plugin.getLogger().log(Level.INFO, "Blacklist loaded.");
|
||||
}
|
||||
|
||||
BlacklistLogger blacklistLogger = blist.getLogger();
|
||||
|
||||
@@ -474,7 +509,7 @@ public class WorldConfiguration {
|
||||
}
|
||||
|
||||
// Print an overview of settings
|
||||
if (getBoolean("summary-on-start", true)) {
|
||||
if (summaryOnStart) {
|
||||
plugin.getLogger().log(Level.INFO, blockTNTExplosions
|
||||
? "(" + worldName + ") TNT ignition is blocked."
|
||||
: "(" + worldName + ") TNT ignition is PERMITTED.");
|
||||
@@ -559,7 +594,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;
|
||||
@@ -33,27 +34,29 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockExpEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
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.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.events.BlockBreakBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.events.BlockPlaceBlacklistEvent;
|
||||
@@ -139,7 +142,7 @@ public class WorldGuardBlockListener implements Listener {
|
||||
if (held.getTypeId() > 0
|
||||
&& !(ItemType.usesDamageValue(held.getTypeId())
|
||||
|| BlockType.usesData(held.getTypeId()))) {
|
||||
held.setDurability((short) -1);
|
||||
held.setDurability((short) 0);
|
||||
player.setItemInHand(held);
|
||||
}
|
||||
}
|
||||
@@ -338,12 +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.canBuild(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!set.allows(DefaultFlag.LIGHTER, localPlayer)
|
||||
if (!set.allows(DefaultFlag.LIGHTER)
|
||||
&& !set.canBuild(localPlayer)
|
||||
&& !plugin.hasPermission(player, "worldguard.override.lighter")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -363,6 +365,14 @@ public class WorldGuardBlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.FIREBALL && event.getPlayer() == null) {
|
||||
// wtf bukkit, FIREBALL is supposed to be reserved to players
|
||||
if (!set.allows(DefaultFlag.GHAST_FIREBALL)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (cause == IgniteCause.LIGHTNING && !set.allows(DefaultFlag.LIGHTNING)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -472,6 +482,13 @@ public class WorldGuardBlockListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.ropeLadders && event.getBlock().getType() == Material.LADDER) {
|
||||
if (event.getBlock().getRelative(0, 1, 0).getType() == Material.LADDER) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -668,6 +685,16 @@ public class WorldGuardBlockListener implements Listener {
|
||||
|
||||
int type = event.getNewState().getTypeId();
|
||||
|
||||
if (event instanceof EntityBlockFormEvent) {
|
||||
if (((EntityBlockFormEvent) event).getEntity() instanceof Snowman) {
|
||||
if (wcfg.disableSnowmanTrails) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == BlockID.ICE) {
|
||||
if (wcfg.disableIceFormation) {
|
||||
event.setCancelled(true);
|
||||
@@ -685,6 +712,14 @@ public class WorldGuardBlockListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.allowedSnowFallOver.size() > 0) {
|
||||
int targetId = event.getBlock().getRelative(0, -1, 0).getTypeId();
|
||||
|
||||
if (!wcfg.allowedSnowFallOver.contains(targetId)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.SNOW_FALL, event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
@@ -745,6 +780,20 @@ public class WorldGuardBlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (fromType == BlockID.VINE) {
|
||||
if (wcfg.disableVineGrowth) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions
|
||||
&& !plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.VINE_GROWTH, event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -756,31 +805,46 @@ public class WorldGuardBlockListener implements Listener {
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
|
||||
|
||||
int type = event.getBlock().getTypeId();
|
||||
|
||||
if (type == BlockID.ICE) {
|
||||
switch (event.getBlock().getTypeId()) {
|
||||
case BlockID.ICE:
|
||||
if (wcfg.disableIceMelting) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.ICE_MELT, event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
if (type == BlockID.SNOW) {
|
||||
case BlockID.SNOW:
|
||||
if (wcfg.disableSnowMelting) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.SNOW_MELT, event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case BlockID.SOIL:
|
||||
if (wcfg.disableSoilDehydration) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.SOIL_DRY, event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -832,8 +896,8 @@ public class WorldGuardBlockListener implements Listener {
|
||||
|
||||
if (wcfg.blockPotions.size() > 0) {
|
||||
ItemStack item = event.getItem();
|
||||
if (item.getType() == Material.POTION) {
|
||||
Potion potion = Potion.fromItemStack(item);
|
||||
if (item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
|
||||
Potion potion = Potion.fromDamage(BukkitUtil.getPotionEffectBits(item));
|
||||
for (PotionEffect effect : potion.getEffects()) {
|
||||
if (potion.isSplash() && wcfg.blockPotions.contains(effect.getType())) {
|
||||
event.setCancelled(true);
|
||||
@@ -843,4 +907,18 @@ public class WorldGuardBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a block yields exp
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockExp(BlockExpEvent event) {
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());
|
||||
if (wcfg.disableExpDrops || !plugin.getGlobalRegionManager().allows(DefaultFlag.EXP_DROPS,
|
||||
event.getBlock().getLocation())) {
|
||||
event.setExpToDrop(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,10 +24,8 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
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,20 +33,27 @@ import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.entity.WitherSkull;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.CreeperPowerEvent;
|
||||
import org.bukkit.event.entity.EntityBreakDoorEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityCreatePortalEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@@ -57,6 +62,7 @@ import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.ExpBottleEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PigZapEvent;
|
||||
@@ -83,9 +89,6 @@ import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
public class WorldGuardEntityListener implements Listener {
|
||||
|
||||
private WorldGuardPlugin plugin;
|
||||
private EntityType fireballType;
|
||||
private EntityType witherType;
|
||||
private EntityType witherSkullType;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
@@ -94,10 +97,6 @@ public class WorldGuardEntityListener implements Listener {
|
||||
*/
|
||||
public WorldGuardEntityListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
fireballType = BukkitUtil.tryEnum(EntityType.class, "LARGE_FIREBALL", "FIREBALL");
|
||||
witherType = BukkitUtil.tryEnum(EntityType.class, "WITHER");
|
||||
witherSkullType = BukkitUtil.tryEnum(EntityType.class, "WITHER_SKULL");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,12 +115,24 @@ public class WorldGuardEntityListener implements Listener {
|
||||
WorldConfiguration wcfg = cfg.get(entity.getWorld());
|
||||
|
||||
if (block.getTypeId() == BlockID.SOIL) {
|
||||
if (entity instanceof Creature && wcfg.disableCreatureCropTrampling) {
|
||||
if (/* entity instanceof Creature && // catch for any entity (not thrown for players) */
|
||||
wcfg.disableCreatureCropTrampling) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onExpBottle(ExpBottleEvent event) {
|
||||
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(event.getEntity().getWorld());
|
||||
|
||||
if (wcfg.disableExpDrops || !plugin.getGlobalRegionManager().allows(DefaultFlag.EXP_DROPS,
|
||||
event.getEntity().getLocation())) {
|
||||
event.setExperience(0);
|
||||
// event.setShowEffect(false); // don't want to cancel the bottle entirely I suppose, just the exp
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(event.getEntity().getWorld());
|
||||
@@ -178,7 +189,21 @@ public class WorldGuardEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableExplosionDamage && type == DamageCause.BLOCK_EXPLOSION) {
|
||||
if (type == DamageCause.BLOCK_EXPLOSION
|
||||
&& (wcfg.disableExplosionDamage || wcfg.blockOtherExplosions
|
||||
|| (wcfg.explosionFlagCancellation
|
||||
&& !plugin.getGlobalRegionManager().allows(DefaultFlag.OTHER_EXPLOSION, player.getLocation())))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
// for whatever reason, plugin-caused explosions with a null entity count as block explosions and aren't
|
||||
// handled anywhere else
|
||||
if (type == DamageCause.BLOCK_EXPLOSION
|
||||
&& (wcfg.blockOtherExplosions
|
||||
|| (wcfg.explosionFlagCancellation
|
||||
&& !plugin.getGlobalRegionManager().allows(DefaultFlag.OTHER_EXPLOSION, defender.getLocation())))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -215,6 +240,13 @@ public class WorldGuardEntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (defender instanceof ItemFrame) {
|
||||
if (checkItemFrameProtection(attacker, (ItemFrame) defender)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
@@ -238,97 +270,129 @@ public class WorldGuardEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableExplosionDamage && event.getCause() == DamageCause.ENTITY_EXPLOSION) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
if (wcfg.disableExplosionDamage) {
|
||||
switch (event.getCause()) {
|
||||
case BLOCK_EXPLOSION:
|
||||
case ENTITY_EXPLOSION:
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
Vector pt2 = toVector(attacker.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
if (attacker != null) {
|
||||
if (attacker instanceof Player) {
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
Vector pt2 = toVector(attacker.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer((Player) attacker))) {
|
||||
tryCancelPVPEvent((Player) attacker, player, event, true);
|
||||
} else if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.PVP ,localPlayer)) {
|
||||
tryCancelPVPEvent((Player) attacker, player, event, false);
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer((Player) attacker))) {
|
||||
tryCancelPVPEvent((Player) attacker, player, event, true);
|
||||
} else if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.PVP ,localPlayer)) {
|
||||
tryCancelPVPEvent((Player) attacker, player, event, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null && attacker instanceof TNTPrimed) {
|
||||
if (wcfg.blockTNTExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
if (!set.allows(DefaultFlag.TNT, localPlayer)) {
|
||||
if (attacker instanceof TNTPrimed || attacker instanceof ExplosiveMinecart) {
|
||||
|
||||
// The check for explosion damage should be handled already... But... What ever...
|
||||
if (wcfg.blockTNTExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && wcfg.explosionFlagCancellation) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
if (!set.allows(DefaultFlag.TNT, localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null && attacker instanceof Fireball) {
|
||||
if (wcfg.blockFireballExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
Fireball fireball = (Fireball) attacker;
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
if (fireball.getShooter() instanceof Player) {
|
||||
Vector pt2 = toVector(fireball.getShooter().getLocation());
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer((Player) fireball.getShooter()))) {
|
||||
tryCancelPVPEvent((Player) fireball.getShooter(), player, event, true);
|
||||
} else if (!set.allows(DefaultFlag.PVP, localPlayer)) {
|
||||
tryCancelPVPEvent((Player) fireball.getShooter(), player, event, false);
|
||||
if (attacker instanceof Fireball) {
|
||||
if (attacker instanceof WitherSkull) {
|
||||
if (wcfg.blockWitherSkullExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!set.allows(DefaultFlag.GHAST_FIREBALL, localPlayer)) {
|
||||
if (wcfg.blockFireballExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
Fireball fireball = (Fireball) attacker;
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
if (fireball.getShooter() instanceof Player) {
|
||||
Vector pt2 = toVector(fireball.getShooter().getLocation());
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer((Player) fireball.getShooter()))) {
|
||||
tryCancelPVPEvent((Player) fireball.getShooter(), player, event, true);
|
||||
} else if (!set.allows(DefaultFlag.PVP, localPlayer)) {
|
||||
tryCancelPVPEvent((Player) fireball.getShooter(), player, event, false);
|
||||
}
|
||||
} else {
|
||||
if (!set.allows(DefaultFlag.GHAST_FIREBALL, localPlayer) && wcfg.explosionFlagCancellation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null && attacker instanceof LivingEntity && !(attacker instanceof Player)) {
|
||||
if (attacker instanceof Creeper && wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.disableMobDamage) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!set.allows(DefaultFlag.MOB_DAMAGE, localPlayer)) {
|
||||
if (attacker instanceof LivingEntity && !(attacker instanceof Player)) {
|
||||
if (attacker instanceof Creeper && wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Creeper) {
|
||||
if (!set.allows(DefaultFlag.CREEPER_EXPLOSION, localPlayer)) {
|
||||
if (wcfg.disableMobDamage) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!set.allows(DefaultFlag.MOB_DAMAGE, localPlayer) && !(attacker instanceof Tameable)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Creeper) {
|
||||
if (!set.allows(DefaultFlag.CREEPER_EXPLOSION, localPlayer) && wcfg.explosionFlagCancellation) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (attacker instanceof Tameable) {
|
||||
if (((Tameable) attacker).getOwner() == null) {
|
||||
if (!set.allows(DefaultFlag.MOB_DAMAGE, localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!(((Tameable) attacker).getOwner() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player beastMaster = (Player) ((Tameable) attacker).getOwner();
|
||||
Vector pt2 = toVector(attacker.getLocation());
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer(beastMaster))) {
|
||||
tryCancelPVPEvent(beastMaster, player, event, true);
|
||||
} else if (!set.allows(DefaultFlag.PVP, localPlayer)) {
|
||||
tryCancelPVPEvent(beastMaster, player, event, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,7 +415,7 @@ public class WorldGuardEntityListener implements Listener {
|
||||
}
|
||||
|
||||
// Check Mob
|
||||
if (attacker != null && attacker instanceof LivingEntity && !(attacker instanceof Player)) {
|
||||
if (attacker != null && !(attacker instanceof Player)) {
|
||||
if (wcfg.disableMobDamage) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -368,8 +432,9 @@ public class WorldGuardEntityListener implements Listener {
|
||||
}
|
||||
|
||||
// Check Player
|
||||
if (event.getDamager() instanceof EnderPearl) return;
|
||||
// if (event.getDamager() instanceof EnderPearl || event.getDamager() instanceof Snowball) return;
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
if (event.getDamager() instanceof EnderPearl && attacker == player) return;
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
Vector pt2 = toVector(attacker.getLocation());
|
||||
@@ -382,6 +447,11 @@ public class WorldGuardEntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (defender instanceof ItemFrame) {
|
||||
if (checkItemFrameProtection(attacker, (ItemFrame) defender)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -417,6 +487,25 @@ public class WorldGuardEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == DamageCause.WITHER) {
|
||||
// wither boss DoT tick
|
||||
if (wcfg.disableMobDamage) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
if (!set.allows(DefaultFlag.MOB_DAMAGE, plugin.wrapPlayer(player))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == DamageCause.DROWNING && cfg.hasAmphibiousMode(player)) {
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
@@ -451,7 +540,7 @@ public class WorldGuardEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.teleportOnSuffocation && type == DamageCause.SUFFOCATION) {
|
||||
if (wcfg.teleportOnSuffocation && type == DamageCause.SUFFOCATION) {
|
||||
BukkitUtil.findFreePosition(player);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -493,121 +582,132 @@ public class WorldGuardEntityListener implements Listener {
|
||||
Entity ent = event.getEntity();
|
||||
|
||||
if (cfg.activityHaltToggle) {
|
||||
ent.remove();
|
||||
if (ent != null) {
|
||||
ent.remove();
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// Not all explosions come from an entity
|
||||
if (ent != null) {
|
||||
if (ent.getType() == witherType) {
|
||||
if (wcfg.blockWitherBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.blockWitherExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (ent instanceof Creeper) {
|
||||
if (wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.blockCreeperBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ent.getType() == witherSkullType) {
|
||||
if (wcfg.blockWitherSkullBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.CREEPER_EXPLOSION)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ent instanceof EnderDragon) {
|
||||
if (wcfg.blockEnderDragonBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ent instanceof TNTPrimed || ent instanceof ExplosiveMinecart) {
|
||||
if (wcfg.blockTNTExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.blockTNTBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.TNT)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ent instanceof Fireball) {
|
||||
if (ent instanceof WitherSkull) {
|
||||
if (wcfg.blockWitherSkullExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ent instanceof Creeper) {
|
||||
if (wcfg.blockCreeperBlockDamage) {
|
||||
if (wcfg.blockWitherSkullBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.CREEPER_EXPLOSION)) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ent instanceof EnderDragon) {
|
||||
if (wcfg.blockEnderDragonBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.ENDERDRAGON_BLOCK_DAMAGE)) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ent instanceof TNTPrimed) {
|
||||
if (wcfg.blockTNTBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.blockTNTExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.TNT)) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ent instanceof Fireball) {
|
||||
if (wcfg.blockFireballBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (wcfg.blockFireballExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.blockFireballBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// allow wither skull blocking since there is no dedicated flag atm
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.GHAST_FIREBALL)) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.GHAST_FIREBALL)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ent instanceof Wither) {
|
||||
if (wcfg.blockWitherExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.blockWitherBlockDamage) {
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// unhandled entity
|
||||
if (wcfg.blockOtherExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
for (Block block : event.blockList()) {
|
||||
if (!mgr.getApplicableRegions(toVector(block)).allows(DefaultFlag.OTHER_EXPLOSION)) {
|
||||
event.blockList().clear();
|
||||
if (wcfg.explosionFlagCancellation) event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (wcfg.signChestProtection) {
|
||||
for (Block block : event.blockList()) {
|
||||
if (wcfg.isChestProtected(block)) {
|
||||
@@ -634,31 +734,28 @@ public class WorldGuardEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getEntityType() == witherType) {
|
||||
if (event.getEntityType() == EntityType.WITHER) {
|
||||
if (wcfg.blockWitherExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (event.getEntityType() == witherSkullType) {
|
||||
} else if (event.getEntityType() == EntityType.WITHER_SKULL) {
|
||||
if (wcfg.blockWitherSkullExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (event.getEntityType() == fireballType) {
|
||||
} else if (event.getEntityType() == EntityType.FIREBALL) {
|
||||
if (wcfg.blockFireballExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (event.getEntityType() == EntityType.CREEPER) {
|
||||
} else if (event.getEntityType() == EntityType.CREEPER) {
|
||||
if (wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (event.getEntityType() == EntityType.PRIMED_TNT) {
|
||||
} else if (event.getEntityType() == EntityType.PRIMED_TNT
|
||||
|| event.getEntityType() == EntityType.MINECART_TNT) {
|
||||
if (wcfg.blockTNTExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -678,8 +775,15 @@ public class WorldGuardEntityListener implements Listener {
|
||||
WorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||
|
||||
// allow spawning of creatures from plugins
|
||||
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM)
|
||||
if (!wcfg.blockPluginSpawning && event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.allowTamedSpawns
|
||||
&& event.getEntity() instanceof Tameable // nullsafe check
|
||||
&& ((Tameable) event.getEntity()).isTamed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityType entityType = event.getEntityType();
|
||||
|
||||
@@ -708,6 +812,25 @@ public class WorldGuardEntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.blockGroundSlimes && entityType == EntityType.SLIME
|
||||
&& eventLoc.getY() >= 60
|
||||
&& event.getSpawnReason() == SpawnReason.NATURAL) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onCreatePortal(EntityCreatePortalEvent event) {
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||
|
||||
switch (event.getEntityType()) {
|
||||
case ENDER_DRAGON:
|
||||
if (wcfg.blockEnderDragonPortalCreation) event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
@@ -746,58 +869,40 @@ public class WorldGuardEntityListener implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when an enderman picks up or puts down a block and some other cases.
|
||||
* Called when an entity changes a block somehow
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEndermanPickup(EntityChangeBlockEvent event) {
|
||||
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
||||
Entity ent = event.getEntity();
|
||||
Block block = event.getBlock();
|
||||
Location location = block.getLocation();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(ent.getWorld());
|
||||
if (ent instanceof Enderman) {
|
||||
if (event.getTo() == Material.AIR) {
|
||||
// pickup
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(ent.getWorld());
|
||||
if (wcfg.disableEndermanGriefing) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableEndermanGriefing) {
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.ENDER_BUILD, location)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.ENDER_BUILD, location)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// place
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(ent.getWorld());
|
||||
|
||||
if (wcfg.disableEndermanGriefing) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.ENDER_BUILD, location)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (ent.getType() == witherType) {
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(ent.getWorld());
|
||||
|
||||
} else if (ent.getType() == EntityType.WITHER) {
|
||||
if (wcfg.blockWitherBlockDamage || wcfg.blockWitherExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (/*ent instanceof Zombie && */event instanceof EntityBreakDoorEvent) {
|
||||
if (wcfg.blockZombieDoorDestruction) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -899,4 +1004,41 @@ public class WorldGuardEntityListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks regions and config settings to protect items from being knocked
|
||||
* out of item frames.
|
||||
* @param attacker attacking entity
|
||||
* @param defender item frame being damaged
|
||||
* @return true if the event should be cancelled
|
||||
*/
|
||||
private boolean checkItemFrameProtection(Entity attacker, ItemFrame defender) {
|
||||
World world = attacker.getWorld();
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
if (wcfg.useRegions) {
|
||||
// bukkit throws this event when a player attempts to remove an item from a frame
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
if (attacker instanceof Player) {
|
||||
Player player = (Player) attacker;
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !mgr.getApplicableRegions(defender.getLocation())
|
||||
.canBuild(localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.ENTITY_ITEM_FRAME_DESTROY, defender.getLocation())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (wcfg.blockEntityItemFrameDestroy && !(attacker instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,11 +30,13 @@ import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
@@ -69,64 +71,77 @@ public class WorldGuardHangingListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onHangingingBreak(HangingBreakEvent breakEvent) {
|
||||
if (!(breakEvent instanceof HangingBreakByEntityEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
HangingBreakByEntityEvent event = (HangingBreakByEntityEvent) breakEvent;
|
||||
public void onHangingingBreak(HangingBreakEvent event) {
|
||||
Hanging hanging = event.getEntity();
|
||||
World world = hanging.getWorld();
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (event.getRemover() instanceof Player) {
|
||||
Player player = (Player) event.getRemover();
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
if (hanging instanceof Painting
|
||||
&& !wcfg.getBlacklist().check(
|
||||
new BlockBreakBlacklistEvent(plugin.wrapPlayer(player),
|
||||
toVector(player.getLocation()), ItemID.PAINTING), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (hanging instanceof ItemFrame
|
||||
&& !wcfg.getBlacklist().check(
|
||||
new BlockBreakBlacklistEvent(plugin.wrapPlayer(player),
|
||||
toVector(player.getLocation()), ItemID.ITEM_FRAME), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (event instanceof HangingBreakByEntityEvent) {
|
||||
HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent) event;
|
||||
Entity removerEntity = entityEvent.getRemover();
|
||||
if (removerEntity instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) removerEntity;
|
||||
removerEntity = projectile.getShooter() != null ? projectile.getShooter() : removerEntity;
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, hanging.getLocation())) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
if (removerEntity instanceof Player) {
|
||||
Player player = (Player) removerEntity;
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
if (hanging instanceof Painting
|
||||
&& !wcfg.getBlacklist().check(
|
||||
new BlockBreakBlacklistEvent(plugin.wrapPlayer(player),
|
||||
toVector(player.getLocation()), ItemID.PAINTING), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (hanging instanceof ItemFrame
|
||||
&& !wcfg.getBlacklist().check(
|
||||
new BlockBreakBlacklistEvent(plugin.wrapPlayer(player),
|
||||
toVector(player.getLocation()), ItemID.ITEM_FRAME), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, hanging.getLocation())) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (removerEntity instanceof Creeper) {
|
||||
if (wcfg.blockCreeperBlockDamage || wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(DefaultFlag.CREEPER_EXPLOSION, hanging.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (hanging instanceof Painting
|
||||
&& (wcfg.blockEntityPaintingDestroy
|
||||
|| (wcfg.useRegions
|
||||
&& !plugin.getGlobalRegionManager().allows(DefaultFlag.ENTITY_PAINTING_DESTROY, hanging.getLocation())))) {
|
||||
event.setCancelled(true);
|
||||
} else if (hanging instanceof ItemFrame
|
||||
&& (wcfg.blockEntityItemFrameDestroy
|
||||
|| (wcfg.useRegions
|
||||
&& !plugin.getGlobalRegionManager().allows(DefaultFlag.ENTITY_ITEM_FRAME_DESTROY, hanging.getLocation())))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (event.getRemover() instanceof Creeper) {
|
||||
if (wcfg.blockCreeperBlockDamage || wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(DefaultFlag.CREEPER_EXPLOSION, hanging.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (hanging instanceof Painting
|
||||
&& (wcfg.blockEntityPaintingDestroy
|
||||
|| (wcfg.useRegions
|
||||
&& !plugin.getGlobalRegionManager().allows(DefaultFlag.ENTITY_PAINTING_DESTROY, hanging.getLocation())))) {
|
||||
// Explosions from mobs are not covered by HangingBreakByEntity
|
||||
if (hanging instanceof Painting && wcfg.blockEntityPaintingDestroy
|
||||
&& event.getCause() == RemoveCause.EXPLOSION) {
|
||||
event.setCancelled(true);
|
||||
} else if (hanging instanceof ItemFrame
|
||||
&& (wcfg.blockEntityItemFrameDestroy
|
||||
|| (wcfg.useRegions
|
||||
&& !plugin.getGlobalRegionManager().allows(DefaultFlag.ENTITY_ITEM_FRAME_DESTROY, hanging.getLocation())))) {
|
||||
} else if (hanging instanceof ItemFrame && wcfg.blockEntityItemFrameDestroy
|
||||
&& event.getCause() == RemoveCause.EXPLOSION) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -159,7 +174,7 @@ public class WorldGuardHangingListener implements Listener {
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, placedOn.getLocation())) {
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, placedOn.getRelative(event.getBlockFace()))) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -181,16 +196,16 @@ public class WorldGuardHangingListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity instanceof ItemFrame
|
||||
&& ((!plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.ENTITY_ITEM_FRAME_DESTROY, entity.getLocation())))) {
|
||||
event.setCancelled(true);
|
||||
} else if (entity instanceof Painting
|
||||
&& ((!plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.ENTITY_PAINTING_DESTROY, entity.getLocation())))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// if (entity instanceof ItemFrame
|
||||
// && ((!plugin.getGlobalRegionManager().allows(
|
||||
// DefaultFlag.ENTITY_ITEM_FRAME_DESTROY, entity.getLocation())))) {
|
||||
// event.setCancelled(true);
|
||||
// } else if (entity instanceof Painting
|
||||
// && ((!plugin.getGlobalRegionManager().allows(
|
||||
// DefaultFlag.ENTITY_PAINTING_DESTROY, entity.getLocation())))) {
|
||||
// event.setCancelled(true);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
||||
import org.bukkit.event.painting.PaintingBreakEvent;
|
||||
import org.bukkit.event.painting.PaintingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import com.sk89q.worldedit.blocks.ItemID;
|
||||
import com.sk89q.worldguard.blacklist.events.BlockBreakBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.events.ItemUseBlacklistEvent;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
|
||||
/**
|
||||
* Listener for painting related events.
|
||||
*
|
||||
* @author sk89q
|
||||
* @deprecated Use {@link com.sk89q.worldguard.bukkit.WorldGuardHangingListener} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Warning(reason="This listener has been replaced by WorldGuardHangingListener")
|
||||
public class WorldGuardPaintingListener implements Listener {
|
||||
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin The plugin instance
|
||||
*/
|
||||
public WorldGuardPaintingListener(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register events.
|
||||
*/
|
||||
public void registerEvents() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPaintingBreak(PaintingBreakEvent breakEvent) {
|
||||
if (!(breakEvent instanceof PaintingBreakByEntityEvent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
PaintingBreakByEntityEvent event = (PaintingBreakByEntityEvent) breakEvent;
|
||||
Painting painting = event.getPainting();
|
||||
World world = painting.getWorld();
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (event.getRemover() instanceof Player) {
|
||||
Player player = (Player) event.getRemover();
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new BlockBreakBlacklistEvent(plugin.wrapPlayer(player),
|
||||
toVector(player.getLocation()), ItemID.PAINTING), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, painting.getLocation())) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (event.getRemover() instanceof Creeper) {
|
||||
if (wcfg.blockCreeperBlockDamage || wcfg.blockCreeperExplosions) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(DefaultFlag.CREEPER_EXPLOSION, painting.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.blockEntityPaintingDestroy
|
||||
|| (wcfg.useRegions
|
||||
&& !plugin.getGlobalRegionManager().allows(DefaultFlag.ENTITY_PAINTING_DESTROY, painting.getLocation()))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPaintingPlace(PaintingPlaceEvent event) {
|
||||
Block placedOn = event.getBlock();
|
||||
Player player = event.getPlayer();
|
||||
World world = placedOn.getWorld();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemUseBlacklistEvent(plugin.wrapPlayer(player),
|
||||
toVector(player.getLocation()), ItemID.PAINTING), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, placedOn.getLocation())) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onEntityInteract(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Entity entity = event.getRightClicked();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(entity.getWorld());
|
||||
|
||||
if (wcfg.useRegions && entity instanceof Painting) {
|
||||
if (!plugin.getGlobalRegionManager().canBuild(player, entity.getLocation())) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity instanceof Painting
|
||||
&& ((!plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.ENTITY_PAINTING_DESTROY, entity.getLocation())))) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,14 +22,15 @@ import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.ItemID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -44,7 +45,9 @@ import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -53,12 +56,17 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.blocks.ItemID;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.events.BlockBreakBlacklistEvent;
|
||||
import com.sk89q.worldguard.blacklist.events.BlockInteractBlacklistEvent;
|
||||
@@ -77,6 +85,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
*/
|
||||
public class WorldGuardPlayerListener implements Listener {
|
||||
|
||||
private Pattern opPattern = Pattern.compile("^/op(?:\\s.*)?$", Pattern.CASE_INSENSITIVE);
|
||||
private WorldGuardPlugin plugin;
|
||||
|
||||
/**
|
||||
@@ -100,6 +109,173 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// unsure if anyone actually started using this yet, but just in case...
|
||||
@Deprecated
|
||||
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.
|
||||
* A reference to WorldGuardPlugin is required to keep this method static
|
||||
* although WGBukkit.getPlugin() may be used.
|
||||
* @return true if the movement should not be allowed
|
||||
*/
|
||||
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(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(toWorld);
|
||||
Vector pt = new Vector(to.getBlockX(), to.getBlockY(), to.getBlockZ());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
/*
|
||||
// check if region is full
|
||||
// get the lowest number of allowed members in any region
|
||||
boolean regionFull = false;
|
||||
String maxPlayerMessage = null;
|
||||
if (!hasBypass) {
|
||||
for (ProtectedRegion region : set) {
|
||||
if (region instanceof GlobalProtectedRegion) {
|
||||
continue; // global region can't have a max
|
||||
}
|
||||
// get the max for just this region
|
||||
Integer maxPlayers = region.getFlag(DefaultFlag.MAX_PLAYERS);
|
||||
if (maxPlayers == null) {
|
||||
continue;
|
||||
}
|
||||
int occupantCount = 0;
|
||||
for(Player occupant : world.getPlayers()) {
|
||||
// each player in this region counts as one toward the max of just this region
|
||||
// A person with bypass doesn't count as an occupant of the region
|
||||
if (!occupant.equals(player) && !plugin.getGlobalRegionManager().hasBypass(occupant, world)) {
|
||||
if (region.contains(BukkitUtil.toVector(occupant.getLocation()))) {
|
||||
if (++occupantCount >= maxPlayers) {
|
||||
regionFull = true;
|
||||
maxPlayerMessage = region.getFlag(DefaultFlag.MAX_PLAYERS_MESSAGE);
|
||||
// At least one region in the set is full, we are going to use this message because it
|
||||
// was the first one we detected as full. In reality we should check them all and then
|
||||
// resolve the message from full regions, but that is probably a lot laggier (and this
|
||||
// is already pretty laggy. In practice, we can't really control which one we get first
|
||||
// right here.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
boolean entryAllowed = set.allows(DefaultFlag.ENTRY, localPlayer);
|
||||
if (!hasRemoteBypass && (!entryAllowed /*|| regionFull*/)) {
|
||||
String message = /*maxPlayerMessage != null ? maxPlayerMessage :*/ "You are not permitted to enter this area.";
|
||||
|
||||
player.sendMessage(ChatColor.DARK_RED + message);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Have to set this state
|
||||
if (state.lastExitAllowed == null) {
|
||||
state.lastExitAllowed = plugin.getGlobalRegionManager().get(world)
|
||||
.getApplicableRegions(toVector(from))
|
||||
.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.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// WorldGuardRegionMoveEvent event = new WorldGuardRegionMoveEvent(plugin, player, state, set, from, to);
|
||||
// Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
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);
|
||||
GameMode gameMode = set.getFlag(DefaultFlag.GAME_MODE);
|
||||
|
||||
if (state.lastFarewell != null && (farewell == null
|
||||
|| !state.lastFarewell.equals(farewell))) {
|
||||
String replacedFarewell = plugin.replaceMacros(
|
||||
player, BukkitUtil.replaceColorMacros(state.lastFarewell));
|
||||
player.sendMessage(replacedFarewell.replaceAll("\\\\n", "\n").split("\\n"));
|
||||
}
|
||||
|
||||
if (greeting != null && (state.lastGreeting == null
|
||||
|| !state.lastGreeting.equals(greeting))) {
|
||||
String replacedGreeting = plugin.replaceMacros(
|
||||
player, BukkitUtil.replaceColorMacros(greeting));
|
||||
player.sendMessage(replacedGreeting.replaceAll("\\\\n", "\n").split("\\n"));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (!hasBypass && gameMode != null) {
|
||||
if (player.getGameMode() != gameMode) {
|
||||
state.lastGameMode = player.getGameMode();
|
||||
player.setGameMode(gameMode);
|
||||
} else if (state.lastGameMode == null) {
|
||||
state.lastGameMode = player.getServer().getDefaultGameMode();
|
||||
}
|
||||
} else {
|
||||
if (state.lastGameMode != null) {
|
||||
GameMode mode = state.lastGameMode;
|
||||
state.lastGameMode = null;
|
||||
player.setGameMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
state.lastGreeting = greeting;
|
||||
state.lastFarewell = farewell;
|
||||
state.notifiedForEnter = notifyEnter;
|
||||
state.notifiedForLeave = notifyLeave;
|
||||
state.lastExitAllowed = exitAllowed;
|
||||
state.lastWorld = to.getWorld();
|
||||
state.lastBlockX = to.getBlockX();
|
||||
state.lastBlockY = to.getBlockY();
|
||||
state.lastBlockZ = to.getBlockZ();
|
||||
return false;
|
||||
}
|
||||
|
||||
class PlayerMoveHandler implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
@@ -109,134 +285,26 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (player.getVehicle() != null) return; // handled in vehicle listener
|
||||
if (player.getVehicle() != null) {
|
||||
return; // handled in vehicle listener
|
||||
}
|
||||
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);
|
||||
|
||||
//Flush states in multiworld scenario
|
||||
if (state.lastWorld != null && !state.lastWorld.equals(world)) {
|
||||
plugin.getFlagStateManager().forget(player);
|
||||
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) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You are not permitted to enter this area.");
|
||||
|
||||
boolean result = checkMove(plugin, player, event.getFrom(), event.getTo());
|
||||
if (result) {
|
||||
Location newLoc = event.getFrom();
|
||||
newLoc.setX(newLoc.getBlockX() + 0.5);
|
||||
newLoc.setY(newLoc.getBlockY());
|
||||
newLoc.setZ(newLoc.getBlockZ() + 0.5);
|
||||
event.setTo(newLoc);
|
||||
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.");
|
||||
|
||||
Location newLoc = event.getFrom();
|
||||
newLoc.setX(newLoc.getBlockX() + 0.5);
|
||||
newLoc.setY(newLoc.getBlockY());
|
||||
newLoc.setZ(newLoc.getBlockZ() + 0.5);
|
||||
event.setTo(newLoc);
|
||||
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);
|
||||
GameMode gameMode = set.getFlag(DefaultFlag.GAME_MODE);
|
||||
|
||||
if (state.lastFarewell != null && (farewell == null
|
||||
|| !state.lastFarewell.equals(farewell))) {
|
||||
String replacedFarewell = plugin.replaceMacros(
|
||||
player, BukkitUtil.replaceColorMacros(state.lastFarewell));
|
||||
for (String line : replacedFarewell.split("\n")) {
|
||||
player.sendMessage(ChatColor.AQUA + " ** " + line);
|
||||
}
|
||||
}
|
||||
|
||||
if (greeting != null && (state.lastGreeting == null
|
||||
|| !state.lastGreeting.equals(greeting))) {
|
||||
String replacedGreeting = plugin.replaceMacros(
|
||||
player, BukkitUtil.replaceColorMacros(greeting));
|
||||
for (String line : replacedGreeting.split("\n")) {
|
||||
player.sendMessage(ChatColor.AQUA + " ** " + line);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (!hasBypass && gameMode != null) {
|
||||
if (player.getGameMode() != gameMode) {
|
||||
state.lastGameMode = player.getGameMode();
|
||||
player.setGameMode(gameMode);
|
||||
} else if (state.lastGameMode == null) {
|
||||
state.lastGameMode = player.getServer().getDefaultGameMode();
|
||||
}
|
||||
} else {
|
||||
if (state.lastGameMode != null) {
|
||||
GameMode mode = state.lastGameMode;
|
||||
state.lastGameMode = null;
|
||||
player.setGameMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
@@ -248,8 +316,6 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
if (plugin.getFlagStateManager().getState(player).lastGameMode != null
|
||||
&& gameMode != null && event.getNewGameMode() != gameMode) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + "Your game mode is locked to "
|
||||
+ gameMode + "in this region!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -349,6 +415,10 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (cfg.deopOnJoin) {
|
||||
player.setOp(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -393,6 +463,27 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
plugin.forgetPlayer(player);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
// TODO reduce duplication with right-click-air
|
||||
Player player = event.getPlayer();
|
||||
World world = player.getWorld();
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemUseBlacklistEvent(plugin.wrapPlayer(player),
|
||||
toVector(player.getLocation()),
|
||||
item.getTypeId()), false, false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@@ -425,10 +516,10 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
|
||||
if (wcfg.blockPotions.size() > 0) {
|
||||
ItemStack item = event.getItem();
|
||||
if (item.getType() == Material.POTION) {
|
||||
if (item != null && item.getType() == Material.POTION && !BukkitUtil.isWaterPotion(item)) {
|
||||
PotionEffect blockedEffect = null;
|
||||
|
||||
Potion potion = Potion.fromItemStack(item);
|
||||
Potion potion = Potion.fromDamage(BukkitUtil.getPotionEffectBits(item));
|
||||
for (PotionEffect effect : potion.getEffects()) {
|
||||
if (wcfg.blockPotions.contains(effect.getType())) {
|
||||
blockedEffect = effect;
|
||||
@@ -440,9 +531,9 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
if (plugin.hasPermission(player, "worldguard.override.potions")) {
|
||||
if (potion.isSplash() && wcfg.blockPotionsAlways) {
|
||||
player.sendMessage(ChatColor.RED + "Sorry, potions with " +
|
||||
blockedEffect.getType().getName() +
|
||||
" can't be thrown, even if you have a permission to " +
|
||||
"bypass it, due to limitations (and because overly-reliable potion blocking is on).");
|
||||
blockedEffect.getType().getName() + " can't be thrown, " +
|
||||
"even if you have a permission to bypass it, " +
|
||||
"due to limitations (and because overly-reliable potion blocking is on).");
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
return;
|
||||
}
|
||||
@@ -490,7 +581,7 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (type == BlockID.STONE_BUTTON
|
||||
/*if (type == BlockID.STONE_BUTTON
|
||||
|| type == BlockID.LEVER
|
||||
|| type == BlockID.WOODEN_DOOR
|
||||
|| type == BlockID.TRAP_DOOR
|
||||
@@ -503,11 +594,22 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (type == BlockID.DRAGON_EGG) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to move dragon eggs here!");
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (block.getRelative(event.getBlockFace()).getTypeId() == BlockID.FIRE) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
&& !mgr.getApplicableRegions(block.getRelative(event.getBlockFace())
|
||||
.getLocation()).canBuild(localPlayer)) {
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -537,10 +639,6 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
* @param event Thrown event
|
||||
*/
|
||||
private void handleAirRightClick(PlayerInteractEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
World world = player.getWorld();
|
||||
ItemStack item = player.getItemInHand();
|
||||
@@ -586,8 +684,7 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
|| type == BlockID.FURNACE
|
||||
|| type == BlockID.BURNING_FURNACE
|
||||
|| type == BlockID.BREWING_STAND
|
||||
|| type == BlockID.ENCHANTMENT_TABLE
|
||||
|| type == BlockID.CAULDRON)
|
||||
|| type == BlockID.ENCHANTMENT_TABLE)
|
||||
&& wcfg.removeInfiniteStacks
|
||||
&& !plugin.hasPermission(player, "worldguard.override.infinite-stack")) {
|
||||
for (int slot = 0; slot < 40; slot++) {
|
||||
@@ -602,7 +699,9 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
if (wcfg.useRegions) {
|
||||
Vector pt = toVector(block);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
Block placedIn = block.getRelative(event.getBlockFace());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet placedInSet = mgr.getApplicableRegions(placedIn.getLocation());
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (item.getTypeId() == wcfg.regionWand && plugin.hasPermission(player, "worldguard.region.wand")) {
|
||||
@@ -628,23 +727,159 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
if (item.getTypeId() == BlockID.TNT) {
|
||||
Block placedOn = block.getRelative(event.getBlockFace());
|
||||
// workaround for a bug that allowed tnt to trigger instantly if placed
|
||||
// next to redstone, without plugins getting the block place event
|
||||
// (not sure if this actually still happens)
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !plugin.getGlobalRegionManager().allows(
|
||||
DefaultFlag.TNT, placedOn.getLocation(), localPlayer)) {
|
||||
&& !placedInSet.allows(DefaultFlag.TNT, localPlayer)) {
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getTypeId() == ItemID.INK_SACK
|
||||
&& item.getData() != null
|
||||
&& item.getData().getData() == 15 // bonemeal
|
||||
&& type == BlockID.GRASS) {
|
||||
// hacky workaround for craftbukkit bug
|
||||
// has since been fixed, but leaving for legacy
|
||||
if (item.getTypeId() == BlockID.STEP
|
||||
|| item.getTypeId() == BlockID.WOODEN_STEP) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)) {
|
||||
boolean cancel = false;
|
||||
if ((block.getTypeId() == item.getTypeId())
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
// if we are on a step already, the new block will end up in the same block as the interact
|
||||
cancel = true;
|
||||
} else if (!placedInSet.canBuild(localPlayer)) {
|
||||
// if we are on another block, the half-slab in hand will be pushed to the adjacent block
|
||||
cancel = true;
|
||||
}
|
||||
if (cancel) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getTypeId() == ItemID.BED_ITEM) {
|
||||
// this is mojang-level code, it had better give us the right direction
|
||||
double yaw = (player.getLocation().getYaw() * 4.0F / 360.0F) + 0.5D;
|
||||
int i = (int) yaw;
|
||||
int i1 = (yaw < i ? i - 1 : i) & 3;
|
||||
byte b0 = 0;
|
||||
byte b1 = 0;
|
||||
if (i1 == 0) {
|
||||
b1 = 1;
|
||||
}
|
||||
if (i1 == 1) {
|
||||
b0 = -1;
|
||||
}
|
||||
if (i1 == 2) {
|
||||
b1 = -1;
|
||||
}
|
||||
if (i1 == 3) {
|
||||
b0 = 1;
|
||||
}
|
||||
// end mojang-level code
|
||||
Location headLoc = placedIn.getRelative(b0, 0, b1).getLocation();
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
|
||||
&& !mgr.getApplicableRegions(headLoc).canBuild(localPlayer)) {
|
||||
// note that normal block placement is handled later, this is just a workaround
|
||||
// for the location of the head block of the bed
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (block.getTypeId() == BlockID.PISTON_MOVING_PIECE) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getTypeId() == ItemID.WOODEN_DOOR_ITEM || item.getTypeId() == ItemID.IRON_DOOR_ITEM) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
|
||||
&& !placedInSet.canBuild(localPlayer)) {
|
||||
// note that normal block placement is handled later, this is just a workaround
|
||||
// for the location of the top block of the door
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getTypeId() == ItemID.FIRE_CHARGE || item.getTypeId() == ItemID.FLINT_AND_TINDER) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
|
||||
&& !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.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getTypeId() == ItemID.EYE_OF_ENDER && block.getTypeId() == BlockID.END_PORTAL_FRAME) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to use that here.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (item.getTypeId() == ItemID.INK_SACK
|
||||
&& item.getData() != null) {
|
||||
if (item.getData().getData() == 15 // bonemeal
|
||||
&& (type == BlockID.GRASS
|
||||
|| type == BlockID.SAPLING
|
||||
|| type == BlockID.CROPS
|
||||
|| type == BlockID.BROWN_MUSHROOM
|
||||
|| type == BlockID.RED_MUSHROOM
|
||||
|| type == BlockID.PUMPKIN_STEM
|
||||
|| type == BlockID.MELON_STEM
|
||||
|| type == BlockID.POTATOES
|
||||
|| type == BlockID.CARROTS
|
||||
|| type == BlockID.COCOA_PLANT
|
||||
|| type == BlockID.LONG_GRASS)) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to use that here.");
|
||||
return;
|
||||
}
|
||||
} else if (item.getData().getData() == 3) { // cocoa beans
|
||||
// craftbukkit doesn't throw a block place for this, so workaround
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
if (!(event.getBlockFace() == BlockFace.DOWN || event.getBlockFace() == BlockFace.UP)) {
|
||||
event.setCancelled(true);
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to plant that here.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (type == BlockID.FLOWER_POT) { // no api for this atm
|
||||
if (item.getTypeId() == BlockID.RED_FLOWER
|
||||
|| item.getTypeId() == BlockID.YELLOW_FLOWER
|
||||
|| item.getTypeId() == BlockID.SAPLING
|
||||
|| item.getTypeId() == BlockID.RED_MUSHROOM
|
||||
|| item.getTypeId() == BlockID.BROWN_MUSHROOM
|
||||
|| item.getTypeId() == BlockID.CACTUS
|
||||
|| item.getTypeId() == BlockID.LONG_GRASS
|
||||
|| item.getTypeId() == BlockID.DEAD_BUSH) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to plant that here.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,7 +898,10 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
|| type == BlockID.DISPENSER
|
||||
|| type == BlockID.FURNACE
|
||||
|| type == BlockID.BURNING_FURNACE
|
||||
|| type == BlockID.BREWING_STAND) {
|
||||
|| type == BlockID.BREWING_STAND
|
||||
|| type == BlockID.TRAPPED_CHEST
|
||||
|| type == BlockID.HOPPER
|
||||
|| type == BlockID.DROPPER) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)
|
||||
&& !set.allows(DefaultFlag.CHEST_ACCESS, localPlayer)) {
|
||||
@@ -674,8 +912,19 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (type == BlockID.DRAGON_EGG) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to move dragon eggs here!");
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == BlockID.LEVER
|
||||
|| type == BlockID.STONE_BUTTON
|
||||
|| type == BlockID.WOODEN_BUTTON
|
||||
|| type == BlockID.NOTE_BLOCK
|
||||
|| type == BlockID.REDSTONE_REPEATER_OFF
|
||||
|| type == BlockID.REDSTONE_REPEATER_ON
|
||||
@@ -690,7 +939,11 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
|| type == BlockID.BREWING_STAND
|
||||
|| type == BlockID.ENCHANTMENT_TABLE
|
||||
|| type == BlockID.CAULDRON
|
||||
|| type == BlockID.DRAGON_EGG) {
|
||||
|| type == BlockID.ENDER_CHEST // blah
|
||||
|| type == BlockID.BEACON
|
||||
|| type == BlockID.ANVIL
|
||||
|| type == BlockID.HOPPER
|
||||
|| type == BlockID.DROPPER) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)
|
||||
&& !set.allows(DefaultFlag.USE, localPlayer)) {
|
||||
@@ -701,6 +954,20 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (type == BlockID.REDSTONE_REPEATER_OFF
|
||||
|| type == BlockID.REDSTONE_REPEATER_ON
|
||||
|| type == BlockID.COMPARATOR_OFF
|
||||
|| type == BlockID.COMPARATOR_ON) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)) {
|
||||
// using build and not use because it can potentially damage a circuit and use is more general-purposed
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to use that in this area.");
|
||||
event.setUseInteractedBlock(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (type == BlockID.CAKE_BLOCK) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)
|
||||
@@ -712,10 +979,15 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (BlockType.isRailBlock(type) && item.getTypeId() == ItemID.MINECART) {
|
||||
if (BlockType.isRailBlock(type)
|
||||
&& (item.getTypeId() == ItemID.MINECART
|
||||
|| item.getTypeId() == ItemID.POWERED_MINECART
|
||||
|| item.getTypeId() == ItemID.STORAGE_MINECART
|
||||
|| item.getTypeId() == ItemID.TNT_MINECART
|
||||
|| item.getTypeId() == ItemID.HOPPER_MINECART)) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)
|
||||
&& !set.allows(DefaultFlag.PLACE_VEHICLE, localPlayer)) {
|
||||
&& !placedInSet.canBuild(localPlayer)
|
||||
&& !placedInSet.allows(DefaultFlag.PLACE_VEHICLE, localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to place vehicles here.");
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
@@ -725,8 +997,8 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
|
||||
if (item.getTypeId() == ItemID.WOOD_BOAT) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)
|
||||
&& !set.allows(DefaultFlag.PLACE_VEHICLE, localPlayer)) {
|
||||
&& !placedInSet.canBuild(localPlayer)
|
||||
&& !placedInSet.allows(DefaultFlag.PLACE_VEHICLE, localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission to place vehicles here.");
|
||||
event.setUseItemInHand(Result.DENY);
|
||||
event.setCancelled(true);
|
||||
@@ -736,13 +1008,18 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
}
|
||||
|
||||
if (wcfg.getBlacklist() != null) {
|
||||
if(type != BlockID.CHEST
|
||||
if (player.isSneaking() // sneak + right clicking no longer opens guis as of some recent version
|
||||
|| (type != BlockID.CHEST
|
||||
&& type != BlockID.DISPENSER
|
||||
&& type != BlockID.FURNACE
|
||||
&& type != BlockID.BURNING_FURNACE
|
||||
&& type != BlockID.BREWING_STAND
|
||||
&& type != BlockID.ENCHANTMENT_TABLE
|
||||
&& type != BlockID.CAULDRON) {
|
||||
&& type != BlockID.ANVIL
|
||||
&& type != BlockID.ENDER_CHEST
|
||||
&& type != BlockID.TRAPPED_CHEST
|
||||
&& type != BlockID.HOPPER
|
||||
&& type != BlockID.DROPPER)) {
|
||||
if (!wcfg.getBlacklist().check(
|
||||
new ItemUseBlacklistEvent(plugin.wrapPlayer(player), toVector(block),
|
||||
item.getTypeId()), false, false)) {
|
||||
@@ -778,7 +1055,10 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
|| type == BlockID.FURNACE
|
||||
|| type == BlockID.BURNING_FURNACE
|
||||
|| type == BlockID.ENCHANTMENT_TABLE
|
||||
|| type == BlockID.BREWING_STAND)) {
|
||||
|| type == BlockID.BREWING_STAND
|
||||
|| type == BlockID.TRAPPED_CHEST
|
||||
|| type == BlockID.HOPPER
|
||||
|| type == BlockID.DROPPER)) {
|
||||
|
||||
if (wcfg.isChestProtected(block, player)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "The chest is protected.");
|
||||
@@ -865,7 +1145,9 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (type == BlockID.STONE_PRESSURE_PLATE || type == BlockID.WOODEN_PRESSURE_PLATE) {
|
||||
if (type == BlockID.STONE_PRESSURE_PLATE || type == BlockID.WOODEN_PRESSURE_PLATE
|
||||
|| type == BlockID.TRIPWIRE || type == BlockID.PRESSURE_PLATE_LIGHT
|
||||
|| type == BlockID.PRESSURE_PLATE_HEAVY) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, world)
|
||||
&& !set.canBuild(localPlayer)
|
||||
&& !set.allows(DefaultFlag.USE, localPlayer)) {
|
||||
@@ -951,7 +1233,8 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.ITEM_DROP, player.getLocation())) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(player, player.getWorld())
|
||||
&& !plugin.getGlobalRegionManager().allows(DefaultFlag.ITEM_DROP, player.getLocation())) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED + "You don't have permission to do that in this area.");
|
||||
}
|
||||
@@ -996,7 +1279,8 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (!plugin.getGlobalRegionManager().canBuild(
|
||||
player, event.getBlockClicked().getRelative(event.getBlockFace()))) {
|
||||
player, event.getBlockClicked().getRelative(event.getBlockFace()))
|
||||
&& !(event.getItemStack().getTypeId() == ItemID.MILK_BUCKET)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@@ -1012,6 +1296,16 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerFish(PlayerFishEvent event) {
|
||||
WorldConfiguration wcfg = plugin.getGlobalStateManager().get(event.getPlayer().getWorld());
|
||||
|
||||
if (wcfg.disableExpDrops || !plugin.getGlobalRegionManager().allows(DefaultFlag.EXP_DROPS,
|
||||
event.getPlayer().getLocation())) {
|
||||
event.setExpToDrop(0);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@@ -1099,6 +1393,40 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority= EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
World world = event.getFrom().getWorld();
|
||||
ConfigurationManager cfg = plugin.getGlobalStateManager();
|
||||
WorldConfiguration wcfg = cfg.get(world);
|
||||
|
||||
if (wcfg.useRegions) {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(event.getFrom().getWorld());
|
||||
Vector pt = new Vector(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
|
||||
Vector ptFrom = new Vector(event.getFrom().getBlockX(), event.getFrom().getBlockY(), event.getFrom().getBlockZ());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
ApplicableRegionSet setFrom = mgr.getApplicableRegions(ptFrom);
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(event.getPlayer());
|
||||
|
||||
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) {
|
||||
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
|
||||
&& !(set.allows(DefaultFlag.ENDERPEARL, localPlayer)
|
||||
&& setFrom.allows(DefaultFlag.ENDERPEARL, localPlayer))) {
|
||||
event.getPlayer().sendMessage(ChatColor.DARK_RED + "You're not allowed to go there.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@@ -1112,22 +1440,96 @@ public class WorldGuardPlayerListener implements Listener {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
String[] parts = event.getMessage().split(" ");
|
||||
String lowerCommand = parts[0].toLowerCase();
|
||||
String usedCommand = event.getMessage().toLowerCase();
|
||||
|
||||
Set<String> allowedCommands = set.getFlag(DefaultFlag.ALLOWED_CMDS, localPlayer);
|
||||
Set<String> blockedCommands = set.getFlag(DefaultFlag.BLOCKED_CMDS, localPlayer);
|
||||
|
||||
if (allowedCommands != null && !allowedCommands.contains(lowerCommand)
|
||||
&& (blockedCommands == null || blockedCommands.contains(lowerCommand))) {
|
||||
player.sendMessage(ChatColor.RED + lowerCommand + " is not allowed in this area.");
|
||||
/*
|
||||
* blocked used allow?
|
||||
* x x no
|
||||
* x x y no
|
||||
* x y x yes
|
||||
* x y x y no
|
||||
*
|
||||
* allowed used allow?
|
||||
* x x yes
|
||||
* x x y yes
|
||||
* x y x no
|
||||
* x y x y yes
|
||||
*/
|
||||
String result = "";
|
||||
String[] usedParts = usedCommand.split(" ");
|
||||
if (blockedCommands != null) {
|
||||
blocked:
|
||||
for (String blockedCommand : blockedCommands) {
|
||||
String[] blockedParts = blockedCommand.split(" ");
|
||||
for (int i = 0; i < blockedParts.length && i < usedParts.length; i++) {
|
||||
if (blockedParts[i].equalsIgnoreCase(usedParts[i])) {
|
||||
// first part matches - check if it's the whole thing
|
||||
if (i + 1 == blockedParts.length) {
|
||||
// consumed all blocked parts, block entire command
|
||||
result = blockedCommand;
|
||||
break blocked;
|
||||
} else {
|
||||
// more blocked parts to check, also check used length
|
||||
if (i + 1 == usedParts.length) {
|
||||
// all that was used, but there is more in blocked
|
||||
// allow this, check next command in flag
|
||||
continue blocked;
|
||||
} else {
|
||||
// more in both blocked and used, continue checking
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allowedCommands != null) {
|
||||
allowed:
|
||||
for (String allowedCommand : allowedCommands) {
|
||||
String[] allowedParts = allowedCommand.split(" ");
|
||||
for (int i = 0; i < allowedParts.length && i < usedParts.length; i++) {
|
||||
if (allowedParts[i].equalsIgnoreCase(usedParts[i])) {
|
||||
// this part matches - check if it's the whole thing
|
||||
if (i + 1 == allowedParts.length) {
|
||||
// consumed all allowed parts before reaching used length
|
||||
// this command is definitely allowed
|
||||
result = "";
|
||||
break allowed;
|
||||
} else {
|
||||
// more allowed parts to check
|
||||
if (i + 1 == usedParts.length) {
|
||||
// all that was used, but there is more in allowed
|
||||
// block for now, check next part of flag
|
||||
result = usedCommand;
|
||||
continue allowed;
|
||||
} else {
|
||||
// more in both allowed and used, continue checking for match
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// doesn't match at all, block it, check next flag string
|
||||
result = usedCommand;
|
||||
continue allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + result + " is not allowed in this area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (blockedCommands != null && blockedCommands.contains(lowerCommand)
|
||||
&& (allowedCommands == null || !allowedCommands.contains(lowerCommand))) {
|
||||
player.sendMessage(ChatColor.RED + lowerCommand + " is blocked in this area.");
|
||||
if (cfg.blockInGameOp) {
|
||||
if (opPattern.matcher(event.getMessage()).matches()) {
|
||||
player.sendMessage(ChatColor.RED + "/op can only be used in console (as set by a WG setting).");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.hasHangingEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -34,9 +32,6 @@ import java.util.Set;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import com.sk89q.bukkit.util.CommandsManagerRegistration;
|
||||
import com.sk89q.minecraft.util.commands.*;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -50,6 +45,15 @@ import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.sk89q.bukkit.util.CommandsManagerRegistration;
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissionsException;
|
||||
import com.sk89q.minecraft.util.commands.CommandUsageException;
|
||||
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||
import com.sk89q.minecraft.util.commands.MissingNestedCommandException;
|
||||
import com.sk89q.minecraft.util.commands.SimpleInjector;
|
||||
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
||||
import com.sk89q.wepif.PermissionsResolverManager;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.commands.GeneralCommands;
|
||||
@@ -66,6 +70,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.
|
||||
@@ -96,7 +105,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) {
|
||||
@@ -105,9 +114,18 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current instance of WorldGuard
|
||||
* @return WorldGuardPlugin instance
|
||||
*/
|
||||
public static WorldGuardPlugin inst() {
|
||||
return inst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on plugin enable.
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onEnable() {
|
||||
|
||||
@@ -137,12 +155,12 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
LegacyWorldGuardMigration.migrateBlacklist(this);
|
||||
|
||||
try {
|
||||
// Load the configuration
|
||||
configuration.load();
|
||||
globalRegionManager.preload();
|
||||
// Load the configuration
|
||||
configuration.load();
|
||||
globalRegionManager.preload();
|
||||
} catch (FatalConfigurationLoadingException e) {
|
||||
e.printStackTrace();
|
||||
getServer().shutdown();
|
||||
e.printStackTrace();
|
||||
getServer().shutdown();
|
||||
}
|
||||
|
||||
// Migrate regions after the regions were loaded because
|
||||
@@ -152,7 +170,8 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
flagStateManager = new FlagStateManager(this);
|
||||
|
||||
if (configuration.useRegionsScheduler) {
|
||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, flagStateManager, FlagStateManager.RUN_DELAY, FlagStateManager.RUN_DELAY);
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, flagStateManager,
|
||||
FlagStateManager.RUN_DELAY, FlagStateManager.RUN_DELAY);
|
||||
}
|
||||
|
||||
// Register events
|
||||
@@ -162,11 +181,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
(new WorldGuardWeatherListener(this)).registerEvents();
|
||||
(new WorldGuardVehicleListener(this)).registerEvents();
|
||||
(new WorldGuardServerListener(this)).registerEvents();
|
||||
if (hasHangingEvent()) {
|
||||
(new WorldGuardHangingListener(this)).registerEvents();
|
||||
} else {
|
||||
(new WorldGuardPaintingListener(this)).registerEvents();
|
||||
}
|
||||
(new WorldGuardHangingListener(this)).registerEvents();
|
||||
configuration.updateCommandBookGodMode();
|
||||
|
||||
if (getServer().getPluginManager().isPluginEnabled("CommandBook")) {
|
||||
@@ -194,6 +209,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
/**
|
||||
* Called on plugin disable.
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
globalRegionManager.unload();
|
||||
configuration.unload();
|
||||
|
||||
@@ -18,11 +18,9 @@ import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.event.vehicle.VehicleMoveEvent;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.FlagStateManager.PlayerFlagState;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class WorldGuardVehicleListener implements Listener {
|
||||
|
||||
@@ -82,96 +80,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,9 @@ public class GeneralCommands {
|
||||
if (item2.getTypeId() == item.getTypeId() &&
|
||||
((!ItemType.usesDamageValue(item.getTypeId()) && ignoreDamaged)
|
||||
|| item.getDurability() == item2.getDurability()) &&
|
||||
item.getEnchantments().equals(item2.getEnchantments())) {
|
||||
((item.getItemMeta() == null && item2.getItemMeta() == null)
|
||||
|| (item.getItemMeta() != null &&
|
||||
item.getItemMeta().equals(item2.getItemMeta())))) {
|
||||
// This stack won't fit in the parent stack
|
||||
if (item2.getAmount() > needed) {
|
||||
item.setAmount(max);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,11 +30,11 @@ import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException;
|
||||
import com.sk89q.worldguard.protection.databases.RegionDBUtil;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException;
|
||||
import com.sk89q.worldguard.protection.databases.RegionDBUtil;
|
||||
|
||||
// @TODO: A lot of code duplication here! Need to fix.
|
||||
|
||||
@@ -44,15 +44,30 @@ public class RegionMemberCommands {
|
||||
public RegionMemberCommands(WorldGuardPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Command(aliases = {"addmember", "addmember"}, usage = "<id> <members...>",
|
||||
desc = "Add a member to a region", min = 2)
|
||||
|
||||
@Command(aliases = {"addmember", "addmember"},
|
||||
usage = "<id> <members...>",
|
||||
flags = "w:",
|
||||
desc = "Add a member to a region",
|
||||
min = 2)
|
||||
public void addMember(CommandContext args, CommandSender sender) throws CommandException {
|
||||
|
||||
Player player = plugin.checkPlayer(sender);
|
||||
World world = player.getWorld();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
final World world;
|
||||
Player player = null;
|
||||
LocalPlayer localPlayer = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
localPlayer = plugin.wrapPlayer(player);
|
||||
}
|
||||
if (args.hasFlag('w')) {
|
||||
world = plugin.matchWorld(sender, args.getFlag('w'));
|
||||
} else {
|
||||
if (player != null) {
|
||||
world = player.getWorld();
|
||||
} else {
|
||||
throw new CommandException("No world specified. Use -w <worldname>.");
|
||||
}
|
||||
}
|
||||
|
||||
String id = args.getString(0);
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
@@ -64,19 +79,21 @@ public class RegionMemberCommands {
|
||||
|
||||
id = region.getId();
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember." + id.toLowerCase());
|
||||
if (localPlayer != null) {
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.addmember." + id.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
RegionDBUtil.addToDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
|
||||
RegionDBUtil.addToDomain(region.getMembers(), args.getParsedPaddedSlice(1, 0), 0);
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW
|
||||
+ "Region '" + id + "' updated.");
|
||||
|
||||
|
||||
try {
|
||||
mgr.save();
|
||||
} catch (ProtectionDatabaseException e) {
|
||||
@@ -84,15 +101,30 @@ public class RegionMemberCommands {
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(aliases = {"addowner", "addowner"}, usage = "<id> <owners...>",
|
||||
desc = "Add an owner to a region", min = 2)
|
||||
|
||||
@Command(aliases = {"addowner", "addowner"},
|
||||
usage = "<id> <owners...>",
|
||||
flags = "w:",
|
||||
desc = "Add an owner to a region",
|
||||
min = 2)
|
||||
public void addOwner(CommandContext args, CommandSender sender) throws CommandException {
|
||||
|
||||
Player player = plugin.checkPlayer(sender);
|
||||
World world = player.getWorld();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
final World world;
|
||||
Player player = null;
|
||||
LocalPlayer localPlayer = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
localPlayer = plugin.wrapPlayer(player);
|
||||
}
|
||||
if (args.hasFlag('w')) {
|
||||
world = plugin.matchWorld(sender, args.getFlag('w'));
|
||||
} else {
|
||||
if (player != null) {
|
||||
world = player.getWorld();
|
||||
} else {
|
||||
throw new CommandException("No world specified. Use -w <worldname>.");
|
||||
}
|
||||
}
|
||||
|
||||
String id = args.getString(0);
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
@@ -106,46 +138,63 @@ public class RegionMemberCommands {
|
||||
|
||||
Boolean flag = region.getFlag(DefaultFlag.BUYABLE);
|
||||
DefaultDomain owners = region.getOwners();
|
||||
if (flag != null && flag && owners != null && owners.size() == 0) {
|
||||
if (!plugin.hasPermission(player, "worldguard.region.unlimited")) {
|
||||
int maxRegionCount = plugin.getGlobalStateManager().get(world).getMaxRegionCount(player);
|
||||
if (maxRegionCount >= 0 && mgr.getRegionCountOfPlayer(localPlayer)
|
||||
>= maxRegionCount) {
|
||||
throw new CommandException("You already own the maximum allowed amount of regions.");
|
||||
if (localPlayer != null) {
|
||||
if (flag != null && flag && owners != null && owners.size() == 0) {
|
||||
if (!plugin.hasPermission(player, "worldguard.region.unlimited")) {
|
||||
int maxRegionCount = plugin.getGlobalStateManager().get(world).getMaxRegionCount(player);
|
||||
if (maxRegionCount >= 0 && mgr.getRegionCountOfPlayer(localPlayer)
|
||||
>= maxRegionCount) {
|
||||
throw new CommandException("You already own the maximum allowed amount of regions.");
|
||||
}
|
||||
}
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.unclaimed." + id.toLowerCase());
|
||||
} else {
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner." + id.toLowerCase());
|
||||
}
|
||||
}
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.unclaimed." + id.toLowerCase());
|
||||
}
|
||||
|
||||
RegionDBUtil.addToDomain(region.getOwners(), args.getParsedPaddedSlice(1, 0), 0);
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW
|
||||
+ "Region '" + id + "' updated.");
|
||||
|
||||
try {
|
||||
mgr.save();
|
||||
} catch (ProtectionDatabaseException e) {
|
||||
throw new CommandException("Failed to write regions: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(aliases = {"removemember", "remmember", "removemem", "remmem"},
|
||||
usage = "<id> <owners...>",
|
||||
flags = "aw:",
|
||||
desc = "Remove an owner to a region",
|
||||
min = 1)
|
||||
public void removeMember(CommandContext args, CommandSender sender) throws CommandException {
|
||||
final World world;
|
||||
Player player = null;
|
||||
LocalPlayer localPlayer = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
localPlayer = plugin.wrapPlayer(player);
|
||||
}
|
||||
if (args.hasFlag('w')) {
|
||||
world = plugin.matchWorld(sender, args.getFlag('w'));
|
||||
} else {
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner.member." + id.toLowerCase());
|
||||
if (player != null) {
|
||||
world = player.getWorld();
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.addowner." + id.toLowerCase());
|
||||
throw new CommandException("No world specified. Use -w <worldname>.");
|
||||
}
|
||||
}
|
||||
|
||||
RegionDBUtil.addToDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW
|
||||
+ "Region '" + id + "' updated.");
|
||||
|
||||
try {
|
||||
mgr.save();
|
||||
} catch (ProtectionDatabaseException e) {
|
||||
throw new CommandException("Failed to write regions: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(aliases = {"removemember", "remmember", "removemem", "remmem"}, usage = "<id> <owners...>",
|
||||
desc = "Remove an owner to a region", min = 2)
|
||||
public void removeMember(CommandContext args, CommandSender sender) throws CommandException {
|
||||
|
||||
Player player = plugin.checkPlayer(sender);
|
||||
World world = player.getWorld();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
String id = args.getString(0);
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
@@ -157,19 +206,28 @@ public class RegionMemberCommands {
|
||||
|
||||
id = region.getId();
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember." + id.toLowerCase());
|
||||
if (localPlayer != null) {
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.removemember." + id.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
RegionDBUtil.removeFromDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
|
||||
if (args.hasFlag('a')) {
|
||||
region.getMembers().removeAll();
|
||||
} else {
|
||||
if (args.argsLength() < 2) {
|
||||
throw new CommandException("List some names to remove, or use -a to remove all.");
|
||||
}
|
||||
RegionDBUtil.removeFromDomain(region.getMembers(), args.getParsedPaddedSlice(1, 0), 0);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW
|
||||
+ "Region '" + id + "' updated.");
|
||||
|
||||
|
||||
try {
|
||||
mgr.save();
|
||||
} catch (ProtectionDatabaseException e) {
|
||||
@@ -177,16 +235,31 @@ public class RegionMemberCommands {
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Command(aliases = {"removeowner", "remowner"}, usage = "<id> <owners...>",
|
||||
desc = "Remove an owner to a region", min = 2)
|
||||
|
||||
@Command(aliases = {"removeowner", "remowner"},
|
||||
usage = "<id> <owners...>",
|
||||
flags = "aw:",
|
||||
desc = "Remove an owner to a region",
|
||||
min = 1)
|
||||
public void removeOwner(CommandContext args,
|
||||
CommandSender sender) throws CommandException {
|
||||
|
||||
Player player = plugin.checkPlayer(sender);
|
||||
World world = player.getWorld();
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
final World world;
|
||||
Player player = null;
|
||||
LocalPlayer localPlayer = null;
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
localPlayer = plugin.wrapPlayer(player);
|
||||
}
|
||||
if (args.hasFlag('w')) {
|
||||
world = plugin.matchWorld(sender, args.getFlag('w'));
|
||||
} else {
|
||||
if (player != null) {
|
||||
world = player.getWorld();
|
||||
} else {
|
||||
throw new CommandException("No world specified. Use -w <worldname>.");
|
||||
}
|
||||
}
|
||||
|
||||
String id = args.getString(0);
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
@@ -198,19 +271,28 @@ public class RegionMemberCommands {
|
||||
|
||||
id = region.getId();
|
||||
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner." + id.toLowerCase());
|
||||
if (localPlayer != null) {
|
||||
if (region.isOwner(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner.own." + id.toLowerCase());
|
||||
} else if (region.isMember(localPlayer)) {
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner.member." + id.toLowerCase());
|
||||
} else {
|
||||
plugin.checkPermission(sender, "worldguard.region.removeowner." + id.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
RegionDBUtil.removeFromDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
|
||||
if (args.hasFlag('a')) {
|
||||
region.getOwners().removeAll();
|
||||
} else {
|
||||
if (args.argsLength() < 2) {
|
||||
throw new CommandException("List some names to remove, or use -a to remove all.");
|
||||
}
|
||||
RegionDBUtil.removeFromDomain(region.getOwners(), args.getParsedPaddedSlice(1, 0), 0);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW
|
||||
+ "Region '" + id + "' updated.");
|
||||
|
||||
|
||||
try {
|
||||
mgr.save();
|
||||
} catch (ProtectionDatabaseException e) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class ToggleCommands {
|
||||
|
||||
if (removed > 10) {
|
||||
sender.sendMessage("" + removed + " entities (>10) auto-removed from "
|
||||
+ world.toString());
|
||||
+ world.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ public class WorldGuardCommands {
|
||||
plugin.getGlobalRegionManager().unload();
|
||||
plugin.getGlobalStateManager().load();
|
||||
plugin.getGlobalRegionManager().preload();
|
||||
// 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 removeAll() {
|
||||
groups.clear();
|
||||
players.clear();
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class ApplicableRegionSet implements Iterable<ProtectedRegion> {
|
||||
/**
|
||||
* Checks if a player can build in an area.
|
||||
*
|
||||
* @param player The player to chec
|
||||
* @param player The player to check
|
||||
* @return build ability
|
||||
*/
|
||||
public boolean canBuild(LocalPlayer player) {
|
||||
@@ -353,9 +353,9 @@ public class ApplicableRegionSet implements Iterable<ProtectedRegion> {
|
||||
lastPriority = region.getPriority();
|
||||
}
|
||||
|
||||
try {
|
||||
if (!needsClear.isEmpty()) {
|
||||
return needsClear.values().iterator().next();
|
||||
} catch (NoSuchElementException e) {
|
||||
} else {
|
||||
if (globalRegion != null) {
|
||||
V gFlag = globalRegion.getFlag(flag);
|
||||
if (gFlag != null) return gFlag;
|
||||
|
||||
@@ -36,12 +36,11 @@ import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.ConfigurationManager;
|
||||
import com.sk89q.worldguard.bukkit.WorldConfiguration;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException;
|
||||
import com.sk89q.worldguard.protection.databases.ProtectionDatabase;
|
||||
import com.sk89q.worldguard.protection.databases.YAMLDatabase;
|
||||
import com.sk89q.worldguard.protection.databases.MySQLDatabase;
|
||||
import com.sk89q.worldguard.protection.databases.ProtectionDatabase;
|
||||
import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException;
|
||||
import com.sk89q.worldguard.protection.databases.YAMLDatabase;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.FlatRegionManager;
|
||||
import com.sk89q.worldguard.protection.managers.PRTreeRegionManager;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
|
||||
@@ -160,8 +159,10 @@ public class GlobalRegionManager {
|
||||
RegionManager manager = new PRTreeRegionManager(database);
|
||||
manager.load();
|
||||
|
||||
plugin.getLogger().info(manager.getRegions().size()
|
||||
+ " regions loaded for '" + name + "'");
|
||||
if (plugin.getGlobalStateManager().get(world).summaryOnStart) {
|
||||
plugin.getLogger().info(manager.getRegions().size()
|
||||
+ " regions loaded for '" + name + "'");
|
||||
}
|
||||
|
||||
return manager;
|
||||
} catch (ProtectionDatabaseException e) {
|
||||
|
||||
@@ -37,9 +37,10 @@ public final class DefaultFlag {
|
||||
public static final StateFlag CREEPER_EXPLOSION = new StateFlag("creeper-explosion", true, RegionGroup.ALL);
|
||||
public static final StateFlag ENDERDRAGON_BLOCK_DAMAGE = new StateFlag("enderdragon-block-damage", true);
|
||||
public static final StateFlag GHAST_FIREBALL = new StateFlag("ghast-fireball", true, RegionGroup.ALL);
|
||||
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", true, RegionGroup.ALL);
|
||||
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);
|
||||
@@ -58,6 +59,8 @@ public final class DefaultFlag {
|
||||
public static final StateFlag LEAF_DECAY = new StateFlag("leaf-decay", true);
|
||||
public static final StateFlag GRASS_SPREAD = new StateFlag("grass-growth", true);
|
||||
public static final StateFlag MYCELIUM_SPREAD = new StateFlag("mycelium-spread", true);
|
||||
public static final StateFlag VINE_GROWTH = new StateFlag("vine-growth", true);
|
||||
public static final StateFlag SOIL_DRY = new StateFlag("soil-dry", true);
|
||||
public static final StateFlag ENDER_BUILD = new StateFlag("enderman-grief", true);
|
||||
public static final StateFlag INVINCIBILITY = new StateFlag("invincible", false, RegionGroup.ALL);
|
||||
public static final StateFlag EXP_DROPS = new StateFlag("exp-drops", true, RegionGroup.ALL);
|
||||
@@ -66,6 +69,7 @@ public final class DefaultFlag {
|
||||
public static final StateFlag ENTRY = new StateFlag("entry", true);
|
||||
public static final StateFlag EXIT = new StateFlag("exit", true);
|
||||
public static final StateFlag ITEM_DROP = new StateFlag("item-drop", true);
|
||||
public static final StateFlag ENDERPEARL = new StateFlag("enderpearl", true);
|
||||
public static final StateFlag ENTITY_PAINTING_DESTROY = new StateFlag("entity-painting-destroy", true);
|
||||
public static final StateFlag ENTITY_ITEM_FRAME_DESTROY = new StateFlag("entity-item-frame-destroy", true);
|
||||
public static final StateFlag POTION_SPLASH = new StateFlag("potion-splash", true);
|
||||
@@ -77,14 +81,17 @@ 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);
|
||||
public static final IntegerFlag MAX_FOOD = new IntegerFlag("feed-max-hunger", RegionGroup.ALL);
|
||||
// public static final IntegerFlag MAX_PLAYERS = new IntegerFlag("max-players-allowed", RegionGroup.ALL);
|
||||
// public static final StringFlag MAX_PLAYERS_MESSAGE = new StringFlag("max-players-reject-message", RegionGroup.ALL);
|
||||
public static final LocationFlag TELE_LOC = new LocationFlag("teleport", RegionGroup.MEMBERS);
|
||||
public static final LocationFlag SPAWN_LOC = new LocationFlag("spawn", RegionGroup.MEMBERS);
|
||||
public static final StateFlag ENABLE_SHOP = new StateFlag("allow-shop", false);
|
||||
public static final BooleanFlag BUYABLE = new BooleanFlag("buyable");
|
||||
public static final DoubleFlag PRICE = new DoubleFlag("price");
|
||||
public static final SetFlag<String> BLOCKED_CMDS = new SetFlag<String>("blocked-cmds", RegionGroup.ALL, new CommandStringFlag(null));
|
||||
@@ -94,24 +101,39 @@ public final class DefaultFlag {
|
||||
PASSTHROUGH, BUILD, CONSTRUCT, PVP, CHEST_ACCESS, PISTONS,
|
||||
TNT, LIGHTER, USE, PLACE_VEHICLE, DESTROY_VEHICLE, SLEEP,
|
||||
MOB_DAMAGE, MOB_SPAWNING, DENY_SPAWN, INVINCIBILITY, EXP_DROPS,
|
||||
CREEPER_EXPLOSION, ENDERDRAGON_BLOCK_DAMAGE, GHAST_FIREBALL, ENDER_BUILD,
|
||||
CREEPER_EXPLOSION, OTHER_EXPLOSION, ENDERDRAGON_BLOCK_DAMAGE, GHAST_FIREBALL, ENDER_BUILD,
|
||||
GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_ENTER, NOTIFY_LEAVE,
|
||||
EXIT, ENTRY, LIGHTNING, ENTITY_PAINTING_DESTROY,
|
||||
ENTITY_ITEM_FRAME_DESTROY, ITEM_DROP,
|
||||
EXIT, ENTRY, LIGHTNING, ENTITY_PAINTING_DESTROY, ENDERPEARL,
|
||||
ENTITY_ITEM_FRAME_DESTROY, ITEM_DROP, /*MAX_PLAYERS, MAX_PLAYERS_MESSAGE,*/
|
||||
HEAL_AMOUNT, HEAL_DELAY, MIN_HEAL, MAX_HEAL,
|
||||
FEED_DELAY, FEED_AMOUNT, MIN_FOOD, MAX_FOOD,
|
||||
SNOW_FALL, SNOW_MELT, ICE_FORM, ICE_MELT, GAME_MODE,
|
||||
MUSHROOMS, LEAF_DECAY, GRASS_SPREAD, MYCELIUM_SPREAD, SEND_CHAT,
|
||||
RECEIVE_CHAT, FIRE_SPREAD, LAVA_FIRE, LAVA_FLOW, WATER_FLOW,
|
||||
SNOW_FALL, SNOW_MELT, ICE_FORM, ICE_MELT, SOIL_DRY, GAME_MODE,
|
||||
MUSHROOMS, LEAF_DECAY, GRASS_SPREAD, MYCELIUM_SPREAD, VINE_GROWTH,
|
||||
SEND_CHAT, RECEIVE_CHAT, FIRE_SPREAD, LAVA_FIRE, LAVA_FLOW, WATER_FLOW,
|
||||
TELE_LOC, SPAWN_LOC, POTION_SPLASH,
|
||||
BLOCKED_CMDS, ALLOWED_CMDS, PRICE, BUYABLE,
|
||||
BLOCKED_CMDS, ALLOWED_CMDS, PRICE, BUYABLE, ENABLE_SHOP
|
||||
};
|
||||
|
||||
|
||||
private 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;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
||||
setMinMaxPoints(min, pt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector2D> getPoints() {
|
||||
List<BlockVector2D> pts = new ArrayList<BlockVector2D>();
|
||||
int x1 = min.getBlockX();
|
||||
@@ -85,8 +86,8 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
||||
|
||||
pts.add(new BlockVector2D(x1, z1));
|
||||
pts.add(new BlockVector2D(x2, z1));
|
||||
pts.add(new BlockVector2D(x1, z2));
|
||||
pts.add(new BlockVector2D(x2, z2));
|
||||
pts.add(new BlockVector2D(x1, z2));
|
||||
|
||||
return pts;
|
||||
}
|
||||
|
||||
@@ -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,10 +19,10 @@
|
||||
|
||||
package com.sk89q.worldguard;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
|
||||
@org.junit.Ignore
|
||||
public class TestPlayer extends LocalPlayer {
|
||||
@@ -49,32 +49,27 @@ public class TestPlayer extends LocalPlayer {
|
||||
|
||||
@Override
|
||||
public Vector getPosition() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return new Vector(0, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(String msg) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
System.out.println("TestPlayer{" + this.name + "} kicked!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ban(String msg) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
System.out.println("TestPlayer{" + this.name + "} banned!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
System.out.println("-> TestPlayer{" + this.name + "}: " + msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return groups.toArray(new String[groups.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import com.sk89q.worldguard.protection.managers.PRTreeRegionManager;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
|
||||
public class PRTreeRegionEntryExitTest extends RegionEntryExitTest {
|
||||
@Override
|
||||
protected RegionManager createRegionManager() throws Exception {
|
||||
return new PRTreeRegionManager(null);
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2013 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.TestPlayer;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroup;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
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.ProtectedRegion;
|
||||
|
||||
public abstract class RegionEntryExitTest {
|
||||
static String ENTRY_ID = "entry_rg";
|
||||
static String EXIT_ID = "exit_rg";
|
||||
static String BUILDER_GROUP = "builder";
|
||||
static String VIP_GROUP = "vip";
|
||||
|
||||
Vector inEntry = new Vector(5, 64, 5);
|
||||
Vector inExit = new Vector(-5, 65, -5);
|
||||
|
||||
RegionManager manager;
|
||||
ProtectedRegion globalRegion;
|
||||
ProtectedRegion entryRegion;
|
||||
ProtectedRegion exitRegion;
|
||||
TestPlayer vip_player;
|
||||
TestPlayer builder_player;
|
||||
|
||||
protected abstract RegionManager createRegionManager() throws Exception;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
setUpGlobalRegion();
|
||||
|
||||
manager = createRegionManager();
|
||||
|
||||
setUpPlayers();
|
||||
setUpEntryRegion();
|
||||
setUpExitRegion();
|
||||
}
|
||||
|
||||
void setUpPlayers() {
|
||||
vip_player = new TestPlayer("dudu");
|
||||
vip_player.addGroup(VIP_GROUP);
|
||||
|
||||
builder_player = new TestPlayer("esskay");
|
||||
builder_player.addGroup(BUILDER_GROUP);
|
||||
|
||||
// @Test
|
||||
// assertFalse(builderPlayer.wuvs(vip_player)); // causes test to fail
|
||||
}
|
||||
|
||||
void setUpGlobalRegion() {
|
||||
globalRegion = new GlobalProtectedRegion("__global__");
|
||||
}
|
||||
|
||||
void setUpEntryRegion() {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
domain.addGroup(VIP_GROUP);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(ENTRY_ID, new BlockVector(1, 0, 1), new BlockVector(10, 255, 10));
|
||||
|
||||
region.setMembers(domain);
|
||||
manager.addRegion(region);
|
||||
|
||||
entryRegion = region;
|
||||
// this is the way it's supposed to work
|
||||
// whatever the group flag is set to is the group that the flag APPLIES to
|
||||
// in this case, non members (esskay) should be DENIED entry
|
||||
entryRegion.setFlag(DefaultFlag.ENTRY, StateFlag.State.DENY);
|
||||
entryRegion.setFlag(DefaultFlag.ENTRY.getRegionGroupFlag(), RegionGroup.NON_MEMBERS);
|
||||
}
|
||||
|
||||
void setUpExitRegion() throws Exception {
|
||||
DefaultDomain domain = new DefaultDomain();
|
||||
domain.addGroup(BUILDER_GROUP);
|
||||
|
||||
ProtectedRegion region = new ProtectedCuboidRegion(EXIT_ID, new BlockVector(-1, 0, -1), new BlockVector(-10, 255, -10));
|
||||
|
||||
region.setOwners(domain);
|
||||
manager.addRegion(region);
|
||||
|
||||
entryRegion = region;
|
||||
// same as above
|
||||
entryRegion.setFlag(DefaultFlag.EXIT, StateFlag.State.DENY);
|
||||
entryRegion.setFlag(DefaultFlag.EXIT.getRegionGroupFlag(), RegionGroup.NON_OWNERS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntry() throws Exception {
|
||||
ApplicableRegionSet appl;
|
||||
|
||||
appl = manager.getApplicableRegions(inEntry);
|
||||
// ProtectedRegion rg = appl.iterator().next();
|
||||
// System.out.println("rg " + rg.getId());
|
||||
// System.out.println("mem " + rg.getMembers().toGroupsString());
|
||||
// System.out.println("flag " + appl.getFlag(DefaultFlag.ENTRY));
|
||||
// System.out.println("grp " + appl.getFlag(DefaultFlag.ENTRY.getRegionGroupFlag()));
|
||||
// System.out.println("===");
|
||||
assertTrue("Allowed Entry", appl.allows(DefaultFlag.ENTRY, vip_player));
|
||||
assertFalse("Forbidden Entry", appl.allows(DefaultFlag.ENTRY, builder_player));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExit() throws Exception {
|
||||
ApplicableRegionSet appl;
|
||||
|
||||
appl = manager.getApplicableRegions(inExit);
|
||||
// ProtectedRegion rg = appl.iterator().next();
|
||||
// System.out.println("rg " + rg.getId());
|
||||
// System.out.println("own " + rg.getOwners().toGroupsString());
|
||||
// System.out.println("flag " + appl.getFlag(DefaultFlag.EXIT));
|
||||
// System.out.println("grp " + appl.getFlag(DefaultFlag.EXIT.getRegionGroupFlag()));
|
||||
// System.out.println("===");
|
||||
assertTrue("Allowed Exit", appl.allows(DefaultFlag.EXIT, builder_player));
|
||||
assertFalse("Forbidden Exit", appl.allows(DefaultFlag.EXIT, vip_player));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,6 +19,15 @@
|
||||
|
||||
package com.sk89q.worldguard.protection;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
@@ -26,19 +35,11 @@ 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 abstract class RegionOverlapTest {
|
||||
static String COURTYARD_ID = "courtyard";
|
||||
@@ -166,7 +167,6 @@ public abstract class RegionOverlapTest {
|
||||
HashSet<ProtectedRegion> test = new HashSet<ProtectedRegion>();
|
||||
test.add(courtyard);
|
||||
test.add(fountain);
|
||||
System.out.println(test);
|
||||
|
||||
// Outside
|
||||
appl = manager.getApplicableRegions(outside);
|
||||
|
||||
@@ -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;
|
||||
|
||||
+25
-4
@@ -1,14 +1,12 @@
|
||||
package com.sk89q.worldguard.protection;
|
||||
package com.sk89q.worldguard.protection.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class RegionIntersectTest {
|
||||
@@ -79,4 +77,27 @@ public class RegionIntersectTest {
|
||||
|
||||
assertEquals("Check for '" + region2.getId() + "' region failed.", expected, actual);
|
||||
}
|
||||
|
||||
private static final BlockVector2D[] polygon = {
|
||||
new BlockVector2D(1, 0),
|
||||
new BlockVector2D(4, 3),
|
||||
new BlockVector2D(4, -3),
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testIntersection() throws Exception {
|
||||
final ProtectedCuboidRegion cuboidRegion = new ProtectedCuboidRegion("cuboidRegion", new BlockVector(-3, -3, -3), new BlockVector(3, 3, 3));
|
||||
for (int angle = 0; angle < 360; angle += 90) {
|
||||
final BlockVector2D[] rotatedPolygon = new BlockVector2D[polygon.length];
|
||||
for (int i = 0; i < polygon.length; i++) {
|
||||
final BlockVector2D vertex = polygon[i];
|
||||
rotatedPolygon[i] = vertex.transform2D(angle, 0, 0, 0, 0).toBlockVector2D();
|
||||
}
|
||||
|
||||
final ProtectedPolygonalRegion polygonalRegion = new ProtectedPolygonalRegion("polygonalRegion", Arrays.asList(rotatedPolygon), -3, 3);
|
||||
|
||||
assertTrue(String.format("%s does not intersect (cuboid.intersectsEdges(polygonal)", Arrays.asList(rotatedPolygon)), cuboidRegion.intersectsEdges(polygonalRegion));
|
||||
assertTrue(String.format("%s does not intersect (polygonal.intersectsEdges(cuboid)", Arrays.asList(rotatedPolygon)), polygonalRegion.intersectsEdges(cuboidRegion));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user