forge

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider struct {
	provider.BaseProvider
}

func New

func New() *Provider

func (*Provider) Download

func (p *Provider) Download(gameVersion, serverVersion, installDir string, onProgress func(current, total int64)) error

Download downloads the Forge server files to the specified installation directory. It uses a default background context.

func (*Provider) DownloadContext added in v2.1.0

func (p *Provider) DownloadContext(ctx context.Context, gameVersion, serverVersion, installDir string, onProgress func(current, total int64)) error

DownloadContext downloads the Forge server files to the specified installation directory with context support. It handles both standard installer JARs and legacy zip patches (which require merging with a vanilla server JAR).

Parameters:

  • ctx: the context to control the download cancellation.
  • gameVersion: the Minecraft version string (e.g., "1.21.6", "1.7.10-pre4", "1.4").
  • serverVersion: the Forge loader version.
  • installDir: the directory where the server files will be saved.
  • onProgress: a callback function to report download progress.

Returns:

  • error: an error if the download or patching (for legacy versions) fails.

func (*Provider) DownloadURL

func (p *Provider) DownloadURL(gameVersion, serverVersion string) (string, error)

DownloadURL returns the download URL for the Forge server file for a given game version and loader version. It uses a default background context.

func (*Provider) DownloadURLContext added in v2.1.0

func (p *Provider) DownloadURLContext(ctx context.Context, gameVersion, serverVersion string) (string, error)

DownloadURLContext returns the download URL for the Forge server file for a given game version and loader version with context support. It determines the correct URL format based on the game version.

Parameters:

  • ctx: the context to control the request lifetime.
  • gameVersion: the Minecraft version string (e.g., "1.21.6", "1.7.10-pre4", "1.4").
  • serverVersion: the Forge loader version string (e.g., "14.23.4.2720").

Returns:

  • string: the direct download URL for the Forge server installer/archive file if the versions exist.
  • error: an error if the game version or loader version is not found, or if any HTTP or JSON decoding issues occur.

func (*Provider) GameVersions

func (p *Provider) GameVersions() ([]string, error)

GameVersions fetches the list of all Minecraft Forge-supported game versions from the official Forge maven metadata. It uses a default background context.

func (*Provider) GameVersionsContext added in v2.1.0

func (p *Provider) GameVersionsContext(ctx context.Context) ([]string, error)

GameVersionsContext fetches the list of all Minecraft Forge-supported game versions from the official Forge maven metadata with context support.

Parameters:

  • ctx: the context to control the request lifetime.

Returns:

  • []string: a slice of Minecraft versions supported by Forge (e.g., "1.21.6", "1.7.10-pre4", "1.4").
  • error: an error if any HTTP or JSON decoding issues occur.

func (*Provider) ServerVersions

func (p *Provider) ServerVersions(gameVersion string) ([]string, error)

ServerVersions fetches a list of available Forge loader versions for a given Minecraft version. It uses a default background context.

func (*Provider) ServerVersionsContext added in v2.1.0

func (p *Provider) ServerVersionsContext(ctx context.Context, gameVersion string) ([]string, error)

ServerVersionsContext fetches a list of available Forge loader versions for a given Minecraft version with context support. It retrieves the data from the official Forge maven metadata.

Parameters:

  • ctx: the context to control the request lifetime.
  • gameVersion: the Minecraft version string (e.g., "1.21.6", "1.7.10-pre4", "1.4").

Returns:

  • []string: a slice of Forge loader versions (e.g., "56.0.3", "14.23.4.2720").
  • error: an error if the game version is not supported or if any HTTP or JSON decoding issues occur.

Jump to

Keyboard shortcuts

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