me.armar.plugins.autorank.updater
Class Updater

java.lang.Object
  extended by me.armar.plugins.autorank.updater.Updater

public class Updater
extends java.lang.Object

Check dev.bukkit.org to find updates for a given plugin, and download the updates if needed.

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

Version:
2.0
Author:
Gravity

Nested Class Summary
static class Updater.UpdateResult
          Gives the dev the result of the update process.
private  class Updater.UpdateRunnable
           
static class Updater.UpdateType
          Allows the dev to specify the type of update that will be run.
 
Field Summary
private  boolean announce
           
private  java.lang.String apiKey
           
private static int BYTE_SIZE
           
private  org.bukkit.configuration.file.YamlConfiguration config
           
private  java.io.File file
           
private static java.lang.String HOST
           
private  int id
           
private static java.lang.String LINK_VALUE
           
private static java.lang.String[] NO_UPDATE_TAG
           
private  org.bukkit.plugin.Plugin plugin
           
private static java.lang.String QUERY
           
private  Updater.UpdateResult result
           
private  java.lang.Thread thread
           
private static java.lang.String TITLE_VALUE
           
private  Updater.UpdateType type
           
private static java.lang.String TYPE_VALUE
           
private  java.lang.String updateFolder
           
private  java.net.URL url
           
private static java.lang.String VERSION_VALUE
           
private  java.lang.String versionGameVersion
           
private  java.lang.String versionLink
           
private  java.lang.String versionName
           
private  java.lang.String versionType
           
 
Constructor Summary
Updater(org.bukkit.plugin.Plugin plugin, int id, java.io.File file, Updater.UpdateType type, boolean announce)
          Initialize the updater
 
Method Summary
 java.lang.String getLatestFileLink()
          Get the latest version's file link.
 java.lang.String getLatestGameVersion()
          Get the latest version's game version.
 java.lang.String getLatestName()
          Get the latest version's name.
 java.lang.String getLatestType()
          Get the latest version's release type (release, beta, or alpha).
 Updater.UpdateResult getResult()
          Get the result of the update process.
private  boolean hasTag(java.lang.String version)
          Evaluate whether the version number is marked showing that it should not be updated by this program
private  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.
private  boolean read()
           
private  void saveFile(java.io.File folder, java.lang.String file, java.lang.String u)
          Save an update from dev.bukkit.org into the server's update folder.
private  void unzip(java.lang.String file)
          Part of Zip-File-Extractor, modified by Gravity for use with Bukkit
private  boolean versionCheck(java.lang.String title)
          Check to see if the program should continue by evaluation whether the plugin is already updated, or shouldn't be updated
private  void waitForThread()
          As the result of Updater output depends on the thread's completion, it is necessary to wait for the thread to finish before allowing anyone to check the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

plugin

private org.bukkit.plugin.Plugin plugin

type

private Updater.UpdateType type

versionName

private java.lang.String versionName

versionLink

private java.lang.String versionLink

versionType

private java.lang.String versionType

versionGameVersion

private java.lang.String versionGameVersion

announce

private boolean announce

url

private java.net.URL url

file

private java.io.File file

thread

private java.lang.Thread thread

id

private int id

apiKey

private java.lang.String apiKey

TITLE_VALUE

private static final java.lang.String TITLE_VALUE
See Also:
Constant Field Values

LINK_VALUE

private static final java.lang.String LINK_VALUE
See Also:
Constant Field Values

TYPE_VALUE

private static final java.lang.String TYPE_VALUE
See Also:
Constant Field Values

VERSION_VALUE

private static final java.lang.String VERSION_VALUE
See Also:
Constant Field Values

QUERY

private static final java.lang.String QUERY
See Also:
Constant Field Values

HOST

private static final java.lang.String HOST
See Also:
Constant Field Values

NO_UPDATE_TAG

private static final java.lang.String[] NO_UPDATE_TAG

BYTE_SIZE

private static final int BYTE_SIZE
See Also:
Constant Field Values

config

private org.bukkit.configuration.file.YamlConfiguration config

updateFolder

private java.lang.String updateFolder

result

private Updater.UpdateResult result
Constructor Detail

Updater

public Updater(org.bukkit.plugin.Plugin plugin,
               int id,
               java.io.File file,
               Updater.UpdateType type,
               boolean announce)
Initialize the updater

Parameters:
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
Method Detail

getResult

public Updater.UpdateResult getResult()
Get the result of the update process.


getLatestType

public java.lang.String getLatestType()
Get the latest version's release type (release, beta, or alpha).


getLatestGameVersion

public java.lang.String getLatestGameVersion()
Get the latest version's game version.


getLatestName

public java.lang.String getLatestName()
Get the latest version's name.


getLatestFileLink

public java.lang.String getLatestFileLink()
Get the latest version's file link.


waitForThread

private void waitForThread()
As the result of Updater output depends on the thread's completion, it is necessary to wait for the thread to finish before allowing anyone to check the result.


saveFile

private void saveFile(java.io.File folder,
                      java.lang.String file,
                      java.lang.String u)
Save an update from dev.bukkit.org into the server's update folder.


unzip

private void unzip(java.lang.String file)
Part of Zip-File-Extractor, modified by Gravity for use with Bukkit


pluginFile

private 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.


versionCheck

private boolean versionCheck(java.lang.String title)
Check to see if the program should continue by evaluation whether the plugin is already updated, or shouldn't be updated


hasTag

private boolean hasTag(java.lang.String version)
Evaluate whether the version number is marked showing that it should not be updated by this program


read

private boolean read()