mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 10:37:41 +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-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
|
||||||
@ -96,4 +98,4 @@ blacklist:
|
|||||||
file:
|
file:
|
||||||
enable: on
|
enable: on
|
||||||
path: worldguard/logs/%w-%Y-%m-%d.log
|
path: worldguard/logs/%w-%Y-%m-%d.log
|
||||||
open-files: 10
|
open-files: 10
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the configuration for individual worlds.
|
* Holds the configuration for individual worlds.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
* @author Michael
|
* @author Michael
|
||||||
*/
|
*/
|
||||||
@ -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;
|
||||||
@ -102,18 +104,18 @@ public class WorldConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin
|
||||||
* @param worldName
|
* @param worldName
|
||||||
*/
|
*/
|
||||||
public WorldConfiguration(WorldGuardPlugin plugin, String worldName) {
|
public WorldConfiguration(WorldGuardPlugin plugin, String worldName) {
|
||||||
File baseFolder = new File(plugin.getDataFolder(), "worlds/" + worldName);
|
File baseFolder = new File(plugin.getDataFolder(), "worlds/" + worldName);
|
||||||
configFile = new File(baseFolder, "config.yml");
|
configFile = new File(baseFolder, "config.yml");
|
||||||
blacklistFile = new File(baseFolder, "blacklist.txt");
|
blacklistFile = new File(baseFolder, "blacklist.txt");
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.worldName = worldName;
|
this.worldName = worldName;
|
||||||
|
|
||||||
WorldGuardPlugin.createDefaultConfiguration(configFile, "config_world.yml");
|
WorldGuardPlugin.createDefaultConfiguration(configFile, "config_world.yml");
|
||||||
WorldGuardPlugin.createDefaultConfiguration(blacklistFile, "blacklist.txt");
|
WorldGuardPlugin.createDefaultConfiguration(blacklistFile, "blacklist.txt");
|
||||||
|
|
||||||
@ -128,7 +130,7 @@ public WorldConfiguration(WorldGuardPlugin plugin, String worldName) {
|
|||||||
private void loadConfiguration() {
|
private void loadConfiguration() {
|
||||||
Configuration config = new Configuration(this.configFile);
|
Configuration config = new Configuration(this.configFile);
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
enforceOneSession = config.getBoolean("protection.enforce-single-session", true);
|
||||||
itemDurability = config.getBoolean("protection.item-durability", true);
|
itemDurability = config.getBoolean("protection.item-durability", true);
|
||||||
|
|
||||||
@ -136,7 +138,7 @@ private void loadConfiguration() {
|
|||||||
simulateSponge = config.getBoolean("simulation.sponge.enable", true);
|
simulateSponge = config.getBoolean("simulation.sponge.enable", true);
|
||||||
spongeRadius = Math.max(1, config.getInt("simulation.sponge.radius", 3)) - 1;
|
spongeRadius = Math.max(1, config.getInt("simulation.sponge.radius", 3)) - 1;
|
||||||
redstoneSponges = config.getBoolean("simulation.sponge.redstone", false);
|
redstoneSponges = config.getBoolean("simulation.sponge.redstone", false);
|
||||||
|
|
||||||
pumpkinScuba = config.getBoolean("pumpkin-scuba", false);
|
pumpkinScuba = config.getBoolean("pumpkin-scuba", false);
|
||||||
|
|
||||||
noPhysicsGravel = config.getBoolean("physics.no-physics-gravel", 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);
|
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);
|
||||||
@ -184,7 +189,7 @@ private void loadConfiguration() {
|
|||||||
blockCreatureSpawn = new HashSet<CreatureType>();
|
blockCreatureSpawn = new HashSet<CreatureType>();
|
||||||
for (String creatureName : config.getStringList("mobs.block-creature-spawn", null)) {
|
for (String creatureName : config.getStringList("mobs.block-creature-spawn", null)) {
|
||||||
CreatureType creature = CreatureType.fromName(creatureName);
|
CreatureType creature = CreatureType.fromName(creatureName);
|
||||||
|
|
||||||
if (creature == null) {
|
if (creature == null) {
|
||||||
logger.warning("WorldGuard: Unknown mob type '" + creatureName + "'");
|
logger.warning("WorldGuard: Unknown mob type '" + creatureName + "'");
|
||||||
} else {
|
} else {
|
||||||
@ -265,7 +270,7 @@ private void loadConfiguration() {
|
|||||||
logger.log(Level.INFO, preventLavaFire
|
logger.log(Level.INFO, preventLavaFire
|
||||||
? "WorldGuard: (" + worldName + ") Lava fire is blocked."
|
? "WorldGuard: (" + worldName + ") Lava fire is blocked."
|
||||||
: "WorldGuard: (" + worldName + ") Lava fire is PERMITTED.");
|
: "WorldGuard: (" + worldName + ") Lava fire is PERMITTED.");
|
||||||
|
|
||||||
if (disableFireSpread) {
|
if (disableFireSpread) {
|
||||||
logger.log(Level.INFO, "WorldGuard: (" + worldName + ") All fire spread is disabled.");
|
logger.log(Level.INFO, "WorldGuard: (" + worldName + ") All fire spread is disabled.");
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,7 +92,18 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
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) {
|
} else if (defender instanceof Player) {
|
||||||
Player player = (Player) defender;
|
Player player = (Player) defender;
|
||||||
|
|
||||||
if (cfg.hasGodMode(player)) {
|
if (cfg.hasGodMode(player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == DamageCause.DROWNING && cfg.hasAmphibiousMode(player)) {
|
if (type == DamageCause.DROWNING && cfg.hasAmphibiousMode(player)) {
|
||||||
player.setRemainingAir(player.getMaximumAir());
|
player.setRemainingAir(player.getMaximumAir());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == DamageCause.DROWNING && wcfg.pumpkinScuba
|
if (type == DamageCause.DROWNING && wcfg.pumpkinScuba
|
||||||
&& (player.getInventory().getHelmet().getType() == Material.PUMPKIN
|
&& (player.getInventory().getHelmet().getType() == Material.PUMPKIN
|
||||||
|| player.getInventory().getHelmet().getType() == Material.JACK_O_LANTERN)) {
|
|| player.getInventory().getHelmet().getType() == Material.JACK_O_LANTERN)) {
|
||||||
@ -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;
|
||||||
@ -334,9 +345,9 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
|
|||||||
|
|
||||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||||
WorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
WorldConfiguration wcfg = cfg.get(event.getEntity().getWorld());
|
||||||
|
|
||||||
//CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
|
//CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
|
||||||
CreatureType creaType = event.getCreatureType();
|
CreatureType creaType = event.getCreatureType();
|
||||||
Boolean cancelEvent = false;
|
Boolean cancelEvent = false;
|
||||||
|
|
||||||
if (wcfg.blockCreatureSpawn.contains(creaType)) {
|
if (wcfg.blockCreatureSpawn.contains(creaType)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user