mcversion

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2022 License: MIT Imports: 8 Imported by: 0

README

mcversion

GitHub release (latest SemVer including pre-releases) Go Doc GitHub go.mod Go version GitHub Workflow Status Go ReportCard

A small golang library to access the minecraft version API.

Getting Started

Installation
go get github.com/mcversion/mcversion
Usage
package main
import (
	"fmt"
	"github.com/thelolagemann/mcversion"
)

func main() {
	version, err := mcversion.Version("1.12.2")
	if err != nil {
		panic(err)
	}
	fmt.Println(version.Name)
}

// Output: 1.12.2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ManifestVersion

type ManifestVersion struct {
	Id          string    `json:"id"`
	Type        string    `json:"type"`
	URL         string    `json:"url"`
	Time        time.Time `json:"time"`
	ReleaseTime time.Time `json:"releaseTime"`
}

ManifestVersion is a version in the manifest. In order to get the VersionInfo, which contains extended information about a specific version, call the Info method on the ManifestVersion, or alternatively call the Version method with the specified ID.

func (ManifestVersion) Info

func (m ManifestVersion) Info() (VersionInfo, error)

Info returns the VersionInfo for the calling ManifestVersion. See also: Version.

type ManifestVersionV2

type ManifestVersionV2 struct {
	ManifestVersion
	SHA1            []byte `json:"sha1"`
	ComplianceLevel int    `json:"complianceLevel"`
}

ManifestVersionV2 like ManifestVersion, with the addition of the SHA1 and ComplianceLevel fields.

type VersionInfo

type VersionInfo struct {
	Arguments struct {
		Game []interface{} `json:"game"`
		Jvm  []interface{} `json:"jvm"`
	} `json:"arguments"`
	AssetIndex struct {
		ID        string `json:"id"`
		Sha1      string `json:"sha1"`
		Size      int    `json:"size"`
		TotalSize int    `json:"totalSize"`
		URL       string `json:"url"`
	} `json:"assetIndex"`
	Assets          string `json:"assets"`
	ComplianceLevel int    `json:"complianceLevel"`
	Downloads       struct {
		Client struct {
			Sha1 string `json:"sha1"`
			Size int    `json:"size"`
			URL  string `json:"url"`
		} `json:"client"`
		ClientMappings struct {
			Sha1 string `json:"sha1"`
			Size int    `json:"size"`
			URL  string `json:"url"`
		} `json:"client_mappings"`
		Server struct {
			Sha1 string `json:"sha1"`
			Size int    `json:"size"`
			URL  string `json:"url"`
		} `json:"server"`
		ServerMappings struct {
			Sha1 string `json:"sha1"`
			Size int    `json:"size"`
			URL  string `json:"url"`
		} `json:"server_mappings"`
	} `json:"downloads"`
	ID          string `json:"id"`
	JavaVersion struct {
		Component    string `json:"component"`
		MajorVersion int    `json:"majorVersion"`
	} `json:"javaVersion"`
	Libraries []struct {
		Downloads struct {
			Artifact struct {
				Path string `json:"path"`
				Sha1 string `json:"sha1"`
				Size int    `json:"size"`
				URL  string `json:"url"`
			} `json:"artifact"`
		} `json:"downloads"`
		Name  string `json:"name"`
		Rules []struct {
			Action string `json:"action"`
			Os     struct {
				Name string `json:"name"`
			} `json:"os"`
		} `json:"rules,omitempty"`
		Natives struct {
			Osx string `json:"osx"`
		} `json:"natives,omitempty"`
		Extract struct {
			Exclude []string `json:"exclude"`
		} `json:"extract,omitempty"`
	} `json:"libraries"`
	Logging struct {
		Client struct {
			Argument string `json:"argument"`
			File     struct {
				ID   string `json:"id"`
				Sha1 string `json:"sha1"`
				Size int    `json:"size"`
				URL  string `json:"url"`
			} `json:"file"`
			Type string `json:"type"`
		} `json:"client"`
	} `json:"logging"`
	MainClass              string    `json:"mainClass"`
	MinimumLauncherVersion int       `json:"minimumLauncherVersion"`
	ReleaseTime            time.Time `json:"releaseTime"`
	Time                   time.Time `json:"time"`
	Type                   string    `json:"type"`
}

VersionInfo contains extended information about a version, not present in the VersionManifest.

func AllVersions

func AllVersions() ([]VersionInfo, error)

AllVersions returns all versions.

func LatestRelease

func LatestRelease() (VersionInfo, error)

LatestRelease returns the latest release.

func LatestSnapshot

func LatestSnapshot() (VersionInfo, error)

LatestSnapshot returns the latest snapshot.

func Version

func Version(id string) (VersionInfo, error)

Version returns a version by id.

type VersionManifest

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

VersionManifest is the manifest of all versions.

func Manifest

func Manifest() (VersionManifest, error)

Manifest returns the manifest of all versions.

func (VersionManifest) AllVersions

func (vM VersionManifest) AllVersions() ([]VersionInfo, error)

AllVersions returns all versions.

func (VersionManifest) LatestRelease

func (vM VersionManifest) LatestRelease() (VersionInfo, error)

LatestRelease returns the latest release.

func (VersionManifest) LatestSnapshot

func (vM VersionManifest) LatestSnapshot() (VersionInfo, error)

LatestSnapshot returns the latest snapshot.

func (VersionManifest) Version

func (vM VersionManifest) Version(id string) (VersionInfo, error)

Version fetches a version by id.

type VersionManifestV2

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

VersionManifestV2 like VersionManifest, but includes the SHA1, and compliance level in the Versions field.

func ManifestV2

func ManifestV2() (VersionManifestV2, error)

ManifestV2 like Manifest, but includes the SHA1, and compliance level in the fields of each ManifestVersionV2.

Jump to

Keyboard shortcuts

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