instances

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 32 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://preview.minepkg.io/docs/manifest#requirements",
		},
	}
)
View Source
var (
	// ErrLaunchNotImplemented is returned if attemting 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` beeing set
	ErrNoCredentials = errors.New("can not launch without mojang credentials")
	// ErrNoPaidAccount is returned when an instance is launched without `MojangProfile` beeing set
	ErrNoPaidAccount = errors.New("you need to buy Minecraft to launch it")
	// ErrNoVersion is returned if no mc version was detected
	ErrNoVersion = errors.New("could not detect minecraft version")
	// 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://preview.minepkg.io/docs/manifest#devjar`,
			"Make sure that your build is outputing jar files",
		},
	}
)

Functions

func LockfileFromPath added in v0.1.0

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

Types

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 redownloaded
	// 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.MinepkgAPI
	AuthCredentials *LaunchCredentials
	// 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) AreDependenciesOutdated

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

AreDependenciesOutdated 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) AreRequirementsOutdated

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

AreRequirementsOutdated 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) 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) 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) 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.Libraries, 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) 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) 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) 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) 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  string
	UUID        string
	AccessToken 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 savegame 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 determins the amount by modcount + 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

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

Jump to

Keyboard shortcuts

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