Class CustomPlayerEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
net.mathias2246.buildmc.api.event.CustomPlayerEvent
- Direct Known Subclasses:
PlayerEnterClaimEvent,PlayerLeaveClaimEvent,PlayerSpawnTeleportPreConditionEvent
public abstract class CustomPlayerEvent
extends org.bukkit.event.player.PlayerEvent
Base class for player-related custom events that support metadata.
This class extends PlayerEvent to automatically associate
an event instance with a Player, while also providing
MetadataHolder-based metadata support for attaching
custom contextual data.
Subclasses must define their own static HandlerList
and override getHandlers() in accordance with
Bukkit’s 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.Fields inherited from class org.bukkit.event.player.PlayerEvent
player -
Constructor Summary
ConstructorsConstructorDescriptionCustomPlayerEvent(@NotNull org.bukkit.entity.Player player) Constructs a newCustomPlayerEventfor the given player. -
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.player.PlayerEvent
getPlayerMethods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Field Details
-
metadataHolder
Internal holder for metadata entries.
-
-
Constructor Details
-
CustomPlayerEvent
public CustomPlayerEvent(@NotNull @NotNull org.bukkit.entity.Player player) Constructs a newCustomPlayerEventfor the given player.- Parameters:
player- the player associated with this event (must not benull)- Throws:
NullPointerException- ifplayerisnull
-
-
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)
-