mojang

package
v0.0.0-...-ad31fdb Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApiMojangDotComAddr = "https://api.mojang.com"
View Source
var HttpClient = &http.Client{
	Timeout: 10 * time.Second,
	Transport: &http.Transport{
		MaxIdleConnsPerHost: 1024,
	},
}
View Source
var SessionServerMojangComAddr = "https://sessionserver.mojang.com"

Functions

func EncodeTextures

func EncodeTextures(textures *TexturesProp) string

Types

type BadRequestError

type BadRequestError struct {
	ResponseError
	ErrorType string
	Message   string
}

When passed request params are invalid, Mojang returns 400 Bad Request error

func (*BadRequestError) Error

func (e *BadRequestError) Error() string

func (*BadRequestError) IsMojangError

func (*BadRequestError) IsMojangError() bool

type CapeTexturesResponse

type CapeTexturesResponse struct {
	Url string `json:"url"`
}

type EmptyResponse

type EmptyResponse struct {
}

Mojang API doesn't return a 404 Not Found error for non-existent data identifiers Instead, they return 204 with an empty body

func (*EmptyResponse) Error

func (*EmptyResponse) Error() string

func (*EmptyResponse) IsMojangError

func (*EmptyResponse) IsMojangError() bool

type ForbiddenError

type ForbiddenError struct {
	ResponseError
}

When Mojang decides you're such a bad guy, this error appears (even if the request has no authorization)

func (*ForbiddenError) Error

func (*ForbiddenError) Error() string

type ProfileInfo

type ProfileInfo struct {
	Id       string `json:"id"`
	Name     string `json:"name"`
	IsLegacy bool   `json:"legacy,omitempty"`
	IsDemo   bool   `json:"demo,omitempty"`
}

func UsernamesToUuids

func UsernamesToUuids(usernames []string) ([]*ProfileInfo, error)

Exchanges usernames array to array of uuids See https://wiki.vg/Mojang_API#Playernames_-.3E_UUIDs

type Property

type Property struct {
	Name      string `json:"name"`
	Signature string `json:"signature,omitempty"`
	Value     string `json:"value"`
}

type ResponseError

type ResponseError interface {
	IsMojangError() bool
}

type ServerError

type ServerError struct {
	ResponseError
	Status int
}

ServerError happens when Mojang's API returns any response with 50* status

func (*ServerError) Error

func (e *ServerError) Error() string

func (*ServerError) IsMojangError

func (*ServerError) IsMojangError() bool

type SignedTexturesResponse

type SignedTexturesResponse struct {
	Id    string      `json:"id"`
	Name  string      `json:"name"`
	Props []*Property `json:"properties"`
	// contains filtered or unexported fields
}

func UuidToTextures

func UuidToTextures(uuid string, signed bool) (*SignedTexturesResponse, error)

Obtains textures information for provided uuid See https://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape

func (*SignedTexturesResponse) DecodeTextures

func (t *SignedTexturesResponse) DecodeTextures() (*TexturesProp, error)

type SkinTexturesMetadata

type SkinTexturesMetadata struct {
	Model string `json:"model"`
}

type SkinTexturesResponse

type SkinTexturesResponse struct {
	Url      string                `json:"url"`
	Metadata *SkinTexturesMetadata `json:"metadata,omitempty"`
}

type TexturesProp

type TexturesProp struct {
	Timestamp   int64             `json:"timestamp"`
	ProfileID   string            `json:"profileId"`
	ProfileName string            `json:"profileName"`
	Textures    *TexturesResponse `json:"textures"`
}

func DecodeTextures

func DecodeTextures(encodedTextures string) (*TexturesProp, error)

type TexturesResponse

type TexturesResponse struct {
	Skin *SkinTexturesResponse `json:"SKIN,omitempty"`
	Cape *CapeTexturesResponse `json:"CAPE,omitempty"`
}

type TooManyRequestsError

type TooManyRequestsError struct {
	ResponseError
}

When you exceed the set limit of requests, this error will be returned

func (*TooManyRequestsError) Error

func (*TooManyRequestsError) Error() string

func (*TooManyRequestsError) IsMojangError

func (*TooManyRequestsError) IsMojangError() bool

Jump to

Keyboard shortcuts

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