provider

package
v2.0.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseProvider

type BaseProvider struct {
	// contains filtered or unexported fields
}

BaseProvider implements the logging functionality shared by all providers. It is intended to be embedded in specific provider implementations. Since the logger can be nil, methods check for its existence before logging.

func (*BaseProvider) Log

func (b *BaseProvider) Log(format string, v ...any)

Log prints a formatted message if a logger is configured. It is a helper to avoid repeated nil checks in the provider code.

func (*BaseProvider) SetLogger

func (b *BaseProvider) SetLogger(l Logger)

SetLogger sets the logger instance for the provider. This allows external callers (like main) to inject a logger.

type Logger

type Logger interface {
	Printf(format string, v ...any)
}

Logger defines the interface for logging messages. It abstraction allows the application to inject standard log.Logger, or any custom logger that supports Printf.

type Provider

type Provider interface {
	// GameVersions returns a list of available game versions (e.g., "1.16.5", "15w14a", "1.18-pre2").
	GameVersions() ([]string, error)

	// ServerVersions returns a list of available server builds/loader versions for a specific game version.
	ServerVersions(gameVersion string) ([]string, error)

	// DownloadURL returns the direct download URL for the server jar.
	DownloadURL(gameVersion, serverVersion string) (string, error)

	// Download downloads the server jar to the specified directory.
	// onProgress is called periodically with bytes downloaded and total file size.
	Download(gameVersion, serverVersion, installDir string, onProgress func(current, total int64)) error

	// SetLogger injects a logger into the provider.
	SetLogger(l Logger)

	// Log logs a message using the injected logger, if available.
	Log(format string, v ...any)
}

Provider defines the standard interface that all Minecraft server providers must implement.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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