Skip to content

NighterDevelopment/PluginUpdateCore

Repository files navigation

PluginUpdateCore

Automatic update checking and configuration management library for Minecraft plugins.

Features

  • Modrinth Update Checker - Automatic update detection from Modrinth.
  • Version Comparison - Semantic versioning support.
  • Config Auto-Update - Version-tracked configuration file updates.
  • Smart Backups - Only creates backups when meaningful changes are detected.
  • Rich Notifications - Formatted console and in-game update messages.
  • User Preservation - Keeps user customizations during config updates.
  • Daily Limits - Prevents notification spam, once per day per player.

Installation

Maven

<repositories>
    <repository>
        <id>jitpack</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.github.NighterDevelopment</groupId>
        <artifactId>PluginUpdateCore</artifactId>
        <version>1.0.4</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

Gradle Kotlin DSL

repositories {
    maven("https://jitpack.io")
}

dependencies {
    implementation("com.github.NighterDevelopment:PluginUpdateCore:1.0.4")
}

Local Gradle Tasks

Preview the update log layout:

./gradlew printUpdateLog

On Windows:

.\gradlew.bat printUpdateLog

Quick Start

Update Checker

import io.github.pluginupdatecore.updater.UpdateChecker;

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        // Find your project ID at: https://modrinth.com/plugin/YOUR_PROJECT
        new UpdateChecker(this, "YOUR_MODRINTH_PROJECT_ID");
    }
}

Update notifications are not blocked by Modrinth server-version metadata. If an update is newer than the installed plugin version, the console and eligible operators can still be notified.

Config Updater

import io.github.pluginupdatecore.updater.ConfigUpdater;

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        ConfigUpdater configUpdater = new ConfigUpdater(this);
        configUpdater.checkAndUpdateConfig();

        reloadConfig();
    }
}

How It Works

UpdateChecker

  1. Fetches all versions from the Modrinth API.
  2. Finds the latest release version.
  3. Compares the latest version with the current plugin version.
  4. Displays a console notification when an update is available.
  5. Sends in-game notifications to operators once per day.

Console Output Example

========================================================================
                            UPDATE AVAILABLE
========================================================================

Plugin          : PluginUpdateCore
Current version : 1.0.4
Latest version  : 1.1.0

Download        : https://modrinth.com/plugin/example/version/1.1.0

========================================================================

ConfigUpdater

  1. Adds a config_version key to config.yml.
  2. Compares the file version with the plugin version.
  3. Loads current user configuration and bundled defaults.
  4. Creates a timestamped backup when meaningful changes are detected.
  5. Merges user values with new defaults.
  6. Saves the updated configuration and reloads the plugin config.

Finding Your Modrinth Project ID

  1. Go to your plugin page on Modrinth.
  2. Look at the URL: https://modrinth.com/plugin/YOUR_PROJECT_ID.
  3. The project ID is the slug after /plugin/.

API Reference

UpdateChecker

Method Description
new UpdateChecker(plugin, projectId) Initialize and start checking
checkForUpdates() Manually check for updates asynchronously
isUpdateAvailable() Check if an update is available
getLatestVersion() Get latest version string
getDownloadUrl() Get Modrinth download page URL
getDirectLink() Get direct JAR download URL
isServerVersionSupported() Always returns true; compatibility gating has been removed

ConfigUpdater

Method Description
new ConfigUpdater(plugin) Create updater instance
checkAndUpdateConfig() Check and update config if needed
getCurrentVersion() Get current plugin version
getConfigVersionKey() Get version key name (config_version)

Version

Method Description
new Version(string) Parse version string
compareTo(other) Compare versions
isNewerThan(other) Check if newer
isOlderThan(other) Check if older
isEqualTo(other) Check if equal
getMajor() Get major version number
getMinor() Get minor version number
getPatch() Get patch version number
getBuild() Get build version number

Requirements

  • Minecraft 1.21+
  • Java 21+
  • Paper or compatible forks

License

This library is licensed under the MIT License. See LICENSE for details.