Merge remote-tracking branch 'remotes/origin/master'

This commit is contained in:
sk89q 2011-06-06 11:15:40 -07:00
commit 9e1bde4b00
3 changed files with 53 additions and 4 deletions

View File

@ -72,6 +72,7 @@ public void registerEvents() {
pm.registerEvent(Event.Type.SIGN_CHANGE, this, Priority.High, plugin); pm.registerEvent(Event.Type.SIGN_CHANGE, this, Priority.High, plugin);
pm.registerEvent(Event.Type.REDSTONE_CHANGE, this, Priority.High, plugin); pm.registerEvent(Event.Type.REDSTONE_CHANGE, this, Priority.High, plugin);
pm.registerEvent(Event.Type.SNOW_FORM, this, Priority.High, plugin); pm.registerEvent(Event.Type.SNOW_FORM, this, Priority.High, plugin);
pm.registerEvent(Event.Type.LEAVES_DECAY, this, Priority.High, plugin);
} }
/** /**
@ -481,7 +482,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
int oy = blockPlaced.getY(); int oy = blockPlaced.getY();
int oz = blockPlaced.getZ(); int oz = blockPlaced.getZ();
clearSpongeWater(plugin, world, ox, oy, oz); SpongeUtil.clearSpongeWater(plugin, world, ox, oy, oz);
} }
} }
@ -508,10 +509,10 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) {
Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz); Block sponge = world.getBlockAt(ox + cx, oy + cy, oz + cz);
if (sponge.getTypeId() == 19 if (sponge.getTypeId() == 19
&& sponge.isBlockIndirectlyPowered()) { && sponge.isBlockIndirectlyPowered()) {
clearSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); SpongeUtil.clearSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz);
} else if (sponge.getTypeId() == 19 } else if (sponge.getTypeId() == 19
&& !sponge.isBlockIndirectlyPowered()) { && !sponge.isBlockIndirectlyPowered()) {
addSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz); SpongeUtil.addSpongeWater(plugin, world, ox + cx, oy + cy, oz + cz);
} }
} }
} }
@ -599,4 +600,49 @@ public void onSnowForm(SnowFormEvent event) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@Override
public void onLeavesDecay(LeavesDecayEvent event) {
if (event.isCancelled()) {
return;
}
if (!plugin.getGlobalRegionManager().allows(DefaultFlag.LEAF_DECAY, event.getBlock().getLocation())) {
event.setCancelled(true);
}
}
/**
* Drops a sign item and removes a sign.
*
* @param block
*/
private void dropSign(Block block) {
block.setTypeId(0);
block.getWorld().dropItemNaturally(block.getLocation(),
new ItemStack(Material.SIGN, 1));
}
/**
* Remove water around a sponge.
*
* @param world
* @param ox
* @param oy
* @param oz
*/
private void clearSpongeWater(World world, int ox, int oy, int oz) {
ConfigurationManager cfg = plugin.getGlobalConfiguration();
WorldConfiguration wcfg = cfg.get(world);
for (int cx = -wcfg.spongeRadius; cx <= wcfg.spongeRadius; cx++) {
for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) {
for (int cz = -wcfg.spongeRadius; cz <= wcfg.spongeRadius; cz++) {
if (isBlockWater(world, ox + cx, oy + cy, oz + cz)) {
world.getBlockAt(ox + cx, oy + cy, oz + cz).setTypeId(0);
}
}
}
}
}
} }

View File

@ -260,6 +260,7 @@ private void handleBlockLeftClick(PlayerInteractEvent event) {
if (type == Material.STONE_BUTTON if (type == Material.STONE_BUTTON
|| type == Material.LEVER || type == Material.LEVER
|| type == Material.WOODEN_DOOR || type == Material.WOODEN_DOOR
|| type == Material.TRAP_DOOR
|| type == Material.NOTE_BLOCK) { || type == Material.NOTE_BLOCK) {
if (!plugin.getGlobalRegionManager().hasBypass(player, world) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.allows(DefaultFlag.USE) && !set.allows(DefaultFlag.USE)
@ -383,6 +384,7 @@ private void handleBlockRightClick(PlayerInteractEvent event) {
|| type == Material.DIODE_BLOCK_OFF || type == Material.DIODE_BLOCK_OFF
|| type == Material.DIODE_BLOCK_ON || type == Material.DIODE_BLOCK_ON
|| type == Material.WOODEN_DOOR || type == Material.WOODEN_DOOR
|| type == Material.TRAP_DOOR
|| type == Material.WORKBENCH) { || type == Material.WORKBENCH) {
if (!plugin.getGlobalRegionManager().hasBypass(player, world) if (!plugin.getGlobalRegionManager().hasBypass(player, world)
&& !set.allows(DefaultFlag.USE) && !set.allows(DefaultFlag.USE)

View File

@ -44,6 +44,7 @@ public final class DefaultFlag {
public static final StateFlag USE = new StateFlag("use", false); public static final StateFlag USE = new StateFlag("use", false);
public static final StateFlag PLACE_VEHICLE = new StateFlag("vehicle-place", false); public static final StateFlag PLACE_VEHICLE = new StateFlag("vehicle-place", false);
public static final StateFlag SNOW_FALL = new StateFlag("snow-fall", true); public static final StateFlag SNOW_FALL = new StateFlag("snow-fall", true);
public static final StateFlag LEAF_DECAY = new StateFlag("leaf-decay", true);
public static final StringFlag GREET_MESSAGE = new StringFlag("greeting"); public static final StringFlag GREET_MESSAGE = new StringFlag("greeting");
public static final StringFlag FAREWELL_MESSAGE = new StringFlag("farewell"); public static final StringFlag FAREWELL_MESSAGE = new StringFlag("farewell");
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter"); public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
@ -63,7 +64,7 @@ public final class DefaultFlag {
TNT, LIGHTER, FIRE_SPREAD, LAVA_FIRE, CHEST_ACCESS, WATER_FLOW, LAVA_FLOW, TNT, LIGHTER, FIRE_SPREAD, LAVA_FIRE, CHEST_ACCESS, WATER_FLOW, LAVA_FLOW,
USE, PLACE_VEHICLE, GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_ENTER, USE, PLACE_VEHICLE, GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_ENTER,
NOTIFY_LEAVE, DENY_SPAWN, HEAL_DELAY, HEAL_AMOUNT, TELE_LOC, NOTIFY_LEAVE, DENY_SPAWN, HEAL_DELAY, HEAL_AMOUNT, TELE_LOC,
TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE, SNOW_FALL, TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE, SNOW_FALL, LEAF_DECAY,
GHAST_FIREBALL GHAST_FIREBALL
}; };