Class CustomEvent
- Direct Known Subclasses:
BuildMcFinishedLoadingEvent,BuildMcRegistryEvent,ClaimCreateEvent,ClaimProtectionChangeEvent,ClaimRemoveEvent,ClaimWhitelistChangeEvent,EndStateChangeEvent,PlayerHeadDropEvent
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
FieldsModifier and TypeFieldDescriptionprotected final MetadataHolderInternal holder for metadata entries. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract @NotNull org.bukkit.event.HandlerListReturns theHandlerListfor this event type.Returns an unmodifiable view of the metadata map associated with this event.voidputMetadata(@NotNull String key, @NotNull Object value) Adds or updates a metadata entry for this event.voidremoveMetadata(@NotNull String key) Removes a metadata entry associated with the given key.Methods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Field Details
-
metadataHolder
Internal holder for metadata entries.
-
-
Constructor Details
-
CustomEvent
public CustomEvent()
-
-
Method Details
-
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)orremoveMetadata(String)to modify entries.- Returns:
- an unmodifiable map of metadata (never
null)
-
putMetadata
Adds or updates a metadata entry for this event.- Parameters:
key- the metadata key (must not benull)value- the metadata value (must not benull)- Throws:
NullPointerException- ifkeyorvalueisnull
-
removeMetadata
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 benull)- Throws:
NullPointerException- ifkeyisnull
-
getHandlers
@NotNull public abstract @NotNull org.bukkit.event.HandlerList getHandlers()Returns theHandlerListfor this event type.Bukkit requires each concrete event class to define its own static
HandlerListinstance and to return it from this method. This is necessary for Bukkitâs event registration and dispatch system.- Specified by:
getHandlersin classorg.bukkit.event.Event- Returns:
- the handler list for this event (never
null)
-