Added mobs.block-above-ground-slimes to block slimes spawning naturally above ground (in swamps).

This commit is contained in:
sk89q 2012-11-06 18:47:31 -08:00
parent 671fd58568
commit 80a8ac9e98
2 changed files with 10 additions and 0 deletions

View File

@ -103,6 +103,7 @@ public class WorldConfiguration {
public boolean blockEntityPaintingDestroy;
public boolean blockEntityItemFrameDestroy;
public boolean blockPluginSpawning;
public boolean blockGroundSlimes;
public boolean disableContactDamage;
public boolean disableFallDamage;
public boolean disableLavaDamage;
@ -340,6 +341,7 @@ private void loadConfiguration() {
blockEntityPaintingDestroy = getBoolean("mobs.block-painting-destroy", false);
blockEntityItemFrameDestroy = getBoolean("mobs.block-item-frame-destroy", false);
blockPluginSpawning = getBoolean("mobs.block-plugin-spawning", true);
blockGroundSlimes = getBoolean("mobs.block-above-ground-slimes", false);
disableFallDamage = getBoolean("player-damage.disable-fall-damage", false);
disableLavaDamage = getBoolean("player-damage.disable-lava-damage", false);

View File

@ -37,6 +37,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@ -678,6 +679,13 @@ public void onCreatureSpawn(CreatureSpawnEvent event) {
return;
}
}
if (wcfg.blockGroundSlimes && entityType == EntityType.SLIME
&& eventLoc.getY() >= 60
&& event.getSpawnReason() == SpawnReason.NATURAL) {
event.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)