From 0d4aab35b9d2f58c532e2874b947e3a64586c469 Mon Sep 17 00:00:00 2001 From: drtshock Date: Wed, 9 Oct 2013 22:32:26 -0500 Subject: [PATCH] let's ping mbaxter with this commit --- .../com/drtshock/playervaults/Listeners.java | 8 +- .../drtshock/playervaults/PlayerVaults.java | 32 +- .../playervaults/util/EconomyOperations.java | 11 +- .../drtshock/playervaults/util/Updater.java | 537 +++++++++++++++++- .../playervaults/util/VaultHolder.java | 5 +- .../playervaults/util/VaultManager.java | 13 +- src/main/resources/config.yml | 7 +- 7 files changed, 546 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/drtshock/playervaults/Listeners.java b/src/main/java/com/drtshock/playervaults/Listeners.java index 11328ac..9048094 100644 --- a/src/main/java/com/drtshock/playervaults/Listeners.java +++ b/src/main/java/com/drtshock/playervaults/Listeners.java @@ -38,7 +38,6 @@ public class Listeners implements Listener { public Listeners(PlayerVaults playerVaults) { this.plugin = playerVaults; } - VaultManager vm = new VaultManager(plugin); /** @@ -198,7 +197,9 @@ public class Listeners implements Listener { } /** - * Check if the location given is a sign, and if so, remove it from the signs.yml file + * Check if the location given is a sign, and if so, remove it from the + * signs.yml file + * * @param location The location to check */ public void blockChangeCheck(Location location) { @@ -213,7 +214,8 @@ public class Listeners implements Listener { } /** - * Don't let a player open a trading inventory OR a minecart while he has his vault open. + * Don't let a player open a trading inventory OR a minecart while he has + * his vault open. */ @EventHandler public void onInteractEntity(PlayerInteractEntityEvent event) { diff --git a/src/main/java/com/drtshock/playervaults/PlayerVaults.java b/src/main/java/com/drtshock/playervaults/PlayerVaults.java index cbd516f..7ef062f 100644 --- a/src/main/java/com/drtshock/playervaults/PlayerVaults.java +++ b/src/main/java/com/drtshock/playervaults/PlayerVaults.java @@ -5,6 +5,7 @@ import com.drtshock.playervaults.commands.SignSetInfo; import com.drtshock.playervaults.commands.VaultViewInfo; import com.drtshock.playervaults.util.Lang; import com.drtshock.playervaults.util.Updater; +import com.drtshock.playervaults.util.Updater.UpdateType; import com.drtshock.playervaults.util.VaultManager; import java.io.File; @@ -96,26 +97,15 @@ public class PlayerVaults extends JavaPlugin { * Checks for available updates. */ public void checkUpdate() { - new BukkitRunnable() { - - public void run() { - if (getConfig().getBoolean("check-update")) { - if (getConfig().getBoolean("check-update")) { - try { - Updater u = new Updater(getDescription().getVersion()); - if (UPDATE = u.getUpdate()) { - LINK = u.getLink(); - NEWVERSION = u.getNewVersion(); - } - } catch (Exception e) { - getLogger().log(Level.WARNING, "Failed to check for updates."); - getLogger().log(Level.WARNING, "Report this stack trace to gomeow."); - e.printStackTrace(); - } - } - } + if (getConfig().getBoolean("check-update")) { + Updater.UpdateType updateType = (getConfig().getBoolean("download-update") ? UpdateType.DEFAULT : UpdateType.NO_DOWNLOAD); + Updater updater = new Updater(this, 50123, this.getFile(), updateType, false); + UPDATE = updater.getResult() == Updater.UpdateResult.UPDATE_AVAILABLE; + NEWVERSION = updater.getLatestName(); + if (updater.getResult() == Updater.UpdateResult.SUCCESS) { + getLogger().info("Successfully updated Playervaults for next restart!"); } - }.runTaskAsynchronously(this); + } } /** @@ -219,9 +209,9 @@ public class PlayerVaults extends JavaPlugin { /** * Set an object in the config.yml * - * @param path The path in the config. + * @param path The path in the config. * @param object What to be saved. - * @param conf Where to save the object. + * @param conf Where to save the object. */ public void setInConfig(String path, T object, YamlConfiguration conf) { conf.set(path, object); diff --git a/src/main/java/com/drtshock/playervaults/util/EconomyOperations.java b/src/main/java/com/drtshock/playervaults/util/EconomyOperations.java index 2f42718..375d87f 100644 --- a/src/main/java/com/drtshock/playervaults/util/EconomyOperations.java +++ b/src/main/java/com/drtshock/playervaults/util/EconomyOperations.java @@ -18,7 +18,6 @@ import org.bukkit.entity.Player; public class EconomyOperations { private static YamlConfiguration BUKKIT_CONFIG = new YamlConfiguration(); - public static PlayerVaults PLUGIN; public EconomyOperations(PlayerVaults instance) throws IOException, InvalidConfigurationException { @@ -29,12 +28,14 @@ public class EconomyOperations { /** * Have a player pay to open a vault. + * * @param player The player to pay. * @return The transaction success. */ public static boolean payToOpen(Player player, int number) { - if (!BUKKIT_CONFIG.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !PlayerVaults.USE_VAULT) + if (!BUKKIT_CONFIG.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !PlayerVaults.USE_VAULT) { return true; + } if (PlayerVaults.VM.vaultExists(player.getName(), number)) { return payToCreate(player); } else { @@ -50,12 +51,14 @@ public class EconomyOperations { /** * Have a player pay to create a vault. + * * @param player The player to pay. * @return The transaction success */ public static boolean payToCreate(Player player) { - if (!BUKKIT_CONFIG.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !PlayerVaults.USE_VAULT) + if (!BUKKIT_CONFIG.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !PlayerVaults.USE_VAULT) { return true; + } double cost = BUKKIT_CONFIG.getDouble("economy.cost-to-create", 100); EconomyResponse resp = PlayerVaults.ECON.withdrawPlayer(player.getName(), cost); @@ -69,6 +72,7 @@ public class EconomyOperations { /** * Have a player get his money back when vault is deleted. + * * @param player The player to receive the money. * @return The transaction success. */ @@ -97,5 +101,4 @@ public class EconomyOperations { } return false; } - } diff --git a/src/main/java/com/drtshock/playervaults/util/Updater.java b/src/main/java/com/drtshock/playervaults/util/Updater.java index 47c97d8..d5fefef 100644 --- a/src/main/java/com/drtshock/playervaults/util/Updater.java +++ b/src/main/java/com/drtshock/playervaults/util/Updater.java @@ -1,49 +1,524 @@ +/* + * Updater for Bukkit. + * + * This class provides the means to safely and easily update a plugin, or check to see if it is updated using dev.bukkit.org + */ + package com.drtshock.playervaults.util; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; +import java.io.*; +import java.net.MalformedURLException; import java.net.URL; +import java.net.URLConnection; +import java.util.Enumeration; +import java.util.logging.Level; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; +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 org.w3c.dom.Document; -import org.xml.sax.SAXException; +/** + * 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 + * + * @author Gravity + */ public class Updater { - public Updater(String v) throws SAXException, IOException, ParserConfigurationException { - String oldVersion = v.substring(0, 5); - HttpURLConnection connection = (HttpURLConnection) new URL("http://dev.bukkit.org/projects/playervaults/files.rss").openConnection(); - connection.setConnectTimeout(10000); - connection.setReadTimeout(10000); - connection.setUseCaches(false); - Document feed = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(connection.getInputStream()); - newVersion = feed.getElementsByTagName("title").item(1).getTextContent().substring(1); - String link = feed.getElementsByTagName("link").item(1).getTextContent(); - this.link = new BufferedReader(new InputStreamReader(new URL("http://is.gd/create.php?format=simple&url=" + link).openStream())).readLine(); - if (v.contains("SNAPSHOT") && !newVersion.equals(oldVersion)) { - update = false; + private Plugin plugin; + private Updater.UpdateType type; + private String versionName; + private String versionLink; + private String versionType; + private String versionGameVersion; + + private int sizeLine; // Used for detecting file size + private int multiplier; // Used for determining when to broadcast download updates + private boolean announce; // Whether to announce file downloads + + private URL url; // Connecting to RSS + private File file; // The plugin's file + private Thread thread; // Updater thread + + private int id = -1; // Project's Curse ID + private String apiKey = null; // BukkitDev ServerMods API key + private static final String TITLE_VALUE = "name"; // Gets remote file's title + private static final String LINK_VALUE = "downloadUrl"; // Gets remote file's download link + private static final String TYPE_VALUE = "releaseType"; // Gets remote file's release type + private static final String VERSION_VALUE = "gameVersion"; // Gets remote file's build version + private static final String QUERY = "/servermods/files?projectIds="; // Path to GET + private static final String HOST = "https://api.curseforge.com"; // Slugs will be appended to this to get to the project's RSS feed + + private String[] noUpdateTag = {"-DEV", "-PRE", "-SNAPSHOT"}; // If the version number contains one of these, don't update. + private static final int BYTE_SIZE = 1024; // Used for downloading files + private YamlConfiguration config; // Config file + private String updateFolder = YamlConfiguration.loadConfiguration(new File("bukkit.yml")).getString("settings.update-folder"); // The folder that downloads will be placed in + private Updater.UpdateResult result = Updater.UpdateResult.SUCCESS; // Used for determining the outcome of the update process + + /** + * Gives the dev the result of the update process. Can be obtained by called getResult(). + */ + public enum UpdateResult { + /** + * The updater found an update, and has readied it to be loaded the next time the server restarts/reloads. + */ + SUCCESS, + /** + * The updater did not find an update, and nothing was downloaded. + */ + NO_UPDATE, + /** + * The server administrator has disabled the updating system + */ + DISABLED, + /** + * The updater found an update, but was unable to download it. + */ + FAIL_DOWNLOAD, + /** + * For some reason, the updater was unable to contact dev.bukkit.org to download the file. + */ + 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'. + */ + FAIL_NOVERSION, + /** + * The id provided by the plugin running the updater was invalid and doesn't exist on DBO. + */ + FAIL_BADID, + /** + * The server administrator has improperly configured their API key in the configuration + */ + FAIL_APIKEY, + /** + * The updater found an update, but because of the UpdateType being set to NO_DOWNLOAD, it wasn't downloaded. + */ + UPDATE_AVAILABLE + } + + /** + * Allows the dev to specify the type of update that will be run. + */ + public enum UpdateType { + /** + * Run a version check, and then if the file is out of date, download the newest version. + */ + DEFAULT, + /** + * Don't run a version check, just find the latest update and download it. + */ + NO_VERSION_CHECK, + /** + * Get information about the version and the download size, but don't actually download anything. + */ + NO_DOWNLOAD + } + + /** + * 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 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) { + this.plugin = plugin; + this.type = type; + this.announce = announce; + this.file = file; + this.id = id; + + File pluginFile = plugin.getDataFolder().getParentFile(); + File updaterFile = new File(pluginFile, "Updater"); + File updaterConfigFile = new File(updaterFile, "config.yml"); + + if (!updaterFile.exists()) { + updaterFile.mkdir(); + } + if (!updaterConfigFile.exists()) { + try { + updaterConfigFile.createNewFile(); + } catch (IOException e) { + plugin.getLogger().log(Level.SEVERE, "The updater could not create a configuration in {0}", updaterFile.getAbsolutePath()); + e.printStackTrace(); + } + } + config = YamlConfiguration.loadConfiguration(updaterConfigFile); + + config.addDefault("api-key", "PUT_API_KEY_HERE"); + config.addDefault("disable", false); + + if (config.get("api-key", null) == null) { + config.options().copyDefaults(true); + try { + config.save(updaterConfigFile); + } catch (IOException e) { + plugin.getLogger().log(Level.SEVERE, "The updater could not save the configuration in {0}", updaterFile.getAbsolutePath()); + e.printStackTrace(); + } + } + + if (config.getBoolean("disable")) { + result = Updater.UpdateResult.DISABLED; return; } - update = !newVersion.equals(oldVersion); + + String key = config.getString("api-key"); + if (key.equalsIgnoreCase("PUT_API_KEY_HERE") || key.equals("")) { + key = null; + } + + apiKey = key; + + try { + url = new URL(HOST + QUERY + id); + } catch (MalformedURLException e) { + plugin.getLogger().log(Level.SEVERE, "The project ID provided for updating, {0} is invalid.", id); + result = Updater.UpdateResult.FAIL_BADID; + e.printStackTrace(); + } + + thread = new Thread(new Updater.UpdateRunnable()); + thread.start(); } - private String newVersion; - private String link; - private boolean update; - - public boolean getUpdate() { - return update; + /** + * Get the result of the update process. + */ + public Updater.UpdateResult getResult() { + waitForThread(); + return result; } - public String getNewVersion() { - return newVersion; + /** + * Get the latest version's release type (release, beta, or alpha) + */ + public String getLatestType() { + waitForThread(); + return versionType; } - public String getLink() { - return link; + /** + * Get the latest version's game version + */ + public String getLatestGameVersion() { + waitForThread(); + return versionGameVersion; + } + + /** + * Get the latest version's name + */ + public String getLatestName() { + waitForThread(); + return versionName; + } + + /** + * 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()) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + /** + * Save an update from dev.bukkit.org into the server's update folder. + */ + private void saveFile(File folder, String file, String u) { + if (!folder.exists()) { + folder.mkdir(); + } + BufferedInputStream in = null; + FileOutputStream fout = null; + try { + // Download the file + URL url = new URL(u); + int fileLength = url.openConnection().getContentLength(); + in = new BufferedInputStream(url.openStream()); + fout = new FileOutputStream(folder.getAbsolutePath() + "/" + file); + + byte[] data = new byte[BYTE_SIZE]; + int count; + if (announce) plugin.getLogger().log(Level.INFO, "About to download a new update: {0}", versionName); + long downloaded = 0; + while ((count = in.read(data, 0, BYTE_SIZE)) != -1) { + downloaded += count; + fout.write(data, 0, count); + int percent = (int) (downloaded * 100 / fileLength); + if (announce & (percent % 10 == 0)) { + plugin.getLogger().log(Level.INFO, "Downloading update: {0}% of {1} bytes.", new Object[]{percent, fileLength}); + } + } + //Just a quick check to make sure we didn't leave any files from last time... + for (File xFile : new File("plugins/" + updateFolder).listFiles()) { + if (xFile.getName().endsWith(".zip")) { + xFile.delete(); + } + } + // Check to see if it's a zip file, if it is, unzip it. + File dFile = new File(folder.getAbsolutePath() + "/" + file); + if (dFile.getName().endsWith(".zip")) { + // Unzip + unzip(dFile.getCanonicalPath()); + } + if (announce) plugin.getLogger().info("Finished updating."); + } catch (Exception ex) { + plugin.getLogger().warning("The auto-updater tried to download a new update, but was unsuccessful."); + result = Updater.UpdateResult.FAIL_DOWNLOAD; + } finally { + try { + if (in != null) { + in.close(); + } + if (fout != null) { + fout.close(); + } + } catch (Exception ex) { + } + } + } + + /** + * Part of Zip-File-Extractor, modified by H31IX for use with Bukkit + */ + private void unzip(String file) { + try { + File fSourceZip = new File(file); + String zipPath = file.substring(0, file.length() - 4); + ZipFile zipFile = new ZipFile(fSourceZip); + Enumeration e = zipFile.entries(); + while (e.hasMoreElements()) { + ZipEntry entry = e.nextElement(); + File destinationFilePath = new File(zipPath, entry.getName()); + destinationFilePath.getParentFile().mkdirs(); + if (entry.isDirectory()) { + continue; + } else { + BufferedInputStream bis = new BufferedInputStream(zipFile.getInputStream(entry)); + int b; + byte buffer[] = new byte[BYTE_SIZE]; + FileOutputStream fos = new FileOutputStream(destinationFilePath); + BufferedOutputStream bos = new BufferedOutputStream(fos, BYTE_SIZE); + while ((b = bis.read(buffer, 0, BYTE_SIZE)) != -1) { + bos.write(buffer, 0, b); + } + bos.flush(); + bos.close(); + bis.close(); + String name = destinationFilePath.getName(); + if (name.endsWith(".jar") && pluginFile(name)) { + destinationFilePath.renameTo(new File("plugins/" + updateFolder + "/" + name)); + } + } + entry = null; + destinationFilePath = null; + } + e = null; + zipFile.close(); + zipFile = null; + + // Move any plugin data folders that were included to the right place, Bukkit won't do this for us. + for (File dFile : new File(zipPath).listFiles()) { + if (dFile.isDirectory()) { + if (pluginFile(dFile.getName())) { + File oFile = new File("plugins/" + dFile.getName()); // Get current dir + File[] contents = oFile.listFiles(); // List of existing files in the current dir + for (File cFile : dFile.listFiles()) // Loop through all the files in the new dir + { + boolean found = false; + for (File xFile : contents) // Loop through contents to see if it exists + { + if (xFile.getName().equals(cFile.getName())) { + found = true; + break; + } + } + if (!found) { + // Move the new file into the current dir + cFile.renameTo(new File(oFile.getCanonicalFile() + "/" + cFile.getName())); + } else { + // This file already exists, so we don't need it anymore. + cFile.delete(); + } + } + } + } + dFile.delete(); + } + new File(zipPath).delete(); + fSourceZip.delete(); + } catch (IOException ex) { + plugin.getLogger().warning("The auto-updater tried to unzip a new update file, but was unsuccessful."); + result = Updater.UpdateResult.FAIL_DOWNLOAD; + ex.printStackTrace(); + } + new File(file).delete(); + } + + /** + * 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()) { + if (file.getName().equals(name)) { + return true; + } + } + return false; + } + + /** + * 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) { + String version = plugin.getDescription().getVersion(); + if (title.split(" v").length == 2) { + String remoteVersion = title.split(" v")[1].split(" ")[0]; // Get the newest file's version number + int remVer = -1, curVer = 0; + try { + remVer = calVer(remoteVersion); + curVer = calVer(version); + } catch (NumberFormatException nfe) { + remVer = -1; + } + if (hasTag(version) || version.equalsIgnoreCase(remoteVersion) || curVer >= remVer) { + // We already have the latest version, or this build is tagged for no-update + result = Updater.UpdateResult.NO_UPDATE; + return false; + } + } else { + // The file's name did not contain the string 'vVersion' + plugin.getLogger().log(Level.WARNING, "The author of this plugin ({0}) has misconfigured their Auto Update system", plugin.getDescription().getAuthors().get(0)); + plugin.getLogger().warning("Files uploaded to BukkitDev should contain the version number, seperated from the name by a 'v', such as PluginName v1.0"); + plugin.getLogger().warning("Please notify the author of this error."); + result = Updater.UpdateResult.FAIL_NOVERSION; + return false; + } + } + return true; + } + + /** + * Used to calculate the version string as an Integer + */ + private Integer calVer(String s) throws NumberFormatException { + if (s.contains(".")) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < s.length(); i++) { + Character c = s.charAt(i); + if (Character.isLetterOrDigit(c)) { + sb.append(c); + } + } + return Integer.parseInt(sb.toString()); + } + return Integer.parseInt(s); + } + + /** + * Evaluate whether the version number is marked showing that it should not be updated by this program + */ + private boolean hasTag(String version) { + for (String string : noUpdateTag) { + if (version.contains(string)) { + return true; + } + } + return false; + } + + private boolean read() { + try { + URLConnection conn = url.openConnection(); + conn.setConnectTimeout(5000); + + if (apiKey != null) { + conn.addRequestProperty("X-API-Key", apiKey); + } + conn.addRequestProperty("User-Agent", "Updater (by Gravity)"); + + conn.setDoOutput(true); + + final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String response = reader.readLine(); + + JSONArray array = (JSONArray) JSONValue.parse(response); + + if (array.size() == 0) { + plugin.getLogger().log(Level.WARNING, "The updater could not find any files for the project id {0}", id); + result = Updater.UpdateResult.FAIL_BADID; + return false; + } + + versionName = (String) ((JSONObject) array.get(array.size() - 1)).get(TITLE_VALUE); + versionLink = (String) ((JSONObject) array.get(array.size() - 1)).get(LINK_VALUE); + versionType = (String) ((JSONObject) array.get(array.size() - 1)).get(TYPE_VALUE); + versionGameVersion = (String) ((JSONObject) array.get(array.size() - 1)).get(VERSION_VALUE); + + return true; + } catch (IOException e) { + if (e.getMessage().contains("HTTP response code: 403")) { + plugin.getLogger().warning("dev.bukkit.org rejected the API key provided in plugins/Updater/config.yml"); + plugin.getLogger().warning("Please double-check your configuration to ensure it is correct."); + result = Updater.UpdateResult.FAIL_APIKEY; + } else { + plugin.getLogger().warning("The updater could not contact dev.bukkit.org for updating."); + plugin.getLogger().warning("If you have not recently modified your configuration and this is the first time you are seeing this message, the site may be experiencing temporary downtime."); + result = Updater.UpdateResult.FAIL_DBO; + } + e.printStackTrace(); + return false; + } + } + + + private class UpdateRunnable implements Runnable { + + @Override + public void run() { + if (url != null) { + // Obtain the results of the project's file feed + if (read()) { + if (versionCheck(versionName)) { + if (versionLink != null && type != Updater.UpdateType.NO_DOWNLOAD) { + String name = file.getName(); + // If it's a zip file, it shouldn't be downloaded as the plugin's name + if (versionLink.endsWith(".zip")) { + String[] split = versionLink.split("/"); + name = split[split.length - 1]; + } + saveFile(new File("plugins/" + updateFolder), name, versionLink); + } else { + result = Updater.UpdateResult.UPDATE_AVAILABLE; + } + } + } + } + } } } \ No newline at end of file diff --git a/src/main/java/com/drtshock/playervaults/util/VaultHolder.java b/src/main/java/com/drtshock/playervaults/util/VaultHolder.java index 4feb6f2..3f2a0a0 100644 --- a/src/main/java/com/drtshock/playervaults/util/VaultHolder.java +++ b/src/main/java/com/drtshock/playervaults/util/VaultHolder.java @@ -4,8 +4,8 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; /** - * Represents a VaultHolder to assist in detection of Player Vaults from - * other plugins. + * Represents a VaultHolder to assist in detection of Player Vaults from other + * plugins. */ public class VaultHolder implements InventoryHolder { @@ -43,5 +43,4 @@ public class VaultHolder implements InventoryHolder { public Inventory getInventory() { return inventory; } - } diff --git a/src/main/java/com/drtshock/playervaults/util/VaultManager.java b/src/main/java/com/drtshock/playervaults/util/VaultManager.java index b5c7c48..0f612ed 100644 --- a/src/main/java/com/drtshock/playervaults/util/VaultManager.java +++ b/src/main/java/com/drtshock/playervaults/util/VaultManager.java @@ -16,7 +16,8 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.inventory.Inventory; /** - * A class for managing actual IO to the files, loading inventories, and saving them. + * A class for managing actual IO to the files, loading inventories, and saving + * them. */ public class VaultManager { @@ -25,11 +26,11 @@ public class VaultManager { public VaultManager(PlayerVaults instance) { this.plugin = instance; } - private final String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults"; /** * Saves the inventory to the specified player and vault number. + * * @param inventory The inventory to be saved. * @param player The player of whose file to save to. * @param number The vault number. @@ -57,6 +58,7 @@ public class VaultManager { /** * Load the player's vault and return it. + * * @param holder The holder of the vault. * @param number The vault number. */ @@ -89,7 +91,9 @@ public class VaultManager { } /** - * Gets an inventory without storing references to it. Used for dropping a players inventories on death. + * Gets an inventory without storing references to it. Used for dropping a + * players inventories on death. + * * @param holder The holder of the vault. * @param number The vault number. * @return The inventory of the specified holder and vault number. @@ -115,6 +119,7 @@ public class VaultManager { /** * Deletes a players vault. + * * @param sender The sender of whom to send messages to. * @param holder The vault holder. * @param number The vault number. @@ -137,6 +142,7 @@ public class VaultManager { /** * Get the holder's vault file. Create if doesn't exist. + * * @param holder The vault holder. * @return The holder's vault config file. */ @@ -159,6 +165,7 @@ public class VaultManager { /** * Save the players vault file. + * * @param holder The vault holder of whose file to save. * @param yaml The config to save. * @throws IOException Uh oh! diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 52319eb..f9237a1 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,9 +2,12 @@ # http://dev.bukkit.org/server-mods/playervaults # Made with love :3 -# Whether or not you want to check for updates. -# Will not download an update, that is your job :) +# Whether or not you want to check for updates. +# Will not download an update by default, that is your job :) +# We do not break between minecraft versions so auto updating should not be an issue. +# But it's always a smart idea to read changelogs and such first :) check-update: true +download-update: false # Settings here are for economy integration. playervaults.free bypasses it. economy: