-
Notifications
You must be signed in to change notification settings - Fork 6
Update Checking
If your plugin is uploaded to SpigotMC or Hangar, you can use BlueSlimeCore to check for newer versions.
To find your resource identifier number, first navigate to the overview page for your plugin on SpigotMC.
We will use CombatLogX as an example.
Once the page has loaded, review the address URL for your plugin. You will notice the name of your plugin, then a period, then some numbers.
The numbers are your resource identifier. In our example, the resource identifier for CombatLogX is 31689
.
Add the following code to your main plugin class. Your main class is the java file that extends JavaPlugin
.
import com.github.sirblobman.api.core.CorePlugin;
import com.github.sirblobman.api.update.SpigotUpdateManager;
@Override
public void onEnable() {
// Your other plugin code....
registerUpdateChecker();
}
private void registerUpdateChecker() {
long resourceId = 31689; // Replace this number with your plugin's identifier.
CorePlugin corePlugin = JavaPlugin.getPlugin(CorePlugin.class);
SpigotUpdateManager updateManager = corePlugin.getSpigotUpdateManager();
updateManager.addResource(this, resourceId);
}
BlueSlimeCore will now check for updates when a server using your plugin is started up. Here is an example output log.
Server owners can disable the update checker by setting update-checker: false
in the BlueSlimeCore config.yml file.
[BlueSlimeCore] [Update Checker] A possible update was found for plugin 'CombatLogX'.
[BlueSlimeCore] [Update Checker] Current Version: 11.1.0.2.915
[BlueSlimeCore] [Update Checker] New Version: 11.1.0.3.929
[BlueSlimeCore] [Update Checker] Download Link: https://www.spigotmc.org/resources/31689/
To find your resource identifier number, first navigate to the hangar page for your plugin on Hangar. We will use BlueSlimeCore as an example. Once the page has loaded, review the address URL for your plugin. You will notice the author and project name. The author is the first part of the URL, the project name is the second part. In our example, the author name is 'SirBlobman' and the project name is 'BlueSlimeCore'
Add the following code to your main plugin class. Your main class is the java file that extends JavaPlugin
.
import com.github.sirblobman.api.core.CorePlugin;
import com.github.sirblobman.api.update.HangarInfo;
import com.github.sirblobman.api.update.HangarUpdateManager;
@Override
public void onEnable() {
// Your other plugin code....
registerUpdateChecker();
}
private void registerUpdateChecker() {
String author = "SirBlobman"; // Replace with your author
String projectName = "BlueSlimeCore"; // Replace with your project name
HangarInfo hangarInfo = new HangarInfo(author, projectName);
CorePlugin corePlugin = JavaPlugin.getPlugin(CorePlugin.class);
HangarUpdateManager hangarUpdateManager = corePlugin.getHangarUpdateManager();
hangarUpdateManager.addProject(this, hangarInfo);
}
BlueSlimeCore will now check for updates when a server using your plugin is started up. Here is an example output log.
Server owners can disable the update checker by setting update-checker: false
in the BlueSlimeCore config.yml file.
[Blue Slime Core] [Update Checker] Found a possible update for plugin 'BlueSlimeCore'.
[Blue Slime Core] [Update Checker] Local Version: 2.9.0.Beta-331
[Blue Slime Core] [Update Checker] Remote Version: 2.7.0.303
[Blue Slime Core] [Update Checker] Download Link: https://hangar.papermc.io/SirBlobman/BlueSlimeCore