Skip to content

Commit

Permalink
Add disable-entity-block-damage setting to disable ender crystal bloc…
Browse files Browse the repository at this point in the history
…k damage (but works for creepers too!).
  • Loading branch information
totemo committed Mar 16, 2016
1 parent 646ed4e commit da11f3b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>nu.nerd</groupId>
<artifactId>KitchenSink</artifactId>
<name>KitchenSink</name>
<version>0.10.0</version>
<version>0.11.0</version>
<packaging>jar</packaging>
<description>A plugin for miscellaneous functionality that hasn't found a home elsewhere.</description>
<url>https://github.com/NerdNu/KitchenSink</url>
Expand Down
9 changes: 9 additions & 0 deletions src/nu/nerd/kitchensink/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class Configuration {
public List<Integer> DISABLE_DISPENSED;
public List<Integer> DISABLE_BUFF;
public Map<EntityType, Set<Material>> DISABLED_DROPS;
public EnumSet<EntityType> 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;
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions src/nu/nerd/kitchensink/KitchenSinkListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit da11f3b

Please sign in to comment.