Reference Implementation
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
public class MyBestPluginAntiCheat extends JavaPlugin { private FileConfiguration antileakConfig; @Override public void onEnable() { loadAntileakConfig(); String productId = antileakConfig.getString("license.product-id"); String licenseKey = antileakConfig.getString("license.key"); if (productId.equals("your-product-id-here") || licenseKey.equals("your-license-key-here")) { getLogger().severe("License details not configured. Please edit antileak.yml"); Bukkit.getPluginManager().disablePlugin(this); return; } validateLicense(productId, licenseKey); } private void validateLicense(String productId, String licenseKey) { UlisesLib ulib = new UlisesLib(); while (true) { if (ulib.isLicenseValid(productId, licenseKey)) { String discordId = ulib.getDiscordId(productId, licenseKey); String expiresAt = ulib.getExpirationDate(productId, licenseKey); getLogger().info("License validated for Discord ID: " + discordId); getLogger().info("License expires: " + expiresAt); loadFeatures(); startPeriodicChecks(); break; } else { String error = ulib.getLastError(); getLogger().severe("License validation failed: " + error); if (error != null && error.contains("Unable to connect to the backend server")) { getLogger().warning("Retrying connection in 30 seconds..."); try { Thread.sleep(30000); } catch (InterruptedException e) { Bukkit.getPluginManager().disablePlugin(this); break; } } else { Bukkit.getPluginManager().disablePlugin(this); break; } } } } private void startPeriodicChecks() { Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> { UlisesLib ulib = new UlisesLib(); String productId = antileakConfig.getString("license.product-id"); String licenseKey = antileakConfig.getString("license.key"); if (!ulib.isLicenseValid(productId, licenseKey)) { String error = ulib.getLastError(); getLogger().severe("Periodic license check failed: " + error); if (!error.contains("Unable to connect to the backend server")) { Bukkit.getScheduler().runTask(this, () -> Bukkit.getPluginManager().disablePlugin(this) ); } } else { getLogger().info("Periodic license check passed."); } }, 20L * 60 * 10, 20L * 60 * 10); }}Built by Ulises - Citymoon Dynamics