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
@@ -52,6 +52,7 @@ public enum Lang {
/**
* Lang enum constructor.
*
* @param path The string path.
* @param start The default string.
*/
@@ -62,6 +63,7 @@ public enum Lang {
/**
* Set the {@code YamlConfiguration} to use.
*
* @param config The config to set.
*/
public static void setFile(YamlConfiguration config) {
@@ -77,6 +79,7 @@ public enum Lang {
/**
* Get the default value of the path.
*
* @return The default value of the path.
*/
public String getDefault() {
@@ -85,6 +88,7 @@ public enum Lang {
/**
* Get the path to the string.
*
* @return The path to the string.
*/
public String getPath() {
@@ -34,23 +34,12 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.io.*;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
@@ -148,6 +137,7 @@ public class Metrics {
* website. Plotters can be added to the graph object returned.
*
* @param name The name of the graph
*
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
*/
public Graph createGraph(final String name) {
@@ -488,6 +478,7 @@ public class Metrics {
* GZip compress a string of bytes
*
* @param input
*
* @return
*/
public static byte[] gzip(String input) {
@@ -529,6 +520,7 @@ public class Metrics {
* @param json
* @param key
* @param value
*
* @throws UnsupportedEncodingException
*/
private static void appendJSONPair(StringBuilder json, String key, String value) throws UnsupportedEncodingException {
@@ -561,6 +553,7 @@ public class Metrics {
* Escape a string to create a valid JSON string
*
* @param text
*
* @return
*/
private static String escapeJSON(String text) {
@@ -607,6 +600,7 @@ public class Metrics {
* Encode text as UTF-8
*
* @param text the text to encode
*
* @return the encoded text, as UTF-8
*/
private static String urlEncode(final String text) throws UnsupportedEncodingException {
@@ -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) {