provider

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileProvider is an update provider that simply downloads a given file.
	FileProvider = "FILE"

	// PaperProvider is an update provider that downloads the server jar from PaperMC.
	PaperProvider = "PAPER"
)

Variables

View Source
var ErrAlreadyUpToDate = errors.New("paper version is already at the latest build")

ErrAErrAlreadyUpToDate is an error returned when the server is already at the latest build for the given version.

Functions

func DownloadFile

func DownloadFile(url string, filepath string) error

DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.

func Verify

func Verify(path string, expected string) error

Verify makes sure that the downloaded file's hash matches what the expected hash is. The hasing function used is `sha256`.

Types

type File

type File struct {
	URL string
}

File is an update provider that downloads a new server version from a given URL.

func (File) Download

func (f File) Download(path string) error

Download downloads a file from a given URL.

type Paper

type Paper struct {
	Version string
}

Paper is an update provider that downloads a new Paper server version.

func (Paper) Download

func (p Paper) Download(filepath string) error

Download gets the latest build of Paper from their website for the given Minecraft version.

type PaperApplication

type PaperApplication struct {
	Name string `json:"name"`
	Hash string `json:"sha256"`
}

PaperApplication holds the name and hash of a file for a Paper build.

type PaperBuild

type PaperBuild struct {
	Build    int           `json:"build"`
	Download PaperDownload `json:"downloads"`
	Version  string        `json:"version"`
}

PaperBuild holds the API response data for a particular Paper build.

func Load added in v1.3.0

func Load(path string) (*PaperBuild, error)

Load reads saved version information from a file. If the file does not exist, this function returns an empty struct and no error.

func (PaperBuild) Save added in v1.3.0

func (p PaperBuild) Save(path string) error

Save write a Paper build to a file on disk.

type PaperBuilds

type PaperBuilds struct {
	Builds []int `json:"builds"`
}

PaperBuilds is the representation of the Paper API response for a version.

type PaperDownload

type PaperDownload struct {
	Application PaperApplication `json:"application"`
}

PaperDownload contains information about a build's file.

type PaperVersions

type PaperVersions struct {
	VersionGroups []string `json:"version_groups"`
	Versions      []string `json:"versions"`
}

PaperVersions is the representation of all Paper versions returned by the API.

type Provider

type Provider interface {
	Download(string) error
}

Provider is an interface for a Minecraft server jar provider, such as PaperMC.

func MatchProvider

func MatchProvider(args []string) (prov Provider)

MatchProvider creates and returns a provider for the given command arguments.

Jump to

Keyboard shortcuts

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