Class RareUpdateEvent
Carries the rare's unique id, the updated LivingEntity, its associated
EntityData definition, and the Location where it is located.
This event is posted synchronously on the server thread.
What counts as an update: this event is fired both when a rare is first
registered/tracked by RareSpawns (see isNew()) and when RareSpawns
refreshes tracked rares in response to world/player events handled by
UpdateEvent:
- Chunk loads (
ChunkLoadEvent) — rares in the loaded chunk are refreshed. - Player joins (
PlayerJoinEvent) — after a short delay, nearby rares are refreshed. - Player teleports (
PlayerTeleportEvent) — after a short delay, nearby rares are refreshed.
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
ConstructorsConstructorDescriptionRareUpdateEvent(String id, EntityData data, org.bukkit.entity.LivingEntity rare, org.bukkit.Location location, boolean New) Creates a new RareUpdateEvent. -
Method Summary
Modifier and TypeMethodDescriptionvoidFires this RareUpdateEvent via the Bukkit event bus.Gets the data backing the updated 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 was updated.org.bukkit.LocationGets the location of the rare at the time of this update.org.bukkit.entity.LivingEntityGets the updated rare entity instance.booleanisNew()Returns true if this rare entity is newly spawned, false if it is an update to an existing entity.Methods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Field Details
-
called
protected boolean called
-
-
Constructor Details
-
RareUpdateEvent
public RareUpdateEvent(String id, EntityData data, org.bukkit.entity.LivingEntity rare, org.bukkit.Location location, boolean New) Creates a new RareUpdateEvent.- Parameters:
id- Unique id of the rare definition that was updated.data- The configuration/data backing the updated rare.rare- The updated rare entity instance.location- The world location of the rare at the time of this update.New-trueif this is the initial registration of the rare;falsefor a subsequent refresh/update.
-
-
Method Details
-
callEvent
public void callEvent()Fires this RareUpdateEvent 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 was updated.- Returns:
- rare id
-
getRareEntity
public org.bukkit.entity.LivingEntity getRareEntity()Gets the updated rare entity instance.- Returns:
- the rare
LivingEntity
-
getEntityData
Gets the data backing the updated rare.- Returns:
EntityDataassociated with this update
-
getLocation
public org.bukkit.Location getLocation()Gets the location of the rare at the time of this update.- Returns:
Location
-
isNew
public boolean isNew()Returns true if this rare entity is newly spawned, false if it is an update to an existing entity.- Returns:
- true if newly spawned, false if updated
-
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
-