Documentation ¶
Index ¶
- type Config
- type Server
- func (server *Server) Accept() (*player.Player, error)
- func (server *Server) Close() error
- func (server *Server) CloseOnProgramEnd()
- func (server *Server) JoinMessage(message string)
- func (server *Server) MaxPlayerCount() int
- func (server *Server) Player(uuid uuid.UUID) (*player.Player, bool)
- func (server *Server) PlayerByName(name string) (*player.Player, bool)
- func (server *Server) PlayerCount() int
- func (server *Server) Players() []*player.Player
- func (server *Server) QuitMessage(message string)
- func (server *Server) Run() error
- func (server *Server) SetName(a ...interface{})
- func (server *Server) SetNamef(format string, a ...interface{})
- func (server *Server) Start() error
- func (server *Server) Uptime() time.Duration
- func (server *Server) World() *world.World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Network holds settings related to network aspects of the server. Network struct { // Address is the address on which the server should listen. Players may connect to this address in // order to join. Address string } Server struct { // Name is the name of the server as it shows up in the server list. Name string // MaximumPlayers is the maximum amount of players allowed to join the server at the same time. If set // to 0, the amount of maximum players will grow every time a player joins. MaximumPlayers int // ShutdownMessage is the message shown to players when the server shuts down. If empty, players will // be directed to the menu screen right away. ShutdownMessage string // AuthEnabled controls whether or not players must be connected to Xbox Live in order to join the server. AuthEnabled bool // JoinMessage is the message that appears when a player joins the server. Leave this empty to disable it. // %v is the placeholder for the username of the player JoinMessage string // QuitMessage is the message that appears when a player leaves the server. Leave this empty to disable it. // %v is the placeholder for the username of the player QuitMessage string } World struct { // Name is the name of the world that the server holds. A world with this name will be loaded and // the name will be displayed at the top of the player list in the in-game pause menu. Name string // Folder is the folder that the data of the world resides in. Folder string // MaximumChunkRadius is the maximum chunk radius that players may set in their settings. If they try // to set it above this number, it will be capped and set to the max. MaximumChunkRadius int // SimulationDistance is the maximum distance in chunks that a chunk must be to a player in order for // it to receive random ticks. This field may be set to 0 to disable random block updates altogether. SimulationDistance int } }
Config is the configuration of a Dragonfly server. It holds settings that affect different aspects of the server, such as its name and maximum players.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a configuration with the default values filled out.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements a Dragonfly server. It runs the main server loop and handles the connections of players trying to join the server.
func New ¶
New returns a new server using the Config passed. If nil is passed, a default configuration is returned. (A call to dragonfly.DefaultConfig().) The Logger passed will be used to log errors and information to. If nil is passed, a default Logger is used by calling logrus.New(). Note that no two servers should be active at the same time. Doing so anyway will result in unexpected behaviour.
func (*Server) Accept ¶
Accept accepts an incoming player into the server. It blocks until a player connects to the server. Accept returns an error if the Server is closed using a call to Close.
func (*Server) CloseOnProgramEnd ¶
func (server *Server) CloseOnProgramEnd()
CloseOnProgramEnd closes the server right before the program ends, so that all data of the server are saved properly.
func (*Server) JoinMessage ¶
JoinMessage changes the join message for all players on the server. Leave this empty to disable it. %v is the placeholder for the username of the player
func (*Server) MaxPlayerCount ¶
MaxPlayerCount returns the maximum amount of players that are allowed to play on the server at the same time. Players trying to join when the server is full will be refused to enter. If the config has a maximum player count set to 0, MaxPlayerCount will return Server.PlayerCount + 1.
func (*Server) Player ¶
Player looks for a player on the server with the UUID passed. If found, the player is returned and the bool returns holds a true value. If not, the bool returned is false and the player is nil.
func (*Server) PlayerByName ¶
PlayerByName looks for a player on the server with the name passed. If found, the player is returned and the bool returns holds a true value. If not, the bool is false and the player is nil
func (*Server) PlayerCount ¶
PlayerCount returns the current player count of the server. It is equivalent to calling len(server.Players()).
func (*Server) Players ¶
Players returns a list of all players currently connected to the server. Note that the slice returned is not updated when new players join or leave, so it is only valid for as long as no new players join or players leave.
func (*Server) QuitMessage ¶
QuitMessage changes the leave message for all players on the server. Leave this empty to disable it. %v is the placeholder for the username of the player
func (*Server) Run ¶
Run runs the server and blocks until it is closed using a call to Close(). When called, the server will accept incoming connections. Run will block the current goroutine until the server is stopped. To start the server on a different goroutine, use (*Server).Start() instead. After a call to Run, calls to Server.Accept() may be made to accept players into the server.
func (*Server) SetName ¶
func (server *Server) SetName(a ...interface{})
SetName sets the name of the Server, also known as the MOTD. This name is displayed in the server list. The formatting of the name passed follows the rules of fmt.Sprint.
func (*Server) SetNamef ¶
SetNamef sets the name of the Server, also known as the MOTD. This name is displayed in the server list. The formatting of the name passed follows the rules of fmt.Sprintf.
func (*Server) Start ¶
Start runs the server but does not block, unlike Run, but instead accepts connections on a different goroutine. Connections will be accepted until the listener is closed using a call to Close. One started, players may be accepted using Server.Accept().
Directories ¶
Path | Synopsis |
---|---|
Package cmd implements a Minecraft specific command system, which may be used simply by 'plugging' it in and sending commands registered in an AvailableCommandsPacket.
|
Package cmd implements a Minecraft specific command system, which may be used simply by 'plugging' it in and sending commands registered in an AvailableCommandsPacket. |
internal
|
|