Documentation
¶
Index ¶
- type Provider
- func (p *Provider) Download(gameVersion, serverVersion, installDir string, ...) error
- func (p *Provider) DownloadContext(ctx context.Context, gameVersion, serverVersion, installDir string, ...) error
- func (p *Provider) DownloadURL(gameVersion, serverVersion string) (string, error)
- func (p *Provider) DownloadURLContext(ctx context.Context, gameVersion, serverVersion string) (string, error)
- func (p *Provider) GameVersions() ([]string, error)
- func (p *Provider) GameVersionsContext(ctx context.Context) ([]string, error)
- func (p *Provider) ServerVersions(gameVersion string) ([]string, error)
- func (p *Provider) ServerVersionsContext(ctx context.Context, gameVersion string) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
provider.BaseProvider
}
func (*Provider) Download ¶
func (p *Provider) Download(gameVersion, serverVersion, installDir string, onProgress func(current, total int64)) error
Download downloads the PurpurMC server JAR to the specified installation directory. It uses a default background context.
func (*Provider) DownloadContext ¶
func (p *Provider) DownloadContext(ctx context.Context, gameVersion, serverVersion, installDir string, onProgress func(current, total int64)) error
DownloadContext downloads the PurpurMC server JAR to the specified installation directory with context support.
Parameters:
- ctx: the context to control the download cancellation.
- gameVersion: the Minecraft version string (e.g., "1.21.11", "1.14.1").
- serverVersion: the Purpur build number.
- installDir: the directory where the server JAR will be saved.
- onProgress: a callback function to report download progress.
Returns:
- error: an error if the download fails.
func (*Provider) DownloadURL ¶
DownloadURL returns the download URL for the PurpurMC server JAR for a given game version and build number. It uses a default background context.
func (*Provider) DownloadURLContext ¶
func (p *Provider) DownloadURLContext(ctx context.Context, gameVersion, serverVersion string) (string, error)
DownloadURLContext returns the download URL for the PurpurMC server JAR for a given game version and build number with context support.
Parameters:
- ctx: the context to control the request lifetime.
- gameVersion: the Minecraft version string (e.g., "1.21.11", "1.14.1").
- serverVersion: the PurpurMC build number for the specified version.
Returns:
- string: the direct download URL for the PurpurMC server JAR file if the build exists.
- error: an error if the game version or build number is not found, or if any HTTP or JSON decoding issues occur.
func (*Provider) GameVersions ¶
GameVersions fetches the list of all Minecraft Purpur-supported game versions from the official PurpurMC API. It uses a default background context.
func (*Provider) GameVersionsContext ¶
GameVersionsContext fetches the list of all Minecraft Purpur-supported game versions from the official PurpurMC API with context support.
Parameters:
- ctx: the context to control the request lifetime.
Returns:
- []string: a slice of Minecraft versions supported by Purpur (e.g., "1.21.11", "1.14.1").
- error: an error if any HTTP or JSON decoding issues occur.
func (*Provider) ServerVersions ¶
ServerVersions fetches the list of all available PurpurMC build numbers for a given game version. It uses a default background context.
func (*Provider) ServerVersionsContext ¶
ServerVersionsContext fetches the list of all available PurpurMC build numbers for a given game version with context support.
Parameters:
- ctx: the context to control the request lifetime.
- gameVersion: the Minecraft version string (e.g., "1.21.11", "1.14.1").
Returns:
- []string: a slice of build numbers for the specified game version.
- error: an error if the game version is not supported or if any HTTP or JSON decoding issues occur.