Fabric

Fabric

For most mods, use magicutils-fabric-bundle and wire the runtime through FabricBootstrap.

java
public final class MyMod implements ModInitializer {    private static final String MOD_ID = "mymod";    private MinecraftServer server;    private FabricBootstrap.RuntimeResult magic;    @Override    public void onInitialize() {        magic = FabricBootstrap.forMod(MOD_ID, () -> server)                .enableCommands()                .buildRuntime();        CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {            if (magic.commandRegistry() != null) {                magic.commandRegistry().registerCommand(dispatcher, new ExampleCommand());            }        });        ServerLifecycleEvents.SERVER_STARTED.register(server -> this.server = server);        ServerLifecycleEvents.SERVER_STOPPING.register(server -> {            this.server = null;            if (magic != null) {                magic.runtime().close();                magic = null;            }        });    }}

FabricBootstrap wires Platform, ConfigManager, Logger, LanguageManager, Messages, and an optional Fabric command registry. Actual command registration still happens in Fabric's Brigadier callback.

Bootstrap Options

FabricBootstrap.Builder supports the following configuration:

MethodDescription
slf4j(logger)Bind an SLF4J logger for console output.
configDir(path)Override the config/lang data directory.
enableCommands()Create a CommandRegistry during bootstrap.
permissionPrefix(prefix)Set the permission node prefix for commands.
opLevel(int)Operator threshold used for permission fallbacks.
configureCommands(consumer)Register commands during bootstrap.
enableDiagnostics()Enable the diagnostics service.
configureDiagnostics(consumer)Register custom diagnostic checks.
initLanguage(boolean)Enable/disable language manager initialization.
bindLoggerLanguage(boolean)Bind the language manager to the logger.
setMessagesManager(boolean)Set the global Messages language manager.
registerMessages(boolean)Register the plugin's messages scope.
addMagicUtilsMessages(boolean)Register built-in MagicUtils messages.
bindClientLocaleSync(boolean)Follow each player's client locale.
translations(consumer)Configure additional translations.

Modular Setup

If you do not want the bundle, combine the platform adapter with the Fabric integration modules you need:

  • magicutils-fabric
  • magicutils-commands-fabric (this module provides FabricBootstrap)
  • magicutils-logger-fabric
  • magicutils-placeholders-fabric

FabricBootstrap lives in magicutils-commands-fabric, so a bootstrap-first modular setup must include it even if you do not register any commands.

Permissions

Fabric permissions integrate with fabric-permissions-api-v0 when installed. If no permission provider exists, MagicUtils falls back to op-level checks. Use opLevel(...) on FabricBootstrap or CommandRegistry.create(...) when you need a different default operator level.

Placeholders

Fabric placeholder support is optional and activates automatically when placeholder mods are present:

Config Format

Default config format on Fabric is JSONC. You can override it via <config>.format or magicutils.format (see the Config module docs).

Bundle Strategy

  • Embed magicutils-fabric-bundle in your mod.
  • Or ship one shared bundle mod on the server and depend on it.