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  boolean doInstall(java.io.File downloadedFile, org.bukkit.command.CommandSender causer)
          Does some post-installation-activities, like extracting zips or relaoding the plugin.
 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.
 java.lang.String getLatestVersion(org.bukkit.command.CommandSender causer)
          Returns the latest plugin version.
 org.bukkit.plugin.Plugin getPlugin()
          Returns the Plugin which started the updater.
 org.bukkit.plugin.Plugin getUpdatePlugin()
          Return the Plugin which should be updated.
 int hashCode()
           
 boolean isNewVersionAvaiable()
          Returns if a new version is avaiable.
 boolean isNewVersionAvaiable(org.bukkit.command.CommandSender causer)
          Returns if a new version is avaiable.
protected abstract  java.lang.String parseVersion(java.lang.String title)
          Parses the version out of the BukkitDev-upload-title.
 java.lang.String toString()
           
 void tryInstall()
          This method checks the latest plugin-version and updates it if required.
 boolean tryInstall(org.bukkit.command.CommandSender causer)
          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

getPlugin

public org.bukkit.plugin.Plugin getPlugin()
Returns the Plugin which started the updater.

Returns:
The Plugin which started the updater.

getUpdatePlugin

public org.bukkit.plugin.Plugin getUpdatePlugin()
Return the Plugin which should be updated.

Returns:
The Plugin which should be updated.

tryInstall

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


tryInstall

public boolean tryInstall(org.bukkit.command.CommandSender causer)
This method checks the latest plugin-version and updates it if required. You can call this in onEnable().

Parameters:
causer - The executor of the action.
Returns:
If the installation was successful.

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.

getLatestVersion

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

Parameters:
causer - The executor of the action.
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)
Parses the version out of the BukkitDev-upload-title.

Parameters:
title - The BukkitDev-upload-title.
Returns:
The parsed version.

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.

isNewVersionAvaiable

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

Parameters:
causer - The executor of the action.
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 boolean doInstall(java.io.File downloadedFile,
                                     org.bukkit.command.CommandSender causer)
                              throws java.io.IOException
Does some post-installation-activities, like extracting zips or relaoding the plugin.

Parameters:
downloadedFile - The downloaded file from BukkitDev.
causer - The executor of the action.
Returns:
If the post-installation-activity was successful.
Throws:
java.io.IOException - If something goes wrong with the post-installation-activities.

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