This commit is contained in:
drtshock
2014-01-20 12:22:09 -07:00
parent 0362170e9b
commit 2d6ac31c2c
19 changed files with 660 additions and 641 deletions
@@ -1,5 +1,11 @@
package com.drtshock.playervaults.util;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
@@ -9,24 +15,18 @@ import java.util.logging.Level;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
/**
* Check dev.bukkit.org to find updates for a given plugin, and download the updates if needed.
* <p/>
* <b>VERY, VERY IMPORTANT</b>: 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.
* <br>
* It is a <b>BUKKIT POLICY</b> that you include a boolean value in your config that prevents the auto-updater from running <b>AT ALL</b>.
* <br>
* If you fail to include this option in your config, your plugin will be <b>REJECTED</b> when you attempt to submit it to dev.bukkit.org.
* <b>VERY, VERY IMPORTANT</b>: 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. <br> It is a
* <b>BUKKIT POLICY</b> that you include a boolean value in your config that prevents the auto-updater from running
* <b>AT ALL</b>. <br> If you fail to include this option in your config, your plugin will be <b>REJECTED</b> when you
* attempt to submit it to dev.bukkit.org.
* <p/>
* 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.
* <br>
* If you are unsure about these rules, please read the plugin submission guidelines: http://goo.gl/8iU5l
* 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. <br> If you are unsure about these rules, please read the plugin submission
* guidelines: http://goo.gl/8iU5l
*
* @author Gravity
*/
@@ -92,7 +92,8 @@ public class Updater {
*/
FAIL_DBO,
/**
* When running the version check, the file on DBO did not contain the a version in the format 'vVersion' such as 'v1.0'.
* When running the version check, the file on DBO did not contain the a version in the format 'vVersion' such
* as 'v1.0'.
*/
FAIL_NOVERSION,
/**
@@ -130,10 +131,11 @@ public class Updater {
/**
* Initialize the updater
*
* @param plugin The plugin that is checking for an update.
* @param id The dev.bukkit.org id of the project
* @param file The file that the plugin is running from, get this by doing this.getFile() from within your main class.
* @param type Specify the type of update this will be. See {@link UpdateType}
* @param plugin The plugin that is checking for an update.
* @param id The dev.bukkit.org id of the project
* @param file The file that the plugin is running from, get this by doing this.getFile() from within your main
* class.
* @param type Specify the type of update this will be. See {@link UpdateType}
* @param announce True if the program should announce the progress of new updates in console
*/
public Updater(Plugin plugin, int id, File file, Updater.UpdateType type, boolean announce) {
@@ -230,8 +232,8 @@ public class Updater {
}
/**
* 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.
* 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.
*/
private void waitForThread() {
if (thread != null && thread.isAlive()) {
@@ -378,7 +380,8 @@ public class Updater {
}
/**
* Check if the name of a jar is one of the plugins currently installed, used for extracting the correct files out of a zip.
* 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 pluginFile(String name) {
for (File file : new File("plugins").listFiles()) {
@@ -390,7 +393,8 @@ public class Updater {
}
/**
* Check to see if the program should continue by evaluation whether the plugin is already updated, or shouldn't be updated
* Check to see if the program should continue by evaluation whether the plugin is already updated, or shouldn't be
* updated
*/
private boolean versionCheck(String title) {
if (type != Updater.UpdateType.NO_VERSION_CHECK) {