Phpcraft
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Phpcraft\Account Class Reference

Public Member Functions

 __construct (string $username)
 
 loginUsingProfiles ()
 
 isOnline ()
 

Static Public Member Functions

static cliLogin ()
 
static online (string $name, string $password)
 
static getAccountIdFromProfileName (string $profile_name)
 
static validateUsername (string $username)
 

Public Attributes

 $username
 
 $profileId = null
 
 $accessToken = null
 

Static Public Attributes

static $allowed_username_characters = []
 

Detailed Description

A Mojang or Minecraft account.

Constructor & Destructor Documentation

◆ __construct()

Phpcraft\Account::__construct ( string  $username)

Contructs an Account for "offline mode" usage. For online usage, use Account::online or Account::cliLogin. Okay, I lied, if you call Account::loginUsingProfiles you might be able to convert such an instance into one for "online mode" usage.

Parameters
string$usernameThe in-game name.

Member Function Documentation

◆ cliLogin()

static Phpcraft\Account::cliLogin ( )
static

Asks the user of the CLI application for a logged-in Account for "online mode" usage using \Asyncore\stdin.

Returns
Account

◆ getAccountIdFromProfileName()

static Phpcraft\Account::getAccountIdFromProfileName ( string  $profile_name)
static
Parameters
string$profile_name
Returns
string|null

◆ isOnline()

Phpcraft\Account::isOnline ( )

Returns whether this account can be used to join servers in online mode.

Returns
boolean

◆ loginUsingProfiles()

Phpcraft\Account::loginUsingProfiles ( )

Attempts to turns an "offline mode" instance into an "online mode" instance using .minecraft/launcher_profiles.json.

Returns
boolean Whether it was successful.

◆ online()

static Phpcraft\Account::online ( string  $name,
string  $password 
)
static

Creates a logged-in Account instance for "online mode" usage.

Parameters
string$nameThe Mojang account email address or in-game name if unmigrated.
string$passwordThe account's password.
Returns
Account|null

◆ validateUsername()

static Phpcraft\Account::validateUsername ( string  $username)
static

Returns true if the given username is valid.

Parameters
string$username
Returns
bool

Member Data Documentation

◆ $accessToken

string null Phpcraft\Account::$accessToken = null

The access token for the account or null if offline.

◆ $allowed_username_characters

Phpcraft\Account::$allowed_username_characters = []
static

◆ $profileId

string null Phpcraft\Account::$profileId = null

The selected profile ID or null if offline.

◆ $username

string Phpcraft\Account::$username

The in-game name.