minecraft

package
v0.0.0-...-5c9ae66 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps a RCON connection exposing required features

func NewClient

func NewClient() Client

NewClient with default settings

func (Client) CountPlayers

func (c Client) CountPlayers(ctx context.Context) (int, error)

CountPlayers returns the number of players returned by the RCON list command

func (Client) Players

func (c Client) Players(ctx context.Context) (int, []string, error)

Players returns the number of players and their names as returned by the RCON list command

func (Client) Restart

func (c Client) Restart(ctx context.Context) error

Restart the server via RCON

func (Client) SendCommand

func (c Client) SendCommand(ctx context.Context, command string) (rcon.Message, error)

SendCommand to the server via RCON

func (Client) SendMessage

func (c Client) SendMessage(ctx context.Context, msg string) error

SendMessage to the server via RCON

func (Client) Setup

func (c Client) Setup(address string, password string) (Client, error)

Setup brings the Client into a functional state by starting a RCON session with the provided credentials

func (Client) Whitelist

func (c Client) Whitelist(ctx context.Context, username string) error

Whitelist the provided username

type CommandSender

type CommandSender interface {
	SendCommand(ctx context.Context, command string) (rcon.Message, error)
}

CommandSender defines the minimal interface for sending RCON Commands

type ReconnectingRCON

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

ReconnectingRCON wraps a RCON client reconnecting it on connection errors

func NewReconnectingRCON

func NewReconnectingRCON(address, password string) *ReconnectingRCON

NewReconnectingRCON for the provided address and password

func (*ReconnectingRCON) Reconnect

func (c *ReconnectingRCON) Reconnect(ctx context.Context) error

Reconnect the session

func (*ReconnectingRCON) SendCommand

func (c *ReconnectingRCON) SendCommand(ctx context.Context, command string) (rcon.Message, error)

SendCommand reconnecting the underlying session on any permanent connection errors

func (*ReconnectingRCON) Setup

func (c *ReconnectingRCON) Setup() error

Setup establishes the initial connection and authenticates the session

Jump to

Keyboard shortcuts

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