Interface ManagementContext


public interface ManagementContext
Context passed to ManagementScript.onStart(ManagementContext).

Unlike ScriptContext, this context is not tied to any single client. It provides cross-client coordination via ClientOrchestrator and per-client access via ClientProvider.

See Also:
  • Method Details

    • getOrchestrator

      ClientOrchestrator getOrchestrator()
      Returns the orchestrator for cross-client script and group management.
    • getClientProvider

      ClientProvider getClientProvider()
      Returns the client provider for accessing individual connected clients and their GameAPI / EventBus instances.
    • getMessageBus

      MessageBus getMessageBus()
      Returns the message bus for inter-script communication.
    • getSharedState

      SharedState getSharedState()
      Returns the shared state store for cross-script data sharing.
    • targets

      default Set<ManagementTarget> targets()
      Returns what the user has told this script to manage, as it is now.

      The host limits getOrchestrator() and getClientProvider() to these targets: clients and scripts they do not cover are left out of every list, and a call that would act on one fails with a result saying it is not in this script's targets. An empty set means the script has not been applied to anything yet, so it sees no clients at all.

      Targets can change while the script runs, and a group target's name changes when the group is renamed, so read this when you need it rather than keeping it from ManagementScript.onStart(ManagementContext).

      A host that does not scope management scripts returns ManagementTarget.WholeHost, which is what this default does.

      Returns:
      this script's targets; never null
    • configFor

      default ScriptConfig configFor(String accountUuid)
      Returns this script's settings as they apply to the client on account accountUuid.

      The user can give a management script different values for different targets. Each value comes from the first of these that sets it:

      1. a ManagementTarget.ClientScript target on that account;
      2. a ManagementTarget.Group target the client is a member of, the oldest group first;
      3. the defaults: the config ManagementScript.onConfigUpdate(ScriptConfig) receives.

      When the script targets more than one script on the same client, their values are taken in the order the targets were added; use configFor(String, String) to name the one you mean. A client the targets do not cover gets the defaults, as does every client of a script that manages the whole host.

      onConfigUpdate still receives only the defaults, and is not called when a target's own values change. Those can change at any time, so read this when you act on a client rather than keeping it.

      A host that keeps no per-target settings returns an empty config, so every getter returns the fallback it is given; this default does that.

      Parameters:
      accountUuid - the client's account UUID, as ManagementTarget.ClientScript.accountUuid() gives it
      Returns:
      the merged config; never null
    • configFor

      default ScriptConfig configFor(String accountUuid, String scriptName)
      Returns this script's settings as they apply to the script named scriptName on the client on account accountUuid: the same order as configFor(String), with only that script's own values in the first place.

      This default returns configFor(String).

      Parameters:
      accountUuid - the client's account UUID
      scriptName - the client script's manifest name
      Returns:
      the merged config; never null
    • clientLauncher

      default ClientLauncher clientLauncher()
      Returns the launcher for starting, stopping and watching clients through the BotWithUs launcher service, limited to this script's targets.

      A host that does not talk to the launcher service returns ClientLauncher.unavailable(), which is what this default does: every call throws LauncherException.SERVICE_UNAVAILABLE.

      Returns:
      the launcher; never null