Developers¶
Would you like to interface with Solstice?
Add the Maven repository:
...and add the dependency:
Replace VERSION with the preferred version. E.g. 1.9.6+1.21.1 (without v).
Adding modules¶
This section explains how you can set up the integration of custom modules to Solstice.
Create a class that implements me.alexdevs.solstice.api.module.ModuleEntrypoint.
This interface exposes the method register(), used to return the list of modules to load by Solstice.
package com.example.modules;
import me.alexdevs.solstice.api.module.ModuleBase;
import me.alexdevs.solstice.api.module.ModuleEntrypoint;
import me.alexdevs.solstice.api.module.ModuleRegistry;
import java.util.HashSet;
import java.util.List;
public class ModuleProvider implements ModuleEntrypoint {
// Create a ModuleRegistry instance
private static final ModuleRegistry MODULES = new ModuleRegistry("my_addon");
// Register modules
public static MyModule MY_MODULE = MODULES.register(MyModule::new, "my_module");
public static MyCoolModule MY_COOL_MODULE = MODULES.register(MyCoolModule::new, "my_cool_module");
// Return the registered modules.
// This method is only called once!
@Override
public HashSet<ModuleBase> register() {
return MODULES.getModules();
}
}
"solstice" entry point to your fabric.mod.json, under the "entrypoints" field, along the "main" entry point:
"entrypoints": {
// Main entrypoint of your Fabric mod
"main": [
"com.example.modules.MyMod"
],
// Add this entry point to the list:
"solstice": [
"com.example.modules.ModuleProvider"
]
// ...
},
Module example¶
All Solstice modules extend the abstract class me.alexdevs.solstice.api.module.ModuleBase.
Modules need to provide a SolsticeIdentifier to the super constructor, ideally all lowercase, this ID is used to differentiate between modules and is also used to make permission nodes.
package com.example.modules.mymodule;
import me.alexdevs.solstice.Solstice;
import me.alexdevs.solstice.api.module.ModuleBase;
// Use ModuleBase.Toggleable to make it toggleable from modules.conf.
public class MyModule extends ModuleBase {
public MyModule(SolsticeIdenifier id) {
super(id);
}
@Override
public void init() {
// Register the configuration section
Solstice.configManager.registerData(id, MyModuleConfig.class, MyModuleConfig::new);
// Register the locale
Solstice.localeManager.registerModule(id, MyModuleLocale.MODULE);
// Register the player data
Solstice.playerData.registerData(id, MyModulePlayerData.class, MyModulePlayerData::new);
// Register the server data
Solstice.serverData.registerData(id, MyModuleServerData.class, MyModuleServerData::new);
// Add a command to your module
commands.add(new MyCommand(this));
}
}
See the source code of Solstice modules for practical examples.
Solstice Identifier¶
The SolsticeIdentifier class is a wrapper around Minecraft's ResourceLocation/Identifier to facilitate multiversion compatibility.