From 424b580eb98d945b704c3cf729781ed2ccda156e Mon Sep 17 00:00:00 2001 From: Wizjany Date: Fri, 20 May 2011 20:32:50 -0400 Subject: [PATCH 1/2] Added ghast fireball handling (instead of grouping with tnt) and fixed god mode player ignition. --- .../bukkit/WorldGuardEntityListener.java | 17 +++++++++++++++-- .../protection/flags/DefaultFlag.java | 6 ++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java index 473bb734..834bea26 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java @@ -108,6 +108,7 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) { if (wcfg.disableLavaDamage && type == DamageCause.LAVA) { event.setCancelled(true); + if (cfg.hasGodMode(player)) player.setFireTicks(0); return; } @@ -268,6 +269,7 @@ public void onEntityDamage(EntityDamageEvent event) { if (cfg.hasGodMode(player)) { event.setCancelled(true); + player.setFireTicks(0); return; } @@ -326,8 +328,9 @@ public void onEntityExplode(EntityExplodeEvent event) { Location l = event.getLocation(); World world = l.getWorld(); WorldConfiguration wcfg = cfg.get(world); + Entity ent = event.getEntity(); - if (event.getEntity() instanceof LivingEntity) { + if (ent instanceof LivingEntity) { if (wcfg.blockCreeperBlockDamage) { event.setCancelled(true); return; @@ -347,7 +350,17 @@ public void onEntityExplode(EntityExplodeEvent event) { return; } } - } else { // Shall assume that this is TNT + } else if (ent instanceof Fireball) { + if (wcfg.useRegions) { + Vector pt = toVector(l); + RegionManager mgr = plugin.getGlobalRegionManager().get(world); + + if (!mgr.getApplicableRegions(pt).allows(DefaultFlag.GHAST_FIREBALL)) { + event.setCancelled(true); + return; + } + } + } else if (ent instanceof TNTPrimed) { if (wcfg.blockTNT) { event.setCancelled(true); return; diff --git a/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java b/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java index 84804ab0..494f5ca2 100644 --- a/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java +++ b/src/main/java/com/sk89q/worldguard/protection/flags/DefaultFlag.java @@ -29,8 +29,9 @@ public final class DefaultFlag { public static final StateFlag BUILD = new StateFlag("build", 'b', true); public static final StateFlag PVP = new StateFlag("pvp", 'p', true); public static final StateFlag MOB_DAMAGE = new StateFlag("mob-damage", 'm', true); - public static final StateFlag MOB_SPAWNING = new StateFlag("mob-spawning", 'M', true); + public static final StateFlag MOB_SPAWNING = new StateFlag("mob-spawning", true); public static final StateFlag CREEPER_EXPLOSION = new StateFlag("creeper-explosion", 'c', true); + public static final StateFlag GHAST_FIREBALL = new StateFlag("ghast-fireball", true); public static final StateFlag SLEEP = new StateFlag("sleep", true); public static final StateFlag TNT = new StateFlag("tnt", 't', true); public static final StateFlag LIGHTER = new StateFlag("lighter", 'l', true); @@ -62,7 +63,8 @@ public final class DefaultFlag { TNT, LIGHTER, FIRE_SPREAD, LAVA_FIRE, CHEST_ACCESS, WATER_FLOW, LAVA_FLOW, USE, PLACE_VEHICLE, GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_GREET, NOTIFY_FAREWELL, DENY_SPAWN, HEAL_DELAY, HEAL_AMOUNT, TELE_LOC, - TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE, SNOW_FALL + TELE_PERM, SPAWN_LOC, SPAWN_PERM, BUYABLE, PRICE, SNOW_FALL, + GHAST_FIREBALL }; private DefaultFlag() { From 4850bdefdf2d64a4fd022abae116bfa0614fdfce Mon Sep 17 00:00:00 2001 From: Wizjany Date: Mon, 23 May 2011 22:23:42 -0400 Subject: [PATCH 2/2] Added config option to disable explosion-caused damage to players. --- .../com/sk89q/worldguard/bukkit/WorldConfiguration.java | 2 ++ .../worldguard/bukkit/WorldGuardEntityListener.java | 9 +++++++++ src/main/resources/config_world.yml | 1 + 3 files changed, 12 insertions(+) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java index d5e97ced..9a0b9a6d 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldConfiguration.java @@ -93,6 +93,7 @@ public class WorldConfiguration { public boolean teleportOnSuffocation; public boolean disableVoidDamage; public boolean teleportOnVoid; + public boolean disableExplosionDamage; public boolean useRegions; public boolean highFreqFlags; public int regionWand = 287; @@ -194,6 +195,7 @@ private void loadConfiguration() { teleportOnSuffocation = config.getBoolean("player-damage.teleport-on-suffocation", false); disableVoidDamage = config.getBoolean("player-damage.disable-void-damage", false); teleportOnVoid = config.getBoolean("player-damage.teleport-on-void-falling", false); + disableExplosionDamage = config.getBoolean("player-damage.disable-explosion-damage", false); signChestProtection = config.getBoolean("chest-protection.enable", false); diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java index 834bea26..9f059dfd 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java @@ -128,6 +128,10 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) { return; } + if (wcfg.disableExplosionDamage && event.getCause() == DamageCause.BLOCK_EXPLOSION) { + event.setCancelled(true); + return; + } } } @@ -151,6 +155,11 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { return; } + if (wcfg.disableExplosionDamage && event.getCause() == DamageCause.ENTITY_EXPLOSION) { + event.setCancelled(true); + return; + } + if (attacker != null && attacker instanceof Player) { if (wcfg.useRegions) { Vector pt = toVector(defender.getLocation()); diff --git a/src/main/resources/config_world.yml b/src/main/resources/config_world.yml index 96270441..d0c47f62 100644 --- a/src/main/resources/config_world.yml +++ b/src/main/resources/config_world.yml @@ -81,6 +81,7 @@ player-damage: teleport-on-suffocation: off disable-void-damage: off teleport-on-void-falling: off + disable-explosion-damage: off regions: enable: on