Added config to disable damage from falling into the void.

This commit is contained in:
Wizjany 2011-04-03 05:48:32 -04:00
parent 21a04cc8c8
commit 3cb9b90ef0
3 changed files with 36 additions and 18 deletions

View File

@ -67,6 +67,8 @@ player-damage:
disable-suffocation-damage: off disable-suffocation-damage: off
disable-contact-damage: off disable-contact-damage: off
teleport-on-suffocation: off teleport-on-suffocation: off
disable-void-damage: off
teleport-on-void-falling: off
regions: regions:
enable: on enable: on

View File

@ -86,6 +86,8 @@ public class WorldConfiguration {
public boolean disableDrowningDamage; public boolean disableDrowningDamage;
public boolean disableSuffocationDamage; public boolean disableSuffocationDamage;
public boolean teleportOnSuffocation; public boolean teleportOnSuffocation;
public boolean disableVoidDamage;
public boolean teleportOnVoid;
public boolean useRegions; public boolean useRegions;
public boolean highFreqFlags; public boolean highFreqFlags;
public int regionWand = 287; public int regionWand = 287;
@ -169,6 +171,9 @@ private void loadConfiguration() {
disableSuffocationDamage = config.getBoolean("player-damage.disable-suffocation-damage", false); disableSuffocationDamage = config.getBoolean("player-damage.disable-suffocation-damage", false);
disableContactDamage = config.getBoolean("player-damage.disable-contact-damage", false); disableContactDamage = config.getBoolean("player-damage.disable-contact-damage", false);
teleportOnSuffocation = config.getBoolean("player-damage.teleport-on-suffocation", false); teleportOnSuffocation = config.getBoolean("player-damage.teleport-on-suffocation", false);
disableVoidDamage = config.getBoolean("player-damage.disable-void-damage", false);
//this is pretty useless since presumably there won't be much above them if they fall into a big hole
teleportOnVoid = config.getBoolean("player-damage.teleport-on-void-falling", false);
useRegions = config.getBoolean("regions.enable", true); useRegions = config.getBoolean("regions.enable", true);
highFreqFlags = config.getBoolean("regions.high-frequency-flags", false); highFreqFlags = config.getBoolean("regions.high-frequency-flags", false);

View File

@ -93,6 +93,17 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
return; return;
} }
if (wcfg.teleportOnVoid && type == DamageCause.VOID) {
findFreePosition(player);
event.setCancelled(true);
return;
}
if (wcfg.disableVoidDamage && type == DamageCause.VOID) {
event.setCancelled(true);
return;
}
} }
} }
@ -263,7 +274,7 @@ public void onEntityDamage(EntityDamageEvent event) {
return; return;
} }
if (wcfg.teleportOnSuffocation && type == DamageCause.SUFFOCATION) { if (wcfg.teleportOnSuffocation && type == DamageCause.SUFFOCATION) {
findFreePosition(player); findFreePosition(player);
event.setCancelled(true); event.setCancelled(true);
return; return;