Section 05 / Distribution Lifecycle
Automated Binary Update & Integrity Verification
UlisesLib includes built-in methods for checking updates, downloading the latest jar, and verifying its integrity. All security validations (license status, HWID binding, IP limits) are handled automatically by the library.
boolean checkForUpdate(String productId, String licenseKey, String currentVersion)
Checks if a newer version of the product jar is available. Returns true if an update exists.
Invocation Example
Java
String currentVersion = "1.0.0";if (ulib.checkForUpdate(productId, licenseKey, currentVersion)) { getLogger().info("Update available! Downloading..."); ulib.downloadUpdate(productId, licenseKey, hwid);}File downloadUpdate(String productId, String licenseKey, String hwid)
Downloads the latest jar file. Automatically handles HWID binding on first download. Returns the downloaded File, or null if download fails.
Invocation Example
Java
String hwid = ulib._getHwid();File updatedJar = ulib.downloadUpdate(productId, licenseKey, hwid);if (updatedJar != null) { getLogger().info("Update downloaded: " + updatedJar.getName()); if (ulib.verifyChecksum(productId, licenseKey, hwid, updatedJar)) { getLogger().info("Checksum verified!"); }}boolean verifyChecksum(String productId, String licenseKey, String hwid, File jarFile)
Verifies the SHA-256 checksum of the downloaded jar file to ensure file integrity.
Invocation Example
Java
File jarFile = new File("plugins/MyPlugin.jar");boolean valid = ulib.verifyChecksum(productId, licenseKey, hwid, jarFile);if (!valid) { getLogger().warning("Checksum mismatch! File may be corrupted.");}String getCurrentVersion(String productId, String licenseKey)
Returns the latest version string of the product jar available on the server.
Invocation Example
Java
String latestVersion = ulib.getCurrentVersion(productId, licenseKey);getLogger().info("Latest version available: " + latestVersion);Automated Pre-Download Assertions
Each update payload download verifies the following conditions prior to file release:
- License Status: Only active, non-expired licenses can download updates
- HWID Binding: Hardware ID is validated and bound to the license on first download
- IP Limit: Respects the IP limit configured per license
Complete Auto-Update Implementation Routine
checkAndApplyUpdate.java
Java
private void checkAndApplyUpdate(String productId, String licenseKey) { String currentVersion = this.getDescription().getVersion(); String hwid = ulib.getHardwareId(); if (ulib.checkForUpdate(productId, licenseKey, currentVersion)) { String latestVersion = ulib.getCurrentVersion(productId, licenseKey); getLogger().info("New version available: " + latestVersion + " (current: " + currentVersion + ")"); File updatedJar = ulib.downloadUpdate(productId, licenseKey, hwid); if (updatedJar != null) { if (ulib.verifyChecksum(productId, licenseKey, hwid, updatedJar)) { getLogger().info("Update downloaded and verified successfully!"); getLogger().info("Restart the server to apply the update."); } else { getLogger().warning("Checksum verification failed. Update may be corrupted."); } } } else { getLogger().info("Plugin is up to date."); }}Built by Ulises - Citymoon Dynamics