minecraft

package
v1.0.38 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SettingVelocitySecret = "velocity_forwarding_secret"
)

Variables

This section is empty.

Functions

func DetectModpackLoader

func DetectModpackLoader(candidates ...string) (models.ModLoader, bool)

Inspects candidate strings for modloader identification

func FindMostRecentMinecraftVersion

func FindMostRecentMinecraftVersion(versions []string) string

func GenerateVelocitySecret

func GenerateVelocitySecret() (string, error)

GenerateVelocitySecret generates a cryptographically secure 32-byte (256-bit) secret

func GetAllConfigs

func GetAllConfigs(serverDataPath string, loader models.ModLoader) (map[string]any, error)

GetAllConfigs returns all configuration files for a server

func GetAllVersions

func GetAllVersions() []string

Returns all versions including snapshots

func GetJavaVersion

func GetJavaVersion(mcVersion string) (string, error)

Fetches required Java version for a specific Minecraft version

func GetLatestSnapshot

func GetLatestSnapshot() string

Returns the latest snapshot version

func GetLatestVersion

func GetLatestVersion() string

Returns the latest Minecraft release version

func GetModsPath

func GetModsPath(serverDataPath string, loader models.ModLoader) string

GetModsPath returns the path where mods should be stored for a given server

func GetProtocolVersion

func GetProtocolVersion(mcVersion string) int

Get protocol version for a Minecraft version string

func GetTPSCommand

func GetTPSCommand(modLoader models.ModLoader) string

func GetVersionDate

func GetVersionDate(version string) (time.Time, error)

Returns the release date of a Minecraft version

func GetVersions

func GetVersions() []string

Returns a list of all Minecraft release versions

func IsSnapshot

func IsSnapshot(version string) bool

Checks if a version is a snapshot

func IsValidModFile

func IsValidModFile(filename string, loader models.ModLoader) bool

IsValidModFile checks if a file is a valid mod file for the given loader

func IsValidVersion

func IsValidVersion(version string) bool

Checks if a given version string is a valid Minecraft version

func LoadYAMLConfig

func LoadYAMLConfig(serverDataPath string, configFile ConfigFile) (map[string]any, error)

LoadYAMLConfig loads a YAML configuration file

func MatchModLoader

func MatchModLoader(input string) (models.ModLoader, bool)

func ParsePlayerListFromOutput

func ParsePlayerListFromOutput(output string) (int, []string)

ParsePlayerListFromOutput parses player count and names from list command output.

func ParseTPSFromOutput

func ParseTPSFromOutput(output string) float64

ParseTPSFromOutput parses TPS value from various server command outputs.

func SaveServerProperties

func SaveServerProperties(serverDataPath string, properties ServerProperties) error

SaveServerProperties saves the server.properties file

func SaveYAMLConfig

func SaveYAMLConfig(serverDataPath string, configFile ConfigFile, config map[string]any) error

SaveYAMLConfig saves a YAML configuration file

func SyncVelocitySecretToDataPath

func SyncVelocitySecretToDataPath(dataPath string, secret string) (string, error)

SyncVelocitySecretToDataPath writes or updates the Velocity modern forwarding secret in paper-global.yml or paper.yml

Types

type ConfigFile

type ConfigFile string

ConfigFile represents a generic configuration file type

const (
	ConfigServerProperties ConfigFile = "server.properties"
	ConfigBukkit           ConfigFile = "bukkit.yml"
	ConfigSpigot           ConfigFile = "spigot.yml"
	ConfigPaper            ConfigFile = "paper.yml"
	ConfigPaperGlobal      ConfigFile = "config/paper-global.yml"
	ConfigPaperWorld       ConfigFile = "config/paper-world-defaults.yml"
)

func GetConfigFiles

func GetConfigFiles(loader models.ModLoader) []ConfigFile

GetConfigFiles returns the configuration files for a specific mod loader

type LatestVersions

type LatestVersions struct {
	Release  string `json:"release"`
	Snapshot string `json:"snapshot"`
}

type ModLoaderInfo

type ModLoaderInfo struct {
	Name              string
	DisplayName       string
	Description       string
	Category          string
	ModsDirectory     string
	ConfigDirectory   string
	SupportedVersions []string
	FileExtensions    []string
}

ModLoaderInfo contains information about a specific mod loader

func GetAllModLoaders

func GetAllModLoaders() []ModLoaderInfo

GetAllModLoaders returns information about all available mod loaders

func GetModLoaderInfo

func GetModLoaderInfo(loader models.ModLoader) ModLoaderInfo

GetModLoaderInfo returns information about a specific mod loader

type ProtocolVersionEntry

type ProtocolVersionEntry struct {
	MinecraftVersion string `json:"minecraftVersion"`
	Version          int    `json:"version"`
	DataVersion      int    `json:"dataVersion"`
	UsesNetty        bool   `json:"usesNetty"`
	MajorVersion     string `json:"majorVersion"`
	ReleaseType      string `json:"releaseType"`
}

type SLPClient

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

Implements the Minecraft Server List Ping protocol

func NewSLPClient

func NewSLPClient(timeout time.Duration) *SLPClient

SLP client with timeout

func (*SLPClient) Ping

func (c *SLPClient) Ping(ctx context.Context, host string, port int, mcVersion string) (*SLPResult, error)

Server list ping to host and port

type SLPResult

type SLPResult struct {
	Version struct {
		Name     string `json:"name"`
		Protocol int    `json:"protocol"`
	} `json:"version"`
	Players struct {
		Max    int `json:"max"`
		Online int `json:"online"`
		Sample []struct {
			Name string `json:"name"`
			ID   string `json:"id"`
		} `json:"sample"`
	} `json:"players"`
	Description    json.RawMessage `json:"description"`
	Favicon        string          `json:"favicon,omitempty"`
	EnforcesSecure bool            `json:"enforcesSecureChat,omitempty"`
	LatencyMs      int64
	MOTD           string   // Parsed from Description
	PlayerNames    []string // Extracted player names
}

Parsed response from a server list ping

type ServerProperties

type ServerProperties map[string]string

ServerProperties represents the Minecraft server.properties file

func LoadServerProperties

func LoadServerProperties(serverDataPath string) (ServerProperties, error)

LoadServerProperties loads the server.properties file from a server's data directory

func (ServerProperties) GetBool

func (p ServerProperties) GetBool(key string, defaultValue bool) bool

func (ServerProperties) GetInt

func (p ServerProperties) GetInt(key string, defaultValue int) int

func (ServerProperties) GetString

func (p ServerProperties) GetString(key string, defaultValue string) string

func (ServerProperties) SetBool

func (p ServerProperties) SetBool(key string, value bool)

func (ServerProperties) SetInt

func (p ServerProperties) SetInt(key string, value int)

func (ServerProperties) SetString

func (p ServerProperties) SetString(key, value string)

type Version

type Version struct {
	ID              string    `json:"id"`
	Type            string    `json:"type"`
	URL             string    `json:"url"`
	Time            time.Time `json:"time"`
	ReleaseTime     time.Time `json:"releaseTime"`
	SHA1            string    `json:"sha1"`
	ComplianceLevel int       `json:"complianceLevel"`
}

A single Minecraft version entry

func GetVersionInfo

func GetVersionInfo(version string) (*Version, error)

Returns detailed information about a specific version

type VersionManifestV2

type VersionManifestV2 struct {
	Latest   LatestVersions `json:"latest"`
	Versions []Version      `json:"versions"`
}

type VersionMetadata

type VersionMetadata struct {
	JavaVersion struct {
		Component    string `json:"component"`
		MajorVersion int    `json:"majorVersion"`
	} `json:"javaVersion"`
}

Metadata for a specific version

Jump to

Keyboard shortcuts

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