Class MetadataHolder
java.lang.Object
net.mathias2246.buildmc.api.event.MetadataHolder
Base class providing metadata support for custom events.
Metadata allows additional context to be stored and shared with plugins without needing to subclass the event. Each entry is a key-value pair. Keys must be unique within a single event instance.
This class provides an unmodifiable view for external access to prevent accidental modification of the internal state.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns an unmodifiable view of all metadata entries associated with this event.Provides internal access to the mutable metadata map.voidputMetadata(@NotNull String key, @NotNull Object value) Adds a new metadata entry or updates the value for an existing key.voidremoveMetadata(@NotNull String key) Removes a metadata entry from the event.
-
Constructor Details
-
MetadataHolder
public MetadataHolder()
-
-
Method Details
-
getMetadata
Returns an unmodifiable view of all metadata entries associated with this event.This map should not be modified directly; use
putMetadata(String, Object)orremoveMetadata(String)to update entries.- Returns:
- an unmodifiable map containing all metadata (never
null)
-
mutableMetadata
-
putMetadata
Adds a new metadata entry or updates the value for an existing key.- Parameters:
key- the metadata key (must not benull)value- the metadata value (must not benull)- Throws:
NullPointerException- ifkeyorvalueisnull
-
removeMetadata
Removes a metadata entry from the event.If the key does not exist, this method does nothing.
- Parameters:
key- the metadata key to remove (must not benull)- Throws:
NullPointerException- ifkeyisnull
-