Ulises Licenses | Ulises SoftwareUlises Licenses
FeaturesPricingAPIAnnouncements
Solutions
Java & Kotlin LicensingMinecraft Plugin LicensingBuiltByBit IntegrationPolymart Integration
Discord
Dashboard
  • Overview
  • Installation
  • Plugin Integration
  • Complete Example
  • API Methods
  • Connection Management
  • Auto-Update
  • Best Practices
  1. Docs
  2. /
  3. Complete Example

Complete PaperMC Java Plugin Example

Production-ready JavaPlugin lifecycle implementation incorporating configuration loading, initial license assertion, connection retry loop, and asynchronous periodic health checks.

MyBestPluginAntiCheat.java
Java
1public class MyBestPluginAntiCheat extends JavaPlugin {2    private FileConfiguration antileakConfig;3 4    @Override5    public void onEnable() {6        loadAntileakConfig();7 8        String productId = antileakConfig.getString("license.product-id");9        String licenseKey = antileakConfig.getString("license.key");10 11        if (productId.equals("your-product-id-here") || licenseKey.equals("your-license-key-here")) {12            getLogger().severe("License details not configured. Please edit antileak.yml");13            Bukkit.getPluginManager().disablePlugin(this);14            return;15        }16 17        validateLicense(productId, licenseKey);18    }19 20    private void validateLicense(String productId, String licenseKey) {21        getServer().getScheduler().runTaskAsynchronously(this, () -> {22            UlisesLib ulib = new UlisesLib();23            int attempts = 0;24 25            while (attempts < 5) {26                if (ulib.isLicenseValid(productId, licenseKey)) {27                    String discordId = ulib.getDiscordId(productId, licenseKey);28                    String expiresAt = ulib.getExpirationDate(productId, licenseKey);29 30                    getLogger().info("License validated for Discord ID: " + discordId);31                    getLogger().info("License expires: " + expiresAt);32 33                    getServer().getScheduler().runTask(this, () -> {34                        loadFeatures();35                        startPeriodicChecks();36                    });37                    return;38                }39 40                attempts++;41                String code = ulib.getLastErrorCode();42                if (!isTransientError(ulib) || attempts >= 5) {43                    getLogger().severe("License rejected (" + code + "). Disabling.");44                    getServer().getScheduler().runTask(this, () ->45                        Bukkit.getPluginManager().disablePlugin(this)46                    );47                    return;48                }49 50                getLogger().warning("Transient error (" + code + "). Retrying...");51                try {52                    Thread.sleep(5000L * attempts);53                } catch (InterruptedException e) {54                    Thread.currentThread().interrupt();55                    getServer().getScheduler().runTask(this, () ->56                        Bukkit.getPluginManager().disablePlugin(this)57                    );58                    return;59                }60            }61        });62    }63 64    private boolean isTransientError(UlisesLib ulib) {65        String code = ulib.getLastErrorCode();66        return code != null && (code.equals("NETWORK_ERROR") || code.equals("TIMEOUT")67            || code.equals("SERVER_ERROR") || code.equals("MAX_RETRIES")68            || code.equals("RATE_LIMIT") || code.equals("RATE_LIMIT_LOCAL"));69    }70 71    private final java.util.concurrent.atomic.AtomicInteger consecutiveDefinitiveFailures =72        new java.util.concurrent.atomic.AtomicInteger(0);73 74    private void startPeriodicChecks() {75        Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {76            UlisesLib ulib = new UlisesLib();77            String productId = antileakConfig.getString("license.product-id");78            String licenseKey = antileakConfig.getString("license.key");79 80            if (ulib.isLicenseValid(productId, licenseKey)) {81                consecutiveDefinitiveFailures.set(0);82                getLogger().info("Periodic license check passed.");83                return;84            }85 86            if (isTransientError(ulib)) {87                getLogger().warning("Transient error (" + ulib.getLastErrorCode() + "). Will retry next cycle.");88                return;89            }90 91            int failures = consecutiveDefinitiveFailures.incrementAndGet();92            if (failures >= 3) {93                getLogger().severe("License rejected (" + ulib.getLastErrorCode() + "). Disabling.");94                Bukkit.getScheduler().runTask(this, () ->95                    Bukkit.getPluginManager().disablePlugin(this)96                );97            } else {98                getLogger().warning("License check failed (" + ulib.getLastErrorCode() + "). Attempt " + failures + "/3.");99            }100        }, 20L * 60 * 10, 20L * 60 * 10);101    }102}
PREVIOUS MODULE← Plugin IntegrationNEXT MODULEAPI Methods →

Built by Ulises - Citymoon Dynamics

Ulises Licenses | Ulises SoftwareUlises Licenses | Ulises Software

License management for Minecraft plugins and Java applications.

Discord

Legal

  • Terms of Service
  • Privacy Policy
  • Refund Policy
  • DPA

Docs

  • Overview
  • Installation
  • Plugin Integration
  • Complete Example
  • API Methods
  • Connection Management
  • Auto-Update
  • Best Practices

History

  • Announcements
  • Citymoon Dynamics

Company

  • About
  • Security
  • Status
  • Contact

Solutions

  • Java & Kotlin
  • Minecraft Plugins
  • BuiltByBit
  • Polymart

© 2025-2030 Citymoon Dynamics (citymoon.org). All rights reserved.