Documentation
¶
Index ¶
- Variables
- func FormatText(input string) c.Component
- func RegisterCommands(p *proxy.Proxy, store *ConfigStore, queue *QueueManager)
- type Config
- type ConfigStore
- type LimboHandler
- func (h *LimboHandler) FindBestFallback(excludeServer string) proxy.RegisteredServer
- func (h *LimboHandler) HandleCommand(e *proxy.CommandExecuteEvent)
- func (h *LimboHandler) HandleDisconnect(e *proxy.DisconnectEvent)
- func (h *LimboHandler) HandleInitialServer(e *proxy.PlayerChooseInitialServerEvent)
- func (h *LimboHandler) HandleKick(e *proxy.KickedFromServerEvent)
- func (h *LimboHandler) Start(ctx context.Context)
- type Messages
- type QueueManager
- func (qm *QueueManager) Enqueue(targetServer string, player proxy.Player) int
- func (qm *QueueManager) GetActiveTargetServers() []string
- func (qm *QueueManager) GetAllQueuesSummary() map[string]int
- func (qm *QueueManager) GetNextBatch(targetServer string, limit int) []*QueuedPlayer
- func (qm *QueueManager) GetPosition(id uuid.UUID) (targetServer string, position int, total int, found bool)
- func (qm *QueueManager) GetQueueCount(targetServer string) int
- func (qm *QueueManager) Remove(id uuid.UUID) (string, bool)
- func (qm *QueueManager) TotalQueuedPlayers() int
- type QueuedPlayer
Constants ¶
This section is empty.
Variables ¶
var Plugin = proxy.Plugin{ Name: "SmartLimbo", Init: func(ctx context.Context, p *proxy.Proxy) error { log := logr.FromContextOrDiscard(ctx) configPath := filepath.Join("config", "smartlimbo.toml") store := NewConfigStore(configPath) if _, err := store.Load(); err != nil { log.Error(err, "Failed to load smartlimbo configuration") return err } queue := NewQueueManager() handler := NewLimboHandler(p, store, queue, log) handler.Start(ctx) event.Subscribe(p.Event(), 0, func(e *proxy.KickedFromServerEvent) { handler.HandleKick(e) }) event.Subscribe(p.Event(), 0, func(e *proxy.PlayerChooseInitialServerEvent) { handler.HandleInitialServer(e) }) event.Subscribe(p.Event(), 0, func(e *proxy.CommandExecuteEvent) { handler.HandleCommand(e) }) event.Subscribe(p.Event(), 0, func(e *proxy.DisconnectEvent) { handler.HandleDisconnect(e) }) RegisterCommands(p, store, queue) log.Info("SmartLimbo loaded (smart failover, per-server queue & protected limbo active)") return nil }, }
Plugin is the Gate SmartLimbo failover and reconnection queue plugin.
Functions ¶
func FormatText ¶
FormatText parses MiniMessage, RGB, Legacy color tags, and Click/Hover tags into a Minecraft Component.
func RegisterCommands ¶
func RegisterCommands(p *proxy.Proxy, store *ConfigStore, queue *QueueManager)
RegisterCommands registers /reconnect, /rc, /queue, /leave, and /smartlimbo commands.
Types ¶
type Config ¶
type Config struct {
LimboServer string `toml:"limbo_server"`
DirectConnectServer string `toml:"direct_connect_server"`
FallbackServers []string `toml:"fallback_servers"`
TaskIntervalMs int `toml:"task_interval_ms"`
QueueNotifyIntervalMs int `toml:"queue_notify_interval_ms"`
NotifyMode string `toml:"notify_mode"`
ReconnectBatchSize int `toml:"reconnect_batch_size"`
ReconnectDelayMs int `toml:"reconnect_delay_ms"`
PingTimeoutMs int `toml:"ping_timeout_ms"`
ProtectedLimbo bool `toml:"protected_limbo"`
AllowedCommands []string `toml:"allowed_commands"`
Messages Messages `toml:"messages"`
}
Config represents the complete SmartLimbo configuration.
type ConfigStore ¶
type ConfigStore struct {
// contains filtered or unexported fields
}
ConfigStore manages thread-safe configuration reading and updating.
func NewConfigStore ¶
func NewConfigStore(path string) *ConfigStore
NewConfigStore creates a new ConfigStore instance.
func (*ConfigStore) Get ¶
func (cs *ConfigStore) Get() *Config
Get returns the current Config snapshot.
func (*ConfigStore) IsCommandAllowed ¶
func (cs *ConfigStore) IsCommandAllowed(cmd string) bool
IsCommandAllowed checks if a command name is allowed in Limbo.
func (*ConfigStore) Load ¶
func (cs *ConfigStore) Load() (*Config, error)
Load reads and parses the configuration file.
type LimboHandler ¶
type LimboHandler struct {
// contains filtered or unexported fields
}
LimboHandler manages kicks, failovers, background server pinging, and batch auto-reconnection.
func NewLimboHandler ¶
func NewLimboHandler(p *proxy.Proxy, store *ConfigStore, queue *QueueManager, log logr.Logger) *LimboHandler
NewLimboHandler creates a new LimboHandler instance.
func (*LimboHandler) FindBestFallback ¶
func (h *LimboHandler) FindBestFallback(excludeServer string) proxy.RegisteredServer
FindBestFallback finds the highest priority online fallback server from the configured list.
func (*LimboHandler) HandleCommand ¶
func (h *LimboHandler) HandleCommand(e *proxy.CommandExecuteEvent)
HandleCommand intercepts commands executed while inside the protected Limbo server.
func (*LimboHandler) HandleDisconnect ¶
func (h *LimboHandler) HandleDisconnect(e *proxy.DisconnectEvent)
HandleDisconnect cleans player from all queues upon logout.
func (*LimboHandler) HandleInitialServer ¶
func (h *LimboHandler) HandleInitialServer(e *proxy.PlayerChooseInitialServerEvent)
HandleInitialServer handles failover if the direct connect server is unavailable.
func (*LimboHandler) HandleKick ¶
func (h *LimboHandler) HandleKick(e *proxy.KickedFromServerEvent)
HandleKick intercepts server kicks and moves the player to the best available fallback server + queue.
func (*LimboHandler) Start ¶
func (h *LimboHandler) Start(ctx context.Context)
Start begins the background queue worker and notification routines.
type Messages ¶
type Messages struct {
KickedToLimbo string `toml:"kicked_to_limbo"`
QueueActionbar string `toml:"queue_actionbar"`
QueueChat string `toml:"queue_chat"`
ServerOnline string `toml:"server_online"`
ReconnectSuccess string `toml:"reconnect_success"`
ReconnectFailed string `toml:"reconnect_failed"`
LeftQueue string `toml:"left_queue"`
NotInQueue string `toml:"not_in_queue"`
QueueInfo string `toml:"queue_info"`
CommandBlocked string `toml:"command_blocked"`
}
Messages holds user-customizable chat and action bar notifications.
type QueueManager ¶
type QueueManager struct {
// contains filtered or unexported fields
}
QueueManager manages per-server smart queues with thread safety.
func NewQueueManager ¶
func NewQueueManager() *QueueManager
NewQueueManager creates a new QueueManager instance.
func (*QueueManager) Enqueue ¶
func (qm *QueueManager) Enqueue(targetServer string, player proxy.Player) int
Enqueue adds a player to the queue for targetServer and returns their 1-indexed position.
func (*QueueManager) GetActiveTargetServers ¶
func (qm *QueueManager) GetActiveTargetServers() []string
GetActiveTargetServers returns all server names currently having waiting players.
func (*QueueManager) GetAllQueuesSummary ¶
func (qm *QueueManager) GetAllQueuesSummary() map[string]int
GetAllQueuesSummary returns a summary map of server name to queue length.
func (*QueueManager) GetNextBatch ¶
func (qm *QueueManager) GetNextBatch(targetServer string, limit int) []*QueuedPlayer
GetNextBatch pops up to limit players from targetServer's queue.
func (*QueueManager) GetPosition ¶
func (qm *QueueManager) GetPosition(id uuid.UUID) (targetServer string, position int, total int, found bool)
GetPosition returns the target server, 1-indexed position, total players, and whether the player is queued.
func (*QueueManager) GetQueueCount ¶
func (qm *QueueManager) GetQueueCount(targetServer string) int
GetQueueCount returns the count of players in a specific queue.
func (*QueueManager) Remove ¶
func (qm *QueueManager) Remove(id uuid.UUID) (string, bool)
Remove removes a player from any queue they are in.
func (*QueueManager) TotalQueuedPlayers ¶
func (qm *QueueManager) TotalQueuedPlayers() int
TotalQueuedPlayers returns the total count of queued players across all servers.