Added config option to block zombies from breaking down doors

This commit is contained in:
Wizjany 2013-01-11 22:02:15 -05:00
parent 0d0ba31d3a
commit a240e5d128
2 changed files with 11 additions and 7 deletions

View File

@ -112,6 +112,7 @@ public class WorldConfiguration {
public boolean blockEntityItemFrameDestroy;
public boolean blockPluginSpawning;
public boolean blockGroundSlimes;
public boolean blockZombieDoorDestruction;
public boolean disableContactDamage;
public boolean disableFallDamage;
public boolean disableLavaDamage;
@ -352,6 +353,7 @@ private void loadConfiguration() {
blockPluginSpawning = getBoolean("mobs.block-plugin-spawning", true);
blockGroundSlimes = getBoolean("mobs.block-above-ground-slimes", false);
blockOtherExplosions = getBoolean("mobs.block-other-explosions", false);
blockZombieDoorDestruction = getBoolean("mobs.block-zombie-door-destruction", false);
disableFallDamage = getBoolean("player-damage.disable-fall-damage", false);
disableLavaDamage = getBoolean("player-damage.disable-lava-damage", false);

View File

@ -48,6 +48,7 @@
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.CreeperPowerEvent;
import org.bukkit.event.entity.EntityBreakDoorEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityCreatePortalEvent;
@ -823,7 +824,7 @@ public void onEntityRegainHealth(EntityRegainHealthEvent event) {
}
/**
* Called when an enderman picks up or puts down a block and some other cases.
* Called when an entity changes a block somehow
*
* @param event Relevant event details
*/
@ -833,11 +834,11 @@ public void onEndermanPickup(EntityChangeBlockEvent event) {
Block block = event.getBlock();
Location location = block.getLocation();
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(ent.getWorld());
if (ent instanceof Enderman) {
if (event.getTo() == Material.AIR) {
// pickup
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(ent.getWorld());
if (wcfg.disableEndermanGriefing) {
event.setCancelled(true);
@ -852,8 +853,6 @@ public void onEndermanPickup(EntityChangeBlockEvent event) {
}
} else {
// place
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(ent.getWorld());
if (wcfg.disableEndermanGriefing) {
event.setCancelled(true);
@ -868,13 +867,16 @@ public void onEndermanPickup(EntityChangeBlockEvent event) {
}
}
} else if (ent.getType() == witherType) {
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(ent.getWorld());
if (wcfg.blockWitherBlockDamage || wcfg.blockWitherExplosions) {
event.setCancelled(true);
return;
}
} else if (/*ent instanceof Zombie && */event instanceof EntityBreakDoorEvent) {
if (wcfg.blockZombieDoorDestruction) {
event.setCancelled(true);
return;
}
}
}