Package org.spongepowered.api.event
Class EventContext
java.lang.Object
org.spongepowered.api.event.EventContext
Provides context for an event outside of the direct chain of causes present
in the event's
Cause.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionMap<EventContextKey<?>, Object> asMap()Gets this event context as aMapof EventContextKeys to Objects.static EventContext.Builderbuilder()Creates a new builder for creating anEventContext.booleancontainsKey(Supplier<? extends EventContextKey<?>> key) Gets whether the providedEventContextKeyis included in this context.booleancontainsKey(EventContextKey<?> key) Gets whether the providedEventContextKeyis included in this context.static EventContextempty()Gets an empty context.boolean<T> Optional<T> get(Supplier<EventContextKey<T>> key) Gets the value corresponding to the given key from the context.<T> Optional<T> get(EventContextKey<T> key) Gets the value corresponding to the given key from the context.inthashCode()Set<EventContextKey<?>> keySet()Gets allEventContextKeys present in this context.static EventContextof(Map<EventContextKey<?>, Object> entries) Creates a newEventContextfrom the given map of entries.<T> Trequire(Supplier<EventContextKey<T>> key) Gets the value corresponding to the given key from the context.<T> Trequire(EventContextKey<T> key) Gets the value corresponding to the given key from the context.toString()
-
Method Details
-
empty
Gets an empty context.- Returns:
- The empty context
-
of
Creates a newEventContextfrom the given map of entries.- Parameters:
entries- The context entries- Returns:
- The new EventContext
-
builder
Creates a new builder for creating anEventContext.- Returns:
- The new builder
-
get
Gets the value corresponding to the given key from the context.- Type Parameters:
T- The type of the value stored with the key- Parameters:
key- The key- Returns:
- The context value, if found
-
get
Gets the value corresponding to the given key from the context.- Type Parameters:
T- The type of the value stored with the key- Parameters:
key- The key- Returns:
- The context value, if found
-
require
Gets the value corresponding to the given key from the context.If the key is not available,
NoSuchElementExceptionwill be thrown.- Type Parameters:
T- The type of the value stored with the key- Parameters:
key- The key- Returns:
- The context value, if found
-
require
Gets the value corresponding to the given key from the context.If the key is not available,
NoSuchElementExceptionwill be thrown.- Type Parameters:
T- The type of the value stored with the key- Parameters:
key- The key- Returns:
- The context value, if found
-
containsKey
Gets whether the providedEventContextKeyis included in this context.- Parameters:
key- The context key to check- Returns:
- True if the key is used and there is an entry for it
-
containsKey
Gets whether the providedEventContextKeyis included in this context.- Parameters:
key- The context key to check- Returns:
- True if the key is used and there is an entry for it
-
keySet
Gets allEventContextKeys present in this context.- Returns:
- All present keys
-
asMap
Gets this event context as aMapof EventContextKeys to Objects.- Returns:
- A map view of this context
-
equals
-
hashCode
public int hashCode() -
toString
-