alts

A Minecraft Java Edition account library for sign-in, account management, an encrypted store and a shared vault.

A Minecraft Java Edition account library for Java 25, covering sign-in, account management, bulk operations, an encrypted local store and a shared vault.

Install Getting started API reference

Features

Quick start

// 1. Wire the host seams once at startup. H is your texture-handle type; a host that draws no
//    avatars can use any type and leave textureUploader unset.
//    build() also reads whatever store is already on disk, so alts.store().accounts()
//    is populated the moment it returns. Close the runtime when the host is done with it.
AltsRuntime<MyHandle> alts = new AltsRuntime.Builder<MyHandle>()
        .sessionInjector(new MySessionInjector())   // REQUIRED: install a SessionData as the live session
        .vaultDirectory(() -> myDataDir)             // REQUIRED: where the two encrypted store files live
        .mainThread(myExecutor::execute)             // REQUIRED: run a task on the host's main thread
        .toastSink(new MyToastSink())                // REQUIRED: surface a notification
        .textureUploader(new MyUploader())           // optional: avatar bytes -> host texture
        .microsoftAuth(MicrosoftAuthConfig.of(MY_AZURE_CLIENT_ID))  // optional: your own Azure app id
        .build();

// 2. Sign in through the browser.
alts.loginService().loginMicrosoft(LoginMode.ADD)
        .thenAccept(result -> { /* result.success(), result.account(), result.failure() */ });

// Or with a device code, when there is no browser to open.
alts.loginService().loginDeviceCode(
                (userCode, verificationUri, expiresAt) -> show(verificationUri, userCode),
                LoginMode.ADD)
        .thenAccept(result -> { /* result.success(), result.failure().map(AltsFailure::kind) */ });

// 3. Operate on a stored account without logging into it. A failure throws AltsException;
//    switch on e.kind().
AccountServices services = alts.accountServices(account);
PlayerProfile profile = services.profile().fetch();
Entitlements owned = services.entitlements().fetch();

// 4. On shutdown: write what is pending and release the store files.
alts.close();

The getting started guide walks through every step, and the examples compile against the library.