Compare commits

...
15 Commits
10 changed files with 173 additions and 52 deletions

No files matched your search

+17
View File
@@ -1,3 +1,20 @@
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.
+1 -1
View File
@@ -51,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}"/>
+2 -1
View File
@@ -26,9 +26,9 @@ protection:
item-durability: on
simulation:
classic-water: off
sponge:
enable: on
redstone: off
radius: 3
physics:
@@ -73,6 +73,7 @@ regions:
default:
build: true
chest-access: false
pvp: true
blacklist:
logging:
@@ -65,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);
}
}
@@ -123,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;
}
@@ -132,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(
@@ -171,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);
@@ -243,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
*
@@ -343,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);
}
}
@@ -393,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;
}
}
}
@@ -190,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);
@@ -216,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;
@@ -181,6 +183,8 @@ public class WorldGuardPlugin extends JavaPlugin {
registerEvent(Event.Type.BLOCK_INTERACT, blockListener, Priority.High);
registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.High);
registerEvent(Event.Type.BLOCK_RIGHTCLICKED, blockListener, Priority.High);
registerEvent(Event.Type.BLOCK_BURN, blockListener, Priority.High);
registerEvent(Event.Type.REDSTONE_CHANGE, blockListener, Priority.High);
registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.High);
registerEvent(Event.Type.ENTITY_DAMAGEDBY_PROJECTILE, entityListener, Priority.High);
@@ -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);
@@ -297,6 +302,7 @@ public class WorldGuardPlugin extends JavaPlugin {
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();
@@ -414,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;
}
@@ -445,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;
@@ -465,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;
@@ -480,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);
@@ -613,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);
@@ -1257,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();
}
}
@@ -68,9 +68,11 @@ public class ApplicableRegionSet {
*/
public boolean allowsFlag(String flag) {
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);
@@ -27,4 +27,5 @@ 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();