com.quartercode.quarterbukkit.api
Class Updater

java.lang.Object
  extended by com.quartercode.quarterbukkit.api.Updater
Direct Known Subclasses:
QuarterBukkitUpdater

public abstract class Updater
extends java.lang.Object

This class is for checking the plugin-versions and updating plugins.


Field Summary
protected  org.bukkit.plugin.Plugin plugin
           
protected  java.lang.String slug
           
protected  org.bukkit.plugin.Plugin updatePlugin
           
 
Constructor Summary
Updater(org.bukkit.plugin.Plugin plugin, org.bukkit.plugin.Plugin updatePlugin, java.lang.String slug)
          Creates a new abstract Updater.
 
Method Summary
protected abstract  void doInstall(java.io.File downloadedFile)
           
 boolean equals(java.lang.Object obj)
           
 void extract(java.io.File zip, java.lang.String zipPath, java.io.File destinationFile)
          Extracts some Files in a zip.
 java.lang.String getLatestVersion()
          Returns the latest plugin version.
 int hashCode()
           
 boolean isNewVersionAvaiable()
          Returns if a new version is avaiable.
protected abstract  java.lang.String parseVersion(java.lang.String title)
           
 java.lang.String toString()
           
 void tryInstall()
          This method checks the latest plugin-version and updates it if required.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

plugin

protected final org.bukkit.plugin.Plugin plugin

updatePlugin

protected final org.bukkit.plugin.Plugin updatePlugin

slug

protected final java.lang.String slug
Constructor Detail

Updater

public Updater(org.bukkit.plugin.Plugin plugin,
               org.bukkit.plugin.Plugin updatePlugin,
               java.lang.String slug)
Creates a new abstract Updater.

Parameters:
plugin - The plugin which starts the updater.
updatePlugin - The plugin which should be updated.
slug - The BukkitDev-slug. Say we have the URL http://dev.bukkit.org/server-mods/quarterbukkit, quarterbukkit is the slug.
Method Detail

tryInstall

public void tryInstall()
This method checks the latest plugin-version and updates it if required. You can call this in onEnable().


getLatestVersion

public java.lang.String getLatestVersion()
                                  throws java.io.IOException,
                                         javax.xml.stream.XMLStreamException
Returns the latest plugin version.

Returns:
The latest plugin version.
Throws:
java.io.IOException - If something goes wrong with the file system.
javax.xml.stream.XMLStreamException - If something goes wrong with the version XML-feed.

parseVersion

protected abstract java.lang.String parseVersion(java.lang.String title)

isNewVersionAvaiable

public boolean isNewVersionAvaiable()
                             throws java.io.IOException,
                                    javax.xml.stream.XMLStreamException
Returns if a new version is avaiable.

Returns:
If a new version is avaiable.
Throws:
java.io.IOException - If something goes wrong with the file system.
javax.xml.stream.XMLStreamException - If something goes wrong with the version XML-feed.

doInstall

protected abstract void doInstall(java.io.File downloadedFile)
                           throws java.io.IOException
Throws:
java.io.IOException

extract

public void extract(java.io.File zip,
                    java.lang.String zipPath,
                    java.io.File destinationFile)
             throws java.util.zip.ZipException,
                    java.io.IOException
Extracts some Files in a zip. You can use this in doInstall().

Parameters:
zip - The zip as a File.
zipPath - The path in the zip file (relative).
destinationFile - Where to extract the File.
Throws:
java.util.zip.ZipException - If something goes wrong in the ZipFile.
java.io.IOException - If something goes wrong with the file system.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object