ReturnableEvent

public abstract class ReturnableEvent<T extends Object> extends Event

Represents an event that can return a result.

Parameters

T

The type of the result.

Constructors

Link copied to clipboard

Properties

Link copied to clipboard
@Deprecated(message = "I think Event class constructor is more useful than this system.")
private final Map<String, Object> metadata

The metadata of the event. This can be used to store additional information about the event.

Link copied to clipboard
private final T result

The result of the event.

Functions

Link copied to clipboard
public final Object getMeta(String key)

Gets a metadata value by key.

Link copied to clipboard
public final Map<String, Object> getMetadata()

The metadata of the event. This can be used to store additional information about the event.

Link copied to clipboard
public final T getMetaOrDefault<T extends Any>(String key, T default)

Gets a metadata value by key or a default value if the value is null.

Link copied to clipboard
public final T getResult()

The result of the event.

Link copied to clipboard
public final T getResultOrDefault(T default)

Gets the result of the event or a default value if the result is null.

Link copied to clipboard
public final Object setMeta(String key, Object value)

Sets a metadata key-value pair.

Link copied to clipboard
public final Unit setResult(T result)

Sets the result of the event.