Be more lax with entity spawns.

This commit is contained in:
sk89q 2014-08-24 15:53:45 -07:00
parent 913d5d64ae
commit edebb0efc9
2 changed files with 34 additions and 1 deletions

View File

@ -176,6 +176,7 @@ public class WorldConfiguration {
public boolean explosionFlagCancellation;
public boolean disableDeathMessages;
public boolean disableObsidianGenerators;
public boolean strictEntitySpawn;
private Map<String, Integer> maxRegionCounts;
@ -314,10 +315,13 @@ private void loadConfiguration() {
summaryOnStart = getBoolean("summary-on-start", true);
opPermissions = getBoolean("op-permissions", true);
buildPermissions = getBoolean("build-permission-nodes.enable", false);
buildPermissionDenyMessage = CommandUtils.replaceColorMacros(
getString("build-permission-nodes.deny-message", "&eSorry, but you are not permitted to do that here."));
strictEntitySpawn = getBoolean("strictness.block-entity-spawns-with-untraceable-cause", false);
itemDurability = getBoolean("protection.item-durability", true);
removeInfiniteStacks = getBoolean("protection.remove-infinite-stacks", false);
disableExpDrops = getBoolean("protection.disable-xp-orb-drops", false);

View File

@ -453,7 +453,36 @@ public void onBlockFromTo(BlockFromToEvent event) {
@EventHandler(ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
Events.fireToCancel(event, new SpawnEntityEvent(event, Cause.unknown(), event.getEntity()));
switch (event.getSpawnReason()) {
case DISPENSE_EGG:
case EGG:
case SPAWNER_EGG:
if (getWorldConfig(event.getEntity().getWorld()).strictEntitySpawn) {
Events.fireToCancel(event, new SpawnEntityEvent(event, Cause.unknown(), event.getEntity()));
}
break;
case NATURAL:
case JOCKEY:
case CHUNK_GEN:
case SPAWNER:
case LIGHTNING:
case BUILD_SNOWMAN:
case BUILD_IRONGOLEM:
case BUILD_WITHER:
case VILLAGE_DEFENSE:
case VILLAGE_INVASION:
case BREEDING:
case SLIME_SPLIT:
case REINFORCEMENTS:
case NETHER_PORTAL:
case INFECTION:
case CURED:
case OCELOT_BABY:
case SILVERFISH_BLOCK:
case MOUNT:
case CUSTOM:
case DEFAULT:
}
}
@EventHandler(ignoreCancelled = true)