public class Updater
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Updater.ReleaseType
Represents the various release types of a file on BukkitDev.
|
static class |
Updater.UpdateResult
Gives the developer the result of the update process.
|
static class |
Updater.UpdateType
Allows the developer to specify the type of update that will be run.
|
Constructor and Description |
---|
Updater(org.bukkit.plugin.Plugin plugin,
int id,
java.io.File file,
Updater.UpdateType type,
boolean announce)
Initialize the updater.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getLatestFileLink()
Get the latest version's direct file link.
|
java.lang.String |
getLatestGameVersion()
Get the latest version's game version (such as "CB 1.2.5-R1.0").
|
java.lang.String |
getLatestName()
Get the latest version's name (such as "Project v1.0").
|
Updater.ReleaseType |
getLatestType()
Get the latest version's release type.
|
Updater.UpdateResult |
getResult()
Get the result of the update process.
|
boolean |
shouldUpdate(java.lang.String localVersion,
java.lang.String remoteVersion)
If you wish to run mathematical versioning checks, edit this method.
|
public Updater(org.bukkit.plugin.Plugin plugin, int id, java.io.File file, Updater.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 Updater.UpdateType
announce
- True if the program should announce the progress of new updates in console.public Updater.UpdateResult getResult()
Updater.UpdateResult
public Updater.ReleaseType getLatestType()
Updater.ReleaseType
public java.lang.String getLatestGameVersion()
public java.lang.String getLatestName()
public java.lang.String getLatestFileLink()
public boolean shouldUpdate(java.lang.String localVersion, java.lang.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(String)
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 version