Class RareSpawnEvent
Carries the spawn's unique id, the spawned LivingEntity, its associated
EntityData definition, and the Location where it appeared.
This event is posted synchronously on the server thread.
Spawn origin: SpawnCause indicates where the spawn originated.
SpawnCause.INTERNAL— spawned by RareSpawns' own systems (built-in logic, schedules, config rules, or internal commands).SpawnCause.EXTERNAL— spawned through the RareSpawns public API (typically initiated by another plugin via an API call).SpawnCause.NULL— unknown/unspecified.
Listen to this event to implement custom reactions (e.g., announcements, additional effects, logging, or integrations).
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRareSpawnEvent(String id, EntityData data, org.bukkit.entity.LivingEntity rare, org.bukkit.Location location, SpawnCause cause) Creates a new RareSpawnEvent. -
Method Summary
Modifier and TypeMethodDescriptionvoidFires this RareSpawnEvent via the Bukkit event bus.getCause()Gets the origin/cause of this spawn.Gets the data backing the spawned rare.static org.bukkit.event.HandlerListRequired boilerplate for Bukkit custom events.org.bukkit.event.HandlerListRequired boilerplate for Bukkit custom events.getId()Gets the unique id of the rare definition that spawned.org.bukkit.LocationGets the location where the rare spawned.org.bukkit.entity.LivingEntityGets the spawned rare entity instance.Methods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Field Details
-
called
protected boolean called
-
-
Constructor Details
-
RareSpawnEvent
public RareSpawnEvent(String id, EntityData data, org.bukkit.entity.LivingEntity rare, org.bukkit.Location location, SpawnCause cause) Creates a new RareSpawnEvent.- Parameters:
id- Unique id of the rare definition that spawned.data- The configuration/data backing the spawned rare.rare- The spawned rare entity instance.location- The world location where the rare spawned.cause- The origin of the spawn, seeSpawnCausefor semantics.
-
-
Method Details
-
callEvent
public void callEvent()Fires this RareSpawnEvent via the Bukkit event bus.Calls Bukkit.getPluginManager().callEvent(this) synchronously on the main server thread, notifying all registered listeners. This event is not cancellable.
This method is single-use. If invoked more than once, it throws an
IllegalStateException. After a successful dispatch, the internalcalledflag is set totrueto prevent re-dispatch.Only call from the server thread. From asynchronous contexts, schedule a synchronous task first.
- Throws:
IllegalStateException- if the event has already been dispatched
-
getId
Gets the unique id of the rare definition that spawned.- Returns:
- rare id
-
getRareEntity
public org.bukkit.entity.LivingEntity getRareEntity()Gets the spawned rare entity instance.- Returns:
- the rare
LivingEntity
-
getEntityData
Gets the data backing the spawned rare.- Returns:
EntityDataassociated with this spawn
-
getLocation
public org.bukkit.Location getLocation()Gets the location where the rare spawned.- Returns:
- spawn
Location
-
getCause
Gets the origin/cause of this spawn.INTERNAL = spawned by RareSpawns' internal systems; EXTERNAL = spawned via the public API by an external caller; NULL = unknown.
- Returns:
SpawnCausedescribing where the spawn originated
-
getHandlers
public org.bukkit.event.HandlerList getHandlers()Required boilerplate for Bukkit custom events.- Specified by:
getHandlersin classorg.bukkit.event.Event
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()Required boilerplate for Bukkit custom events.- Returns:
- static handler list
-