Added SpawnReasons to CreatureSpawn events. Thanks winsock!

By: EvilSeph <evilseph@unaligned.org>
This commit is contained in:
CraftBukkit/Spigot 2011-06-21 16:20:11 -04:00
parent 82899bb5e6
commit 9e46607f98
2 changed files with 5 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import net.minecraft.server.*;
import org.bukkit.entity.Arrow;
import org.bukkit.Effect;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.weather.ThunderChangeEvent;
import org.bukkit.event.world.SpawnChangeEvent;
@ -346,7 +347,7 @@ public class CraftWorld implements World {
EntityLiving entityCreature = (EntityLiving) EntityTypes.a(creatureType.getName(), world);
entityCreature.setPosition(loc.getX(), loc.getY(), loc.getZ());
creature = (LivingEntity) CraftEntity.getEntity(server, entityCreature);
world.addEntity(entityCreature);
world.addEntity(entityCreature, SpawnReason.CUSTOM);
} catch (Exception e) {
// if we fail, for any reason, return null.
creature = null;

View file

@ -41,6 +41,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
@ -190,7 +191,7 @@ public class CraftEventFactory {
/**
* CreatureSpawnEvent
*/
public static CreatureSpawnEvent callCreatureSpawnEvent(EntityLiving entityliving) {
public static CreatureSpawnEvent callCreatureSpawnEvent(EntityLiving entityliving, SpawnReason spawnReason) {
org.bukkit.entity.Entity entity = entityliving.getBukkitEntity();
CraftServer craftServer = (CraftServer) entity.getServer();
@ -229,7 +230,7 @@ public class CraftEventFactory {
type = CreatureType.MONSTER;
}
CreatureSpawnEvent event = new CreatureSpawnEvent(entity, type, entity.getLocation());
CreatureSpawnEvent event = new CreatureSpawnEvent(entity, type, entity.getLocation(), spawnReason);
craftServer.getPluginManager().callEvent(event);
return event;
}