dart_minecraft library

The core dart_minecraft library with Mojang, Minecraft and Microsoft APIs. It wraps authentication APIs, content APIs and account management APIs. Furthermore, there are server pinging features to get the status of any Minecraft: Java Edition server.

Classes

BlockedServer
Represents a blocked server that the player shouldn't be allowed to join.
LegacyProfileTextures
Represents all textures for a legacy minecraft profile.
MinecraftNews
A Minecraft News item.
MinecraftPatch
A Patch/Version of Minecraft, including a image and a description.
MinecraftStatistics
Stores Minecraft Sale Statistics.
MojangStatus
Contains the MojangSiteStatus of all Minecraft and Mojang sites.
Name
A Name helper class used for Mojang.getNameHistory(). It contains the name and the date it was changed to.
PacketReader
Reads different server packets from binary into objects.
PacketWriter
Writes various different server packets into binary.
Pair<A, B>
Creates a pair of values.
Profile
A Minecraft user including their skin/cape.
ProfileNameChangeInfo
ProfileTexture
Represents a single texture for a minecraft profile. Could be a cape or skin.
ServerPacket
The basis of each and every packet for post 1.6 servers.
Version
A Minecraft Version.
VersionManifest
A manifest of all currently available Minecraft Versions. Also has latest release and snapshot versions.

Enums

MinecraftPatchType
MinecraftStatisticsItem
Statistics items that can be selected.
MojangSiteStatus
The status of a site.
PacketCompression
SkinModel
The skin model of a texture

Extensions

MinecraftStatisticsItemExt on MinecraftStatisticsItem
Extension on MinecraftStatisticsItem to give each enum value a string value.

Functions

answerSecurityChallenges(AccessToken accessToken, List<SecurityChallenge> answers) Future<bool>
Allows an authenticated user to verify their location by answering their security questions. You can get the security challenges through getSecurityChallenges. Also check if this is needed using areSecurityChallengesNeeded.
areSecurityChallengesNeeded(AccessToken accessToken) Future<bool>
Checks whether or not the user has to answer the security challenges. This will return true if the current location is not verified and needs to be verified using getSecurityChallenges and answerSecurityChallenges.
authenticate(String username, String password, {String? clientToken}) Future<MojangAccount>
Authenticates a user with given credentials username and password. This only works with Mojang accounts and does not work with migrated Microsoft accounts.
authenticateWithXBOX(String xstsToken, String userHash) Future<String>
Perform a login with a previously acquired XSTS Token. This returns a classic Minecraft access token which can be used in the Minecraft client to authenticate itself.
authenticateXBL(String msAccessToken) Future<XboxToken>
Authenticate with XBOX Live. This requires a previously acquired Microsoft Access Token. A Microsoft Access Token is acquired by following through the Microsoft Authentication Scheme. To be specific, this function requires the access_token from the login.live.com/oauth20_token.srf endpoint.
authenticateXSTS(String xblToken) Future<XboxToken>
Retrieves a XBOX Live Security token for the XBOX Live token. The XBOX Live token can be acquired using authenticateXBL.
canMigrate(AccessToken accessToken) Future<bool>
Checks whether this user can already migrate their account from a Mojang account to a Microsoft account. This function will simply return 'false' if the access token is invalid or expired.
changeName(String uuid, String newName, AccessToken accessToken, String password) Future<bool>
Changes the Mojang account name to newName.
changePassword(String currentPassword, String newPassword, AccessToken accessToken) Future<bool>
Changes the currentPassword to the new newPassword. This requires a valid accessToken and will throw a ArgumentError if it is not. Be careful to what values you pass into newPassword, as the accessToken will get invalidated and you will need it to log into your account again.
changeSkin(Uri skinUrl, AccessToken accessToken, [SkinModel skinModel = SkinModel.classic]) Future<bool>
Change the skin with the texture of the skin at skinUrl.
getAttributes(String accessToken) Future<PlayerAttributes>
Gets player attributes. Some attributes define gameplay features which are enabled through XBOX live, which are presumably also parental control features. Attributes also give information about the ban status of a player.
getBlockedPlayers(String accessToken) Future<List<String>>
Gets the list of players this player has blocked. Chat messages or Realms notifications are hidden from blocked players.
getBlockedServers() Future<List<BlockedServer>>
Returns a list of blocked servers.
getCertificates(String accessToken) Future<PlayerCertificates>
Gets certificates used to cryptographically sign chat messages since 1.19.
getCurrentProfile(AccessToken accessToken) Future<Profile>
Get's the Minecraft profile for the currently logged in user. This requires a valid access token.
getLibraryUrl(String package, String name, String version, {String? os}) String
Get the URL for a maven library. The os string should be null or "linux", "windows" or "osx".
getName(String uuid) Future<PlayerUuid>
Get the name and UUID by a player's UUID.
getNameChangeInfo(String accessToken) Future<ProfileNameChangeInfo>
getNameHistory(String uuid) Future<List<Name>>
Returns the name history for the account with uuid.
getNews() Future<List<MinecraftNews>>
Returns a List of the most recent news for Minecraft.
getPatchNotes() Future<List<MinecraftPatch>>
Returns a List of the most recent patch notes for Minecraft: Java Edition.
getProfile(String uuid) Future<Profile>
Returns the user profile including skin/cape information. Does not require authentication.
getResourceUrl(String hash) String
Get the resource URL for a given hash.
getSecurityChallenges(AccessToken accessToken) Future<List<SecurityChallenge>>
Fetches the list of security challenges one must answer to access the account. Check if this is needed using areSecurityChallengesNeeded.
getStatistics(List<MinecraftStatisticsItem> items) Future<MinecraftStatistics>
Get's Minecraft: Java Edition, Minecraft Dungeons, Cobalt and Scrolls purchase statistics.
getStatus() Future<MojangStatus>
Returns the Mojang and Minecraft API and website status.
getUuid(String username, {DateTime? timestamp}) Future<PlayerUuid>
Returns the UUID for player username.
getUuids(List<String> usernames) Future<List<PlayerUuid>>
Returns a List of player UUIDs by a List of player names.
getVersions() Future<VersionManifest>
Returns a Manifest with all Minecraft: Java Edition Versions, including alpha/beta and snapshot versions.
invalidate(MojangAccount mojangAccount) Future<bool>
Invalidates the accessToken of given mojangAccount.
isNameAvailable(String name, AccessToken accessToken) Future<bool>
Checks whether or not given name is available or not. A name must be at least 3 characters and at most 16 characters long and not include any invalid characters to be valid. If your access token is invalid, this will silently fail and return false.
isNameAvailableNoAuth(String name) Future<bool>
Essentially the same as isNameAvailable, however this function does not require any authentication. It is not exactly accurate, however can be used to determine if a name was blocked by Mojang's name filter and/or the name is used on a empty Mojang account.
ping(String serverUri, {int port = 25565, Duration timeout = const Duration(seconds: 30)}) Future<ResponsePacket?>
Ping a single server. port will default to 25565 as that is the default Minecraft server port. This method is for post 1.6 servers.
pingUri(String serverUri) Future<ResponsePacket?>
refresh(MojangAccount account) Future<MojangAccount>
Refreshes the account. The account data will be overridden with the new refreshed data. The return value is also the same account object.
reserveName(String newName, AccessToken accessToken) Future<bool>
Reserves the newName for this Mojang Account.
resetSkin(String uuid, AccessToken accessToken) Future<void>
Reset's the player's skin.
signout(String username, String password) Future<bool>
Signs the user out and invalidates the accessToken.
validate(AccessToken accessToken, {String? clientToken}) Future<bool>
Checks if given accessToken and clientToken are still valid.

Exceptions / Errors

AuthException
Thrown when invalid credentials are passed to any authentication service.
PingException
TooManyRequestsException
Thrown when the rate limit for a endpoint has been exceeded.