From edebb0efc92c977a81a097b7c25cced5431bb2a0 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 24 Aug 2014 15:53:45 -0700 Subject: [PATCH] Be more lax with entity spawns. --- .../worldguard/bukkit/WorldConfiguration.java | 4 +++ .../listener/EventAbstractionListener.java | 31 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java index 466b1c00..bae4a93a 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java @@ -176,6 +176,7 @@ public class WorldConfiguration { public boolean explosionFlagCancellation; public boolean disableDeathMessages; public boolean disableObsidianGenerators; + public boolean strictEntitySpawn; private Map maxRegionCounts; @@ -314,10 +315,13 @@ private void loadConfiguration() { summaryOnStart = getBoolean("summary-on-start", true); opPermissions = getBoolean("op-permissions", true); + buildPermissions = getBoolean("build-permission-nodes.enable", false); buildPermissionDenyMessage = CommandUtils.replaceColorMacros( getString("build-permission-nodes.deny-message", "&eSorry, but you are not permitted to do that here.")); + strictEntitySpawn = getBoolean("strictness.block-entity-spawns-with-untraceable-cause", false); + itemDurability = getBoolean("protection.item-durability", true); removeInfiniteStacks = getBoolean("protection.remove-infinite-stacks", false); disableExpDrops = getBoolean("protection.disable-xp-orb-drops", false); diff --git a/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java b/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java index 9cd32652..ff096467 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/listener/EventAbstractionListener.java @@ -453,7 +453,36 @@ public void onBlockFromTo(BlockFromToEvent event) { @EventHandler(ignoreCancelled = true) public void onCreatureSpawn(CreatureSpawnEvent event) { - Events.fireToCancel(event, new SpawnEntityEvent(event, Cause.unknown(), event.getEntity())); + switch (event.getSpawnReason()) { + case DISPENSE_EGG: + case EGG: + case SPAWNER_EGG: + if (getWorldConfig(event.getEntity().getWorld()).strictEntitySpawn) { + Events.fireToCancel(event, new SpawnEntityEvent(event, Cause.unknown(), event.getEntity())); + } + break; + case NATURAL: + case JOCKEY: + case CHUNK_GEN: + case SPAWNER: + case LIGHTNING: + case BUILD_SNOWMAN: + case BUILD_IRONGOLEM: + case BUILD_WITHER: + case VILLAGE_DEFENSE: + case VILLAGE_INVASION: + case BREEDING: + case SLIME_SPLIT: + case REINFORCEMENTS: + case NETHER_PORTAL: + case INFECTION: + case CURED: + case OCELOT_BABY: + case SILVERFISH_BLOCK: + case MOUNT: + case CUSTOM: + case DEFAULT: + } } @EventHandler(ignoreCancelled = true)