Documentation ¶
Overview ¶
Package proxy contains Gate's Minecraft Java edition proxy implementation.
Index ¶
- Variables
- type ChannelRegistrar
- type CommandExecuteEvent
- func (c *CommandExecuteEvent) Allowed() bool
- func (c *CommandExecuteEvent) Command() string
- func (c *CommandExecuteEvent) Forward() bool
- func (c *CommandExecuteEvent) OriginalCommand() string
- func (c *CommandExecuteEvent) SetAllowed(allowed bool)
- func (c *CommandExecuteEvent) SetCommand(commandline string)
- func (c *CommandExecuteEvent) SetForward(forward bool)
- func (c *CommandExecuteEvent) Source() command.Source
- type ConnectionHandshakeEvent
- type ConnectionRequest
- type ConnectionResult
- type ConnectionStatus
- type DisconnectEvent
- type DisconnectPlayerKickResult
- type GameProfileRequestEvent
- func (e *GameProfileRequestEvent) Conn() Inbound
- func (e *GameProfileRequestEvent) GameProfile() profile.GameProfile
- func (e *GameProfileRequestEvent) OnlineMode() bool
- func (e *GameProfileRequestEvent) Original() profile.GameProfile
- func (e *GameProfileRequestEvent) SetGameProfile(p profile.GameProfile)
- type Inbound
- type KickedFromServerEvent
- func (e *KickedFromServerEvent) KickedDuringServerConnect() bool
- func (e *KickedFromServerEvent) OriginalReason() component.Component
- func (e *KickedFromServerEvent) Player() Player
- func (e *KickedFromServerEvent) Result() ServerKickResult
- func (e *KickedFromServerEvent) Server() RegisteredServer
- func (e *KickedFromServerEvent) SetResult(result ServerKickResult)
- type LoginEvent
- type LoginStatus
- type MessageOption
- type MessageType
- type NotifyKickResult
- type Options
- type PermissionsSetupEvent
- type PingEvent
- type Player
- type PlayerAvailableCommandsEvent
- type PlayerChatEvent
- type PlayerChooseInitialServerEvent
- type PlayerModInfoEvent
- type PlayerSettingsChangedEvent
- type Players
- type Plugin
- type PluginMessageEvent
- func (p *PluginMessageEvent) Allowed() bool
- func (p *PluginMessageEvent) Data() []byte
- func (p *PluginMessageEvent) Identifier() message.ChannelIdentifier
- func (p *PluginMessageEvent) SetForward(forward bool)
- func (p *PluginMessageEvent) Source() message.ChannelMessageSource
- func (p *PluginMessageEvent) Target() message.ChannelMessageSink
- type PluginMessageForwardResult
- type PostLoginEvent
- type PreLoginEvent
- func (e *PreLoginEvent) Allow()
- func (e *PreLoginEvent) Conn() Inbound
- func (e *PreLoginEvent) Deny(reason component.Component)
- func (e *PreLoginEvent) ForceOfflineMode()
- func (e *PreLoginEvent) ForceOnlineMode()
- func (e *PreLoginEvent) Reason() component.Component
- func (e *PreLoginEvent) Result() PreLoginResult
- func (e *PreLoginEvent) Username() string
- type PreLoginResult
- type PreShutdownEvent
- type Proxy
- func (p *Proxy) ChannelRegistrar() *ChannelRegistrar
- func (p *Proxy) Command() *command.Manager
- func (p *Proxy) Config() config.Config
- func (p *Proxy) DisconnectAll(reason component.Component)
- func (p *Proxy) Event() event.Manager
- func (p *Proxy) Player(id uuid.UUID) Player
- func (p *Proxy) PlayerByName(username string) Player
- func (p *Proxy) PlayerCount() int
- func (p *Proxy) Players() []Player
- func (p *Proxy) Register(info ServerInfo) (RegisteredServer, bool)
- func (p *Proxy) Server(name string) RegisteredServer
- func (p *Proxy) Servers() []RegisteredServer
- func (p *Proxy) Shutdown(reason component.Component)
- func (p *Proxy) Start(stop <-chan struct{}) error
- func (p *Proxy) Unregister(info ServerInfo) bool
- type ReadyEvent
- type RedirectPlayerKickResult
- type RegisteredServer
- type ServerConnectedEvent
- type ServerConnection
- type ServerInfo
- type ServerKickResult
- type ServerPostConnectEvent
- type ServerPreConnectEvent
- func (e *ServerPreConnectEvent) Allow(server RegisteredServer)
- func (e *ServerPreConnectEvent) Allowed() bool
- func (e *ServerPreConnectEvent) Deny()
- func (e *ServerPreConnectEvent) OriginalServer() RegisteredServer
- func (e *ServerPreConnectEvent) Player() Player
- func (e *ServerPreConnectEvent) Server() RegisteredServer
- type ShutdownEvent
- type TabCompleteEvent
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoBackendConnection = errors.New("player has no backend server connection yet") ErrTooLongChatMessage = errors.New("server bound chat message can not exceed 256 characters") )
var ErrClosedConn = errors.New("connection is closed")
Indicates a connection is already closed.
var ErrProxyAlreadyRun = errors.New("proxy was already run, create a new one")
Returned by Proxy.Run if the proxy instance was already run.
var ErrServerOnlineMode = errors.New("backend server is online mode, but should be offline")
An error in a ConnectionRequest when the backend server is in online mode.
var (
// Indicates that the connection is a 1.8-1.12 Forge connection.
LegacyForge connectionType = &legacyForgeConnType{
connType: &connType{
initialClientPhase_: notStartedLegacyForgeHandshakeClientPhase,
initialBackendPhase_: notStartedLegacyForgeHandshakeBackendPhase,
},
}
)
var Plugins []Plugin
Plugins is used to register plugins with the proxy. The plugin's init hook is run after the proxy is initialized and before serving any connections.
If one init hook errors, the proxy cancels the boot and shuts down; will fire the ShutdownEvent so other plugins can gracefully de-initialize.
Functions ¶
This section is empty.
Types ¶
type ChannelRegistrar ¶
type ChannelRegistrar struct {
// contains filtered or unexported fields
}
func NewChannelRegistrar ¶
func NewChannelRegistrar() *ChannelRegistrar
func (*ChannelRegistrar) ChannelsForProtocol ¶
func (r *ChannelRegistrar) ChannelsForProtocol(protocol proto.Protocol) sets.String
ChannelsForProtocol returns all the channel names to register depending on the Minecraft protocol version.
func (*ChannelRegistrar) FromID ¶
func (r *ChannelRegistrar) FromID(channel string) (message.ChannelIdentifier, bool)
func (*ChannelRegistrar) LegacyChannelIDs ¶
func (r *ChannelRegistrar) LegacyChannelIDs() sets.String
LegacyChannelIDs returns all legacy channel IDs.
func (*ChannelRegistrar) ModernChannelIDs ¶
func (r *ChannelRegistrar) ModernChannelIDs() sets.String
ModernChannelIDs returns all channel IDs (as strings) for use with Minecraft 1.13 and above.
type CommandExecuteEvent ¶
type CommandExecuteEvent struct {
// contains filtered or unexported fields
}
CommandExecuteEvent is fired when someone wants to execute a command.
func (*CommandExecuteEvent) Allowed ¶
func (c *CommandExecuteEvent) Allowed() bool
Allowed returns true when the command is allowed to be executed.
func (*CommandExecuteEvent) Command ¶
func (c *CommandExecuteEvent) Command() string
Command returns the whole commandline without the leading "/".
func (*CommandExecuteEvent) Forward ¶ added in v0.12.0
func (c *CommandExecuteEvent) Forward() bool
Forward returns true when the command should be forwarded to the server.
func (*CommandExecuteEvent) OriginalCommand ¶ added in v0.12.0
func (c *CommandExecuteEvent) OriginalCommand() string
OriginalCommand returns the original command if SetCommand has changed it.
func (*CommandExecuteEvent) SetAllowed ¶
func (c *CommandExecuteEvent) SetAllowed(allowed bool)
SetAllowed sets whether the command is allowed to be executed.
func (*CommandExecuteEvent) SetCommand ¶ added in v0.12.0
func (c *CommandExecuteEvent) SetCommand(commandline string)
SetCommand changes the command being executed without the leading "/".
func (*CommandExecuteEvent) SetForward ¶ added in v0.12.0
func (c *CommandExecuteEvent) SetForward(forward bool)
SetForward sets whether the command should be forwarded to the server.
func (*CommandExecuteEvent) Source ¶
func (c *CommandExecuteEvent) Source() command.Source
Source returns the command source that wants to run the command.
type ConnectionHandshakeEvent ¶
type ConnectionHandshakeEvent struct {
// contains filtered or unexported fields
}
ConnectionHandshakeEvent is fired when a handshake is established between a client and the proxy.
func (*ConnectionHandshakeEvent) Connection ¶
func (e *ConnectionHandshakeEvent) Connection() Inbound
Connection returns the inbound connection.
type ConnectionRequest ¶
type ConnectionRequest interface { // Returns the server that this connection request is for. Server() RegisteredServer // This method is blocking, initiates the connection to the // remote Server and returns a result after the user has logged on // or an error when an error occurred (e.g. could not net.Dial the Server, ctx was canceled, etc.). // // The given Context can be used to cancel the connection initiation, but // has no effect if the connection was already established or canceled. // // No messages will be communicated to the client: // You are responsible for all error handling. Connect(ctx context.Context) (ConnectionResult, error) // This method is the same as Connect, but the proxy's built-in // handling will be used to provide errors to the player and returns // true if the player was successfully connected. ConnectWithIndication(ctx context.Context) (successful bool) }
ConnectionRequest can send a connection request to another server on the proxy. A connection request is created using Player.CreateConnectionRequest(RegisteredServer).
type ConnectionResult ¶
type ConnectionResult interface { Status() ConnectionStatus // The connection result status. // May be nil! Reason() Component // Returns a reason for the failure to connect to the server. }
ConnectionResult is the result of a ConnectionRequest.
type ConnectionStatus ¶
type ConnectionStatus uint8
ConnectionStatus is the status for a ConnectionResult
const ( // The player was successfully connected to the server. SuccessConnectionStatus ConnectionStatus = iota // The player is already connected to this server. AlreadyConnectedConnectionStatus // A connection is already in progress. InProgressConnectionStatus // A plugin has cancelled this connection. CanceledConnectionStatus // The server disconnected the player. // A reason MAY be provided in the ConnectionResult.Reason(). ServerDisconnectedConnectionStatus )
func (ConnectionStatus) AlreadyConnected ¶
func (r ConnectionStatus) AlreadyConnected() bool
AlreadyConnected id true if the player is already connected to this server.
func (ConnectionStatus) Canceled ¶
func (r ConnectionStatus) Canceled() bool
Canceled is true if a plugin has cancelled this connection.
func (ConnectionStatus) ConnectionInProgress ¶
func (r ConnectionStatus) ConnectionInProgress() bool
ConnectionInProgress is true if a connection is already in progress.
func (ConnectionStatus) ServerDisconnected ¶
func (r ConnectionStatus) ServerDisconnected() bool
ServerDisconnected is true if the server disconnected the player. A reason MAY be provided in the ConnectionResult.Reason().
func (ConnectionStatus) Successful ¶
func (r ConnectionStatus) Successful() bool
Successful is true if the player was successfully connected to the server.
type DisconnectEvent ¶
type DisconnectEvent struct {
// contains filtered or unexported fields
}
func (*DisconnectEvent) LoginStatus ¶
func (e *DisconnectEvent) LoginStatus() LoginStatus
func (*DisconnectEvent) Player ¶
func (e *DisconnectEvent) Player() Player
type DisconnectPlayerKickResult ¶
DisconnectPlayerKickResult is a ServerKickResult and tells the proxy to disconnect the player with the specified reason.
type GameProfileRequestEvent ¶
type GameProfileRequestEvent struct {
// contains filtered or unexported fields
}
GameProfileRequestEvent is fired after the PreLoginEvent in order to set up the game profile for the user. This can be used to configure a custom profile for a user, i.e. skin replacement.
func NewGameProfileRequestEvent ¶
func NewGameProfileRequestEvent( inbound Inbound, original profile.GameProfile, onlineMode bool, ) *GameProfileRequestEvent
func (*GameProfileRequestEvent) Conn ¶
func (e *GameProfileRequestEvent) Conn() Inbound
minecraftConn returns the inbound connection that is connecting to the proxy.
func (*GameProfileRequestEvent) GameProfile ¶
func (e *GameProfileRequestEvent) GameProfile() profile.GameProfile
GameProfile returns the game profile that will be used to initialize the connection with. Should no profile be set, the original profile (given by the proxy) will be used.
func (*GameProfileRequestEvent) OnlineMode ¶
func (e *GameProfileRequestEvent) OnlineMode() bool
OnlineMode specifies whether the user connected in online/offline mode.
func (*GameProfileRequestEvent) Original ¶
func (e *GameProfileRequestEvent) Original() profile.GameProfile
OriginalServer returns the by the proxy created offline or online (Mojang authenticated) game profile.
func (*GameProfileRequestEvent) SetGameProfile ¶
func (e *GameProfileRequestEvent) SetGameProfile(p profile.GameProfile)
SetGameProfile sets the profile to use for this connection.
type Inbound ¶
type Inbound interface { Protocol() proto.Protocol // The current protocol version the connection uses. VirtualHost() net.Addr // The hostname, the client sent us, to join the server, if applicable. RemoteAddr() net.Addr // The player's IP address. Active() bool // Whether the connection remains active. // Closed returns a receive-only channel that can be used to know when the connection was closed. // (e.g. for canceling work in an event handler) Closed() <-chan struct{} }
Inbound is an incoming connection to the proxy.
type KickedFromServerEvent ¶
type KickedFromServerEvent struct {
// contains filtered or unexported fields
}
Fired when a player is kicked from a server. You may either allow the proxy to kick the player (with an optional reason override) or redirect the player to a separate server. By default, the proxy will notify the user (if they are already connected to a server) or disconnect them (if they are not on a server and no other servers are available).
func (*KickedFromServerEvent) KickedDuringServerConnect ¶
func (e *KickedFromServerEvent) KickedDuringServerConnect() bool
KickedDuringServerConnect returns true if the player got kicked while connecting to another server.
func (*KickedFromServerEvent) OriginalReason ¶
func (e *KickedFromServerEvent) OriginalReason() component.Component
OriginalReason returns the reason the server kicked the player from the server. May return nil!
func (*KickedFromServerEvent) Player ¶
func (e *KickedFromServerEvent) Player() Player
Player returns the player that got kicked.
func (*KickedFromServerEvent) Result ¶
func (e *KickedFromServerEvent) Result() ServerKickResult
KickedDuringServerConnect returns current kick result. The proxy sets a default non-nil result but an event handler may has set it nil when handling the event.
func (*KickedFromServerEvent) Server ¶
func (e *KickedFromServerEvent) Server() RegisteredServer
Server returns the server the player got kicked from.
func (*KickedFromServerEvent) SetResult ¶
func (e *KickedFromServerEvent) SetResult(result ServerKickResult)
KickedDuringServerConnect sets the kick result.
type LoginEvent ¶
type LoginEvent struct {
// contains filtered or unexported fields
}
func (*LoginEvent) Allow ¶
func (e *LoginEvent) Allow()
func (*LoginEvent) Allowed ¶
func (e *LoginEvent) Allowed() bool
func (*LoginEvent) Deny ¶
func (e *LoginEvent) Deny(reason component.Component)
func (*LoginEvent) Player ¶
func (e *LoginEvent) Player() Player
func (*LoginEvent) Reason ¶
func (e *LoginEvent) Reason() component.Component
Is nil if Allowed() returns true
type LoginStatus ¶
type LoginStatus uint8
const ( SuccessfulLoginStatus LoginStatus = iota ConflictingLoginStatus CanceledByUserLoginStatus CanceledByProxyLoginStatus CanceledByUserBeforeCompleteLoginStatus )
type MessageOption ¶ added in v0.13.0
MessageOption is an option for Player.SendMessageWith.
func MessageWithSender ¶ added in v0.13.0
func MessageWithSender(id uuid.UUID) MessageOption
MessageWithSender modifies the sender identity of the chat message.
func MessageWithType ¶ added in v0.13.0
func MessageWithType(t MessageType) MessageOption
MessageWithType modifies chat message type.
type MessageType ¶ added in v0.13.0
type MessageType uint8
MessageType is a chat message type.
const ( // ChatMessageType is a standard chat message. ChatMessageType MessageType = iota // SystemMessageType is a system chat message. // e.g. client is willing to accept messages from commands, // but does not want general chat from other players. SystemMessageType )
Chat message types.
type NotifyKickResult ¶
NotifyKickResult is ServerKickResult and notifies the player with the specified message but does nothing else. This is only a valid result to use if the player was trying to connect to a different server, otherwise it is treated like a DisconnectPlayerKickResult result.
type Options ¶
type Options struct { // Config requires configuration // validated by config.Validate. Config *config.Config // The event manager to use. // If none is set, no events are sent. EventMgr event.Manager // Logger is the logger to be used by the Proxy. // If none is set, does no logging at all. Logger logr.Logger // Authenticator to authenticate users in online mode. // If not set, creates a default one. Authenticator auth.Authenticator }
Options are the options for a new Java edition Proxy.
type PermissionsSetupEvent ¶
type PermissionsSetupEvent struct {
// contains filtered or unexported fields
}
PermissionsSetupEvent is fired once a permission.Subject's permissions are being initialized.
func (*PermissionsSetupEvent) Func ¶
func (p *PermissionsSetupEvent) Func() permission.Func
Func returns the permission.Func used for the subject.
func (*PermissionsSetupEvent) SetFunc ¶
func (p *PermissionsSetupEvent) SetFunc(fn permission.Func)
SetFunc sets the permission.Func usec for the subject. If fn is nil, the default Func fill be used.
func (*PermissionsSetupEvent) Subject ¶
func (p *PermissionsSetupEvent) Subject() permission.Subject
Subject returns the subject the permissions are setup for.
type PingEvent ¶
type PingEvent struct {
// contains filtered or unexported fields
}
PingEvent is fired when a server list ping request is sent by a remote client.
func (*PingEvent) Connection ¶
Connection returns the inbound connection.
func (*PingEvent) Ping ¶
func (p *PingEvent) Ping() *ping.ServerPing
Ping returns the used ping. (pre-initialized by the proxy)
func (*PingEvent) SetPing ¶
func (p *PingEvent) SetPing(ping *ping.ServerPing)
SetPing sets the ping response to use.
type Player ¶
type Player interface { Inbound command.Source message.ChannelMessageSource message.ChannelMessageSink ID() uuid.UUID // The Minecraft ID of the player. Username() string // The username of the player. // CurrentServer returns the current server connection of the player. CurrentServer() ServerConnection // May be nil, if there is no backend server connection! Ping() time.Duration // The player's ping or -1 if currently unknown. OnlineMode() bool // Whether the player was authenticated with Mojang's session servers. // CreateConnectionRequest creates a connection request to begin switching the backend server. CreateConnectionRequest(target RegisteredServer) ConnectionRequest GameProfile() profile.GameProfile // Returns the player's game profile. Settings() player.Settings // The players client settings. Returns player.DefaultSettings if known. // Disconnect disconnects the player with a reason. // Once called, further interface calls to this player become undefined. Disconnect(reason component.Component) // SpoofChatInput sends chats input onto the player's current server as if // they typed it into the client chat box. SpoofChatInput(input string) error // SendResourcePack sends the specified resource pack from url to the user. If at all possible, // send the resource pack with a sha1 hash using SendResourcePackWithHash. To monitor the status // of the sent resource pack, subscribe to PlayerResourcePackStatusEvent. SendResourcePack(url string) error // SendResourcePackWithHash sends the specified resource pack from url to the user, // using the specified 20-byte SHA-1 hash of the resource pack file. To monitor the // status of the sent resource pack, subscribe to PlayerResourcePackStatusEvent. SendResourcePackWithHash(url string, sha1Hash []byte) error // SendActionBar sends an action bar to the player. SendActionBar(msg component.Component) error // SendMessageWith sends a chat message with optional modifications. SendMessageWith(msg component.Component, opts ...MessageOption) error player.TabList }
Player is a connected Minecraft player.
type PlayerAvailableCommandsEvent ¶ added in v0.12.0
type PlayerAvailableCommandsEvent struct {
// contains filtered or unexported fields
}
PlayerAvailableCommandsEvent allows plugins to modify the packet indicating commands available on the server to a Minecraft 1.13+ client.
func (*PlayerAvailableCommandsEvent) Player ¶ added in v0.12.0
func (p *PlayerAvailableCommandsEvent) Player() Player
Player returns the player that is about to see the available commands.
func (*PlayerAvailableCommandsEvent) RootNode ¶ added in v0.12.0
func (p *PlayerAvailableCommandsEvent) RootNode() *brigodier.RootCommandNode
RootNode returns the available commands to the Player.
type PlayerChatEvent ¶
type PlayerChatEvent struct {
// contains filtered or unexported fields
}
PlayerChatEvent is fired when a player sends a chat message. Note that messages with a leading "/" do not trigger this event, but instead CommandExecuteEvent.
func (*PlayerChatEvent) Allowed ¶
func (c *PlayerChatEvent) Allowed() bool
Allowed returns true when the chat message is allowed.
func (*PlayerChatEvent) Message ¶
func (c *PlayerChatEvent) Message() string
Message returns the message the player sent.
func (*PlayerChatEvent) Player ¶
func (c *PlayerChatEvent) Player() Player
Player returns the player that sent the message.
func (*PlayerChatEvent) SetAllowed ¶
func (c *PlayerChatEvent) SetAllowed(allowed bool)
SetAllowed sets whether the chat message is allowed.
type PlayerChooseInitialServerEvent ¶
type PlayerChooseInitialServerEvent struct {
// contains filtered or unexported fields
}
PlayerChooseInitialServerEvent is fired when a player has finished connecting to the proxy and we need to choose the first server to connect to.
func (*PlayerChooseInitialServerEvent) InitialServer ¶
func (e *PlayerChooseInitialServerEvent) InitialServer() RegisteredServer
InitialServer returns the initial server or nil if no server is configured.
func (*PlayerChooseInitialServerEvent) Player ¶
func (e *PlayerChooseInitialServerEvent) Player() Player
Player returns the player to find the initial server for.
func (*PlayerChooseInitialServerEvent) SetInitialServer ¶
func (e *PlayerChooseInitialServerEvent) SetInitialServer(server RegisteredServer)
SetInitialServer sets the initial server for the player.
type PlayerModInfoEvent ¶
type PlayerModInfoEvent struct {
// contains filtered or unexported fields
}
PlayerModInfoEvent is fired when a Forge client sends its mods to the proxy while connecting to a server.
func (*PlayerModInfoEvent) ModInfo ¶
func (e *PlayerModInfoEvent) ModInfo() modinfo.ModInfo
ModInfo is the mod info received by the player.
func (*PlayerModInfoEvent) Player ¶
func (e *PlayerModInfoEvent) Player() Player
Player returns the player who sent the mod info.
type PlayerSettingsChangedEvent ¶
type PlayerSettingsChangedEvent struct {
// contains filtered or unexported fields
}
func (*PlayerSettingsChangedEvent) Player ¶
func (s *PlayerSettingsChangedEvent) Player() Player
Player returns the player whose settings where updates/initialized.
func (*PlayerSettingsChangedEvent) Settings ¶
func (s *PlayerSettingsChangedEvent) Settings() player.Settings
Settings returns player's new settings.
type Players ¶
type Players interface { Len() int // Returns the size of the player list. Range(func(p Player) bool) // Loops through the players, breaks if func returns false. }
Players is a list of players safe for concurrent use.
type Plugin ¶
type Plugin struct { Name string // The name identifying the plugin. Init func(proxy *Proxy) error // The hook to initialize the plugin. }
Plugin provides the ability to extend Gate with external code.
Quick notes on Go's plugin system:
We don't support Go's plugin system as it is not a mature solution. They force your plugin implementation to be highly-coupled with Gate's build toolchain, the end-result would be very brittle, hard to maintain and the overhead would be much higher if the plugin author does not have any control over new versions of Gate.
Now with that made clear, here is how Gate can be customized!
Native Go:
You can use Gate as a framework and compile your code with it. - Create your own Go project/module and `go get -u go.minekube.com/gate` - Within your main function - Add your Plugin to the Plugins - And call cmd/gate.Execute (blocking your main until shutdown). - Subscribe to proxy.ShutdownEvent for de-initializing your plugin.
By running cmd/gate.Execute, Gate will do the whole rest.
- load the config (parse found file, flags and env vars)
- make and run the proxy.Proxy that will call the Plugins init hooks.
Script languages:
- Not yet supported.
type PluginMessageEvent ¶
type PluginMessageEvent struct {
// contains filtered or unexported fields
}
PluginMessageEvent is fired when a plugin message is sent to the proxy, either from a player or a server backend server.
func (*PluginMessageEvent) Allowed ¶
func (p *PluginMessageEvent) Allowed() bool
func (*PluginMessageEvent) Data ¶
func (p *PluginMessageEvent) Data() []byte
func (*PluginMessageEvent) Identifier ¶
func (p *PluginMessageEvent) Identifier() message.ChannelIdentifier
func (*PluginMessageEvent) SetForward ¶
func (p *PluginMessageEvent) SetForward(forward bool)
func (*PluginMessageEvent) Source ¶
func (p *PluginMessageEvent) Source() message.ChannelMessageSource
func (*PluginMessageEvent) Target ¶
func (p *PluginMessageEvent) Target() message.ChannelMessageSink
type PluginMessageForwardResult ¶
type PluginMessageForwardResult struct { }
type PostLoginEvent ¶
type PostLoginEvent struct {
// contains filtered or unexported fields
}
func (*PostLoginEvent) Player ¶
func (e *PostLoginEvent) Player() Player
type PreLoginEvent ¶
type PreLoginEvent struct {
// contains filtered or unexported fields
}
func (*PreLoginEvent) Allow ¶
func (e *PreLoginEvent) Allow()
func (*PreLoginEvent) Conn ¶
func (e *PreLoginEvent) Conn() Inbound
func (*PreLoginEvent) Deny ¶
func (e *PreLoginEvent) Deny(reason component.Component)
func (*PreLoginEvent) ForceOfflineMode ¶
func (e *PreLoginEvent) ForceOfflineMode()
func (*PreLoginEvent) ForceOnlineMode ¶
func (e *PreLoginEvent) ForceOnlineMode()
func (*PreLoginEvent) Reason ¶
func (e *PreLoginEvent) Reason() component.Component
Reason returns the deny reason to disconnect the connection. May be nil!
func (*PreLoginEvent) Result ¶
func (e *PreLoginEvent) Result() PreLoginResult
func (*PreLoginEvent) Username ¶
func (e *PreLoginEvent) Username() string
type PreLoginResult ¶
type PreLoginResult uint8
const ( AllowedPreLogin PreLoginResult = iota DeniedPreLogin ForceOnlineModePreLogin ForceOfflineModePreLogin )
type PreShutdownEvent ¶
type PreShutdownEvent struct {
// contains filtered or unexported fields
}
PreShutdownEvent is fired before the proxy begins to shut down by stopping to accept new connections and disconnect all players.
func (*PreShutdownEvent) Reason ¶
func (s *PreShutdownEvent) Reason() component.Component
Reason returns the shutdown reason used to disconnect players with. May be nil!
func (*PreShutdownEvent) SetReason ¶
func (s *PreShutdownEvent) SetReason(reason component.Component)
SetReason sets the shutdown reason used to disconnect players with.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is Gate's Java edition Minecraft proxy.
func (*Proxy) ChannelRegistrar ¶
func (p *Proxy) ChannelRegistrar() *ChannelRegistrar
func (*Proxy) DisconnectAll ¶
DisconnectAll disconnects all current connected players in parallel and waits until all players have been disconnected.
func (*Proxy) Player ¶
Player returns the online player by their Minecraft id. Returns nil if the player was not found.
func (*Proxy) PlayerByName ¶
PlayerByName returns the online player by their Minecraft name (search is case-insensitive). Returns nil if the player was not found.
func (*Proxy) PlayerCount ¶
PlayerCount returns the number of players on the proxy.
func (*Proxy) Register ¶
func (p *Proxy) Register(info ServerInfo) (RegisteredServer, bool)
Register registers a server with the proxy.
Returns the new registered server and true on success.
On failure either:
- if name already exists, returns the already registered server and false
- if the specified ServerInfo is invalid, returns nil and false.
func (*Proxy) Server ¶
func (p *Proxy) Server(name string) RegisteredServer
Server gets a backend server registered with the proxy by name. Returns nil if not found.
func (*Proxy) Servers ¶
func (p *Proxy) Servers() []RegisteredServer
Servers gets all registered servers.
func (*Proxy) Shutdown ¶
Shutdown stops the Proxy and/or blocks until the Proxy has finished shutdown.
It first stops listening for new connections, disconnects all existing connections with the given reason (nil = blank reason) and waits for all event subscribers to finish.
func (*Proxy) Start ¶
Start runs the Java edition Proxy, blocks until the proxy is Shutdown or an error occurred while starting. The Proxy is already shutdown on method return. Another method of stopping the Proxy is to call Shutdown. A Proxy can only be run once or ErrProxyAlreadyRun is returned.
func (*Proxy) Unregister ¶
func (p *Proxy) Unregister(info ServerInfo) bool
Unregister unregisters the server exactly matching the given ServerInfo and returns true if found.
type ReadyEvent ¶
type ReadyEvent struct{}
ReadyEvent is fired once the proxy was successfully initialized and is ready to serve connections.
type RedirectPlayerKickResult ¶
type RedirectPlayerKickResult struct { Server RegisteredServer // The new server to redirect the kicked player to. Message component.Component // Optional message sent to the player after redirecting. }
RedirectPlayerKickResult is a ServerKickResult and tells the proxy to redirect the player to another server.
type RegisteredServer ¶
type RegisteredServer interface { ServerInfo() ServerInfo Players() Players // The players connected to the server on THIS proxy. //TODO Ping() (*ServerPing, error) Equals(RegisteredServer) bool }
RegisteredServer is a backend server that has been registered with the proxy.
type ServerConnectedEvent ¶
type ServerConnectedEvent struct {
// contains filtered or unexported fields
}
ServerConnectedEvent is fired before the player completely transitions to the target server and the connection to the previous server has been de-established.
Use Server to get the target server since Player.CurrentServer is yet nil or listen for ServerPostConnectEvent instead.
func (*ServerConnectedEvent) Player ¶
func (s *ServerConnectedEvent) Player() Player
Player returns the associated player.
func (*ServerConnectedEvent) PreviousServer ¶
func (s *ServerConnectedEvent) PreviousServer() RegisteredServer
PreviousServer returns the server the player was previously connected to. May return nil if there was none!
func (*ServerConnectedEvent) Server ¶
func (s *ServerConnectedEvent) Server() RegisteredServer
Server returns the server the player connected to.
type ServerConnection ¶
type ServerConnection interface { message.ChannelMessageSink message.ChannelMessageSource Server() RegisteredServer // Returns the server that this connection is connected to. Player() Player // Returns the player that this connection is associated with. }
ServerConnection is a connection to a backend server from the proxy for a client.
type ServerInfo ¶
type ServerInfo interface { Name() string // Returns the server name. Addr() net.Addr // Returns the server address. Equals(ServerInfo) bool // TODO move as function other package together with ServerInfo interface and make this method implementation optional and default to Name() & Addr.String() comparison }
ServerInfo is the info of a backend server.
func NewServerInfo ¶
func NewServerInfo(name string, addr net.Addr) ServerInfo
type ServerKickResult ¶
type ServerKickResult interface {
// contains filtered or unexported methods
}
ServerKickResult is the result of a KickedFromServerEvent and is implemented by
DisconnectPlayerKickResult ¶
RedirectPlayerKickResult ¶
NotifyKickResult
type ServerPostConnectEvent ¶
type ServerPostConnectEvent struct {
// contains filtered or unexported fields
}
ServerPostConnectEvent is fired after the player has connected to a server. The server the player is now connected to is available in Player().CurrentServer().
func (*ServerPostConnectEvent) Player ¶
func (s *ServerPostConnectEvent) Player() Player
Player returns the associated player.
func (*ServerPostConnectEvent) PreviousServer ¶
func (s *ServerPostConnectEvent) PreviousServer() RegisteredServer
PreviousServer returns the server the player was previously connected to. May return nil if there was none!
type ServerPreConnectEvent ¶
type ServerPreConnectEvent struct {
// contains filtered or unexported fields
}
ServerPreConnectEvent is fired before the player connects to a server.
func (*ServerPreConnectEvent) Allow ¶
func (e *ServerPreConnectEvent) Allow(server RegisteredServer)
Allow the player to connect to the specified server.
func (*ServerPreConnectEvent) Allowed ¶
func (e *ServerPreConnectEvent) Allowed() bool
Allowed returns true whether the connection is allowed.
func (*ServerPreConnectEvent) Deny ¶
func (e *ServerPreConnectEvent) Deny()
Deny will cancel the player to connect to another server.
func (*ServerPreConnectEvent) OriginalServer ¶
func (e *ServerPreConnectEvent) OriginalServer() RegisteredServer
OriginalServer returns the server that the player originally tried to connect to. To get the server the player will connect to, see the Server() of this event. To get the server the player is currently on when this event is fired, use Player.getCurrentServer().
func (*ServerPreConnectEvent) Player ¶
func (e *ServerPreConnectEvent) Player() Player
Player returns the player that tries to connect to another server.
func (*ServerPreConnectEvent) Server ¶
func (e *ServerPreConnectEvent) Server() RegisteredServer
Server returns the server the player will connect to OR nil if Allowed() returns false.
type ShutdownEvent ¶
type ShutdownEvent struct{}
ShutdownEvent is fired by the proxy after the proxy has stopped accepting connections and PreShutdownEvent, but before the proxy process exits.
Subscribe to this event to gracefully stop any subtasks, such as plugin dependencies.
type TabCompleteEvent ¶ added in v0.12.0
type TabCompleteEvent struct {
// contains filtered or unexported fields
}
TabCompleteEvent is fired after a tab complete response is sent by the remote server, for clients on1.12.2 and below. You have the opportunity to modify the response sent to the remote player.
func (*TabCompleteEvent) PartialMessage ¶ added in v0.12.0
func (t *TabCompleteEvent) PartialMessage() string
PartialMessage returns the message being partially completed.
func (*TabCompleteEvent) Player ¶ added in v0.12.0
func (t *TabCompleteEvent) Player() Player
Player returns the player requesting the tab completion.
func (*TabCompleteEvent) SetSuggestions ¶ added in v0.12.0
func (t *TabCompleteEvent) SetSuggestions(s []string)
SetSuggestions sets the suggestions provided to the user.
func (*TabCompleteEvent) Suggestions ¶ added in v0.12.0
func (t *TabCompleteEvent) Suggestions() []string
Suggestions returns all the suggestions provided to the user, as a mutable list.
Source Files ¶
- builtin_cmd_glist.go
- builtin_cmd_server.go
- builtin_commands.go
- bungee_channel.go
- command.go
- connection.go
- connection_type.go
- doc.go
- events.go
- phases.go
- player.go
- plugin.go
- proxy.go
- server.go
- session_backend_login.go
- session_backend_play.go
- session_backend_transition.go
- session_client_play.go
- session_handshake.go
- session_initial_connect.go
- session_login.go
- session_status.go
- switch.go
- tab_list.go