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: 0

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