mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-24 18:19:03 +01:00
Added config to disable damage from falling into the void.
This commit is contained in:
parent
21a04cc8c8
commit
3cb9b90ef0
@ -67,6 +67,8 @@ player-damage:
|
||||
disable-suffocation-damage: off
|
||||
disable-contact-damage: off
|
||||
teleport-on-suffocation: off
|
||||
disable-void-damage: off
|
||||
teleport-on-void-falling: off
|
||||
|
||||
regions:
|
||||
enable: on
|
||||
@ -96,4 +98,4 @@ blacklist:
|
||||
file:
|
||||
enable: on
|
||||
path: worldguard/logs/%w-%Y-%m-%d.log
|
||||
open-files: 10
|
||||
open-files: 10
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
/**
|
||||
* Holds the configuration for individual worlds.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
* @author Michael
|
||||
*/
|
||||
@ -86,6 +86,8 @@ public class WorldConfiguration {
|
||||
public boolean disableDrowningDamage;
|
||||
public boolean disableSuffocationDamage;
|
||||
public boolean teleportOnSuffocation;
|
||||
public boolean disableVoidDamage;
|
||||
public boolean teleportOnVoid;
|
||||
public boolean useRegions;
|
||||
public boolean highFreqFlags;
|
||||
public int regionWand = 287;
|
||||
@ -102,18 +104,18 @@ public class WorldConfiguration {
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param plugin
|
||||
* @param worldName
|
||||
*
|
||||
* @param plugin
|
||||
* @param worldName
|
||||
*/
|
||||
public WorldConfiguration(WorldGuardPlugin plugin, String worldName) {
|
||||
File baseFolder = new File(plugin.getDataFolder(), "worlds/" + worldName);
|
||||
configFile = new File(baseFolder, "config.yml");
|
||||
blacklistFile = new File(baseFolder, "blacklist.txt");
|
||||
|
||||
|
||||
this.plugin = plugin;
|
||||
this.worldName = worldName;
|
||||
|
||||
|
||||
WorldGuardPlugin.createDefaultConfiguration(configFile, "config_world.yml");
|
||||
WorldGuardPlugin.createDefaultConfiguration(blacklistFile, "blacklist.txt");
|
||||
|
||||
@ -128,7 +130,7 @@ public WorldConfiguration(WorldGuardPlugin plugin, String worldName) {
|
||||
private void loadConfiguration() {
|
||||
Configuration config = new Configuration(this.configFile);
|
||||
config.load();
|
||||
|
||||
|
||||
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
||||
itemDurability = config.getBoolean("protection.item-durability", true);
|
||||
|
||||
@ -136,7 +138,7 @@ 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);
|
||||
@ -169,6 +171,9 @@ private void loadConfiguration() {
|
||||
disableSuffocationDamage = config.getBoolean("player-damage.disable-suffocation-damage", false);
|
||||
disableContactDamage = config.getBoolean("player-damage.disable-contact-damage", 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);
|
||||
highFreqFlags = config.getBoolean("regions.high-frequency-flags", false);
|
||||
@ -184,7 +189,7 @@ private void loadConfiguration() {
|
||||
blockCreatureSpawn = new HashSet<CreatureType>();
|
||||
for (String creatureName : config.getStringList("mobs.block-creature-spawn", null)) {
|
||||
CreatureType creature = CreatureType.fromName(creatureName);
|
||||
|
||||
|
||||
if (creature == null) {
|
||||
logger.warning("WorldGuard: Unknown mob type '" + creatureName + "'");
|
||||
} else {
|
||||
@ -265,7 +270,7 @@ private void loadConfiguration() {
|
||||
logger.log(Level.INFO, preventLavaFire
|
||||
? "WorldGuard: (" + worldName + ") Lava fire is blocked."
|
||||
: "WorldGuard: (" + worldName + ") Lava fire is PERMITTED.");
|
||||
|
||||
|
||||
if (disableFireSpread) {
|
||||
logger.log(Level.INFO, "WorldGuard: (" + worldName + ") All fire spread is disabled.");
|
||||
} else {
|
||||
|
@ -92,7 +92,18 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (wcfg.teleportOnVoid && type == DamageCause.VOID) {
|
||||
findFreePosition(player);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.disableVoidDamage && type == DamageCause.VOID) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,18 +237,18 @@ public void onEntityDamage(EntityDamageEvent event) {
|
||||
}
|
||||
} else if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
|
||||
if (cfg.hasGodMode(player)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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)) {
|
||||
@ -263,7 +274,7 @@ public void onEntityDamage(EntityDamageEvent event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wcfg.teleportOnSuffocation && type == DamageCause.SUFFOCATION) {
|
||||
if (wcfg.teleportOnSuffocation && type == DamageCause.SUFFOCATION) {
|
||||
findFreePosition(player);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -334,9 +345,9 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||
|
||||
|
||||
//CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
|
||||
CreatureType creaType = event.getCreatureType();
|
||||
CreatureType creaType = event.getCreatureType();
|
||||
Boolean cancelEvent = false;
|
||||
|
||||
if (wcfg.blockCreatureSpawn.contains(creaType)) {
|
||||
|
Loading…
Reference in New Issue
Block a user