mc

package
v0.0.0-...-713866f Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBridgeNotConnected = errors.New("bridge not connected")

Functions

func ValidRestartPolicy

func ValidRestartPolicy(policy RestartPolicy) bool

func ValidateServerName

func ValidateServerName(name string) error

Types

type BridgeConfig

type BridgeConfig struct {
	URL         string `yaml:"url"`
	AccessToken string `yaml:"access_token,omitempty"`
	ServerName  string `yaml:"server_name,omitempty"`
}

type BridgeStatus

type BridgeStatus struct {
	Configured bool   `json:"configured"`
	Connected  bool   `json:"connected,omitempty"`
	URL        string `json:"url,omitempty"`
}

type Player

type Player struct {
	Name string
}

type RestartPolicy

type RestartPolicy string
const (
	RestartNever     RestartPolicy = "never"
	RestartOnFailure RestartPolicy = "on-failure"
	RestartAlways    RestartPolicy = "always"
)

type Server

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

func NewServer

func NewServer(cfg ServerConfig, bus *event.Bus) *Server

func (*Server) Broadcast

func (s *Server) Broadcast(text string) error

func (*Server) Players

func (s *Server) Players(ctx context.Context) ([]Player, error)

func (*Server) Restart

func (s *Server) Restart(ctx context.Context) (ServerInfo, error)

func (*Server) Run

func (s *Server) Run(ctx context.Context)

func (*Server) RunCommand

func (s *Server) RunCommand(command string) error

func (*Server) RunCommandResponse

func (s *Server) RunCommandResponse(ctx context.Context, command string) (string, error)

func (*Server) Start

func (s *Server) Start(ctx context.Context) (ServerInfo, error)

func (*Server) Status

func (s *Server) Status(ctx context.Context) (ServerInfo, error)

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) (ServerInfo, error)

type ServerConfig

type ServerConfig struct {
	Name          string
	Root          string
	StartCommand  []string
	RestartPolicy RestartPolicy
	Bridge        *BridgeConfig
}

type ServerInfo

type ServerInfo struct {
	Name          string        `json:"name"`
	Root          string        `json:"root"`
	StartCommand  []string      `json:"start_command,omitempty"`
	RestartPolicy RestartPolicy `json:"restart_policy"`
	State         ServerState   `json:"state"`
	Pid           int           `json:"pid,omitempty"`
	StartedAt     *time.Time    `json:"started_at,omitempty"`
	UptimeSeconds int64         `json:"uptime_seconds,omitempty"`
	Bridge        *BridgeStatus `json:"bridge,omitempty"`
}

type ServerState

type ServerState string
const (
	StateStopped  ServerState = "stopped"
	StateStarting ServerState = "starting"
	StateRunning  ServerState = "running"
	StateStopping ServerState = "stopping"
	StateExited   ServerState = "exited"
)

Directories

Path Synopsis
Package event 提供 Minecraft 侧事件总线。
Package event 提供 Minecraft 侧事件总线。
Package queqiao 实现 QueQiao WebSocket 协议。
Package queqiao 实现 QueQiao WebSocket 协议。

Jump to

Keyboard shortcuts

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