public class PluginUpdater extends Object
VERY, VERY IMPORTANT: Because there are no standards for adding auto-update toggles in
your plugin's config, this system provides NO CHECK WITH YOUR CONFIG to make sure the user has
allowed auto-updating.
It is a BUKKIT POLICY that you include a boolean value in your config that prevents the
auto-updater from running AT ALL.
If you fail to include this option in your config, your plugin will be REJECTED when you
attempt to submit it to dev.bukkit.org.
| Modifier and Type | Class and Description |
|---|---|
static class |
PluginUpdater.ReleaseType
Represents the various release types of a file on BukkitDev.
|
static interface |
PluginUpdater.UpdateCallback
Called on main thread when the updater has finished working, regardless of result.
|
static class |
PluginUpdater.UpdateResult
Gives the developer the result of the update process.
|
static class |
PluginUpdater.UpdateType
Allows the developer to specify the type of update that will be run.
|
| Constructor and Description |
|---|
PluginUpdater(org.bukkit.plugin.Plugin plugin,
int id,
File file,
PluginUpdater.UpdateType type,
boolean announce)
Initialize the updater.
|
PluginUpdater(org.bukkit.plugin.Plugin plugin,
int id,
File file,
PluginUpdater.UpdateType type,
PluginUpdater.UpdateCallback callback)
Initialize the updater with the provided callback.
|
PluginUpdater(org.bukkit.plugin.Plugin plugin,
int id,
File file,
PluginUpdater.UpdateType type,
PluginUpdater.UpdateCallback callback,
boolean announce)
Initialize the updater with the provided callback.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getLatestFileLink()
Get the latest version's direct file link.
|
String |
getLatestGameVersion()
Get the latest version's game version (such as "CB 1.2.5-R1.0").
|
String |
getLatestName()
Get the latest version's name (such as "Project v1.0").
|
PluginUpdater.ReleaseType |
getLatestType()
Get the latest version's release type.
|
PluginUpdater.UpdateResult |
getResult()
Get the result of the update process.
|
boolean |
isLatestVersionCheck()
Gets the latest version check result
|
boolean |
shouldUpdate(String localVersion,
String remoteVersion)
If you wish to run mathematical versioning checks, edit this method.
|
public PluginUpdater(org.bukkit.plugin.Plugin plugin,
int id,
File file,
PluginUpdater.UpdateType type,
boolean announce)
plugin - The plugin that is checking for an update.id - The dev.bukkit.org id of the project.file - The file that the plugin is running from, get this by doing this.getFile() from
within your main class.type - Specify the type of update this will be. See PluginUpdater.UpdateTypeannounce - True if the program should announce the progress of new updates in console.public PluginUpdater(org.bukkit.plugin.Plugin plugin,
int id,
File file,
PluginUpdater.UpdateType type,
PluginUpdater.UpdateCallback callback)
plugin - The plugin that is checking for an update.id - The dev.bukkit.org id of the project.file - The file that the plugin is running from, get this by doing this.getFile() from
within your main class.type - Specify the type of update this will be. See PluginUpdater.UpdateTypecallback - The callback instance to notify when the updater has finishedpublic PluginUpdater(org.bukkit.plugin.Plugin plugin,
int id,
File file,
PluginUpdater.UpdateType type,
PluginUpdater.UpdateCallback callback,
boolean announce)
plugin - The plugin that is checking for an update.id - The dev.bukkit.org id of the project.file - The file that the plugin is running from, get this by doing this.getFile() from
within your main class.type - Specify the type of update this will be. See PluginUpdater.UpdateTypecallback - The callback instance to notify when the updater has finishedannounce - True if the program should announce the progress of new updates in console.public String getLatestFileLink()
public String getLatestGameVersion()
public String getLatestName()
public PluginUpdater.ReleaseType getLatestType()
PluginUpdater.ReleaseTypepublic PluginUpdater.UpdateResult getResult()
PluginUpdater.UpdateResultpublic boolean isLatestVersionCheck()
public boolean shouldUpdate(String localVersion, String remoteVersion)
With default behavior, updater will NOT verify that a remote version available on BukkitDev which is not this version is indeed an "update". If a version is present on BukkitDev that is not the version that is currently running, updater will assume that it is a newer version. This is because there is no standard versioning scheme, and creating a calculation that can determine whether a new update is actually an update is sometimes extremely complicated.
updater will call this method from versionCheck() before deciding whether the remote
version is actually an update. If you have a specific versioning scheme with which a
mathematical determination can be reliably made to decide whether one version is higher than
another, you may revise this method, using the local and remote version parameters, to execute
the appropriate check.
Returning a value of false will tell the update process that this is NOT a new version. Without revision, this method will always consider a remote version at all different from that of the local version a new update.
localVersion - the current versionremoteVersion - the remote versionCopyright © 2017. All rights reserved.