Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Plugin = proxy.Plugin{ Name: "SkinsChanger", Init: func(ctx context.Context, p *proxy.Proxy) error { log := logr.FromContextOrDiscard(ctx) cfgStore := NewConfigStore("config") cfg, err := cfgStore.Load() if err != nil { log.Error(err, "Failed to load skins.toml") return err } store := storage.NewStorage("config", cfg.ParsedCacheTTL) if err := store.Load(); err != nil { log.Error(err, "Failed to initialize skins storage") return err } skinFetcher := fetcher.NewMultiProviderFetcher(cfg.MineskinAPIKey, 0) cfgSnapshotProvider := func() *manager.ConfigSnapshot { current := cfgStore.Get() if current == nil { return nil } customMap := make(map[string]struct { Value string Signature string Model string }, len(current.CustomSkins)) for k, v := range current.CustomSkins { customMap[k] = struct { Value string Signature string Model string }{ Value: v.Value, Signature: v.Signature, Model: v.Model, } } return &manager.ConfigSnapshot{ Enabled: current.Enabled, AutoSkinOffline: current.AutoSkinOffline, DefaultSkin: current.DefaultSkin, CacheTTL: current.ParsedCacheTTL, Cooldown: current.ParsedCooldown, RefreshOnChange: current.RefreshOnChange, CustomSkins: customMap, } } mgr := manager.NewManager(p, skinFetcher, store, cfgSnapshotProvider) event.Subscribe(p.Event(), 0, func(e *proxy.GameProfileRequestEvent) { newProf := mgr.ProcessProfileRequest(context.Background(), e.Original(), e.OnlineMode()) e.SetGameProfile(newProf) }) event.Subscribe(p.Event(), 0, func(e *proxy.ServerPostConnectEvent) { mgr.OnServerPostConnect(e.Player()) }) reloadFn := func() error { newCfg, err := cfgStore.Load() if err != nil { return err } _ = store.SaveCache() _ = store.Load() log.Info("SkinsChanger configuration reloaded", "enabled", newCfg.Enabled) return nil } command.RegisterCommands(p, mgr, reloadFn) log.Info("SkinsChanger loaded successfully (Mojang, Ashcon, PlayerDB, Mineskin active)") return nil }, }
Plugin is the SkinsRestorer-like skin management extension for Minekube Gate.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Enabled bool `toml:"enabled"`
AutoSkinOffline bool `toml:"auto_skin_offline"`
DefaultSkin string `toml:"default_skin"`
CacheTTLStr string `toml:"cache_ttl"`
CooldownStr string `toml:"cooldown"`
MineskinAPIKey string `toml:"mineskin_api_key"`
RefreshOnChange bool `toml:"refresh_on_change"`
CustomSkins map[string]CustomSkin `toml:"custom_skins"`
ParsedCacheTTL time.Duration `toml:"-"`
ParsedCooldown time.Duration `toml:"-"`
}
Config represents the TOML configuration file for gate-skinschanger.
type ConfigStore ¶
type ConfigStore struct {
// contains filtered or unexported fields
}
ConfigStore manages loading and thread-safe access to Config.
func NewConfigStore ¶
func NewConfigStore(configDir string) *ConfigStore
NewConfigStore initializes a ConfigStore for the given config directory.
func (*ConfigStore) Get ¶
func (s *ConfigStore) Get() *Config
Get returns the current active configuration snapshot.
func (*ConfigStore) Load ¶
func (s *ConfigStore) Load() (*Config, error)
Load loads or creates skins.toml with defaults.
type CustomSkin ¶
type CustomSkin struct {
Value string `toml:"value"`
Signature string `toml:"signature"`
Model string `toml:"model"`
}
CustomSkin represents a pre-signed alias skin.
Click to show internal directories.
Click to hide internal directories.