Skip to content

Auto Updates

NJDaeger edited this page Jun 16, 2017 · 2 revisions

We have made a new auto-update system that, not only detects an update, but it automatically downloads it and installs it.


How it works

When we made the core, we knew right away that we wanted to create an auto-updater and installer so people wouldn't have to go out of their way to install something new, and so people would actually update their plugins. Our idea was to hook into GitHub and grab the repository the source code was in, and then from there, we grabbed the releases section of the repo. We would then get the latest release and compare its release tag to the version specified in the plugin.yml.

How to implement

Implementing the auto-updater is quite easy, all we need to do is go to the main class of the plugin you're currently in and call the method updateCheck(String repositoryOwner, String repositoryName, boolean autoUpdate). The auto update boolean is used for determining to automatically install the update or not.

Quick example:

package com.coalesce;

import com.coalesce.plugin.CoPlugin;

public final class CoPerms extends CoPlugin {
	
	@Override
	public void onPluginEnable() {
		this.updateCheck("Project-Coalesce", "Core", true);
		
	}
	
	@Override
	public void onPluginDisable() {
	
	}

The CoalesceCore will then handle the request and download the update in another thread.

Clone this wiki locally