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

Commit

Permalink
changed how spawner breaks are handled. Exp dropped by spawners can b…
Browse files Browse the repository at this point in the history
…e stopped
  • Loading branch information
choel committed Aug 9, 2012
1 parent bcace6a commit fd4312d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Expand Up @@ -4,6 +4,7 @@
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ExperienceOrb;
//import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -15,6 +16,7 @@
import org.bukkit.inventory.ItemStack;

import java.util.List;
import java.util.Random;

public class AdjusterBlockListener implements Listener {
public static SpawnerAdjuster plugin; public AdjusterBlockListener(SpawnerAdjuster instance) {
Expand Down Expand Up @@ -126,16 +128,23 @@ public void onBlockBreak(BlockBreakEvent event) {
}
if(SpawnerAdjuster.permCheck(event.getPlayer(), "SpawnerAdjuster.DropSpawners") && SpawnerAdjuster.allowDroppedSpawners) {
if(!event.isCancelled()) {
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
short asdf = 1;
ItemStack spawnerstack = new ItemStack(event.getBlock().getType(), 1, asdf, event.getBlock().getData());
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), spawnerstack);
}
}
if(SpawnerAdjuster.spawnersCanDropExp) {
Random rand = new Random();
ExperienceOrb orb = event.getBlock().getWorld().spawn(event.getBlock().getLocation(), ExperienceOrb.class);
orb.setExperience(rand.nextInt(28) + 18);
}
}
}

/*
* this wil not be used until 1.5 or 2.0 // Or never I guess wtf am I doing?
* this wil not be used until 1.5 or 2.0 // Or never I guess wtf am I doing? //look I added more to this line
* Catches CreatureSpawnEvents and checks to see if redstone is nearby.
* If redstone is near and it is unpowered, prevent the spawn.
*
Expand Down
Expand Up @@ -92,6 +92,12 @@ public static boolean load() {
configYAML.set("system.redstoneForcesSpawn", SpawnerAdjuster.redstoneForcesSpawn);
}

if(configYAML.contains("system.spawnersCanDropExp")) {
SpawnerAdjuster.spawnersCanDropExp = configYAML.getBoolean("system.spawnersCanDropExp", true);
} else {
configYAML.set("system.spawnersCanDropExp", SpawnerAdjuster.spawnersCanDropExp);
}

//radius check

if(configYAML.contains("radiusCheck.useRadiusCheck")) {
Expand Down
Expand Up @@ -108,6 +108,7 @@ public class SpawnerAdjuster extends JavaPlugin {
public static boolean allowEgg = false;
public static boolean allowBoat = false;
public static boolean allowArrow = false;
public static boolean spawnersCanDropExp = true;

public static SpawnerAdjuster getThisPlugin() { //I do not know. Needed for fancy log
return thisPlugin;
Expand Down

0 comments on commit fd4312d

Please sign in to comment.