Class ScriptStateStore

java.lang.Object
com.soulfiremc.server.script.ScriptStateStore

public final class ScriptStateStore extends Object
Per-script state container with typed key access. State is scoped to the ReactiveScriptContext and is automatically cleaned up when the script deactivates (context is GC'd).
  • Constructor Details

    • ScriptStateStore

      public ScriptStateStore()
  • Method Details

    • getOrCreate

      public <T> T getOrCreate(String key, Supplier<T> factory)
      Gets an existing value or creates a new one using the factory.
      Type Parameters:
      T - the value type
      Parameters:
      key - the state key
      factory - supplier to create the initial value
      Returns:
      the existing or newly created value