public class Updater
extends java.lang.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.
An example of a good configuration option would be something similar to 'auto-update: true' - if this value is set to false you may NOT run the auto-updater.
If you are unsure about these rules, please read the plugin submission guidelines: http://goo.gl/8iU5l
Modifier and Type | Class and Description |
---|---|
static class |
Updater.UpdateResult
Gives the dev the result of the update process.
|
static class |
Updater.UpdateType
Allows the dev to specify the type of update that will be run.
|
Constructor and Description |
---|
Updater(org.bukkit.plugin.Plugin plugin,
java.util.logging.Logger logger,
java.lang.String slug,
java.io.File file,
java.lang.String permission)
Initialize the updater
|
Modifier and Type | Method and Description |
---|---|
long |
getFileSize()
Get the total bytes of the file (can only be used after running a version check or a normal run).
|
java.lang.String |
getLatestVersionString()
Get the version string latest file avaliable online.
|
Updater.UpdateResult |
getResult()
Get the result of the update process.
|
boolean |
pluginFile(java.lang.String name)
Check if the name of a jar is one of the plugins currently installed, used for extracting the correct files out of a zip.
|
Updater.UpdateResult |
update(Updater.UpdateType type,
boolean announce)
Update the plugin.
|
public Updater(org.bukkit.plugin.Plugin plugin, java.util.logging.Logger logger, java.lang.String slug, java.io.File file, java.lang.String permission)
plugin
- The plugin that is checking for an update.slug
- The dev.bukkit.org slug of the project (http://dev.bukkit.org/server-mods/SLUG_IS_HERE)file
- The file that the plugin is running from, get this by doing this.getFile() from within your main class.permission
- Permission needed to read the output of the update process.public Updater.UpdateResult update(Updater.UpdateType type, boolean announce)
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 consolepublic Updater.UpdateResult getResult()
public long getFileSize()
public java.lang.String getLatestVersionString()
public boolean pluginFile(java.lang.String name)