Auto Updater
On this page we will explain how to implement the integrated auto updater into your plugin.
Onsharp has its own integrated really simple auto updater. The auto updater works with just one line of code fully automatically. But first we need to clarify what you need to do
Prerequisites
A prepared plugin main class
A fileserver or another server you can upload two permanent files
The users need to enable the KeepPluginsUpdated flag in the config
The Updating Data
For the auto updater to know if an update is available, where the current files are located, and if a changelog exists when an update is performed, you must place a JSON file on a server that provides the auto updater with exactly this information.
The following is a template of how this file should look like:
Now we will briefly explain the individual keys:
version: The version of the plugin which is currently the latest one
changelog: An url or some text which will be printed to the console after updating
files: An url to a zip file containing the files of the plugin
plugin_file: The name of the plugin (without the extension .dll) how the plugin file is called
Please note that the only valid archive file is the ZIP format, other formats like 7-ZIP or WinRAR are not supported.
Implementation
Now we will show you, how to implement the auto updater into your code. Therefore, open op your plugin main class, our example looks like this:
To get the auto updater to work you just need to add one line of code. You need to mark the main class with the AutoUpdater
attribute, like so:
You need to replace the UPDATING_DATA_URL with the url to the JSON file which contains your updating data.
So when you upload a new update, all you have to do is create a ZIP archive containing all the new files, change the url to the ZIP archive in the updating data, change the version to the new version and optionally add a changelog. Now when the server is started, the auto updater will do the rest.
How does the Auto Updater work?
If you would like to know, how the auto updater works, you can read on. If you are not interested, you can stop here.
The procedure of the auto updater is quite simple. Therefore we try to make it as simple as possible for you.
ORE starts and loads plugin for plugin. For each plugin it does the following:
Check if the main class is tagged with AutoUpdater
If yes, download the updating data
Compare the received updating data version with the current version
If the versions are not the same, download the archive
Extract the archive, move the files to the right places, clean up
And reload the plugin
Last updated
Was this helpful?