Minecraft Mods
SunLicense Integration Guide for Minecraft Mods
Last updated
public class ModLicenseManager {
private final SunLicenseAPI licenseApi;
private static final Logger LOGGER = LogManager.getLogger();
public ModLicenseManager() {
this.licenseApi = SunLicenseAPI.getLicense(
"YOUR-LICENSE-KEY",
YOUR_PRODUCT_ID,
"1.0.0",
"YOUR_API_URL"
);
}
public boolean validateLicense() {
try {
licenseApi.validate();
return true;
} catch (IOException e) {
LOGGER.error("License validation failed: " + e.getMessage());
return false;
}
}
}public class YourMod {
private ModLicenseManager licenseManager;
public void onInitialize() { // For Fabric
// OR
public void init(FMLCommonSetupEvent event) { // For Forge
licenseManager = new ModLicenseManager();
if (!licenseManager.validateLicense()) {
LOGGER.error("Invalid license - Mod will not function!");
// Disable mod functionality
return;
}
// Continue with mod initialization
}
}