Class CustomEvent

java.lang.Object
org.bukkit.event.Event
net.mathias2246.buildmc.api.event.CustomEvent
Direct Known Subclasses:
BuildMcFinishedLoadingEvent, BuildMcRegistryEvent, ClaimCreateEvent, ClaimProtectionChangeEvent, ClaimRemoveEvent, ClaimWhitelistChangeEvent, EndStateChangeEvent, PlayerHeadDropEvent

public abstract class CustomEvent extends org.bukkit.event.Event
Base class for custom Bukkit events that support metadata.

This class extends Event and delegates metadata handling to an internal MetadataHolder. Metadata allows plugin developers to attach arbitrary contextual data to events without subclassing or creating wrapper types.

Subclasses must provide their own static HandlerList and override getHandlers() as required by the Bukkit event system.

See Also:
  • 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 final MetadataHolder
    Internal holder for metadata entries.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract @NotNull org.bukkit.event.HandlerList
    Returns the HandlerList for this event type.
    @NotNull Map<String,Object>
    Returns an unmodifiable view of the metadata map associated with this event.
    void
    putMetadata(@NotNull String key, @NotNull Object value)
    Adds or updates a metadata entry for this event.
    void
    removeMetadata(@NotNull String key)
    Removes a metadata entry associated with the given key.

    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

    • metadataHolder

      protected final MetadataHolder metadataHolder
      Internal holder for metadata entries.
  • Constructor Details

    • CustomEvent

      public CustomEvent()
  • Method Details

    • getMetadata

      @NotNull public @NotNull Map<String,Object> getMetadata()
      Returns an unmodifiable view of the metadata map associated with this event.

      The returned map reflects all metadata currently attached to the event. Use putMetadata(String, Object) or removeMetadata(String) to modify entries.

      Returns:
      an unmodifiable map of metadata (never null)
    • putMetadata

      public void putMetadata(@NotNull @NotNull String key, @NotNull @NotNull Object value)
      Adds or updates a metadata entry for this event.
      Parameters:
      key - the metadata key (must not be null)
      value - the metadata value (must not be null)
      Throws:
      NullPointerException - if key or value is null
    • removeMetadata

      public void removeMetadata(@NotNull @NotNull String key)
      Removes a metadata entry associated with the given key.

      If no entry exists for the given key, this method does nothing.

      Parameters:
      key - the metadata key to remove (must not be null)
      Throws:
      NullPointerException - if key is null
    • getHandlers

      @NotNull public abstract @NotNull org.bukkit.event.HandlerList getHandlers()
      Returns the HandlerList for this event type.

      Bukkit requires each concrete event class to define its own static HandlerList instance and to return it from this method. This is necessary for Bukkit’s event registration and dispatch system.

      Specified by:
      getHandlers in class org.bukkit.event.Event
      Returns:
      the handler list for this event (never null)