From da11f3bfdb556eb652bca3b424ba081c595ed0a0 Mon Sep 17 00:00:00 2001 From: totemo Date: Thu, 17 Mar 2016 01:14:17 +1030 Subject: [PATCH] Add disable-entity-block-damage setting to disable ender crystal block damage (but works for creepers too!). --- README.md | 1 + config.yml | 1 + pom.xml | 2 +- src/nu/nerd/kitchensink/Configuration.java | 9 +++++++++ src/nu/nerd/kitchensink/KitchenSinkListener.java | 9 +++++++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c512e28..94fc4eb 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Configuration * `disable-snowgrow` Disable snow being generated. * `disable-drops` Disable items, great for creative servers. * `disable-tnt` Disable TNT from being ignited. +* `disable-entity-block-damage` A list of [EntityType](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html) names for which block damage is disabled if they explode. * `disable-invisibility-on-combat` Remove invisibility potion effects when a player PvPs. * `lower-strength-potion-damage` Reduce damage dealt with strength potions to Minecraft 1.5 levels. * `health-potion-multiplier` The multiplicative factor applied to health from instant health potions (splashed and drunk). diff --git a/config.yml b/config.yml index facb918..4acaa95 100644 --- a/config.yml +++ b/config.yml @@ -9,6 +9,7 @@ buff-shear-drops: 0 disable-snowgrow: false disable-drops: false disable-tnt: false +disable-entity-block-damage: [] disable-invisibility-on-combat: false disable-golem-natural-spawn: false host-keys-check: true diff --git a/pom.xml b/pom.xml index b1b965a..dbdca3a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ nu.nerd KitchenSink KitchenSink - 0.10.0 + 0.11.0 jar A plugin for miscellaneous functionality that hasn't found a home elsewhere. https://github.com/NerdNu/KitchenSink diff --git a/src/nu/nerd/kitchensink/Configuration.java b/src/nu/nerd/kitchensink/Configuration.java index 5fb32d4..62ac4f5 100644 --- a/src/nu/nerd/kitchensink/Configuration.java +++ b/src/nu/nerd/kitchensink/Configuration.java @@ -73,6 +73,7 @@ public class Configuration { public List DISABLE_DISPENSED; public List DISABLE_BUFF; public Map> DISABLED_DROPS; + public EnumSet DISABLE_ENTITY_BLOCK_DAMAGE = EnumSet.noneOf(EntityType.class); public boolean ALLOW_EGG_HATCHING; public boolean DISABLE_PEARL_DROPS_IN_END; public boolean DISABLE_PLAYER_DAMAGE_TO_VILLAGERS; @@ -150,6 +151,14 @@ public void load() { } } } + for (String entityTypeName : plugin.getConfig().getStringList("disable-entity-block-damage")) { + try { + EntityType entityType = EntityType.valueOf(entityTypeName); + DISABLE_ENTITY_BLOCK_DAMAGE.add(entityType); + } catch (IllegalArgumentException ex) { + plugin.getLogger().warning("disable-entity-block-damage contains invalid entity type " + entityTypeName); + } + } WARN_RESTART_ON_JOIN = plugin.getConfig().getBoolean("warn-restart-on-join"); WARN_RESTART_ON_INVENTORY_OPEN = plugin.getConfig().getBoolean("warn-restart-on-inventory-open"); SPRINT_MAX_TICKS = plugin.getConfig().getInt("sprint-max-time", 0); diff --git a/src/nu/nerd/kitchensink/KitchenSinkListener.java b/src/nu/nerd/kitchensink/KitchenSinkListener.java index 545ad36..6401d81 100644 --- a/src/nu/nerd/kitchensink/KitchenSinkListener.java +++ b/src/nu/nerd/kitchensink/KitchenSinkListener.java @@ -55,6 +55,7 @@ import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; +import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; @@ -533,6 +534,14 @@ public void onBlockPhysics(BlockPhysicsEvent event) { } } + @EventHandler(priority = EventPriority.HIGHEST) + public void onEntityExplode(EntityExplodeEvent event) { + plugin.getLogger().info("EntityExplodeEvent"); + if (plugin.config.DISABLE_ENTITY_BLOCK_DAMAGE.contains(event.getEntityType())) { + event.blockList().clear(); + } + } + @EventHandler(priority = EventPriority.MONITOR) public void onEntityDeath(EntityDeathEvent event) { if (plugin.config.DISABLE_PEARL_DROPS_IN_END) {