instances

package
v0.1.28 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PlatformVanilla is a vanilla minecraft instance
	PlatformVanilla uint8 = 1
	// PlatformFabric is a fabric minecraft instance
	PlatformFabric uint8 = 2
	// PlatformForge is forge minecraft instance
	PlatformForge uint8 = 3

	// ErrNoInstance is returned if no mc instance was found
	ErrNoInstance = &commands.CliError{
		Text: "no minepkg.toml file was found in this directory",
		Suggestions: []string{
			fmt.Sprintf("Create it with %s", gchalk.Bold("minepkg init")),
			"Move into a folder containing a minepkg.toml file",
		},
	}
	// ErrMissingRequirementMinecraft is returned if requirements.minecraft is not set
	ErrMissingRequirementMinecraft = &commands.CliError{
		Text: "the manifest is missing the required requirements.minecraft field",
		Suggestions: []string{
			"Add the field as documented here https://minepkg.io/docs/manifest#requirements",
		},
	}
)
View Source
var (
	// ErrLaunchNotImplemented is returned if attempting to start a non vanilla instance
	ErrLaunchNotImplemented = errors.New("can only launch vanilla & fabric instances (for now)")
	// ErrNoCredentials is returned when an instance is launched without `MojangProfile` being set
	ErrNoCredentials = errors.New("can not launch without mojang credentials")
	// ErrNoPaidAccount is returned when an instance is launched without `MojangProfile` being set
	ErrNoPaidAccount = errors.New("you need to buy Minecraft to launch it")
	// ErrInvalidVersion is returned if no mc version was detected
	ErrInvalidVersion = errors.New("supplied version could not be found")
	// ErrNoJava is returned if no java runtime is available to launch
	ErrNoJava = errors.New("no java runtime set to launch instance")
)
View Source
var (
	// TypeSnapshot is a snapshot release
	TypeSnapshot = "snapshot"
	// TypeRelease is a full "normal" release
	TypeRelease = "release"
	// TypeOldBeta is a "old_beta" release
	TypeOldBeta = "old_beta"
	// TypeOldAlpha is a "old_alpha" release
	TypeOldAlpha = "old_alpha"
)
View Source
var (
	// ErrNoFabricLoader is returned if the wanted fabric version was not found
	ErrNoFabricLoader = &commands.CliError{
		Text: "Could not find fabric loader for wanted Minecraft version",
		Suggestions: []string{
			"Check if fabric is compatible with the Minecraft version in your minepkg.toml",
			"Check your requirements.fabric field",
			"Try again later",
		},
	}
	// ErrNoFabricMapping is returned if the wanted fabric mapping was not found
	ErrNoFabricMapping = &commands.CliError{
		Text: "Could not find fabric mapping for wanted Minecraft version",
		Suggestions: []string{
			"Check if fabric is compatible with the Minecraft version in your minepkg.toml",
			"Check your requirements.fabric field",
			"Try again later",
		},
	}
)
View Source
var (
	ErrNoBuildFiles = &commands.CliError{
		Text: "no jar files found",
		Suggestions: []string{
			`Set the "dev.jar" field in your minepkg.toml`,
			`Checkout https://minepkg.io/docs/manifest#devjar`,
			"Make sure that your build is outputting jar files",
		},
	}
)

Functions

func LockfileFromPath added in v0.1.0

func LockfileFromPath(p string) (*manifest.Lockfile, error)

func ProviderRequest added in v0.1.13

func ProviderRequest(dependency *Dependency, requirements manifest.PlatformLock) *provider.Request

Types

type Dependency added in v0.1.13

type Dependency struct {
	Lock *manifest.DependencyLock
	ID   *pkgid.ID
	// contains filtered or unexported fields
}

func (Dependency) InSync added in v0.1.14

func (d Dependency) InSync() bool

func (Dependency) Name added in v0.1.13

func (d Dependency) Name() string

func (*Dependency) ProviderRequest added in v0.1.14

func (d *Dependency) ProviderRequest() *provider.Request

type DependencyList added in v0.1.13

type DependencyList []Dependency

func (DependencyList) Sorted added in v0.1.13

func (d DependencyList) Sorted() DependencyList

Sorted returns a list of all dependencies sorted by the name

type Instance

type Instance struct {
	// GlobalDir contains persistent instance data
	// on linux this usually is $HOME/.config/minepkg
	GlobalDir string
	// CacheDir is similar to cache dir but only contains data that can easily be re-downloaded
	// like java binaries, libraries, assets, versions & mod cache
	// on linux this usually is $HOME/.cache/minepkg
	CacheDir string
	// Directory is the path of this instance. defaults to current working directory
	Directory       string
	Manifest        *manifest.Manifest
	Lockfile        *manifest.Lockfile
	MinepkgAPI      *api.MinepkgClient
	AuthCredentials *LaunchCredentials
	ProviderStore   *provider.Store
	// contains filtered or unexported fields
}

Instance describes a locally installed minecraft instance

func New added in v0.1.0

func New() *Instance

New returns a new instance with the default settings panics if user config or cache directory can not be determined

func NewFromDir added in v0.1.0

func NewFromDir(dir string) (*Instance, error)

NewFromDir tries to detect a instance in the given directory

func NewFromWd added in v0.1.0

func NewFromWd() (*Instance, error)

NewFromWd tries to detect a instance in the current working directory

func (*Instance) AssetsDir

func (i *Instance) AssetsDir() string

AssetsDir returns the path to the assets directory it contains some shared Minecraft resources like sounds & some textures

func (*Instance) BuildLaunchCmd

func (i *Instance) BuildLaunchCmd(opts *LaunchOptions) (*exec.Cmd, error)

BuildLaunchCmd returns a go cmd ready to start minecraft

func (*Instance) BuildMod

func (i *Instance) BuildMod() *exec.Cmd

BuildMod uses the manifest "dev.buildCmd" script to build this package falls back to "gradle --build-cache build"

func (*Instance) Clean added in v0.1.10

func (i *Instance) Clean() error

func (*Instance) CleanAfterExit added in v0.1.25

func (i *Instance) CleanAfterExit()

func (*Instance) CopyLocalSaves

func (i *Instance) CopyLocalSaves() error

CopyLocalSaves copies saves from the instance dir to the minecraft dir this should run BEFORE `Instance.LinkDependencies` because local saves should always have the highest priority

func (*Instance) CopyOverwrites

func (i *Instance) CopyOverwrites() error

CopyOverwrites copies everything from the instance dir (with a few exceptions) to the minecraft dir exceptions are: the minecraft folder itself and minepkg related files (manifest & lockfile)

func (*Instance) DependenciesSynced added in v0.1.14

func (i *Instance) DependenciesSynced() (bool, error)

DependenciesSynced returns true if the dependencies of this instance do not match what is currently set in the lockfile. Dependencies should be updated with "UpdateLockfileDependencies" in most cases if this is true

func (*Instance) Desc

func (i *Instance) Desc() string

Desc returns a one-liner summary of this instance

func (*Instance) EnsureDependencies

func (i *Instance) EnsureDependencies(ctx context.Context) error

EnsureDependencies downloads missing dependencies

func (*Instance) FindMissingAssets

func (i *Instance) FindMissingAssets(man *minecraft.LaunchManifest) ([]minecraft.AssetObject, error)

FindMissingAssets returns all missing assets

func (*Instance) FindMissingDependencies

func (i *Instance) FindMissingDependencies() ([]*manifest.DependencyLock, error)

FindMissingDependencies returns all dependencies that are not present

func (*Instance) FindMissingLibraries

func (i *Instance) FindMissingLibraries(man *minecraft.LaunchManifest) ([]minecraft.Library, error)

FindMissingLibraries returns all missing assets

func (*Instance) FindModJar

func (i *Instance) FindModJar() ([]MatchedJar, error)

FindModJar tries to find the right built mod jar

func (*Instance) GetDependencyList added in v0.1.13

func (i *Instance) GetDependencyList() DependencyList

GetDependencyList returns a list of all dependencies of the instance

func (*Instance) GetLaunchManifest

func (i *Instance) GetLaunchManifest() (*minecraft.LaunchManifest, error)

GetLaunchManifest returns the merged manifest for the instance

func (*Instance) GetResolver added in v0.0.63

func (i *Instance) GetResolver(ctx context.Context) (*resolver.Resolver, error)

func (*Instance) InstancesDir

func (i *Instance) InstancesDir() string

InstancesDir returns the path to the "global" instances directory

func (*Instance) JavaDir

func (i *Instance) JavaDir() string

JavaDir returns the path for local java binaries

func (*Instance) Launch

func (i *Instance) Launch(opts *LaunchOptions) error

Launch will launch the minecraft instance prefer BuildLaunchCmd if you need more control over the process

func (*Instance) LaunchCmd

func (i *Instance) LaunchCmd() string

LaunchCmd returns the cmd used to launch minecraft (if started)

func (*Instance) LibrariesDir

func (i *Instance) LibrariesDir() string

LibrariesDir returns the path to the libraries directory contains libraries needed to load minecraft

func (*Instance) LinkDependencies

func (i *Instance) LinkDependencies() error

LinkDependencies links or copies all missing dependencies into the mods folder

func (*Instance) LockfilePath

func (i *Instance) LockfilePath() string

LockfilePath is the path to the `.minepkg-lock.toml`. The file does not necessarily exist

func (*Instance) ManifestPath

func (i *Instance) ManifestPath() string

ManifestPath is the path to the `minepkg.toml`. The file does not necessarily exist

func (*Instance) McDir

func (i *Instance) McDir() string

McDir is the path where the actual Minecraft instance is living. This is the `minecraft` subfolder this folder contains saves, configs & mods that should be loaded

func (*Instance) ModsDir

func (i *Instance) ModsDir() string

ModsDir is the path where the mods get linked to. This is the `minecraft/mods` subfolder

func (Instance) Outdated added in v0.1.14

func (i Instance) Outdated(ctx context.Context) ([]OutdatedResult, error)

func (*Instance) OverwritesDir

func (i *Instance) OverwritesDir() string

OverwritesDir is the path where overwrite files reside in. They get copied to `McDir` on launch. This is the `overwrites` subfolder

func (*Instance) PackageCacheDir

func (i *Instance) PackageCacheDir() string

PackageCacheDir returns the path to the cache directory. contains downloaded packages (mods & modpacks)

func (*Instance) Platform

func (i *Instance) Platform() uint8

Platform returns the type of loader required to start this instance

func (*Instance) RequirementsSynced added in v0.1.14

func (i *Instance) RequirementsSynced() (bool, error)

RequirementsSynced returns true if the requirements of this instance do not match what is currently set in the lockfile. Requirements should be updated with "UpdateLockfileRequirements" in most cases if this is true

func (*Instance) SaveLockfile

func (i *Instance) SaveLockfile() error

SaveLockfile saves the lockfile to the current directory

func (*Instance) SaveManifest

func (i *Instance) SaveManifest() error

SaveManifest saves the manifest to the current directory

func (*Instance) SetLaunchCredentials added in v0.1.5

func (i *Instance) SetLaunchCredentials(creds *LaunchCredentials)

func (*Instance) SetLaunchManifest added in v0.1.23

func (i *Instance) SetLaunchManifest(m *minecraft.LaunchManifest)

SetLaunchManifest sets the launch manifest for the instance

func (*Instance) UpdateLockfileDependencies

func (i *Instance) UpdateLockfileDependencies(ctx context.Context) error

UpdateLockfileDependencies resolves all dependencies

func (*Instance) UpdateLockfileRequirements

func (i *Instance) UpdateLockfileRequirements(ctx context.Context) error

UpdateLockfileRequirements updates the internal lockfile manifest with `VanillaLock`, `FabricLock` or `ForgeLock` containing the resolved requirements (semver requirement to actual version)

func (*Instance) VersionsDir

func (i *Instance) VersionsDir() string

VersionsDir returns the path to the versions directory

type LaunchCredentials added in v0.1.5

type LaunchCredentials struct {
	// PlayerName is the name that the player has chosen (appears in the game)
	PlayerName string
	// UUID is the player's UUID (strictly required)
	UUID string
	// AccessToken is the mojang api access token (strictly required)
	AccessToken string

	// UserType show if the account is a Mojang account or a Microsoft account
	// allowed values: "mojang" or "msa" (typically "msa" these days)
	UserType string
	// XUID is the player's XUID (for Xbox Live accounts) – kinda optional
	XUID string
	// ClientID is the oauth id that was used to authenticate the player (for Xbox Live accounts) – kinda optional
	ClientID string
}

type LaunchOptions

type LaunchOptions struct {
	LaunchManifest *minecraft.LaunchManifest
	Stdout         io.Writer
	Stderr         io.Writer
	// Offline is not implemented
	Offline bool
	Java    string
	Server  bool
	// Demo launches the client in demo mode. should have no effect on a server
	Demo bool
	// JoinServer can be a server address to join after startup
	JoinServer string
	// StartSave can be a save game name to start after startup
	StartSave string
	Debug     bool
	// RamMiB can be set to the amount of ram in MiB to start Minecraft with
	// 0 determines the amount by mod count + available system ram
	RamMiB int
	// Environment variables to set
	Env []string
}

LaunchOptions are options for launching

type MatchedJar added in v0.0.62

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

func (*MatchedJar) Name added in v0.0.62

func (m *MatchedJar) Name() string

Name returns just the name of the jar eg "my-jar.jar"

func (*MatchedJar) Path added in v0.0.62

func (m *MatchedJar) Path() string

Path returns the full path to the jar file

func (MatchedJar) String added in v0.1.28

func (m MatchedJar) String() string

type MinecraftRelease

type MinecraftRelease struct {
	ID          string `json:"id"`
	Type        string `json:"type"`
	URL         string `json:"url"`
	Time        string `json:"time"`
	ReleaseTime string `json:"releaseTime"`
}

MinecraftRelease is a released minecraft version

type MinecraftReleaseResponse

type MinecraftReleaseResponse struct {
	Latest struct {
		Release  string `json:"release"`
		Snapshot string `json:"snapshot"`
	} `json:"latest"`
	Versions []MinecraftRelease
}

MinecraftReleaseResponse is the response from the "launchermeta" mojang api

func GetMinecraftReleases

func GetMinecraftReleases(ctx context.Context) (*MinecraftReleaseResponse, error)

GetMinecraftReleases returns all available Minecraft releases

type OutdatedResult added in v0.1.14

type OutdatedResult struct {
	Dependency Dependency
	Result     provider.Result
	Error      error
}

Jump to

Keyboard shortcuts

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