Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e78b639018 | ||
|
|
e8ea562b09 | ||
|
|
3b5a729ef3 | ||
|
|
ef7d487ec5 | ||
|
|
b379b8f022 | ||
|
|
a31378c2c8 | ||
|
|
0d2c2121bb | ||
|
|
21040b306a | ||
|
|
541b1dbc44 | ||
|
|
005ac41820 | ||
|
|
dd93772233 | ||
|
|
428fc7e5f6 | ||
|
|
5cf38cc885 | ||
|
|
2f6b51e811 | ||
|
|
2f12da6bc6 | ||
|
|
3985e157d9 | ||
|
|
3034eb5c12 | ||
|
|
f666f1baa9 | ||
|
|
3bbffa7b55 | ||
|
|
bc774e2596 | ||
|
|
65a0e5c188 | ||
|
|
772d2cb580 | ||
|
|
edc6825f83 | ||
|
|
7b2f9e0c86 | ||
|
|
0fa4fa1862 |
No files matched your search
@@ -1,3 +1,33 @@
|
||||
3.2.2:
|
||||
- Changed disable-water-damage to disable-drowning-damage.
|
||||
- Fixed suffocation disable option.
|
||||
- Fixed fire spread blocking.
|
||||
- stopfire and allowfire now work in server console, just like in hMod.
|
||||
|
||||
3.2.1:
|
||||
- Updated for recent Bukkit ItemStack change.
|
||||
|
||||
3.2:
|
||||
- Added regions.default.pvp to control default PvP setting.
|
||||
- Updated WorldGuard for the newer builds of Bukkit.
|
||||
- Fixed creeper explosion blocking.
|
||||
- Added redstone support to sponges, removed classic water.
|
||||
- Fixed item durability disable for hoes.
|
||||
|
||||
|
||||
3.1.2:
|
||||
- Increased the priority of WorldGuard's event handling.
|
||||
|
||||
3.1.1:
|
||||
- Fixed creeper and chest flag conflicting.
|
||||
|
||||
3.1:
|
||||
- Added ability to disable chest protection. New configuration setting
|
||||
(regions.build.chest-access) and new chest flag.
|
||||
- Possibly fixed projectile blocking in no-PvP zones.
|
||||
- Added /regionmembership permission that lets people only change
|
||||
the owners and members of regions they own.
|
||||
|
||||
3.0b2:
|
||||
- Fixed issue where built-in permissions were not (re)loaded.
|
||||
- Fixed /god not working for others.
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
<property name="dist.dir" location="dist"/>
|
||||
<property name="release.dir" location="release"/>
|
||||
<property name="lib.dir" location="lib"/>
|
||||
<property name="docs.dir" location="docs"/>
|
||||
|
||||
<fileset id="libs" dir="${lib.dir}">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="${build.dir}"/>
|
||||
@@ -16,9 +21,7 @@
|
||||
<target name="compile" depends="init">
|
||||
<javac srcdir="${src.dir}" deprecation="true" includeantruntime="true" destdir="${build.dir}" debug="true">
|
||||
<classpath>
|
||||
<fileset dir="${lib.dir}">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
<fileset refid="libs"/>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
@@ -48,7 +51,7 @@
|
||||
</target>
|
||||
|
||||
<!-- Build a release -->
|
||||
<target name="release">
|
||||
<target name="release" depends="clean">
|
||||
<input message="Enter version:" addproperty="version"/>
|
||||
<antcall target="jar"/>
|
||||
<delete dir="${release.dir}"/>
|
||||
@@ -66,11 +69,21 @@
|
||||
<zip destfile="${release.dir}/worldguard-${version}-src.zip" basedir="${release.dir}" excludes="*.zip plugin.yml"/>
|
||||
</target>
|
||||
|
||||
<!-- Javadoc -->
|
||||
<target name="javadoc">
|
||||
<javadoc access="public" author="true" destdir="${docs.dir}" doctitle="WorldGuard API" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.6" sourcepath="src" splitindex="true" use="true" version="true">
|
||||
<classpath>
|
||||
<fileset refid="libs"/>
|
||||
</classpath>
|
||||
</javadoc>
|
||||
</target>
|
||||
|
||||
<!-- Clean the output -->
|
||||
<target name="clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
<delete dir="${release.dir}"/>
|
||||
<delete dir="${docs.dir}"/>
|
||||
</target>
|
||||
|
||||
<!--<target name="-get-version-git" if="git-revision">
|
||||
|
||||
+3
-1
@@ -26,9 +26,9 @@ protection:
|
||||
item-durability: on
|
||||
|
||||
simulation:
|
||||
classic-water: off
|
||||
sponge:
|
||||
enable: on
|
||||
redstone: off
|
||||
radius: 3
|
||||
|
||||
physics:
|
||||
@@ -72,6 +72,8 @@ regions:
|
||||
wand: 287
|
||||
default:
|
||||
build: true
|
||||
chest-access: false
|
||||
pvp: true
|
||||
|
||||
blacklist:
|
||||
logging:
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project default="javadoc">
|
||||
<target name="javadoc">
|
||||
<javadoc access="public" author="true" classpath="P:\Projects\Minecraft\Libraries\GroupUsers.jar;P:\Projects\Minecraft\Libraries\jnbt.jar;P:\Projects\Minecraft\hMod\build\classes;P:\Projects\Minecraft\WorldEdit\build\classes;P:\Projects\Minecraft\Libraries\snakeyaml.jar;P:\Projects\Minecraft\Libraries\jopt-simple-3.2.jar;P:\Projects\Minecraft\Libraries\Permissions.jar;C:\Program Files\eclipse\plugins\org.hamcrest.core_1.1.0.v20090501071000.jar;P:\Projects\Minecraft\Libraries\json_simple-1.1.jar;P:\Projects\Minecraft\CraftBukkit\bin;P:\Projects\Minecraft\Libraries\truezip.jar;C:\Program Files\eclipse\plugins\org.junit_4.8.1.v4_8_1_v20100427-1100\junit.jar;P:\Projects\Minecraft\Bukkit\bin;P:\Projects\Minecraft\mc-dev" destdir="doc" doctitle="Worldguard API" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" packagenames="com.sk89q.worldguard.blacklist,com.sk89q.worldguard.domains,com.sk89q.worldguard.bukkit,com.sk89q.worldguard.protection,com.sk89q.worldguard.util,au.com.bytecode.opencsv,com.sk89q.worldguard,com.sk89q.worldguard.blacklist.loggers,com.sk89q.worldguard.blacklist.events" source="1.6" sourcepath="tests;src" splitindex="true" use="true" version="true"/>
|
||||
</target>
|
||||
</project>
|
||||
@@ -35,6 +35,7 @@ import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.blacklist.events.*;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.AreaFlags;
|
||||
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
|
||||
|
||||
public class WorldGuardBlockListener extends BlockListener {
|
||||
@@ -64,7 +65,7 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
if (!plugin.itemDurability && event.getDamageLevel() == BlockDamageLevel.BROKEN) {
|
||||
ItemStack held = player.getItemInHand();
|
||||
if (held.getTypeId() > 0) {
|
||||
held.setDamage((byte)-1);
|
||||
held.setDurability((short) -1);
|
||||
player.setItemInHand(held);
|
||||
}
|
||||
}
|
||||
@@ -122,7 +123,9 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
for (int cx = -plugin.spongeRadius; cx <= plugin.spongeRadius; cx++) {
|
||||
for (int cy = -plugin.spongeRadius; cy <= plugin.spongeRadius; cy++) {
|
||||
for (int cz = -plugin.spongeRadius; cz <= plugin.spongeRadius; cz++) {
|
||||
if (world.getBlockTypeIdAt(ox + cx, oy + cy, oz + cz) == 19) {
|
||||
Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||
if (sponge.getTypeId() == 19
|
||||
&& (!plugin.redstoneSponges || !sponge.isBlockIndirectlyPowered())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -131,14 +134,16 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.classicWater && isWater) {
|
||||
int blockBelow = world.getBlockTypeIdAt(blockFrom.getX(), blockFrom.getY() - 1, blockFrom.getZ());
|
||||
/*if (plugin.classicWater && isWater) {
|
||||
int blockBelow = blockFrom.getRelative(0, -1, 0).getTypeId();
|
||||
if (blockBelow != 0 && blockBelow != 8 && blockBelow != 9) {
|
||||
world.getBlockAt(blockFrom.getX(), blockFrom.getY(), blockFrom.getZ()).setTypeId(9);
|
||||
event.setCancelled(true);
|
||||
blockFrom.setTypeId(9);
|
||||
if (blockTo.getTypeId() == 0) {
|
||||
blockTo.setTypeId(9);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (plugin.preventWaterDamage.size() > 0 && isWater) {
|
||||
int targetId = world.getBlockTypeIdAt(
|
||||
@@ -170,8 +175,7 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
Block block = event.getBlock();
|
||||
//Player player = event.getPlayer();
|
||||
World world = block.getWorld();
|
||||
boolean isFireSpread = cause == IgniteCause.SLOW_SPREAD
|
||||
|| cause == IgniteCause.SPREAD;
|
||||
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
||||
|
||||
if (plugin.preventLavaFire && cause == IgniteCause.LAVA) {
|
||||
event.setCancelled(true);
|
||||
@@ -242,6 +246,32 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is destroyed from burning
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onBlockBurn(BlockBurnEvent event) {
|
||||
if (plugin.disableFireSpread) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.fireSpreadDisableToggle) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.disableFireSpreadBlocks.size() > 0) {
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (plugin.disableFireSpreadBlocks.contains(block.getTypeId())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when block physics occurs
|
||||
*
|
||||
@@ -288,6 +318,7 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
|
||||
if (!plugin.hasPermission(player, "/regionbypass")
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).allowsFlag(AreaFlags.FLAG_CHEST_ACCESS)
|
||||
&& !plugin.regionManager.getApplicableRegions(pt).canBuild(localPlayer)) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "You don't have permission for this area.");
|
||||
event.setCancelled(true);
|
||||
@@ -341,21 +372,15 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
}
|
||||
|
||||
if (plugin.simulateSponge && blockPlaced.getTypeId() == 19) {
|
||||
if (plugin.redstoneSponges && blockPlaced.isBlockIndirectlyPowered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int ox = blockPlaced.getX();
|
||||
int oy = blockPlaced.getY();
|
||||
int oz = blockPlaced.getZ();
|
||||
|
||||
for (int cx = -plugin.spongeRadius; cx <= plugin.spongeRadius; cx++) {
|
||||
for (int cy = -plugin.spongeRadius; cy <= plugin.spongeRadius; cy++) {
|
||||
for (int cz = -plugin.spongeRadius; cz <= plugin.spongeRadius; cz++) {
|
||||
int id = world.getBlockTypeIdAt(ox + cx, oy + cy, oz + cz);
|
||||
if (id == 8 || id == 9) {
|
||||
world.getBlockAt(ox + cx, oy + cy, oz + cz)
|
||||
.setTypeId(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
clearSpongeWater(world, ox, oy, oz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,4 +416,61 @@ public class WorldGuardBlockListener extends BlockListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when redstone changes
|
||||
* From: the source of the redstone change
|
||||
* To: The redstone dust that changed
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@Override
|
||||
public void onBlockRedstoneChange(BlockFromToEvent event) {
|
||||
World world = event.getBlock().getWorld();
|
||||
Block blockTo = event.getToBlock();
|
||||
|
||||
if (plugin.simulateSponge && plugin.redstoneSponges) {
|
||||
int ox = blockTo.getX();
|
||||
int oy = blockTo.getY();
|
||||
int oz = blockTo.getZ();
|
||||
|
||||
for (int cx = -1; cx <= 1; cx++) {
|
||||
for (int cy = -1; cy <= 1; cy++) {
|
||||
for (int cz = -1; cz <= 1; cz++) {
|
||||
Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||
if (sponge.getTypeId() == 19
|
||||
&& sponge.isBlockIndirectlyPowered()) {
|
||||
clearSpongeWater(world, ox + cx, oy + cy, oz + cz);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove water around a sponge.
|
||||
*
|
||||
* @param world
|
||||
* @param ox
|
||||
* @param oy
|
||||
* @param oz
|
||||
*/
|
||||
private void clearSpongeWater(World world, int ox, int oy, int oz) {
|
||||
for (int cx = -plugin.spongeRadius; cx <= plugin.spongeRadius; cx++) {
|
||||
for (int cy = -plugin.spongeRadius; cy <= plugin.spongeRadius; cy++) {
|
||||
for (int cz = -plugin.spongeRadius; cz <= plugin.spongeRadius; cz++) {
|
||||
Block block = world.getBlockAt(ox + cx, oy + cy, oz + cz);
|
||||
int id = block.getTypeId();
|
||||
if (id == 8 || id == 9) {
|
||||
world.getBlockAt(ox + cx, oy + cy, oz + cz)
|
||||
.setTypeId(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,11 @@ public class WorldGuardEntityListener extends EntityListener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.disableContactDamage && type == DamageCause.CONTACT) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +130,7 @@ public class WorldGuardEntityListener extends EntityListener {
|
||||
|
||||
public void onEntityDamageByProjectile(EntityDamageByProjectileEvent event) {
|
||||
Entity defender = event.getEntity();
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player)defender;
|
||||
@@ -133,6 +139,19 @@ public class WorldGuardEntityListener extends EntityListener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker != null && attacker instanceof Player) {
|
||||
if (plugin.useRegions) {
|
||||
Vector pt = toVector(defender.getLocation());
|
||||
|
||||
if (!plugin.regionManager.getApplicableRegions(pt)
|
||||
.allowsFlag(AreaFlags.FLAG_PVP)) {
|
||||
((Player)attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -176,11 +195,6 @@ public class WorldGuardEntityListener extends EntityListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.disableContactDamage && type == DamageCause.CONTACT) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == DamageCause.DROWNING
|
||||
&& plugin.amphibiousPlayers.contains(player.getName())) {
|
||||
event.setCancelled(true);
|
||||
@@ -202,12 +216,6 @@ public class WorldGuardEntityListener extends EntityListener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.regionManager.getApplicableRegions(BukkitUtil.toVector(event.getEntity().getLocation()))
|
||||
.allowsFlag(AreaFlags.FLAG_CREEPER_EXPLOSION)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.useRegions) {
|
||||
Vector pt = toVector(event.getEntity().getLocation());
|
||||
|
||||
|
||||
@@ -96,6 +96,14 @@ public class WorldGuardPlayerListener extends PlayerListener {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlockClicked();
|
||||
ItemStack item = event.getItem();
|
||||
|
||||
if (!plugin.itemDurability) {
|
||||
// Hoes
|
||||
if (item.getTypeId() >= 290 && item.getTypeId() <= 294) {
|
||||
item.setDurability((byte)-1);
|
||||
player.setItemInHand(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.useRegions && !event.isBlock() && block != null) {
|
||||
Vector pt = toVector(block.getRelative(event.getBlockFace()));
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.logging.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -94,6 +95,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
boolean classicWater;
|
||||
boolean simulateSponge;
|
||||
int spongeRadius;
|
||||
boolean redstoneSponges;
|
||||
|
||||
boolean noPhysicsGravel;
|
||||
boolean noPhysicsSand;
|
||||
@@ -174,21 +176,23 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
* Register used events.
|
||||
*/
|
||||
private void registerEvents() {
|
||||
registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.Normal);
|
||||
registerEvent(Event.Type.BLOCK_DAMAGED, blockListener, Priority.High);
|
||||
registerEvent(Event.Type.BLOCK_FLOW, blockListener, Priority.Normal);
|
||||
registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Priority.Normal);
|
||||
registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Priority.High);
|
||||
registerEvent(Event.Type.BLOCK_PHYSICS, blockListener, Priority.Normal);
|
||||
registerEvent(Event.Type.BLOCK_INTERACT, blockListener, Priority.Normal);
|
||||
registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Normal);
|
||||
registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Normal);
|
||||
registerEvent(Event.Type.BLOCK_INTERACT, blockListener, Priority.High);
|
||||
registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.High);
|
||||
registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.High);
|
||||
registerEvent(Event.Type.BLOCK_BURN, blockListener, Priority.High);
|
||||
registerEvent(Event.Type.REDSTONE_CHANGE, blockListener, Priority.High);
|
||||
|
||||
registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.Normal);
|
||||
registerEvent(Event.Type.ENTITY_DAMAGEDBY_PROJECTILE, entityListener, Priority.Normal);
|
||||
registerEvent(Event.Type.ENTITY_DAMAGEDBY_BLOCK, entityListener, Priority.Normal);
|
||||
registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.Normal);
|
||||
registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.Normal);
|
||||
registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.High);
|
||||
registerEvent(Event.Type.ENTITY_DAMAGEDBY_PROJECTILE, entityListener, Priority.High);
|
||||
registerEvent(Event.Type.ENTITY_DAMAGEDBY_BLOCK, entityListener, Priority.High);
|
||||
registerEvent(Event.Type.ENTITY_DAMAGEDBY_ENTITY, entityListener, Priority.High);
|
||||
registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Priority.High);
|
||||
|
||||
registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.Normal);
|
||||
registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.High);
|
||||
registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal);
|
||||
registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal);
|
||||
registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal);
|
||||
@@ -262,6 +266,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
classicWater = config.getBoolean("simulation.classic-water", false);
|
||||
simulateSponge = config.getBoolean("simulation.sponge.enable", true);
|
||||
spongeRadius = Math.max(1, config.getInt("simulation.sponge.radius", 3)) - 1;
|
||||
redstoneSponges = config.getBoolean("simulation.sponge.redstone", false);
|
||||
|
||||
noPhysicsGravel = config.getBoolean("physics.no-physics-gravel", false);
|
||||
noPhysicsSand = config.getBoolean("physics.no-physics-sand", false);
|
||||
@@ -288,7 +293,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
disableFallDamage = config.getBoolean("player-damage.disable-fall-damage", false);
|
||||
disableLavaDamage = config.getBoolean("player-damage.disable-lava-damage", false);
|
||||
disableFireDamage = config.getBoolean("player-damage.disable-fire-damage", false);
|
||||
disableDrowningDamage = config.getBoolean("player-damage.disable-water-damage", false);
|
||||
disableDrowningDamage = config.getBoolean("player-damage.disable-drowning-damage", false);
|
||||
disableSuffocationDamage = config.getBoolean("player-damage.disable-suffocation-damage", false);
|
||||
disableContactDamage = config.getBoolean("player-damage.disable-contact-damage", false);
|
||||
teleportOnSuffocation = config.getBoolean("player-damage.teleport-on-suffocation", false);
|
||||
@@ -296,6 +301,8 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
useRegions = config.getBoolean("regions.enable", true);
|
||||
regionWand = config.getInt("regions.wand", 287);
|
||||
globalFlags.canBuild = config.getBoolean("regions.default.build", true);
|
||||
globalFlags.canAccessChests = config.getBoolean("regions.default.chest-access", false);
|
||||
globalFlags.canPvP = config.getBoolean("regions.default.pvp", true);
|
||||
|
||||
try {
|
||||
regionLoader.load();
|
||||
@@ -413,23 +420,24 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
/**
|
||||
* Handles a command.
|
||||
*/
|
||||
public boolean onCommand(Player player, Command cmd, String commandLabel, String[] args) {
|
||||
public boolean onCommand(CommandSender sender, Command cmd,
|
||||
String commandLabel, String[] args) {
|
||||
try {
|
||||
return handleCommand(player, cmd.getName(), args);
|
||||
return handleCommand(sender, cmd.getName(), args);
|
||||
} catch (InsufficientArgumentsException e) {
|
||||
if (e.getHelp() != null) {
|
||||
player.sendMessage(ChatColor.RED + e.getHelp());
|
||||
sender.sendMessage(ChatColor.RED + e.getHelp());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (InsufficientPermissionsException e) {
|
||||
player.sendMessage(ChatColor.RED + "You don't have sufficient permission.");
|
||||
sender.sendMessage(ChatColor.RED + "You don't have sufficient permission.");
|
||||
return true;
|
||||
} catch (CommandHandlingException e) {
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
player.sendMessage(ChatColor.RED + "ERROR: " + t.getMessage());
|
||||
sender.sendMessage(ChatColor.RED + "ERROR: " + t.getMessage());
|
||||
t.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
@@ -444,18 +452,20 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
* @return
|
||||
* @throws CommandHandlingException
|
||||
*/
|
||||
private boolean handleCommand(Player player, String cmd, String[] args)
|
||||
private boolean handleCommand(CommandSender sender, String cmd, String[] args)
|
||||
throws CommandHandlingException {
|
||||
|
||||
String senderName = sender instanceof Player ? ((Player)sender).getName() : "Console";
|
||||
|
||||
if (cmd.equalsIgnoreCase("stopfire")) {
|
||||
checkPermission(player, "/stopfire");
|
||||
checkPermission(sender, "/stopfire");
|
||||
checkArgs(args, 0, 0);
|
||||
|
||||
if (!fireSpreadDisableToggle) {
|
||||
getServer().broadcastMessage(ChatColor.YELLOW
|
||||
+ "Fire spread has been globally disabled by " + player.getName() + ".");
|
||||
+ "Fire spread has been globally disabled by " + senderName + ".");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + "Fire spread was already globally disabled.");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Fire spread was already globally disabled.");
|
||||
}
|
||||
|
||||
fireSpreadDisableToggle = true;
|
||||
@@ -464,14 +474,14 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (cmd.equalsIgnoreCase("allowfire")) {
|
||||
checkPermission(player, "/stopfire");
|
||||
checkPermission(sender, "/stopfire");
|
||||
checkArgs(args, 0, 0);
|
||||
|
||||
if (fireSpreadDisableToggle) {
|
||||
getServer().broadcastMessage(ChatColor.YELLOW
|
||||
+ "Fire spread has been globally re-enabled by " + player.getName() + ".");
|
||||
+ "Fire spread has been globally re-enabled by " + senderName + ".");
|
||||
} else {
|
||||
player.sendMessage(ChatColor.YELLOW + "Fire spread was already globally enabled.");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Fire spread was already globally enabled.");
|
||||
}
|
||||
|
||||
fireSpreadDisableToggle = false;
|
||||
@@ -479,6 +489,12 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player)sender;
|
||||
|
||||
if (cmd.equalsIgnoreCase("god")) {
|
||||
checkPermission(player, "/god");
|
||||
checkArgs(args, 0, 1);
|
||||
@@ -612,7 +628,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
// Blocks store their color in the damage value
|
||||
if (item2.getTypeId() == item.getTypeId() &&
|
||||
(!ItemType.usesDamageValue(item.getTypeId())
|
||||
|| item.getDamage() == item2.getDamage())) {
|
||||
|| item.getDurability() == item2.getDurability())) {
|
||||
// This stack won't fit in the parent stack
|
||||
if (item2.getAmount() > needed) {
|
||||
item.setAmount(64);
|
||||
@@ -969,7 +985,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase("addowner") || action.equalsIgnoreCase("addmember")) {
|
||||
if (!hasPermission(player, "/regionclaim")) {
|
||||
if (!hasPermission(player, "/regionclaim") && !hasPermission(player, "/regionmembership")) {
|
||||
checkRegionPermission(player, "/regiondefine");
|
||||
}
|
||||
checkArgs(args, 2, -1, "/region add[member|owner] <id> [player1 [group1 [players/groups...]]]");
|
||||
@@ -1013,7 +1029,7 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (action.equalsIgnoreCase("removeowner") || action.equalsIgnoreCase("removemember")) {
|
||||
if (!hasPermission(player, "/regionclaim")) {
|
||||
if (!hasPermission(player, "/regionclaim") && !hasPermission(player, "/regionmembership")) {
|
||||
checkRegionPermission(player, "/regiondefine");
|
||||
}
|
||||
checkArgs(args, 2, -1, "/region removeowner <id> [owner1 [owner2 [owners...]]]");
|
||||
@@ -1256,13 +1272,16 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
* Checks to see if there are sufficient permissions, otherwise an exception
|
||||
* is raised in that case.
|
||||
*
|
||||
* @param player
|
||||
* @param sender
|
||||
* @param permission
|
||||
* @throws InsufficientPermissionsException
|
||||
*/
|
||||
private void checkPermission(Player player, String permission)
|
||||
private void checkPermission(CommandSender sender, String permission)
|
||||
throws InsufficientPermissionsException {
|
||||
if (!hasPermission(player, permission)) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if (!hasPermission((Player)sender, permission)) {
|
||||
throw new InsufficientPermissionsException();
|
||||
}
|
||||
}
|
||||
@@ -1298,6 +1317,24 @@ public class WorldGuardPlugin extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the region manager.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RegionManager getRegionManager() {
|
||||
return regionManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the region loader.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public ProtectionDatabase getRegionLoader() {
|
||||
return regionLoader;
|
||||
}
|
||||
|
||||
boolean inGroup(Player player, String group) {
|
||||
try {
|
||||
return perms.inGroup(player.getName(), group);
|
||||
|
||||
@@ -67,7 +67,15 @@ public class ApplicableRegionSet {
|
||||
* @return
|
||||
*/
|
||||
public boolean allowsFlag(String flag) {
|
||||
return isFlagAllowed(flag, true, null);
|
||||
boolean def = true;
|
||||
|
||||
if (flag.equals(AreaFlags.FLAG_CHEST_ACCESS)) {
|
||||
def = global.canAccessChests;
|
||||
} else if (flag.equals(AreaFlags.FLAG_PVP)) {
|
||||
def = global.canPvP;
|
||||
}
|
||||
|
||||
return isFlagAllowed(flag, def, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,6 +88,9 @@ public class ApplicableRegionSet {
|
||||
private boolean isFlagAllowed(String flag, boolean def, LocalPlayer player) {
|
||||
boolean found = false;
|
||||
boolean allowed = false; // Used for ALLOW override
|
||||
if (player == null) {
|
||||
allowed = def;
|
||||
}
|
||||
int lastPriority = 0;
|
||||
|
||||
// The algorithm is as follows:
|
||||
@@ -120,6 +131,7 @@ public class ApplicableRegionSet {
|
||||
// default state is now to allow
|
||||
if (region.getFlags().get(flag) == State.ALLOW) {
|
||||
allowed = true;
|
||||
found = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -145,7 +157,8 @@ public class ApplicableRegionSet {
|
||||
lastPriority = region.getPriority();
|
||||
}
|
||||
|
||||
return found == false ? def : allowed || needsClear.size() == 0;
|
||||
return (found == false ? def : allowed)
|
||||
|| (player != null && needsClear.size() == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,6 +44,7 @@ public class AreaFlags {
|
||||
public static final String FLAG_LIGHTER = "l";
|
||||
public static final String FLAG_FIRE_SPREAD = "f";
|
||||
public static final String FLAG_LAVA_FIRE = "F";
|
||||
public static final String FLAG_CHEST_ACCESS = "C";
|
||||
|
||||
/**
|
||||
* Get the user-friendly name of a flag. If a name isn't known, then
|
||||
@@ -71,6 +72,8 @@ public class AreaFlags {
|
||||
return "fire spread";
|
||||
} else if (flag.equals(FLAG_LAVA_FIRE)) {
|
||||
return "lava fire spread";
|
||||
} else if (flag.equals(FLAG_CHEST_ACCESS)) {
|
||||
return "chest access";
|
||||
} else {
|
||||
return flag;
|
||||
}
|
||||
@@ -101,6 +104,8 @@ public class AreaFlags {
|
||||
return FLAG_FIRE_SPREAD;
|
||||
} else if (name.equalsIgnoreCase("lavafirespread")) {
|
||||
return FLAG_LAVA_FIRE;
|
||||
} else if (name.equalsIgnoreCase("chest")) {
|
||||
return FLAG_CHEST_ACCESS;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -26,4 +26,6 @@ package com.sk89q.worldguard.protection;
|
||||
*/
|
||||
public class GlobalFlags {
|
||||
public boolean canBuild = true;
|
||||
public boolean canAccessChests = false;
|
||||
public boolean canPvP = true;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class ApplicableRegionSetTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
manager = new FlatRegionManager();
|
||||
manager = new FlatRegionManager(new GlobalFlags());
|
||||
|
||||
setUpPlayers();
|
||||
setUpCourtyardRegion();
|
||||
|
||||
Reference in new issue
Block a user