Improved amphibious stuff, added pumpkin scuba.

This commit is contained in:
sk89q 2011-04-02 16:07:59 -07:00
parent cc6ac93b7a
commit 5b5349fc34
3 changed files with 15 additions and 0 deletions

View File

@ -19,6 +19,7 @@
#
summary-on-start: on
pumpkin-scuba: off
protection:
item-durability: on

View File

@ -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);

View File

@ -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;
}