Documentation
¶
Overview ¶
Package server implements a high-level implementation of a Minecraft server. Creating such a server may be done using the `server.New()` function. Additional configuration may be passed by using server.Config{...}.New(). `Server.Listen()` may be called to start and run the server. It should be followed up by a loop as such:
for p := range srv.Accept() {
// Use p
}
`Server.Accept()` blocks until a new player connects to the server and spawns in the default world.
Index ¶
- Variables
- type Allower
- type BuildInfo
- type Config
- type Core
- func (srv *Core) Accept() iter.Seq[*player.Player]
- func (srv *Core) Close() error
- func (srv *Core) CloseOnProgramEnd()
- func (srv *Core) End() *world.World
- func (srv *Core) Listen()
- func (srv *Core) MaxPlayerCount() int
- func (srv *Core) Nether() *world.World
- func (srv *Core) Player(uuid uuid.UUID) (*world.EntityHandle, bool)
- func (srv *Core) PlayerByName(name string) (*world.EntityHandle, bool)
- func (srv *Core) PlayerByXUID(xuid string) (*world.EntityHandle, bool)
- func (srv *Core) PlayerCount() int
- func (srv *Core) Players(tx *world.Tx) iter.Seq[*player.Player]
- func (srv *Core) Plugins() *plugin.Hub
- func (srv *Core) World() *world.World
- type Listener
- type MemoryGuard
- type RamGuard
- type UserConfig
Constants ¶
This section is empty.
Variables ¶
var ( // Current contiene la información de la compilación actual. Current = BuildInfo{ Tag: "1.0.1", Release: false, Number: 105, Commit: "nexus-core-sp", } )
Functions ¶
This section is empty.
Types ¶
type Allower ¶
type Allower interface {
// Allow filters what connections are allowed to connect to the Server. The
// address, identity data, and client data of the connection are passed. If
// Admit returns false, the connection is closed with the string returned as
// the disconnect message. WARNING: Use the client data at your own risk, it
// cannot be trusted because it can be freely changed by the player
// connecting.
Allow(addr net.Addr, d login.IdentityData, c login.ClientData) (string, bool)
}
Allower may be implemented to specifically allow or disallow players from joining a Server, by setting the specific Allower implementation through a call to Server.Allow.
type Config ¶
type Config struct {
// Log es el Logger a usar para la información del servidor.
Log *slog.Logger
// Listeners es una lista de funciones para crear escuchadores de red.
Listeners []func(conf Config) (Listener, error)
// Name es el nombre del servidor que se muestra en la lista de juegos.
Name string
// Resources son los paquetes de recursos (texturas) del servidor.
Resources []*resource.Pack
// ResourcesRequired especifica si es obligatorio descargar los recursos para entrar.
ResourcesRequired bool
// DisableResourceBuilding desactiva la creación automática de paquetes de recursos.
DisableResourceBuilding bool
// Allower se usa para permitir o denegar la entrada de jugadores (bans, whitelist).
Allower Allower
// AuthDisabled desactiva la autenticación con Xbox Live.
AuthDisabled bool
// MuteEmoteChat especifica si se silencia el chat de emotes.
MuteEmoteChat bool
// MaxPlayers es la cantidad máxima de jugadores simultáneos.
MaxPlayers int
// MaxChunkRadius es la distancia máxima de visión permitida.
MaxChunkRadius int
// JoinMessage, QuitMessage y ShutdownMessage son los mensajes de unión, salida y apagado.
JoinMessage, QuitMessage, ShutdownMessage chat.Translation
// StatusProvider provee el estado del servidor a la lista de juegos.
StatusProvider minecraft.ServerStatusProvider
// PlayerProvider gestiona la carga y guardado de datos de jugadores.
PlayerProvider player.Provider
// WorldProvider gestiona la carga y guardado de datos del mundo.
WorldProvider world.Provider
// ReadOnlyWorld especifica si los mundos son de solo lectura.
ReadOnlyWorld bool
// Generator especifica el generador de mundos a usar.
Generator func(dim world.Dimension) world.Generator
// RandomTickSpeed es la velocidad de los ticks aleatorios de los bloques.
RandomTickSpeed int
// SaveInterval es la frecuencia con la que se guarda el mundo al disco.
SaveInterval time.Duration
// ChunkUnloadInterval es el tiempo que un chunk permanece cargado sin jugadores.
ChunkUnloadInterval time.Duration
// Entities es el registro de todas las entidades permitidas en el servidor.
Entities world.EntityRegistry
}
Config contiene las opciones para iniciar el servidor NexusPeX.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core implements a NexusPeX server. It runs the main server loop and handles the connections of players trying to join the server.
func (*Core) Accept ¶
Accept accepts incoming players into the server, returning an iterator that yields players that join the server while blocking otherwise. The iterator returned ends when the Server is closed using a call to Close. Players returned are only valid within the block of the for loop used to iterate over them:
for p := range srv.Accept() {
// p is valid here
go func() {
// p is no longer valid here
}()
}
// p is no longer valid here
func (*Core) CloseOnProgramEnd ¶
func (srv *Core) CloseOnProgramEnd()
CloseOnProgramEnd closes the server right before the program ends, so that all data of the server are saved properly.
func (*Core) End ¶
End devuelve el mundo del End del servidor. Los jugadores son transportados allí al entrar en un portal del End en el mundo principal.
func (*Core) Listen ¶
func (srv *Core) Listen()
Listen starts running the server's listeners. Connections will be accepted until the listeners are closed using a call to Close. Once Listen is called, players may be accepted using Server.Accept().
func (*Core) MaxPlayerCount ¶
MaxPlayerCount devuelve el número máximo de jugadores permitidos.
func (*Core) Nether ¶
Nether devuelve el mundo del Nether del servidor. Los jugadores son transportados allí al entrar en un portal del Nether en el mundo principal.
func (*Core) Player ¶
Player looks for a player on the server with the UUID passed. If found, the entity handle is returned and the bool returns holds a true value. If not, the bool returned is false and the handle is nil.
func (*Core) PlayerByName ¶
func (srv *Core) PlayerByName(name string) (*world.EntityHandle, bool)
PlayerByName looks for a player on the server with the name passed. If found, the entity handle is returned and the bool returned holds a true value. If not, the bool is false and the handle is nil
func (*Core) PlayerByXUID ¶
func (srv *Core) PlayerByXUID(xuid string) (*world.EntityHandle, bool)
PlayerByXUID looks for a player on the server with the XUID passed. If found, the entity handle is returned and the bool returned is true. If no player with the XUID was found, nil and false are returned.
func (*Core) PlayerCount ¶
PlayerCount devuelve el número total de jugadores conectados.
func (*Core) Players ¶
Players returns an iterator that yields players currently online. If Players is called from within a transaction, the respective transaction should be passed. Passing nil is otherwise valid. Players returned are only valid within the block of the for loop used to iterate over them:
for p := range srv.Players(nil) {
// p is valid here
go func() {
// p is no longer valid here
}()
}
// p is no longer valid here
Collecting all values from the iterator using a function such as slices.Collect immediately invalidates the players because their transactions will be finished.
type Listener ¶
type Listener interface {
// Accept blocks until the next connection is established and returns it. An error is returned if the Listener was
// closed using Close.
Accept() (session.Conn, error)
// Disconnect disconnects a connection from the Listener with a reason.
Disconnect(conn session.Conn, reason string) error
io.Closer
}
Listener is a source for connections that may be listened on by a Server using Server.listen. Proxies can use this to provide players from a different source.
type MemoryGuard ¶
type MemoryGuard struct {
// contains filtered or unexported fields
}
func NewMemoryGuard ¶
func NewMemoryGuard(l *slog.Logger) *MemoryGuard
func (*MemoryGuard) RunCleanup ¶
func (m *MemoryGuard) RunCleanup()
type RamGuard ¶
type RamGuard struct {
// contains filtered or unexported fields
}
RamGuard se encarga de monitorear y optimizar el uso de memoria del servidor. Basado en MemoryManager.php de PocketMine-MP.
func NewRamGuard ¶
func (*RamGuard) TriggerGarbageCollector ¶
func (r *RamGuard) TriggerGarbageCollector()
TriggerGarbageCollector fuerza la recolección de basura si la memoria es alta.
type UserConfig ¶
type UserConfig struct {
Network struct {
Address string
}
Server struct {
Name string
AuthEnabled bool
DisableJoinQuitMessages bool
MuteEmoteChat bool
}
World struct {
SaveData bool
Folder string
}
Players struct {
MaxCount int
MaximumChunkRadius int
SaveData bool
Folder string
}
Resources struct {
AutoBuildPack bool
Folder string
Required bool
}
}
UserConfig es la configuración de usuario para un servidor NexusPeX.
func DefaultConfig ¶
func DefaultConfig() UserConfig
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package block exports implementations of the Block interface found in the server/world package.
|
Package block exports implementations of the Block interface found in the server/world package. |
|
cube
Package cube provides types and functions to handle positions and rotations of voxel-based objects in a 3D world.
|
Package cube provides types and functions to handle positions and rotations of voxel-based objects in a 3D world. |
|
model
Package model has world.BlockModel implementations for each world.Block implementation in the block package.
|
Package model has world.BlockModel implementations for each world.Block implementation in the block package. |
|
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. |
|
Package event exposes a single exported `Context` type that may be used to influence the execution flow of events that occur on a server.
|
Package event exposes a single exported `Context` type that may be used to influence the execution flow of events that occur on a server. |
|
internal
|
|