use of com.elmakers.mine.bukkit.world.MagicWorld in project MagicPlugin by elBukkit.
the class WorldSpawnListener method onEntitiesLoaded.
@Override
public void onEntitiesLoaded(Chunk chunk, List<Entity> entities) {
MagicWorld magicWorld = controller.getWorld(chunk.getWorld().getName());
if (magicWorld == null)
return;
Plugin plugin = controller.getPlugin();
controller.setDisableSpawnReplacement(true);
for (Entity testEntity : entities) {
if (!(testEntity instanceof LivingEntity))
continue;
if (testEntity instanceof Player)
continue;
LivingEntity entity = (LivingEntity) testEntity;
try {
if (magicWorld.processEntitySpawn(plugin, entity)) {
processedChunkSpawns++;
entity.remove();
}
} catch (Exception ex) {
controller.getLogger().log(Level.SEVERE, "Error replacing mob", ex);
}
}
controller.setDisableSpawnReplacement(false);
}
use of com.elmakers.mine.bukkit.world.MagicWorld in project MagicPlugin by elBukkit.
the class WorldSpawnListener method onEntitySpawn.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event) {
if (controller.isDisableSpawnReplacement() || ignoreReasons.contains(event.getSpawnReason())) {
return;
}
MagicWorld magicWorld = controller.getWorld(event.getLocation().getWorld().getName());
if (magicWorld == null)
return;
LivingEntity entity = event.getEntity();
Plugin plugin = controller.getPlugin();
controller.setDisableSpawnReplacement(true);
try {
if (magicWorld.processEntitySpawn(plugin, entity)) {
entity.remove();
event.setCancelled(true);
processedSpawns++;
}
} catch (Exception ex) {
controller.getLogger().log(Level.SEVERE, "Error replacing mob", ex);
}
controller.setDisableSpawnReplacement(false);
}
use of com.elmakers.mine.bukkit.world.MagicWorld in project MagicPlugin by elBukkit.
the class WorldPlayerListener method onBlockBreak.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
MagicWorld magicWorld = controller.getWorld(block.getWorld().getName());
if (magicWorld == null)
return;
BlockResult result = magicWorld.processBlockBreak(block, event.getPlayer());
if (result == BlockResult.CANCEL) {
event.setCancelled(true);
}
if (result == BlockResult.REMOVE_DROPS) {
event.setCancelled(true);
block.setType(Material.AIR);
}
}
Aggregations