launcher

package
v0.0.0-...-bfe662d Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountNotExist  = errors.New("no such account")
	ErrNoDefaultAccount = errors.New("no default account")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Username string          `json:"username"`
	Uuid     string          `json:"uuid"`
	Xuid     string          `json:"xuid"`
	Secrets  *AccountSecrets `json:"secrets,omitempty"`
}

func (*Account) IsOffline

func (account *Account) IsOffline() bool

type AccountConfig

type AccountConfig struct {
}

type AccountSecrets

type AccountSecrets struct {
	Scheme string          `json:"scheme"`
	Data   string          `json:"data"`
	Params json.RawMessage `json:"params,omitempty"`
}

func AccountPlain

func AccountPlain(token string) *AccountSecrets

type Auth

type Auth struct {
	Name         string
	Uuid         string
	Xuid         string
	RefreshToken string
}

type Config

type Config struct {
	DefaultAccount string `toml:"default-account"`
}

type FabricModMetadata

type FabricModMetadata struct {
	SchemaVersion int    `json:"schemaVersion"`
	ID            string `json:"id"`
	Version       string `json:"version"`
	Name          string `json:"name,omitempty"`
}

https://wiki.fabricmc.net/documentation:fabric_mod_json

func (*FabricModMetadata) ModID

func (meta *FabricModMetadata) ModID() string

func (*FabricModMetadata) ModLoader

func (meta *FabricModMetadata) ModLoader() ModLoaderType

func (*FabricModMetadata) ModVersion

func (meta *FabricModMetadata) ModVersion() string

type Instance

type Instance struct {
	Dir             string
	Config          InstanceConfig
	ManifestVersion *vanilla.Version
}

type InstanceConfig

type InstanceConfig struct {
	Version             string                       `toml:"version"`
	ModLoader           *ModLoader                   `toml:"mod-loader"`
	JavaPath            string                       `toml:"java-path"`
	JvmArgs             []string                     `toml:"jvm-args"`
	AdditionalClasspath []string                     `toml:"additional-classpath"`
	Account             string                       `toml:"account"`
	Mods                map[string]InstanceConfigMod `toml:"mods"`
}

An InstanceConfig is similar to `package.toml` in npm or `Cargo.toml` in cargo. It describes what is considered compatible with a given instance.

func (*InstanceConfig) Clone

func (config *InstanceConfig) Clone() *InstanceConfig

type InstanceConfigMod

type InstanceConfigMod struct {
	Version string `toml:"version"`
}

type InstanceLock

type InstanceLock struct {
}

An InstanceLock is similar to `package-lock.json` in npm or `Cargo.lock` in cargo. It describes a fully resolved instance and may be used to reproduce an instance from scratch.

type Launcher

type Launcher struct {
	Version     string
	HttpClient  *http.Client
	BaseDir     string
	LibraryJobs uint
	AssetJobs   uint
	Modrinth    modrinth.Client
	Offline     bool
}

func (*Launcher) AccountsDir

func (l *Launcher) AccountsDir() string

func (*Launcher) AssetsDir

func (l *Launcher) AssetsDir() string

func (*Launcher) AuthenticateAccount

func (l *Launcher) AuthenticateAccount(account *Account) (*Auth, error)

func (*Launcher) ConfigPath

func (l *Launcher) ConfigPath() string

func (*Launcher) CreateCommand

func (l *Launcher) CreateCommand(ctx context.Context, instance *Instance, auth *Auth) (*exec.Cmd, error)

func (*Launcher) CreateInstance

func (l *Launcher) CreateInstance(name string, loader string, version *vanilla.Version) (*Instance, error)

func (*Launcher) CreateInstanceEx

func (l *Launcher) CreateInstanceEx(name string, loader string, version *vanilla.Version, editConfig func(config *InstanceConfig) error) (*Instance, error)

func (*Launcher) CreateLaunch

func (l *Launcher) CreateLaunch(instance *Instance) *metadata.Launch

func (*Launcher) CreateOfflineAccount

func (l *Launcher) CreateOfflineAccount(username string) (*Account, error)

func (*Launcher) CreateOnlineAccount

func (l *Launcher) CreateOnlineAccount(auth Auth, config *AccountConfig) (*Account, error)

func (*Launcher) DeleteAccount

func (l *Launcher) DeleteAccount(name string) error

func (*Launcher) DeleteInstance

func (l *Launcher) DeleteInstance(name string) error

func (*Launcher) Download

func (l *Launcher) Download(ctx context.Context, url string, size int, wantSha1 string) (string, error)

func (*Launcher) DownloadAssets

func (l *Launcher) DownloadAssets(ctx context.Context, instance *Instance, reporter ProgressReporter) error

func (*Launcher) DownloadLibraries

func (l *Launcher) DownloadLibraries(ctx context.Context, instance *Instance, progress ProgressReporter) error

func (*Launcher) EditInstance

func (l *Launcher) EditInstance(instance *Instance, editFn func(config *InstanceConfig) error) error

func (*Launcher) ExtractNatives

func (l *Launcher) ExtractNatives(instance *Instance) error

func (*Launcher) GetAccount

func (l *Launcher) GetAccount(name string) (*Account, error)

func (*Launcher) GetAccounts

func (l *Launcher) GetAccounts() ([]*LoadAccountResult, error)

func (*Launcher) GetDefaultAccount

func (l *Launcher) GetDefaultAccount() (*Account, error)

func (*Launcher) GetInstance

func (l *Launcher) GetInstance(name string) (*Instance, error)

func (*Launcher) GetInstanceName

func (l *Launcher) GetInstanceName(instance *Instance) string

func (*Launcher) GetInstances

func (l *Launcher) GetInstances() ([]*LoadInstanceResult, error)

func (*Launcher) GetManifest

func (l *Launcher) GetManifest() (*vanilla.Manifest, error)

func (*Launcher) GetMods

func (l *Launcher) GetMods(instance *Instance, preferredLoader ModLoaderType) ([]ModMetadata, error)

func (*Launcher) GetVersion

func (l *Launcher) GetVersion(ctx context.Context, id string) (*vanilla.Version, error)

func (*Launcher) Initialize

func (l *Launcher) Initialize() error

func (*Launcher) InstancesDir

func (l *Launcher) InstancesDir() string

func (*Launcher) LibrariesDir

func (l *Launcher) LibrariesDir() string

func (*Launcher) LoadInstance

func (l *Launcher) LoadInstance(ctx context.Context, name string) (*Instance, error)

func (*Launcher) MetaDir

func (l *Launcher) MetaDir() string

func (*Launcher) Mktemp

func (l *Launcher) Mktemp(pattern string) (*os.File, string, error)

func (*Launcher) PistonMetaIndexPath

func (l *Launcher) PistonMetaIndexPath() string

func (*Launcher) PistonMetaVersionPath

func (l *Launcher) PistonMetaVersionPath(id string) string

func (*Launcher) RenameInstance

func (l *Launcher) RenameInstance(oldName string, newName string) error

func (*Launcher) StartInstance

func (l *Launcher) StartInstance(ctx context.Context, instance *Instance, auth *Auth) error

func (*Launcher) TmpDir

func (l *Launcher) TmpDir() string

func (*Launcher) UpdateManifest

func (l *Launcher) UpdateManifest(ctx context.Context) (*vanilla.Manifest, error)

type LoadAccountResult

type LoadAccountResult struct {
	Path    string
	Account Account
	Error   error
}

type LoadInstanceResult

type LoadInstanceResult struct {
	Path     string
	Instance InstanceConfig
	Error    error
}

type ModLoader

type ModLoader struct {
	Type    ModLoaderType `toml:"type"`
	Version string        `toml:"version"`
}

type ModLoaderType

type ModLoaderType string
const (
	LoaderNone   ModLoaderType = ""
	LoaderFabric ModLoaderType = "fabric"
	LoaderQuilt  ModLoaderType = "quilt"
)

func (ModLoaderType) GetMetadata

func (loader ModLoaderType) GetMetadata(root fs.FS) (ModMetadata, error)

func (*ModLoaderType) MarshalText

func (loader *ModLoaderType) MarshalText() ([]byte, error)

func (*ModLoaderType) UnmarshalText

func (loader *ModLoaderType) UnmarshalText(text []byte) error

type ModMetadata

type ModMetadata interface {
	ModLoader() ModLoaderType
	ModID() string
	ModVersion() string
}

type NopReporter

type NopReporter struct{}

func (NopReporter) End

func (NopReporter) End()

func (NopReporter) Increment

func (NopReporter) Increment()

func (NopReporter) Start

func (NopReporter) Start(string, int)

type ProgressReporter

type ProgressReporter interface {
	Start(stage string, max int)
	Increment()
	End()
}

type QuiltModMetadata

type QuiltModMetadata struct {
	SchemaVersion int `json:"schema_version"`
	QuiltLoader   struct {
		Group   string `json:"group"`
		ID      string `json:"id"`
		Version string `json:"version"`
	} `json:"quilt_loader"`
}

https://wiki.quiltmc.org/en/introduction/setting-up#making-the-mod-yours

func (*QuiltModMetadata) ModId

func (meta *QuiltModMetadata) ModId() string

func (*QuiltModMetadata) ModLoader

func (meta *QuiltModMetadata) ModLoader() ModLoaderType

func (*QuiltModMetadata) ModVersion

func (meta *QuiltModMetadata) ModVersion() string

Jump to

Keyboard shortcuts

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