Documentation ¶
Index ¶
- Variables
- func LockfileFromPath(p string) (*manifest.Lockfile, error)
- func ProviderRequest(dependency *Dependency, requirements manifest.PlatformLock) *provider.Request
- type Dependency
- type DependencyList
- type Instance
- func (i *Instance) AssetsDir() string
- func (i *Instance) BuildLaunchCmd(opts *LaunchOptions) (*exec.Cmd, error)
- func (i *Instance) BuildMod() *exec.Cmd
- func (i *Instance) Clean() error
- func (i *Instance) CleanAfterExit()
- func (i *Instance) CopyLocalSaves() error
- func (i *Instance) CopyOverwrites() error
- func (i *Instance) DependenciesSynced() (bool, error)
- func (i *Instance) Desc() string
- func (i *Instance) EnsureDependencies(ctx context.Context) error
- func (i *Instance) FindMissingAssets(man *minecraft.LaunchManifest) ([]minecraft.AssetObject, error)
- func (i *Instance) FindMissingDependencies() ([]*manifest.DependencyLock, error)
- func (i *Instance) FindMissingLibraries(man *minecraft.LaunchManifest) ([]minecraft.Library, error)
- func (i *Instance) FindModJar() ([]MatchedJar, error)
- func (i *Instance) GetDependencyList() DependencyList
- func (i *Instance) GetLaunchManifest() (*minecraft.LaunchManifest, error)
- func (i *Instance) GetResolver(ctx context.Context) (*resolver.Resolver, error)
- func (i *Instance) InstancesDir() string
- func (i *Instance) JavaDir() string
- func (i *Instance) Launch(opts *LaunchOptions) error
- func (i *Instance) LaunchCmd() string
- func (i *Instance) LibrariesDir() string
- func (i *Instance) LinkDependencies() error
- func (i *Instance) LockfilePath() string
- func (i *Instance) ManifestPath() string
- func (i *Instance) McDir() string
- func (i *Instance) ModsDir() string
- func (i Instance) Outdated(ctx context.Context) ([]OutdatedResult, error)
- func (i *Instance) OverwritesDir() string
- func (i *Instance) PackageCacheDir() string
- func (i *Instance) Platform() uint8
- func (i *Instance) RequirementsSynced() (bool, error)
- func (i *Instance) SaveLockfile() error
- func (i *Instance) SaveManifest() error
- func (i *Instance) SetLaunchCredentials(creds *LaunchCredentials)
- func (i *Instance) SetLaunchManifest(m *minecraft.LaunchManifest)
- func (i *Instance) UpdateLockfileDependencies(ctx context.Context) error
- func (i *Instance) UpdateLockfileRequirements(ctx context.Context) error
- func (i *Instance) VersionsDir() string
- type LaunchCredentials
- type LaunchOptions
- type MatchedJar
- type MinecraftRelease
- type MinecraftReleaseResponse
- type OutdatedResult
Constants ¶
This section is empty.
Variables ¶
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", }, } )
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") )
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" )
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", }, } )
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 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
NewFromDir tries to detect a instance in the given directory
func NewFromWd ¶ added in v0.1.0
NewFromWd tries to detect a instance in the current working directory
func (*Instance) AssetsDir ¶
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 ¶
BuildMod uses the manifest "dev.buildCmd" script to build this package falls back to "gradle --build-cache build"
func (*Instance) CleanAfterExit ¶ added in v0.1.25
func (i *Instance) CleanAfterExit()
func (*Instance) CopyLocalSaves ¶
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 ¶
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
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) EnsureDependencies ¶
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 ¶
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 (*Instance) InstancesDir ¶
InstancesDir returns the path to the "global" instances directory
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) LibrariesDir ¶
LibrariesDir returns the path to the libraries directory contains libraries needed to load minecraft
func (*Instance) LinkDependencies ¶
LinkDependencies links or copies all missing dependencies into the mods folder
func (*Instance) LockfilePath ¶
LockfilePath is the path to the `.minepkg-lock.toml`. The file does not necessarily exist
func (*Instance) ManifestPath ¶
ManifestPath is the path to the `minepkg.toml`. The file does not necessarily exist
func (*Instance) McDir ¶
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 ¶
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 ¶
OverwritesDir is the path where overwrite files reside in. They get copied to `McDir` on launch. This is the `overwrites` subfolder
func (*Instance) PackageCacheDir ¶
PackageCacheDir returns the path to the cache directory. contains downloaded packages (mods & modpacks)
func (*Instance) RequirementsSynced ¶ added in v0.1.14
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 ¶
SaveLockfile saves the lockfile to the current directory
func (*Instance) SaveManifest ¶
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 ¶
UpdateLockfileDependencies resolves all dependencies
func (*Instance) UpdateLockfileRequirements ¶
UpdateLockfileRequirements updates the internal lockfile manifest with `VanillaLock`, `FabricLock` or `ForgeLock` containing the resolved requirements (semver requirement to actual version)
func (*Instance) VersionsDir ¶
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 }