Interface ScenarioStore
public interface ScenarioStore
A scenario's scratch space for one match.
Everything stored here is private to a single scenario in a single game and is discarded when that match ends, which is what lets the same scenario run in several matches at once without any of them seeing each other's state.
The store is thread-safe.
- Since:
- 1.6.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Removes everything.voidclearPlayer(@NotNull UUID playerId) Drops everything stored against one participant.<T> TcomputeIfAbsent(@NotNull String key, @NotNull Class<T> type, @NotNull Supplier<T> factory) The stored value, creating and storing one throughfactorywhen absent.boolean<T> @NotNull Optional<T> The stored value, empty when absent or of a different type.<T> TgetOrDefault(@NotNull String key, @NotNull Class<T> type, T fallback) The stored value, orfallbackwhen absent or of a different type.<T> @NotNull Optional<T> Reads a value stored against one participant.keys()booleanRemoves a key and reports whether anything was stored under it.voidStores a value; a null value removes the key.voidStores a value against one participant; a null value removes it.
-
Method Details
-
get
@NotNull <T> @NotNull Optional<T> get(@NotNull @NotNull String key, @NotNull @NotNull Class<T> type) The stored value, empty when absent or of a different type. -
getOrDefault
The stored value, orfallbackwhen absent or of a different type. -
computeIfAbsent
@NotNull <T> T computeIfAbsent(@NotNull @NotNull String key, @NotNull @NotNull Class<T> type, @NotNull @NotNull Supplier<T> factory) The stored value, creating and storing one throughfactorywhen absent. -
set
Stores a value; a null value removes the key. -
remove
Removes a key and reports whether anything was stored under it. -
contains
-
keys
-
clear
void clear()Removes everything. Cleanup does this automatically. -
getPlayer
@NotNull <T> @NotNull Optional<T> getPlayer(@NotNull @NotNull UUID playerId, @NotNull @NotNull String key, @NotNull @NotNull Class<T> type) Reads a value stored against one participant. -
setPlayer
void setPlayer(@NotNull @NotNull UUID playerId, @NotNull @NotNull String key, @Nullable @Nullable Object value) Stores a value against one participant; a null value removes it. -
clearPlayer
Drops everything stored against one participant.Useful when a player leaves mid-match; the store does not do this on its own, because a scenario may want a disconnecting player's state to survive a reconnect.
-