Adding and fixing support for new and existing explosion types.

This commit is contained in:
Glitchfinder 2012-10-28 19:58:48 -07:00 committed by sk89q
parent f3f1b0870f
commit 9834c30e3a
2 changed files with 49 additions and 2 deletions

View File

@ -95,7 +95,10 @@ public class WorldConfiguration {
public boolean blockTNTBlockDamage; public boolean blockTNTBlockDamage;
public boolean blockCreeperExplosions; public boolean blockCreeperExplosions;
public boolean blockCreeperBlockDamage; public boolean blockCreeperBlockDamage;
public boolean blockWitherExplosions;
public boolean blockWitherBlockDamage; public boolean blockWitherBlockDamage;
public boolean blockWitherSkullExplosions;
public boolean blockWitherSkullBlockDamage;
public boolean blockEnderDragonBlockDamage; public boolean blockEnderDragonBlockDamage;
public boolean blockFireballExplosions; public boolean blockFireballExplosions;
public boolean blockFireballBlockDamage; public boolean blockFireballBlockDamage;
@ -312,7 +315,10 @@ private void loadConfiguration() {
blockCreeperExplosions = getBoolean("mobs.block-creeper-explosions", false); blockCreeperExplosions = getBoolean("mobs.block-creeper-explosions", false);
blockCreeperBlockDamage = getBoolean("mobs.block-creeper-block-damage", false); blockCreeperBlockDamage = getBoolean("mobs.block-creeper-block-damage", false);
blockWitherExplosions = getBoolean("mobs.block-wither-explosions", false);
blockWitherBlockDamage = getBoolean("mobs.block-wither-block-damage", false); blockWitherBlockDamage = getBoolean("mobs.block-wither-block-damage", false);
blockWitherSkullExplosions = getBoolean("mobs.block-wither-skull-explosions", false);
blockWitherSkullBlockDamage = getBoolean("mobs.block-wither-skull-block-damage", false);
blockEnderDragonBlockDamage = getBoolean("mobs.block-enderdragon-block-damage", false); blockEnderDragonBlockDamage = getBoolean("mobs.block-enderdragon-block-damage", false);
blockFireballExplosions = getBoolean("mobs.block-fireball-explosions", false); blockFireballExplosions = getBoolean("mobs.block-fireball-explosions", false);
blockFireballBlockDamage = getBoolean("mobs.block-fireball-block-damage", false); blockFireballBlockDamage = getBoolean("mobs.block-fireball-block-damage", false);

View File

@ -42,6 +42,7 @@
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wither; import org.bukkit.entity.Wither;
import org.bukkit.entity.WitherSkull;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -496,6 +497,23 @@ public void onEntityExplode(EntityExplodeEvent event) {
event.blockList().clear(); event.blockList().clear();
return; return;
} }
if (wcfg.blockWitherExplosions) {
event.setCancelled(true);
return;
}
}
if (ent instanceof WitherSkull) {
if (wcfg.blockWitherSkullBlockDamage) {
event.blockList().clear();
return;
}
if (wcfg.blockWitherSkullExplosions) {
event.setCancelled(true);
return;
}
} }
if (ent instanceof Creeper) { if (ent instanceof Creeper) {
@ -608,12 +626,35 @@ public void onExplosionPrime(ExplosionPrimeEvent event) {
} }
if (event.getEntityType() == EntityType.WITHER) { if (event.getEntityType() == EntityType.WITHER) {
if (wcfg.blockWitherBlockDamage) { if (wcfg.blockWitherExplosions) {
event.setCancelled(true);
return;
}
}
else if (event.getEntityType() == EntityType.WITHER_SKULL) {
if (wcfg.blockWitherSkullExplosions) {
event.setCancelled(true);
return;
}
}
else if (event.getEntityType() == EntityType.LARGE_FIREBALL) {
if (wcfg.blockFireballExplosions) {
event.setCancelled(true);
return;
}
}
else if (event.getEntityType() == EntityType.CREEPER) {
if (wcfg.blockCreeperExplosions) {
event.setCancelled(true);
return;
}
}
else if (event.getEntityType() == EntityType.PRIMED_TNT) {
if (wcfg.blockTNTExplosions) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)