Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
advanced option for stoping all pigs from being spawned by this plugi…
Browse files Browse the repository at this point in the history
…n (unnatural spanwers and forced spawn)
  • Loading branch information
choel committed Mar 29, 2012
1 parent 52842b6 commit 6b651ec
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.bukkit.Material;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -150,6 +151,11 @@ public void onBlockPlace(BlockPlaceEvent event) {
//admin redstone thing here (someday).
}

@EventHandler
public void stopPigSpawn(CreatureSpawnEvent event) {
if(event.getEntityType() == EntityType.PIG && event.getSpawnReason() == SpawnReason.SPAWNER && SpawnerAdjuster.advanced_stopPigSpawns) event.setCancelled(true);
}

private void forceSpawn(CreatureSpawner spawner) {

int range = 1;
Expand Down Expand Up @@ -181,6 +187,10 @@ private void forceSpawn(CreatureSpawner spawner) {
spawnedEnt.remove();
}
/* end anti munson implement */
/* prevent pig spawns if defined as such */
if(spawnedEnt.getType() == EntityType.PIG && SpawnerAdjuster.advanced_stopPigSpawns) {
spawnedEnt.remove();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ public static boolean load() {
configYAML.set("spawner.allowGiant", SpawnerAdjuster.allowGiant);
}

//advanced settings
if(configYAML.contains("advanced.stopPigSpawns")) {
SpawnerAdjuster.advanced_stopPigSpawns = configYAML.getBoolean("advanced.stopPigSpawns", false);
} else {
configYAML.set("advanced.stopPigSpawns", false);
}

//ignorePermissions extended
if(SpawnerAdjuster.ignorePermissions) {
/** This stuff not yet ready (or needed)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public class SpawnerAdjuster extends JavaPlugin {
private spawneradjusterreload reloadExecutor;
private spawneradjusterdebug debugExecutor;

//1.5.1
public static boolean advanced_stopPigSpawns = false;

public static SpawnerAdjuster getThisPlugin() { //I do not know. Needed for fancy log
return thisPlugin;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: SpawnerAdjuster
main: com.sadmean.mc.SpawnerAdjuster.SpawnerAdjuster
version: 1.5.0
version: 1.5.1_INTERNAL
author: Choelian
commands:
spawneradjusterreload:
Expand Down

0 comments on commit 6b651ec

Please sign in to comment.