🟪
SunLicense Docs
  • Welcome
  • Getting Started
    • Quickstart
    • VPS Setup
  • API Documentation
    • License API
    • Java API
  • Automations
    • BuiltByBit Automation
    • Discord Automation
  • PRODUCT INTEGRATIONS
    • Minecraft Plugins
    • Server Software
    • Minecraft Mods
    • Discord Bots
    • FiveM Projects
    • PHP Projects
    • Python Projects
    • JavaScript Projects
    • Lua Projects
  • SERVICES
    • Managed Hosting
  • LINKS
    • Discord
    • Store
    • Java API Wrapper
    • Sample Project
    • Pterodactyl Egg
    • Other Products
Powered by GitBook
On this page
  • Prerequisites
  • Integration Steps
  • Best Practices
  • Common Issues
  1. PRODUCT INTEGRATIONS

Minecraft Mods

SunLicense Integration Guide for Minecraft Mods

Prerequisites

  • Forge/Fabric mod development environment

  • Gradle

  • SunLicense API credentials

Integration Steps

1. Add Repository and Dependency

In your build.gradle:

repositories {
    maven {
        url "https://repo.hapangama.com/releases"
    }
}

dependencies {
    implementation 'com.hapangama:SunLicenseAPI:1.0.3'
}

2. Create License Manager

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;
        }
    }
}

3. Implement in Mod Main Class

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
    }
}

Best Practices

  1. Mod Loading

    • Validate before initializing features

    • Provide clear feedback to users

    • Handle offline mode gracefully

  2. Feature Management

    • Graceful feature disabling

    • Clear user communication

    • Cache validation results

Common Issues

  1. Mod Loading Failures

    • Verify license key

    • Check network connectivity

    • Confirm dependency inclusion

  2. Runtime Problems

    • Monitor mod logs

    • Check for network issues

    • Verify license status

PreviousServer SoftwareNextDiscord Bots

Last updated 4 months ago