Class AltsRuntime<H>
- Type Parameters:
H- the host's opaque texture-handle type (for example a NanoVG image handle)
- All Implemented Interfaces:
AutoCloseable
AltsRuntime.Builder; the library exposes an AltLoginService, a generic
SkinAvatarCache, and the runtime's own AccountStore and HostSecrets.
Build it during host initialization, before any alt screen opens. Each runtime owns its stores:
two runtimes in one process, on two directories, never see each other's accounts or secrets. Two
runtimes cannot share a store file; the second one's AltsRuntime.Builder.build() fails.
A runtime holds a lock on each store file for as long as it is open, so a host closes it when done
with it, ideally with try-with-resources. close() writes what is still waiting and releases
the files. A host that never closes it loses nothing on a normal exit: a shutdown hook flushes the
stores.
- Since:
- 0.1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAccumulating builder that injects the host seams. -
Method Summary
Modifier and TypeMethodDescriptionReturns the account service, for validating or renewing a stored account without installing it as the live session.accountServices(String accessToken, String accountUuid) Returns the account-management surface for a bare access token, when the caller holds a token rather than a storedAltAccount.accountServices(AltAccount account) Returns the full account-management surface for one account — profile, entitlements, name, skin, cape — built over its access token.bulk()Returns the bulk surface, for running one operation over many accounts at a pace the service will tolerate.voidclose()Closes the runtime: writes both stores' pending changes, releases their file locks, and stops their background writers and the shutdown hooks that would otherwise flush them at exit; closes the transport's pooled proxy tunnels; and shuts down the executor if the library created it.Returns the lazy, cached game-stats lookup for one server, keyed by player UUID.Returns the login service callers use to authenticate accounts.Returns the public profile lookup — a player's name and UUID, by either — which needs no account and sends no token.secrets()Returns this runtime's host secrets: the per-user key/value secrets kept apart from the accounts.Returns the avatar cache, generic over this host's texture-handle type.store()Returns this runtime's account store: the saved accounts, the current account, and the encrypted file behind them.toasts()Returns the toast sink the host supplied, the one route for raising a notification.vault()Returns the shared vault's way to AVP 0.5 hosts: it connects to a host on this runtime's transport (its proxy provider, timeouts and executor), by the host's key, and caches the hosts' bearer tokens for this runtime alone.
-
Method Details
-
store
Returns this runtime's account store: the saved accounts, the current account, and the encrypted file behind them. It was loaded from disk byAltsRuntime.Builder.build().- Returns:
- the account store
- Since:
- 1.0.0
-
secrets
Returns this runtime's host secrets: the per-user key/value secrets kept apart from the accounts. They were loaded from disk byAltsRuntime.Builder.build().- Returns:
- the host secrets
- Since:
- 1.0.0
-
close
public void close()Closes the runtime: writes both stores' pending changes, releases their file locks, and stops their background writers and the shutdown hooks that would otherwise flush them at exit; closes the transport's pooled proxy tunnels; and shuts down the executor if the library created it. An executor the host passed toAltsRuntime.Builder.executor(Executor)is left running. Idempotent; a second call does nothing. Once this returns, another runtime may open the same directory.Afterwards the stores write nothing. Their contents stay readable; a mutator still changes the store in memory but records "the store is closed" on
saveError()instead of writing, andload()reads nothing. The transport refuses every request made from then on, and a library-created executor refuses new tasks while letting running ones finish, so a sign-in still in flight when the runtime closes resolves, as a failure if it still had a request to make, and what it would have saved is not saved.Whatever was waiting on the runtime ends here too: a bulk run paced between entries, a device-code sign-in between polls, a scheduled name claim, a browser sign-in waiting for its callback. Each such wait fails on the thread that calls
close(), and so do the callbacks chained onto it: a bulk run'sBulkProgress.finishedand the completion of its report, and whatever a sign-in's future runs as it fails, including continuations the host attached to it. A host that callsclose()from its main thread should expect that work there, and must not block in such a callback on something onlyclose()would release.The vault's cached host tokens are dropped, and a vault operation still in flight fails with
AltsFailure.Kind.CANCELLEDat its next request.A wait that was due far in the future, such as a claim scheduled hours ahead, is failed at once, but the JDK keeps the small task that would have woken it queued in its own delay scheduler until its original time; that task then does nothing.
- Specified by:
closein interfaceAutoCloseable- Since:
- 1.0.0
-
loginService
Returns the login service callers use to authenticate accounts.- Returns:
- the login service
- Since:
- 0.1.0
-
accountService
Returns the account service, for validating or renewing a stored account without installing it as the live session. A host sweeping every alt it holds wants this rather thanAltLoginService.loginAccount(AltAccount), which would switch session once per account.- Returns:
- the account service
- Since:
- 0.8.0
-
accountServices
Returns the full account-management surface for one account — profile, entitlements, name, skin, cape — built over its access token. For operating on an account you hold a live token for; nothing here installs a session.- Parameters:
account- the account to operate on- Returns:
- the account services
- Since:
- 0.11.0
-
accountServices
Returns the account-management surface for a bare access token, when the caller holds a token rather than a storedAltAccount.- Parameters:
accessToken- the Minecraft access tokenaccountUuid- the account UUID for request routing, or null- Returns:
- the account services
- Since:
- 0.11.0
-
profileLookup
Returns the public profile lookup — a player's name and UUID, by either — which needs no account and sends no token.- Returns:
- the profile lookup service
- Since:
- 0.12.0
-
bulk
Returns the bulk surface, for running one operation over many accounts at a pace the service will tolerate. Nothing it does installs a session.- Returns:
- the bulk operations
- Since:
- 0.9.0
-
skinCache
Returns the avatar cache, generic over this host's texture-handle type. Keyed by UUID, so a renamed account keeps its head.- Returns:
- the skin avatar cache
- Since:
- 0.1.0
-
gameStats
Returns the lazy, cached game-stats lookup for one server, keyed by player UUID. If no source was registered forserverId, returns an empty cache that always yieldsnull; a failed fetch likewise surfaces asnullfromAsyncCache.get(Object), so callers degrade cleanly.- Parameters:
serverId- the server whose stats to look up (matches a registered source's id)- Returns:
- the per-server game-stats cache
- Since:
- 0.3.0
-
toasts
Returns the toast sink the host supplied, the one route for raising a notification. The library keeps no static sink of its own.- Returns:
- the toast sink
- Since:
- 0.1.0
-
vault
Returns the shared vault's way to AVP 0.5 hosts: it connects to a host on this runtime's transport (its proxy provider, timeouts and executor), by the host's key, and caches the hosts' bearer tokens for this runtime alone. Open a repository on a connection withSharedVault.- Returns:
- the vault entry
- Since:
- 1.0.0
-