Class AltAccount
SerializedName, which names the
store file's format; only the library's own stores serialize an account, through an internal record of
the same shape, so the store file keeps the shape it had when this was a record. A host's own Gson cannot
read or write this class on the module path, and on the class path only by setting final fields through
reflection: a host that persists accounts itself goes through the accessors and builder(String, String, String, AccountType).
A final class rather than a record since 1.0.0, so a later field is an addition and not a break: build
one with of(String, String, String, AccountType), builder(String, String, String, AccountType) or toBuilder(), and derive copies with the withX
methods. Two accounts are equal when every field is.
When this account lives in a shared repository, lastUsed/lastUsedBy and bans
are shared state so members coordinate (who used it last, where it got banned). For a purely local
account the attribution fields are null.
bans maps a serverId to a BanInfo — bans are per-server, because an account
banned on one server may be fine on another. The serverId is an opaque, host-supplied string
(the same namespace a host uses for game stats); the library never inspects a connection or detects a
server. A null/empty map means "not known to be banned anywhere".
sourceClient/sourceUser record provenance for cross-client sharing: which client
(mod) the alt was added from and the user within that client, so members of a shared repo can tell a
given alt came from, say, one client's user versus another's. They are plain, opaque, implementer-set
strings — the standard defines only the field names, never their values. Both are null for a
purely local or unattributed account, and they ride inside the encrypted repo payload only (the sync
server never sees them), preserving the zero-knowledge guarantee.
refreshToken and expiresAt back silent session renewal. The refresh token is a
durable credential — far longer-lived than the access token — so it is stripped from a shared
repository payload unless that repository has explicitly opted in. expiresAt is epoch millis
and 0 means "unknown", which callers read as "assume expired and renew".
- Since:
- 0.1.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionReturns the sensitive authentication token (OAuth, session, or cookie derived).booleanbanned()Returns whether this account is considered banned on any server.booleanReturns whether this account is considered banned on the given server.Returns the set of server ids on which this account is considered banned.bans()Returns the locally-observed ban records keyed by server id, unmodifiable.static AltAccount.Builderbuilder(String uuid, String username, String accessToken, AccountType type) Starts an account with every other field empty: never used (lastUsed0), unattributed, no bans, no refresh token, expiry unknown.booleanReturns whetherois an account with every field equal to this one's, the bans compared as maps.longReturns the epoch-millis expiry ofaccessToken().inthashCode()Returns a hash over every field, consistent withequals(Object).booleanReturns whether this account carries a usable refresh token.longlastUsed()Returns the epoch-millis timestamp of the last successful login with this account.Returns the member id (Ed25519 identity) that last used this account in a shared repo.mergedOnto(AltAccount existing) Returns this account's identity and credentials applied onto a record the store already holds, so re-authenticating an alt refreshes what it logs in with without discarding what the store learned about it.static AltAccountof(String uuid, String username, String accessToken, AccountType type) Creates a freshly authenticated account stamped as used at the current system time, unattributed.Returns the OAuth refresh token used to renew the session.Returns the client (mod) the alt was added from.Returns the user withinsourceClient()that added the alt.Returns a builder holding every field of this account, to change several at once.toString()Returns a description of this account with both credentials redacted.type()Returns the protocol used to authenticate this account.usedNow()Returns a copy of this account withlastUsedrefreshed to now, preserving any existing attribution.Returns a copy of this account stamped as used now by the given member — for attributing activity inside a shared repository.username()Returns the last known display name of the account.uuid()Returns the unique identifier of the Minecraft player.Returns a copy of this account with the ban record forserverIdset (or cleared).withSource(String sourceClient, String sourceUser) Returns a copy of this account stamped with its provenance — the client it was added from and the user within that client — for cross-client shared repositories.withTokens(String accessToken, String refreshToken, long expiresAt) Returns a copy of this account carrying freshly issued credentials, preserving attribution, bans, and provenance.withUsername(String username) Returns a copy of this account with its username replaced.
-
Method Details
-
of
Creates a freshly authenticated account stamped as used at the current system time, unattributed.- Parameters:
uuid- the player's UUIDusername- the player's usernameaccessToken- the authentication tokentype- the authentication protocol used- Returns:
- a new account with
lastUsedset to now - Since:
- 0.1.0
-
builder
public static AltAccount.Builder builder(String uuid, String username, String accessToken, AccountType type) Starts an account with every other field empty: never used (lastUsed0), unattributed, no bans, no refresh token, expiry unknown. This is what the record's canonical constructor was for: an account rebuilt field by field, from a host's own storage, say.- Parameters:
uuid- the player's UUIDusername- the player's usernameaccessToken- the authentication tokentype- the authentication protocol used- Returns:
- a builder holding those four
- Since:
- 1.0.0
-
toBuilder
Returns a builder holding every field of this account, to change several at once.- Returns:
- a builder that builds an account equal to this one until a field is changed
- Since:
- 1.0.0
-
uuid
Returns the unique identifier of the Minecraft player.- Returns:
- the dashed UUID
- Since:
- 0.1.0
-
username
Returns the last known display name of the account.- Returns:
- the username
- Since:
- 0.1.0
-
accessToken
Returns the sensitive authentication token (OAuth, session, or cookie derived).- Returns:
- the access token
- Since:
- 0.1.0
-
type
Returns the protocol used to authenticate this account.- Returns:
- the account type
- Since:
- 0.1.0
-
lastUsed
public long lastUsed()Returns the epoch-millis timestamp of the last successful login with this account.- Returns:
- the last-used time, or
0when never used - Since:
- 0.1.0
-
lastUsedBy
Returns the member id (Ed25519 identity) that last used this account in a shared repo.- Returns:
- the member id, or
nullwhen used locally / unattributed - Since:
- 0.1.0
-
bans
-
sourceClient
Returns the client (mod) the alt was added from.- Returns:
- the source client, or
nullwhen unattributed - Since:
- 0.2.0
-
sourceUser
Returns the user withinsourceClient()that added the alt.- Returns:
- the source user, or
null - Since:
- 0.2.0
-
refreshToken
Returns the OAuth refresh token used to renew the session.- Returns:
- the refresh token, or
nullwhen the account has none (cookie, session, and offline accounts never do) - Since:
- 0.6.0
-
expiresAt
public long expiresAt()Returns the epoch-millis expiry ofaccessToken().- Returns:
- the expiry, or
0when unknown - Since:
- 0.6.0
-
usedNow
Returns a copy of this account withlastUsedrefreshed to now, preserving any existing attribution.- Returns:
- a copy stamped as used now
- Since:
- 0.1.0
-
usedNow
Returns a copy of this account stamped as used now by the given member — for attributing activity inside a shared repository.- Parameters:
byMember- the member id (Ed25519 identity) that used the account, ornull- Returns:
- a copy stamped as used now by
byMember - Since:
- 0.1.0
-
withBan
Returns a copy of this account with the ban record forserverIdset (or cleared). Other servers' entries are preserved.- Parameters:
serverId- the server the ban applies toban- the ban record, ornullto clear this server's entry- Returns:
- a copy with
serverId's ban entry replaced - Since:
- 0.5.0
-
withUsername
Returns a copy of this account with its username replaced. A username is mutable — a player can rename — so a validation that resolves the current one updates the stored record through this rather than leaving a stale display name behind.- Parameters:
username- the current username- Returns:
- a copy carrying the given username
- Since:
- 0.10.0
-
withSource
Returns a copy of this account stamped with its provenance — the client it was added from and the user within that client — for cross-client shared repositories.- Parameters:
sourceClient- the client (mod) the alt was added from, ornullto clearsourceUser- the user withinsourceClientthat added it, ornull- Returns:
- a copy carrying the given provenance
- Since:
- 0.2.0
-
withTokens
Returns a copy of this account carrying freshly issued credentials, preserving attribution, bans, and provenance. Used by the renewal path, which must persist the rotated refresh token.- Parameters:
accessToken- the newly issued access tokenrefreshToken- the newly issued refresh token, ornullto clear itexpiresAt- the epoch-millis expiry ofaccessToken, or0when unknown- Returns:
- a copy carrying the given credentials
- Since:
- 0.6.0
-
mergedOnto
Returns this account's identity and credentials applied onto a record the store already holds, so re-authenticating an alt refreshes what it logs in with without discarding what the store learned about it. Bans, provenance, and shared attribution come fromexistingunless this account carries its own, and a route that issues no refresh token leaves the stored one in place rather than clearing it.expiresAtis always this account's, because it describes this account's access token.- Parameters:
existing- the stored record for the same UUID, ornullwhen the store holds none- Returns:
- this account merged onto
existing, or this account unchanged when there is none - Since:
- 0.6.0
-
hasRefreshToken
public boolean hasRefreshToken()Returns whether this account carries a usable refresh token.- Returns:
- true if a non-blank refresh token is present
- Since:
- 0.6.0
-
banned
Returns whether this account is considered banned on the given server.- Parameters:
serverId- the server to check- Returns:
trueif a ban record forserverIdis present and flags the account banned- Since:
- 0.5.0
-
banned
public boolean banned()Returns whether this account is considered banned on any server.- Returns:
trueif any server's ban record flags the account banned- Since:
- 0.1.0
-
bannedServers
-
equals
-
hashCode
public int hashCode()Returns a hash over every field, consistent withequals(Object). -
toString
Returns a description of this account with both credentials redacted. Printing the access and refresh tokens verbatim would let a host that logs an account — or anything embedding one, such as a login result — write a durable credential to disk. Identity and state stay readable, because that is what a log is for.
-