This commit is contained in:
sk89q 2011-04-13 03:00:27 -07:00
commit af25c15286
4 changed files with 58 additions and 26 deletions

View File

@ -18,6 +18,7 @@
# Remember to check the compatibility spreadsheet for WorldGuard to see # Remember to check the compatibility spreadsheet for WorldGuard to see
# if any features are currently broken in your version of Bukkit. # if any features are currently broken in your version of Bukkit.
# #
suppress-tick-sync-warnings: false
# For permissions, see http://wiki.sk89q.com/wiki/WorldGuard/Permissions/Bukkit # For permissions, see http://wiki.sk89q.com/wiki/WorldGuard/Permissions/Bukkit
permissions: permissions:

View File

@ -68,6 +68,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
@ -100,4 +102,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

View File

@ -38,7 +38,7 @@
/** /**
* Holds the configuration for individual worlds. * Holds the configuration for individual worlds.
* *
* @author sk89q * @author sk89q
* @author Michael * @author Michael
*/ */
@ -89,6 +89,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;
@ -107,18 +109,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");
@ -133,7 +135,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);
removeInfiniteStacks = config.getBoolean("protection.remove-infinite-stacks", false); removeInfiniteStacks = config.getBoolean("protection.remove-infinite-stacks", false);
@ -142,7 +144,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);
@ -175,7 +177,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);
teleportOnVoid = config.getBoolean("player-damage.teleport-on-void-falling", false);
signChestProtection = config.getBoolean("chest-protection.enable", false); signChestProtection = config.getBoolean("chest-protection.enable", false);
useRegions = config.getBoolean("regions.enable", true); useRegions = config.getBoolean("regions.enable", true);
@ -192,7 +196,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 {
@ -273,7 +277,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 {

View File

@ -18,17 +18,16 @@
*/ */
package com.sk89q.worldguard.bukkit; package com.sk89q.worldguard.bukkit;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.CreatureType; import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;
import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton;
@ -38,10 +37,16 @@
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.*; import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*; import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
public class WorldGuardEntityListener extends EntityListener { public class WorldGuardEntityListener extends EntityListener {
/** /**
@ -73,12 +78,17 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
Entity defender = event.getEntity(); Entity defender = event.getEntity();
DamageCause type = event.getCause(); DamageCause type = event.getCause();
if (defender instanceof Player) { ConfigurationManager cfg = plugin.getGlobalConfiguration();
WorldConfiguration wcfg = cfg.get(defender.getWorld());
if (defender instanceof Wolf) {
if (wcfg.antiWolfDumbness && !(type == DamageCause.VOID)) {
event.setCancelled(true);
return;
}
} else if (defender instanceof Player) {
Player player = (Player) defender; Player player = (Player) defender;
ConfigurationManager cfg = plugin.getGlobalConfiguration();
WorldConfiguration wcfg = cfg.get(player.getWorld());
if (cfg.hasGodMode(player)) { if (cfg.hasGodMode(player)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -93,7 +103,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;
}
} }
} }
@ -227,18 +248,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)) {
@ -264,7 +285,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;
@ -401,13 +422,17 @@ public void findFreePosition(Player player) {
} }
if (free == 2) { if (free == 2) {
if (y - 1 != origY) { if (y - 1 != origY || y == 1) {
loc.setX(x + 0.5); loc.setX(x + 0.5);
loc.setY(y); loc.setY(y);
loc.setZ(z + 0.5); loc.setZ(z + 0.5);
if (y <= 2 && world.getBlockAt(x,0,z).getType() == Material.AIR) {
world.getBlockAt(x,0,z).setTypeId(20);
loc.setY(2);
}
player.setFallDistance(0F);
player.teleport(loc); player.teleport(loc);
} }
return; return;
} }