package org.inventivetalent.npclib.event;

import com.google.common.base.Preconditions;
import org.bukkit.Location;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.inventivetalent.npclib.npc.NPCAbstract;

public class NPCSpawnEvent extends NPCEvent {

	private CreatureSpawnEvent.SpawnReason spawnReason;

	public NPCSpawnEvent(NPCAbstract npc, CreatureSpawnEvent.SpawnReason spawnReason) {
		super(npc);
		this.spawnReason = spawnReason;
	}

	public Location getLocation() {
		return getNpc().getBukkitEntity().getLocation();
	}

	public CreatureSpawnEvent.SpawnReason getSpawnReason() {
		return spawnReason;
	}

	public void setSpawnReason(CreatureSpawnEvent.SpawnReason spawnReason) {
		Preconditions.checkNotNull(spawnReason);
		this.spawnReason = spawnReason;
	}

	private static HandlerList handlerList = new HandlerList();

	@Override
	public HandlerList getHandlers() {
		return handlerList;
	}

	public static HandlerList getHandlerList() {
		return handlerList;
	}
}

package org.inventivetalent.npclib.event;

import com.google.common.base.Preconditions;
import org.bukkit.Location;
import org.bukkit.event.HandlerList;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.inventivetalent.npclib.npc.NPCAbstract;

import javax.annotation.Nonnull;

/**
 * Event called when a new NPC is spawned
 */
public class NPCSpawnEvent extends NPCEvent {

	private CreatureSpawnEvent.SpawnReason spawnReason;

	public NPCSpawnEvent(NPCAbstract npc, CreatureSpawnEvent.SpawnReason spawnReason) {
		super(npc);
		this.spawnReason = spawnReason;
	}

	/**
	 * Get the location where the NPC was spawned
	 *
	 * @return the spawn {@link Location}
	 */
	public Location getLocation() {
		return getNpc().getBukkitEntity().getLocation();
	}

	/**
	 * Get the spawn reason
	 *
	 * @return the {@link org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason}
	 */
	public CreatureSpawnEvent.SpawnReason getSpawnReason() {
		return spawnReason;
	}

	/**
	 * Set the spawn reason
	 *
	 * @param spawnReason the new spawn reason
	 */
	public void setSpawnReason(@Nonnull CreatureSpawnEvent.SpawnReason spawnReason) {
		Preconditions.checkNotNull(spawnReason);
		this.spawnReason = spawnReason;
	}

	private static HandlerList handlerList = new HandlerList();

	@Override
	public HandlerList getHandlers() {
		return handlerList;
	}

	public static HandlerList getHandlerList() {
		return handlerList;
	}
}

add javadoc for NPCSpawnEvent