use of org.bukkit.event.entity.SpawnerSpawnEvent in project Denizen-For-Bukkit by DenizenScript.
the class EntitySpawnScriptEvent method onEntitySpawn.
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
Entity entity = event.getEntity();
this.entity = new EntityTag(entity);
location = new LocationTag(event.getLocation());
if (event instanceof CreatureSpawnEvent) {
CreatureSpawnEvent.SpawnReason creatureReason = ((CreatureSpawnEvent) event).getSpawnReason();
if (creatureReason == CreatureSpawnEvent.SpawnReason.SPAWNER) {
// Let the SpawnerSpawnEvent happen and handle it instead
return;
}
reason = new ElementTag(creatureReason.name());
} else if (event instanceof SpawnerSpawnEvent) {
reason = new ElementTag("SPAWNER");
} else {
reason = new ElementTag("ENTITY_SPAWN");
}
this.event = event;
EntityTag.rememberEntity(entity);
fire(event);
EntityTag.forgetEntity(entity);
}
Aggregations