Interface ManagementContext
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 Summary
Modifier and TypeMethodDescriptiondefault ClientLauncherReturns the launcher for starting, stopping and watching clients through the BotWithUs launcher service, limited to this script's targets.default ScriptConfigReturns this script's settings as they apply to the client on accountaccountUuid.default ScriptConfigReturns this script's settings as they apply to the script namedscriptNameon the client on accountaccountUuid: the same order asconfigFor(String), with only that script's own values in the first place.Returns the client provider for accessing individual connected clients and their GameAPI / EventBus instances.Returns the message bus for inter-script communication.Returns the orchestrator for cross-client script and group management.Returns the shared state store for cross-script data sharing.default Set<ManagementTarget> targets()Returns what the user has told this script to manage, as it is now.
-
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. -
targets
Returns what the user has told this script to manage, as it is now.The host limits
getOrchestrator()andgetClientProvider()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
Returns this script's settings as they apply to the client on accountaccountUuid.The user can give a management script different values for different targets. Each value comes from the first of these that sets it:
- a
ManagementTarget.ClientScripttarget on that account; - a
ManagementTarget.Grouptarget the client is a member of, the oldest group first; - 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.onConfigUpdatestill 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, asManagementTarget.ClientScript.accountUuid()gives it- Returns:
- the merged config; never
null
- a
-
configFor
Returns this script's settings as they apply to the script namedscriptNameon the client on accountaccountUuid: the same order asconfigFor(String), with only that script's own values in the first place.This default returns
configFor(String).- Parameters:
accountUuid- the client's account UUIDscriptName- the client script's manifest name- Returns:
- the merged config; never
null
-
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 throwsLauncherException.SERVICE_UNAVAILABLE.- Returns:
- the launcher; never
null
-