gomine

package module
v0.0.0-...-9b9f7b4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2018 License: MIT Imports: 20 Imported by: 0

README

gomine

Minecraft launcher framework for Golang. Experimental!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncompatibleFormat = errors.New("ReadVersionJSON: JSON format version is higher than supported by library")
View Source
var ErrInvalidFormat = errors.New("ReadVersionJSON: passed JSON object doesn't matches expected schema")

Functions

func EvaluateRules

func EvaluateRules(rules []Rule, profile *Profile) bool

func OsVersion

func OsVersion() (string, error)

Types

type Argument

type Argument struct {
	Value string `json:"value"`
	Rules []Rule `json:"rules"`
}

type Artifact

type Artifact struct {
	SHA1 string `json:"sha1"`
	Size uint64 `json:"size"`
	URL  string `json:"url"`
}

func (*Artifact) Download

func (a *Artifact) Download(targetPath string) error

type Asset

type Asset struct {
	Hash string `json:"hash"`
	Size uint64 `json:"size"`
}

func (*Asset) Download

func (a *Asset) Download(objectsDir string) error

type AssetIndex

type AssetIndex struct {
	ID        string `json:"id"`
	TotalSize uint64 `json:"totalSize"`
	Artifact
}

type AssetIndexContents

type AssetIndexContents struct {
	Objects map[string]Asset `json:"objects"`
}

type AuthData

type AuthData struct {
	UserType   string
	PlayerName string
	UUID       string
	Token      string
}

type AuthProvider

type AuthProvider interface {
	// Login initiates new session using specified credentials.
	Login(user, pass string) (AuthData, error)

	// Refresh updates login information in passed structure to keep user logged in.
	// Old information is no longer usable.
	Refresh(ad *AuthData) error

	// Validate checks whether information in AuthData structure is still usable.
	Validate(ad AuthData) (bool, error)

	// Invalidate terminates session.
	Invalidate(ad AuthData)
}

type Lib

type Lib struct {
	Downloads struct {
		MainJar        *Artifact `json:"artifact"`
		LibClassifiers `json:"classifiers"`
	} `json:"downloads"`
	NativeSuffixes struct {
		Linux   string `json:"linux"`
		MacOS   string `json:"osx"`
		Windows string `json:"windows"`
	} `json:"natives"`
	Name         string `json:"name"`
	Rules        []Rule `json:"rules"`
	ExtractRules struct {
		Exclude []string `json:"exclude"`
	} `json:"extract"`
}

func (*Lib) ExtractNative

func (l *Lib) ExtractNative(libDir, nativeDir string) error

func (*Lib) Native

func (l *Lib) Native() *Artifact

func (*Lib) NativeSavePath

func (l *Lib) NativeSavePath() (string, error)

NativeSavePath returns FS path where library's "native" component should be stored when downloaded (path is relative to libraries directory root).

If library have no native component - empty string is returned.

func (*Lib) SavePath

func (l *Lib) SavePath() (string, error)

SavePath returns FS path where library should be stored when downloaded (path is relative to libraries directory root).

func (*Lib) ShouldUse

func (l *Lib) ShouldUse() bool

func (*Lib) SplitName

func (l *Lib) SplitName() (pkg, name, version string, err error)

type LibClassifiers

type LibClassifiers struct {
	JavaDoc      *Artifact `json:"javadoc"`
	NativesLinux *Artifact `json:"natives-linux"`
	NativesMacOS *Artifact `json:"natives-osx"`
	NativesWin   *Artifact `json:"natives-windows"`
	Sources      *Artifact `json:"sources"`
}

type LogCfg

type LogCfg struct {
	JVMArg string
	Type   string
	File   Artifact `json:"file"`
}

TODO

type MojangAuth

type MojangAuth struct {
	// ClientID must be set to persistent value unique for this client.
	// Changing ClientID will make all old sessions unusable.
	ClientID string

	// URL that will be prepended ot each API endpoint path.
	// Defaults to https://authserver.mojang.com.
	AuthURL string
}

MojangAuth implements AuthProvider using "Yggdrasil" authentication scheme.

func (MojangAuth) Invalidate

func (ma MojangAuth) Invalidate(ad AuthData) error

func (MojangAuth) Login

func (ma MojangAuth) Login(user, pass string) (AuthData, error)

func (MojangAuth) Refresh

func (ma MojangAuth) Refresh(ad *AuthData) error

func (MojangAuth) Validate

func (ma MojangAuth) Validate(ad AuthData) (bool, error)

type Profile

type Profile struct {
	VersionID      string
	GameDir        string
	JVMPath        string
	HeapMaxMB      int
	CustomJVMArgs  string
	CustomGameArgs string

	ResolutionWidth, ResolutionHeight int
}

type Root

type Root struct {
	LauncherDir string
	AuthData    AuthData

	LatestRelease  string
	LatestSnapshot string
	// contains filtered or unexported fields
}

func UseRoot

func UseRoot(path string) Root

func (*Root) AssetsDir

func (r *Root) AssetsDir() string

func (*Root) GetVersion

func (r *Root) GetVersion(id string) (*Version, error)

func (*Root) LibrariesDir

func (r *Root) LibrariesDir() string

func (*Root) RemoteVersions

func (r *Root) RemoteVersions() (*VersionManifest, error)

func (*Root) RunVersion

func (r *Root) RunVersion(ver *Version, prof *Profile, logRedirect io.Writer) error

func (*Root) UpdateVersion

func (r *Root) UpdateVersion(ver *Version) error

func (*Root) Versions

func (r *Root) Versions() (map[string]VersionMeta, error)

func (*Root) VersionsDir

func (r *Root) VersionsDir() string

type Rule

type Rule struct {
	Action RuleAct `json:"action" mapstructure:"action"`
	// OS information. All fields are regexes.
	OS struct {
		Name    string `json:"name" mapstructure:"name"`
		Version string `json:"version" mapstructure:"version"`
		Arch    string `json:"arch" mapstructure:"arch"`
	} `json:"os" mapstructure:"os"`
	Features struct {
		IsDemoUser          *bool `json:"is_demo_user" mapstructure:"is_demo_user"`
		HasCustomResolution *bool `json:"has_custom_resolution" mapstructure:"has_custom_resolution"`
	} `json:"features" mapstructure:"features"`
}

func (Rule) Applies

func (r Rule) Applies(prof *Profile) bool

type RuleAct

type RuleAct string
const (
	ActAllow    RuleAct = "allow"
	ActDisallow RuleAct = "disallow"
)

type Version

type Version struct {
	AssetIndex AssetIndex `json:"assetIndex"`
	Downloads  struct {
		Client Artifact `json:"client"`
		Server Artifact `json:"server"`
	} `json:"downloads"`
	ID        string `json:"id"`
	Libraries []Lib  `json:"libraries"`
	//ClientLog LogCfg
	MainClass string `json:"mainClass"`
	GameArgs  []Argument
	JVMArgs   []Argument
	Type      string `json:"type"`
}

func ReadVersionJSON

func ReadVersionJSON(in []byte) (*Version, error)

func (*Version) BuildClassPath

func (v *Version) BuildClassPath(versionDir, libsDir string) (string, error)

func (*Version) BuildCommandLine

func (v *Version) BuildCommandLine(prof Profile, authData AuthData, versionsDir, libsDir, nativesDir, assetsDir string) (bin string, args []string, err error)

func (*Version) DownloadAssets

func (v *Version) DownloadAssets(assetsDir string) error

func (*Version) DownloadAssetsIndex

func (v *Version) DownloadAssetsIndex(assetsDir string) error

func (*Version) DownloadClient

func (v *Version) DownloadClient(versionsDir string) error

func (*Version) DownloadLibraries

func (v *Version) DownloadLibraries(libDir string) error

func (*Version) ExtractNatives

func (v *Version) ExtractNatives(libDir, nativeDir string) error

type VersionManifest

type VersionManifest struct {
	Latest struct {
		Release  string `json:"release"`
		Snapshot string `json:"snapshot"`
	} `json:"latest"`
	Versions []VersionMeta `json:"versions"`
}

type VersionMeta

type VersionMeta struct {
	ID   string `json:"id"`
	Type string `json:"type"`
	URL  string `json:"url"`

	Installed bool
}

Jump to

Keyboard shortcuts

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