mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-27 21:15:57 +01:00
Merge branch 'master' of https://github.com/wizjany/worldguard
This commit is contained in:
commit
af25c15286
@ -18,6 +18,7 @@
|
||||
# Remember to check the compatibility spreadsheet for WorldGuard to see
|
||||
# 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
|
||||
permissions:
|
||||
|
@ -68,6 +68,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
|
||||
@ -100,4 +102,4 @@ blacklist:
|
||||
file:
|
||||
enable: on
|
||||
path: worldguard/logs/%w-%Y-%m-%d.log
|
||||
open-files: 10
|
||||
open-files: 10
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
/**
|
||||
* Holds the configuration for individual worlds.
|
||||
*
|
||||
*
|
||||
* @author sk89q
|
||||
* @author Michael
|
||||
*/
|
||||
@ -89,6 +89,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;
|
||||
@ -107,18 +109,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");
|
||||
|
||||
@ -133,7 +135,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);
|
||||
removeInfiniteStacks = config.getBoolean("protection.remove-infinite-stacks", false);
|
||||
@ -142,7 +144,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);
|
||||
@ -175,7 +177,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);
|
||||
teleportOnVoid = config.getBoolean("player-damage.teleport-on-void-falling", false);
|
||||
|
||||
signChestProtection = config.getBoolean("chest-protection.enable", false);
|
||||
|
||||
useRegions = config.getBoolean("regions.enable", true);
|
||||
@ -192,7 +196,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 {
|
||||
@ -273,7 +277,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 {
|
||||
|
@ -18,17 +18,16 @@
|
||||
*/
|
||||
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.event.Event.Priority;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
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.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
@ -38,10 +37,16 @@
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
|
||||
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 {
|
||||
|
||||
/**
|
||||
@ -73,12 +78,17 @@ public void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
|
||||
Entity defender = event.getEntity();
|
||||
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;
|
||||
|
||||
ConfigurationManager cfg = plugin.getGlobalConfiguration();
|
||||
WorldConfiguration wcfg = cfg.get(player.getWorld());
|
||||
|
||||
if (cfg.hasGodMode(player)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -93,7 +103,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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,18 +248,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)) {
|
||||
@ -264,7 +285,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;
|
||||
@ -401,13 +422,17 @@ public void findFreePosition(Player player) {
|
||||
}
|
||||
|
||||
if (free == 2) {
|
||||
if (y - 1 != origY) {
|
||||
if (y - 1 != origY || y == 1) {
|
||||
loc.setX(x + 0.5);
|
||||
loc.setY(y);
|
||||
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);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user