Class RareUpdateEvent

java.lang.Object
org.bukkit.event.Event
valorless.rarespawns.api.events.RareUpdateEvent

public class RareUpdateEvent extends org.bukkit.event.Event
Event fired when a rare entity is updated in RareSpawns.

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
    Modifier and Type
    Field
    Description
    protected boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RareUpdateEvent(String id, EntityData data, org.bukkit.entity.LivingEntity rare, org.bukkit.Location location, boolean New)
    Creates a new RareUpdateEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Fires this RareUpdateEvent via the Bukkit event bus.
    Gets the data backing the updated rare.
    static org.bukkit.event.HandlerList
    Required boilerplate for Bukkit custom events.
    org.bukkit.event.HandlerList
    Required boilerplate for Bukkit custom events.
    Gets the unique id of the rare definition that was updated.
    org.bukkit.Location
    Gets the location of the rare at the time of this update.
    org.bukkit.entity.LivingEntity
    Gets the updated rare entity instance.
    boolean
    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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 - true if this is the initial registration of the rare; false for 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 internal called flag is set to true to 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

      public String 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

      public EntityData getEntityData()
      Gets the data backing the updated rare.
      Returns:
      EntityData associated 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:
      getHandlers in class org.bukkit.event.Event
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
      Required boilerplate for Bukkit custom events.
      Returns:
      static handler list