Class MagicUtilsConsumerRegistry

java.lang.Object
dev.ua.theroer.magicutils.platform.MagicUtilsConsumerRegistry

public final class MagicUtilsConsumerRegistry extends Object
Process-wide registry of mods/plugins currently using the shared MagicUtils runtime. On loaders where every consumer shares one classloader (Fabric, NeoForge) this is a plain static holder: the platform bootstrap registers each consuming mod here on startup, and the standalone bundle command reads snapshots from it. Bukkit keeps its own registry (separate plugin classloaders + a reflective bridge to the bundle plugin), but shares the MagicUtilsConsumerInfo snapshot type.

Registrations keep a live MagicUtilsConsumerRuntimeView rather than a frozen MagicUtilsConsumerInfo. The consumer's command/component counts change after registration (commands are wired on server start, components while the runtime is built), so snapshot() / find(String) rebuild a fresh MagicUtilsConsumerInfo from the view at call time. This keeps /magicutils mods honest instead of showing an early snapshot.

This is the single implementation the per-loader registries delegate to, so the holder logic is not duplicated across platforms.

  • Method Details

    • register

      public static void register(MagicUtilsConsumerRegistry.StaticMeta meta, MagicUtilsConsumerRuntimeView view)
      Registers or refreshes a consumer from its static meta plus a live view. The view is read lazily on every snapshot() / find(String), so callers should pass a view backed by the live runtime rather than a captured snapshot.
    • register

      public static void register(MagicUtilsConsumerInfo info)
      Registers or refreshes a consumer from an already-built info. The dynamic fields are frozen at the value they held in info; prefer register(StaticMeta, MagicUtilsConsumerRuntimeView) where a live view is available. Kept for bridges that can only produce a snapshot.
    • unregister

      public static void unregister(@Nullable @Nullable String modName)
      Removes the consumer registered under modName, if any.
    • snapshot

      public static List<MagicUtilsConsumerInfo> snapshot()
      Immutable, name-sorted snapshot of the registered consumers, rebuilt from live views.
    • find

      @Nullable public static @Nullable MagicUtilsConsumerInfo find(@Nullable @Nullable String modName)
      Consumer matching modName ignoring case, rebuilt from its live view, or null.