server

package
v0.0.0-...-6ef5be2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerClosed = errors.New("piston: server already closed or closing")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Address string
}

type Player

type Player struct {
	Username string
	UUID     uuid.UUID

	X int32
	Y int32
	Z int32

	Yaw   uint8
	Pitch uint8
	// contains filtered or unexported fields
}

Player is save for concurrent use

func NewPlayer

func NewPlayer(srv *Server, conn *protocol.Conn, username string, uuid uuid.UUID) Player

Creates a new Player. conn should not be used after passing it to NewPlayer

func (*Player) Disconnect

func (p *Player) Disconnect()

Disconnects a player and closes the connetion

func (*Player) Start

func (p *Player) Start()

Let the player play. This blocks until p.Disconnect is called or the client disconnects.

type Server

type Server struct {
	Overworld *world.World
	// contains filtered or unexported fields
}

Keep a minecraft server Server is save for concurrent use

File Structure: worlds/[name]/[chunk-x]-[chunk-y].gob

func New

func New(config Config) *Server

Initialize a server and load worlds

func (*Server) RegisterOnShutdown

func (srv *Server) RegisterOnShutdown(f func())

Execute f when srv.Shutdown is called. The server will not wait for f to finish

func (*Server) Serve

func (srv *Server) Serve() error

Listen for connections on srv.config.Address

func (*Server) Shutdown

func (srv *Server) Shutdown() error

Shuts the currently running server down. Blocks until srv.Serve() returns

Jump to

Keyboard shortcuts

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