Added creeper block support.

This commit is contained in:
sk89q 2011-01-17 18:38:12 -08:00
parent e8503aa0b9
commit 86a917ddd1
3 changed files with 30 additions and 6 deletions

View File

@ -49,6 +49,7 @@ fire:
mobs:
block-creeper-explosions: off
block-creeper-block-damage: off
spawn:
login-protection: 3
@ -84,12 +85,7 @@ blacklist:
path: worldguard/logs/%Y-%m-%d.log
open-files: 10
# Change sk89q to your name (or sk89q will be able to change regions
# on your server!). Check the documentation to see how to configure this
#
# NOTE: The /reload permission is given to everyone below (only applies to
# WorldGuard) so that you can reload WorldGuard with /reload WorldGuard
# until your configuration work is done
# See http://wiki.sk89q.com/wiki/WorldGuard/Permissions/Bukkit
permissions:
groups:
default:

View File

@ -21,6 +21,7 @@
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -110,4 +111,28 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
}
}
}
@Override
public void onEntityExplode(EntityExplodeEvent event) {
if (event.getEntity() instanceof LivingEntity) {
if (plugin.blockCreeperBlockDamage) {
event.setCancelled(true);
return;
}
if (plugin.blockCreeperExplosions) {
event.setCancelled(true);
return;
}
if (plugin.useRegions) {
Vector pt = toVector(event.getEntity().getLocation());
if (!plugin.regionManager.getApplicableRegions(pt).allowsCreeperExplosions()) {
event.setCancelled(true);
return;
}
}
}
}
}

View File

@ -96,6 +96,7 @@ public class WorldGuardPlugin extends JavaPlugin {
Set<Integer> allowedLavaSpreadOver;
boolean blockCreeperExplosions;
boolean blockCreeperBlockDamage;
int loginProtection;
int spawnProtection;
@ -150,6 +151,7 @@ private void registerEvents() {
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.PLAYER_COMMAND, playerListener, Priority.Normal);
registerEvent(Event.Type.PLAYER_ITEM, playerListener, Priority.Normal);
@ -228,6 +230,7 @@ public void loadConfiguration() {
allowedLavaSpreadOver = new HashSet<Integer>(config.getIntList("fire.lava-spread-blocks", null));
blockCreeperExplosions = config.getBoolean("mobs.block-creeper-explosions", false);
blockCreeperBlockDamage = config.getBoolean("mobs.block-creeper-block-damage", false);
loginProtection = config.getInt("spawn.login-protection", 3);
spawnProtection = config.getInt("spawn.spawn-protection", 0);