Compare commits

...
9 Commits
Author SHA1 Message Date
sk89q 0d2c2121bb 3.2.1 CHANGELOG.txt. 2011-01-31 14:36:33 -08:00
sk89q 21040b306a Updated for ItemStack change in Bukkit. 2011-01-31 14:35:46 -08:00
sk89q 541b1dbc44 Updated for 3.2. 2011-01-30 01:38:39 -08:00
sk89q 005ac41820 Added PvP default flag. 2011-01-30 01:36:59 -08:00
sk89q dd93772233 Fixed creeper explosion block with WorldGuard. 2011-01-30 01:16:16 -08:00
sk89q 428fc7e5f6 Fixed commands for the Bukkit commands change. 2011-01-30 01:03:57 -08:00
sk89q 5cf38cc885 Added redstone support to sponges, removed classic water. 2011-01-28 10:23:43 -08:00
sk89q 2f6b51e811 Fixed item durability disable for hoes. 2011-01-28 00:59:19 -08:00
sk89q 2f12da6bc6 Fixed error in a test. 2011-01-28 00:06:58 -08:00
9 changed files with 113 additions and 29 deletions

No files matched your search

+11
View File
@@ -1,3 +1,14 @@
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.
+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(
@@ -343,21 +347,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 +391,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);
}
}
}
}
}
}
@@ -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,7 @@ 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.REDSTONE_CHANGE, blockListener, Priority.High);
registerEvent(Event.Type.ENTITY_DAMAGED, entityListener, Priority.High);
registerEvent(Event.Type.ENTITY_DAMAGEDBY_PROJECTILE, entityListener, Priority.High);
@@ -262,6 +265,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);
@@ -297,6 +301,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,7 +419,14 @@ 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) {
if (!sender.isPlayer()) {
return true;
}
Player player = (Player)sender;
try {
return handleCommand(player, cmd.getName(), args);
} catch (InsufficientArgumentsException e) {
@@ -613,7 +625,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);
@@ -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();