MinecraftAccount

sealed class MinecraftAccount

An account the client can log into.

Subclasses own their credentials and how those are refreshed. Everything shared between them - the resolved profile, the favourite flag, ban tracking and JSON persistence - lives here.

This was previously the mc-authlib library. The Microsoft/Xbox Live/XSTS/Minecraft token chain behind MicrosoftAccount is implemented by MinecraftAuth.

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var profile: GameProfile?
Link copied to clipboard
Link copied to clipboard

Known as soon as the account exists, unlike profile, which is only resolved once refresh has succeeded at least once.

Functions

Link copied to clipboard
fun isBanned(serverName: String): Boolean
Link copied to clipboard
Link copied to clipboard
fun login(): Pair<SessionWithService, YggdrasilAuthenticationService>

Authenticates the account and returns the session to hand to the game, along with the authentication service that resolves other players' profiles while it is active.

Link copied to clipboard
abstract fun refresh()
Link copied to clipboard
fun toJson(): JsonObject
Link copied to clipboard
fun trackBan(ban: Ban)

Tracking bans is up to the caller - this only stores and expires them.

Link copied to clipboard
fun untrackBan(serverName: String)