From 5b5349fc34f013f6e24417da71f20e8d93e28d0e Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 2 Apr 2011 16:07:59 -0700 Subject: [PATCH] Improved amphibious stuff, added pumpkin scuba. --- config_world.yml | 1 + .../sk89q/worldguard/bukkit/WorldConfiguration.java | 3 +++ .../worldguard/bukkit/WorldGuardEntityListener.java | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/config_world.yml b/config_world.yml index 04a7b08c..055dc802 100644 --- a/config_world.yml +++ b/config_world.yml @@ -19,6 +19,7 @@ # summary-on-start: on +pumpkin-scuba: off protection: item-durability: on diff --git a/src/com/sk89q/worldguard/bukkit/WorldConfiguration.java b/src/com/sk89q/worldguard/bukkit/WorldConfiguration.java index 3a90bbfc..12ccefda 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldConfiguration.java +++ b/src/com/sk89q/worldguard/bukkit/WorldConfiguration.java @@ -60,6 +60,7 @@ public class WorldConfiguration { public boolean classicWater; public boolean simulateSponge; public int spongeRadius; + public boolean pumpkinScuba; public boolean redstoneSponges; public boolean noPhysicsGravel; public boolean noPhysicsSand; @@ -133,6 +134,8 @@ private void loadConfiguration() { simulateSponge = config.getBoolean("simulation.sponge.enable", true); spongeRadius = Math.max(1, config.getInt("simulation.sponge.radius", 3)) - 1; redstoneSponges = config.getBoolean("simulation.sponge.redstone", false); + + pumpkinScuba = config.getBoolean("pumpkin-scuba", false); noPhysicsGravel = config.getBoolean("physics.no-physics-gravel", false); noPhysicsSand = config.getBoolean("physics.no-physics-sand", false); diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java b/src/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java index 37a11eb2..fdd3b5c7 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java @@ -26,6 +26,7 @@ import com.sk89q.worldguard.protection.ApplicableRegionSet; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.CreatureType; import org.bukkit.entity.Creeper; @@ -226,6 +227,15 @@ public void onEntityDamage(EntityDamageEvent event) { } if (type == DamageCause.DROWNING && cfg.hasAmphibiousMode(player)) { + player.setRemainingAir(player.getMaximumAir()); + event.setCancelled(true); + return; + } + + if (type == DamageCause.DROWNING && wcfg.pumpkinScuba + && (player.getInventory().getHelmet().getType() == Material.PUMPKIN + || player.getInventory().getHelmet().getType() == Material.JACK_O_LANTERN)) { + player.setRemainingAir(player.getMaximumAir()); event.setCancelled(true); return; } @@ -242,6 +252,7 @@ public void onEntityDamage(EntityDamageEvent event) { } if (wcfg.disableDrowningDamage && type == DamageCause.DROWNING) { + player.setRemainingAir(player.getMaximumAir()); event.setCancelled(true); return; }