Added anti-wolf-dumbness.

This commit is contained in:
sk89q 2011-04-02 22:44:45 -07:00
parent dcc1b59627
commit 21a04cc8c8
3 changed files with 13 additions and 5 deletions

View File

@ -50,6 +50,7 @@ mobs:
block-creeper-explosions: off
block-creeper-block-damage: off
block-creature-spawn: []
anti-wolf-dumbness: false
spawn:
login-protection: 3

View File

@ -96,6 +96,7 @@ public class WorldConfiguration {
public int maxClaimVolume;
public boolean claimOnlyInsideExistingRegions;
public int maxRegionCountPerPlayer;
public boolean antiWolfDumbness;
/* Configuration data end */
@ -153,6 +154,7 @@ private void loadConfiguration() {
blockCreeperExplosions = config.getBoolean("mobs.block-creeper-explosions", false);
blockCreeperBlockDamage = config.getBoolean("mobs.block-creeper-block-damage", false);
antiWolfDumbness = config.getBoolean("mobs.anti-wolf-dumbness", false);
loginProtection = config.getInt("spawn.login-protection", 3);
spawnProtection = config.getInt("spawn.spawn-protection", 0);

View File

@ -33,8 +33,8 @@
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import com.sk89q.worldedit.Vector;
@ -216,11 +216,16 @@ public void onEntityDamage(EntityDamageEvent event) {
Entity defender = event.getEntity();
DamageCause type = event.getCause();
if (defender instanceof Player) {
Player player = (Player) defender;
ConfigurationManager cfg = plugin.getGlobalConfiguration();
WorldConfiguration wcfg = cfg.get(defender.getWorld());
ConfigurationManager cfg = plugin.getGlobalConfiguration();
WorldConfiguration wcfg = cfg.get(player.getWorld());
if (defender instanceof Wolf) {
if (wcfg.antiWolfDumbness) {
event.setCancelled(true);
return;
}
} else if (defender instanceof Player) {
Player player = (Player) defender;
if (cfg.hasGodMode(player)) {
event.setCancelled(true);