mojango

package module
v0.0.0-...-1c3443a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 5 Imported by: 0

README

go.dev reference Go

mojango

A modern and fast Golang wrapper around the Mojang API

Installation

Use the following command to download the wrapper:

go get -u github.com/Lukaesebrot/mojango

Usage

Before you can use the wrapper, you need to create a client:

func main() {
    // Create a new mojango client
    client := mojango.New()
}

Using this client, you can now use the wrapper's functions as you like:

func main() {
    // Create a new mojango client
    client := mojango.New()
    
    // Fetch a player's UUID
    uuid, err := client.FetchUUID("ksebrt"); if err != nil {
        panic(err)
    }
    fmt.Println(uuid) // Output: 39cc0f91869a486494160d610f18b993
}

Contribution/Help

If you found a bug, have any suggestions or want to improve some code, feel free to create an issue or pull request!

Documentation

Index

Constants

View Source
const (
	StatusGreen  = "green"
	StatusYellow = "yellow"
	StatusRed    = "red"
)

These constants represent the possible states of the Mojang services

Variables

View Source
var ErrNoContent = errors.New("no Mojang API result")
View Source
var ErrTooManyRequests = errors.New("too many Mojang API requests")

Define possible known errors

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents an API client

func New

func New() *Client

New creates a new fasthttp client and wraps it into an API client

func (*Client) FetchMultipleUUIDs

func (client *Client) FetchMultipleUUIDs(usernames []string) (map[string]string, error)

FetchMultipleUUIDs fetches the UUIDs of the given usernames

func (*Client) FetchNameHistory

func (client *Client) FetchNameHistory(uuid string) ([]NameHistoryEntry, error)

FetchNameHistory fetches all names of the given UUID and their corresponding changing timestamps

func (*Client) FetchProfile

func (client *Client) FetchProfile(uuid string, unsigned bool) (*Profile, error)

FetchProfile fetches the profile of the given UUID

func (*Client) FetchStatus

func (client *Client) FetchStatus() (*Status, error)

FetchStatus fetches the states of all Mojang services and wraps them into a single object

func (*Client) FetchUUID

func (client *Client) FetchUUID(username string) (string, error)

FetchUUID fetches the current UUID of the given username

func (*Client) FetchUUIDAtTime

func (client *Client) FetchUUIDAtTime(username string, timestamp int64) (string, error)

FetchUUIDAtTime fetches the UUID of the given username at a given timestamp

type NameHistoryEntry

type NameHistoryEntry struct {
	Name        string `json:"name"`
	ChangedToAt int64  `json:"changedToAt"`
}

NameHistoryEntry represents an entry of the name history of an account

type Profile

type Profile struct {
	UUID       string            `json:"id"`
	Name       string            `json:"name"`
	Properties []ProfileProperty `json:"properties"`
}

Profile represents a whole player profile

type ProfileProperty

type ProfileProperty struct {
	Name      string `json:"name"`
	Value     string `json:"value"`
	Signature string `json:"signature"`
}

ProfileProperty represents a property of a player profile

type Status

type Status struct {
	MinecraftWebsite string
	MojangWebsite    string
	Session          string
	SessionServer    string
	AuthServer       string
	Account          string
	Textures         string
	API              string
}

Status contains all states of the Mojang services

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL