diff --git a/src/main/java/com/drtshock/playervaults/Listeners.java b/src/main/java/com/drtshock/playervaults/Listeners.java index da1b5ba..c47c40f 100644 --- a/src/main/java/com/drtshock/playervaults/Listeners.java +++ b/src/main/java/com/drtshock/playervaults/Listeners.java @@ -1,5 +1,11 @@ package com.drtshock.playervaults; +import com.drtshock.playervaults.commands.VaultOperations; +import com.drtshock.playervaults.commands.VaultViewInfo; +import com.drtshock.playervaults.util.DropOnDeath; +import com.drtshock.playervaults.util.Lang; +import com.drtshock.playervaults.util.VaultManager; + import java.io.IOException; import org.bukkit.ChatColor; @@ -25,12 +31,6 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.inventory.Inventory; -import com.drtshock.playervaults.commands.VaultOperations; -import com.drtshock.playervaults.commands.VaultViewInfo; -import com.drtshock.playervaults.util.DropOnDeath; -import com.drtshock.playervaults.util.Lang; -import com.drtshock.playervaults.util.VaultManager; - public class Listeners implements Listener { public PlayerVaults plugin; @@ -53,7 +53,7 @@ public class Listeners implements Listener { VaultViewInfo info = PlayerVaults.IN_VAULT.get(p.getName()); try { vm.saveVault(inv, info.getHolder(), info.getNumber()); - } catch(IOException e) { + } catch (IOException e) { } PlayerVaults.OPENINVENTORIES.remove(info.toString()); } diff --git a/src/main/java/com/drtshock/playervaults/PlayerVaults.java b/src/main/java/com/drtshock/playervaults/PlayerVaults.java index 1e194ad..575bb54 100644 --- a/src/main/java/com/drtshock/playervaults/PlayerVaults.java +++ b/src/main/java/com/drtshock/playervaults/PlayerVaults.java @@ -1,5 +1,13 @@ package com.drtshock.playervaults; +import com.drtshock.playervaults.commands.Commands; +import com.drtshock.playervaults.commands.SignSetInfo; +import com.drtshock.playervaults.commands.VaultViewInfo; +import com.drtshock.playervaults.util.Lang; +import com.drtshock.playervaults.util.Metrics; +import com.drtshock.playervaults.util.Updater; +import com.drtshock.playervaults.util.VaultManager; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -19,14 +27,6 @@ import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; -import com.drtshock.playervaults.commands.Commands; -import com.drtshock.playervaults.commands.SignSetInfo; -import com.drtshock.playervaults.commands.VaultViewInfo; -import com.drtshock.playervaults.util.Lang; -import com.drtshock.playervaults.util.Metrics; -import com.drtshock.playervaults.util.Updater; -import com.drtshock.playervaults.util.VaultManager; - public class PlayerVaults extends JavaPlugin { public static PlayerVaults PLUGIN; @@ -77,7 +77,7 @@ public class PlayerVaults extends JavaPlugin { @Override public void onDisable() { - for(Player p:Bukkit.getOnlinePlayers()) { + for (Player p : Bukkit.getOnlinePlayers()) { if (IN_VAULT.containsKey(p.getName())) { p.closeInventory(); } @@ -91,7 +91,7 @@ public class PlayerVaults extends JavaPlugin { try { Metrics metrics = new Metrics(this); metrics.start(); - } catch(IOException e) { + } catch (IOException e) { e.printStackTrace(); } } @@ -111,7 +111,7 @@ public class PlayerVaults extends JavaPlugin { LINK = u.getLink(); NEWVERSION = u.getNewVersion(); } - } catch(Exception e) { + } catch (Exception e) { getLogger().log(Level.WARNING, "Failed to check for updates."); getLogger().log(Level.WARNING, "Report this stack trace to gomeow."); e.printStackTrace(); @@ -160,7 +160,7 @@ public class PlayerVaults extends JavaPlugin { if (!signs.exists()) { try { signs.createNewFile(); - } catch(IOException e) { + } catch (IOException e) { log.severe("PlayerVaults has encountered a fatal error trying to load the signs file."); log.severe("Please report this error to drtshock and gomeow."); e.printStackTrace(); @@ -185,7 +185,7 @@ public class PlayerVaults extends JavaPlugin { public void saveSigns() { try { PlayerVaults.SIGNS.save(PlayerVaults.SIGNS_FILE); - } catch(IOException e) { + } catch (IOException e) { log.severe("PlayerVaults has encountered an error trying to save the signs file."); log.severe("Please report this error to drtshock and gomeow."); e.printStackTrace(); @@ -215,7 +215,7 @@ public class PlayerVaults extends JavaPlugin { setInConfig("drop-on-death.inventories", dropInvs, conf); try { conf.save(configFile); - } catch(IOException e) { + } catch (IOException e) { e.printStackTrace(); } } @@ -246,14 +246,14 @@ public class PlayerVaults extends JavaPlugin { int read = 0; byte[] bytes = new byte[1024]; - while((read = defLangStream.read(bytes)) != -1) { + while ((read = defLangStream.read(bytes)) != -1) { out.write(bytes, 0, read); } YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defLangStream); Lang.setFile(defConfig); return; } - } catch(IOException e) { + } catch (IOException e) { e.printStackTrace(); // So they notice log.severe("[PlayerVaults] Couldn't create language file."); log.severe("[PlayerVaults] This is a fatal error. Now disabling"); @@ -262,14 +262,14 @@ public class PlayerVaults extends JavaPlugin { if (defLangStream != null) { try { defLangStream.close(); - } catch(IOException e) { + } catch (IOException e) { e.printStackTrace(); } } if (out != null) { try { out.close(); - } catch(IOException e) { + } catch (IOException e) { e.printStackTrace(); } @@ -277,7 +277,7 @@ public class PlayerVaults extends JavaPlugin { } } YamlConfiguration conf = YamlConfiguration.loadConfiguration(lang); - for(Lang item:Lang.values()) { + for (Lang item : Lang.values()) { if (conf.getString(item.getPath()) == null) { conf.set(item.getPath(), item.getDefault()); } @@ -287,7 +287,7 @@ public class PlayerVaults extends JavaPlugin { PlayerVaults.LANG_FILE = lang; try { conf.save(getLangFile()); - } catch(IOException e) { + } catch (IOException e) { log.log(Level.WARNING, "PlayerVaults: Failed to save lang.yml."); log.log(Level.WARNING, "PlayerVaults: Report this stack trace to drtshock and gomeow."); e.printStackTrace(); diff --git a/src/main/java/com/drtshock/playervaults/commands/Commands.java b/src/main/java/com/drtshock/playervaults/commands/Commands.java index c788fc7..7ce16cb 100644 --- a/src/main/java/com/drtshock/playervaults/commands/Commands.java +++ b/src/main/java/com/drtshock/playervaults/commands/Commands.java @@ -1,14 +1,14 @@ package com.drtshock.playervaults.commands; +import com.drtshock.playervaults.PlayerVaults; +import com.drtshock.playervaults.util.Lang; + import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.drtshock.playervaults.PlayerVaults; -import com.drtshock.playervaults.util.Lang; - public class Commands implements CommandExecutor { @Override @@ -68,7 +68,7 @@ public class Commands implements CommandExecutor { int i = 0; try { i = Integer.parseInt(args[0]); - } catch(NumberFormatException nfe) { + } catch (NumberFormatException nfe) { sender.sendMessage(Lang.TITLE.toString() + Lang.MUST_BE_NUMBER); sender.sendMessage(Lang.TITLE.toString() + "Usage: /" + label + " <#>"); return true; @@ -80,7 +80,7 @@ public class Commands implements CommandExecutor { int i = 0; try { i = Integer.parseInt(args[1]); - } catch(NumberFormatException nfe) { + } catch (NumberFormatException nfe) { sender.sendMessage(Lang.TITLE.toString() + Lang.MUST_BE_NUMBER); sender.sendMessage(Lang.TITLE.toString() + "Usage: /" + label + " <#>"); return true; diff --git a/src/main/java/com/drtshock/playervaults/commands/VaultOperations.java b/src/main/java/com/drtshock/playervaults/commands/VaultOperations.java index da4feee..bd995d2 100644 --- a/src/main/java/com/drtshock/playervaults/commands/VaultOperations.java +++ b/src/main/java/com/drtshock/playervaults/commands/VaultOperations.java @@ -1,5 +1,9 @@ package com.drtshock.playervaults.commands; +import com.drtshock.playervaults.PlayerVaults; +import com.drtshock.playervaults.util.EconomyOperations; +import com.drtshock.playervaults.util.Lang; + import java.io.IOException; import org.bukkit.ChatColor; @@ -7,10 +11,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; -import com.drtshock.playervaults.PlayerVaults; -import com.drtshock.playervaults.util.EconomyOperations; -import com.drtshock.playervaults.util.Lang; - public class VaultOperations { /** @@ -21,7 +21,7 @@ public class VaultOperations { */ public static boolean checkPerms(CommandSender sender, int number) { if (sender.hasPermission("playervaults.amount." + String.valueOf(number))) return true; - for(int x = number; x <= 99; x++) { + for (int x = number; x <= 99; x++) { if (sender.hasPermission("playervaults.amount." + String.valueOf(x))) return true; } return false; @@ -40,7 +40,7 @@ public class VaultOperations { number = Integer.parseInt(arg); if (number == 0) return false; - } catch(NumberFormatException nfe) { + } catch (NumberFormatException nfe) { player.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); return false; } @@ -79,7 +79,7 @@ public class VaultOperations { number = Integer.parseInt(arg); if (number == 0) return false; - } catch(NumberFormatException nfe) { + } catch (NumberFormatException nfe) { player.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); } Inventory inv = PlayerVaults.VM.loadVault(holder, number, true); @@ -109,7 +109,7 @@ public class VaultOperations { if (number == 0) player.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); return; - } catch(NumberFormatException nfe) { + } catch (NumberFormatException nfe) { player.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); } try { @@ -117,7 +117,7 @@ public class VaultOperations { PlayerVaults.VM.deleteVault(player, player.getName(), number); return; } - } catch(IOException e) { + } catch (IOException e) { player.sendMessage(Lang.TITLE.toString() + Lang.DELETE_VAULT_ERROR); } } else { @@ -141,12 +141,12 @@ public class VaultOperations { sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); return; } - } catch(NumberFormatException nfe) { + } catch (NumberFormatException nfe) { sender.sendMessage(Lang.TITLE.toString() + ChatColor.RED + Lang.MUST_BE_NUMBER); } try { PlayerVaults.VM.deleteVault(sender, holder, number); - } catch(IOException e) { + } catch (IOException e) { sender.sendMessage(Lang.TITLE.toString() + Lang.DELETE_VAULT_ERROR); } } else { diff --git a/src/main/java/com/drtshock/playervaults/util/DropOnDeath.java b/src/main/java/com/drtshock/playervaults/util/DropOnDeath.java index 98effc6..9aa8529 100644 --- a/src/main/java/com/drtshock/playervaults/util/DropOnDeath.java +++ b/src/main/java/com/drtshock/playervaults/util/DropOnDeath.java @@ -1,12 +1,12 @@ package com.drtshock.playervaults.util; +import com.drtshock.playervaults.PlayerVaults; + import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import com.drtshock.playervaults.PlayerVaults; - /** * A class that contains a method to drop the contents of a player's vault when they die. */ @@ -18,10 +18,10 @@ public class DropOnDeath { */ public static void drop(Player player) { Location loc = player.getLocation(); - for(int count = 1; count <= PlayerVaults.INVENTORIES_TO_DROP; count++) { + for (int count = 1; count <= PlayerVaults.INVENTORIES_TO_DROP; count++) { Inventory inv = PlayerVaults.VM.getVault(player.getName(), count); ItemStack[] stack = inv.getContents(); - for(ItemStack is:stack) { + for (ItemStack is : stack) { loc.getWorld().dropItemNaturally(loc, is); } } diff --git a/src/main/java/com/drtshock/playervaults/util/EconomyOperations.java b/src/main/java/com/drtshock/playervaults/util/EconomyOperations.java index 9149d01..4d150a3 100644 --- a/src/main/java/com/drtshock/playervaults/util/EconomyOperations.java +++ b/src/main/java/com/drtshock/playervaults/util/EconomyOperations.java @@ -1,5 +1,7 @@ package com.drtshock.playervaults.util; +import com.drtshock.playervaults.PlayerVaults; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -11,8 +13,6 @@ import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import com.drtshock.playervaults.PlayerVaults; - /** * A class that handles all economy operations. */ diff --git a/src/main/java/com/drtshock/playervaults/util/Metrics.java b/src/main/java/com/drtshock/playervaults/util/Metrics.java index da7ea64..98e3e58 100644 --- a/src/main/java/com/drtshock/playervaults/util/Metrics.java +++ b/src/main/java/com/drtshock/playervaults/util/Metrics.java @@ -28,12 +28,6 @@ package com.drtshock.playervaults.util; * either expressed or implied, of anybody else. */ -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginDescriptionFile; - import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -52,6 +46,12 @@ import java.util.Set; import java.util.UUID; import java.util.logging.Level; +import org.bukkit.Bukkit; +import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.configuration.file.YamlConfiguration; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginDescriptionFile; + /** *

* The metrics class obtains data about a plugin and submits statistics about it to the metrics backend. @@ -219,7 +219,7 @@ public class Metrics { */ @SuppressWarnings("deprecation") public boolean start() { - synchronized(optOutLock) { + synchronized (optOutLock) { // Did we opt out? if (isOptOut()) { return false; @@ -238,14 +238,14 @@ public class Metrics { public void run() { try { // This has to be synchronized or it can collide with the disable method. - synchronized(optOutLock) { + synchronized (optOutLock) { // Disable Task, if it is running and the server owner decided to // opt-out if (isOptOut() && taskId > 0) { plugin.getServer().getScheduler().cancelTask(taskId); taskId = -1; // Tell all plotters to stop gathering information. - for(Graph graph:graphs) { + for (Graph graph : graphs) { graph.onOptOut(); } } @@ -260,7 +260,7 @@ public class Metrics { // After the first post we set firstPost to false // Each post thereafter will be a ping firstPost = false; - } catch(IOException e) { + } catch (IOException e) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage()); } } @@ -276,14 +276,14 @@ public class Metrics { * @return true if metrics should be opted out of it */ public boolean isOptOut() { - synchronized(optOutLock) { + synchronized (optOutLock) { try { // Reload the metrics file configuration.load(getConfigFile()); - } catch(IOException ex) { + } catch (IOException ex) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); return true; - } catch(InvalidConfigurationException ex) { + } catch (InvalidConfigurationException ex) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); return true; } @@ -298,7 +298,7 @@ public class Metrics { */ public void enable() throws IOException { // This has to be synchronized or it can collide with the check in the task. - synchronized(optOutLock) { + synchronized (optOutLock) { // Check if the server owner has already set opt-out, if not, set it. if (isOptOut()) { configuration.set("opt-out", false); @@ -319,7 +319,7 @@ public class Metrics { */ public void disable() throws IOException { // This has to be synchronized or it can collide with the check in the task. - synchronized(optOutLock) { + synchronized (optOutLock) { // Check if the server owner has already set opt-out, if not, set it. if (!isOptOut()) { configuration.set("opt-out", true); @@ -375,13 +375,13 @@ public class Metrics { // Acquire a lock on the graphs, which lets us make the assumption we also lock everything // inside of the graph (e.g plotters) - synchronized(graphs) { + synchronized (graphs) { final Iterator iter = graphs.iterator(); - while(iter.hasNext()) { + while (iter.hasNext()) { final Graph graph = iter.next(); - for(Plotter plotter:graph.getPlotters()) { + for (Plotter plotter : graph.getPlotters()) { // The key name to send to the metrics server // The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top // Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME @@ -431,13 +431,13 @@ public class Metrics { } else { // Is this the first update this hour? if (response.contains("OK This is your first update this hour")) { - synchronized(graphs) { + synchronized (graphs) { final Iterator iter = graphs.iterator(); - while(iter.hasNext()) { + while (iter.hasNext()) { final Graph graph = iter.next(); - for(Plotter plotter:graph.getPlotters()) { + for (Plotter plotter : graph.getPlotters()) { plotter.reset(); } } @@ -455,7 +455,7 @@ public class Metrics { try { Class.forName("mineshafter.MineServer"); return true; - } catch(Exception e) { + } catch (Exception e) { return false; } } @@ -561,8 +561,7 @@ public class Metrics { /** * Called when the server owner decides to opt-out of Metrics while the server is running. */ - protected void onOptOut() { - } + protected void onOptOut() {} } @@ -614,8 +613,7 @@ public class Metrics { /** * Called after the website graphs have been updated */ - public void reset() { - } + public void reset() {} @Override public int hashCode() { diff --git a/src/main/java/com/drtshock/playervaults/util/Serialization.java b/src/main/java/com/drtshock/playervaults/util/Serialization.java index dfb201a..b5a2a89 100644 --- a/src/main/java/com/drtshock/playervaults/util/Serialization.java +++ b/src/main/java/com/drtshock/playervaults/util/Serialization.java @@ -28,7 +28,7 @@ public class Serialization { public static Map toMap(JSONObject object) throws JSONException { Map map = new HashMap(); Iterator keys = object.keys(); - while(keys.hasNext()) { + while (keys.hasNext()) { String key = (String) keys.next(); map.put(key, fromJson(object.get(key))); } @@ -49,7 +49,7 @@ public class Serialization { public static List toList(JSONArray array) throws JSONException { List list = new ArrayList(); - for(int i = 0; i < array.length(); i++) { + for (int i = 0; i < array.length(); i++) { list.add(fromJson(array.get(i))); } return list; @@ -58,10 +58,10 @@ public class Serialization { public static List toString(Inventory inv) { List result = new ArrayList(); List items = new ArrayList(); - for(ItemStack is:inv.getContents()) { + for (ItemStack is : inv.getContents()) { items.add(is); } - for(ConfigurationSerializable cs:items) { + for (ConfigurationSerializable cs : items) { if (cs == null) { result.add("null"); } @@ -77,7 +77,7 @@ public class Serialization { Inventory inv = Bukkit.createInventory(holder, (large) ? 54 : 27, ChatColor.RED + "Vault #" + number); holder.setInventory(inv); List contents = new ArrayList(); - for(String piece:stringItems) { + for (String piece : stringItems) { if (piece.equalsIgnoreCase("null")) { contents.add(null); } @@ -85,13 +85,13 @@ public class Serialization { try { ItemStack item = (ItemStack) deserialize(toMap(new JSONObject(piece))); contents.add(item); - } catch(JSONException e) { + } catch (JSONException e) { e.printStackTrace(); } } } ItemStack[] items = new ItemStack[contents.size()]; - for(int x = 0; x < contents.size(); x++) + for (int x = 0; x < contents.size(); x++) items[x] = contents.get(x); inv.setContents(items); return inv; @@ -99,7 +99,7 @@ public class Serialization { public static Map serialize(ConfigurationSerializable cs) { Map serialized = recreateMap(cs.serialize()); - for(Entry entry:serialized.entrySet()) { + for (Entry entry : serialized.entrySet()) { if (entry.getValue() instanceof ConfigurationSerializable) { entry.setValue(serialize((ConfigurationSerializable) entry.getValue())); } @@ -110,7 +110,7 @@ public class Serialization { public static Map recreateMap(Map original) { Map map = new HashMap(); - for(Entry entry:original.entrySet()) { + for (Entry entry : original.entrySet()) { map.put(entry.getKey(), entry.getValue()); } return map; @@ -118,7 +118,7 @@ public class Serialization { @SuppressWarnings({"unchecked", "rawtypes"}) public static ConfigurationSerializable deserialize(Map map) { - for(Entry entry:map.entrySet()) { + for (Entry entry : map.entrySet()) { if (entry.getValue() instanceof Map && ((Map) entry.getValue()).containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) { entry.setValue(deserialize((Map) entry.getValue())); } diff --git a/src/main/java/com/drtshock/playervaults/util/Updater.java b/src/main/java/com/drtshock/playervaults/util/Updater.java index 0d32548..02a6680 100644 --- a/src/main/java/com/drtshock/playervaults/util/Updater.java +++ b/src/main/java/com/drtshock/playervaults/util/Updater.java @@ -24,7 +24,7 @@ public class Updater { 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)) { + if (v.contains("SNAPSHOT") && !newVersion.equals(oldVersion)) { update = false; return; } diff --git a/src/main/java/com/drtshock/playervaults/util/VaultHolder.java b/src/main/java/com/drtshock/playervaults/util/VaultHolder.java index 711f535..063f483 100644 --- a/src/main/java/com/drtshock/playervaults/util/VaultHolder.java +++ b/src/main/java/com/drtshock/playervaults/util/VaultHolder.java @@ -7,41 +7,41 @@ import org.bukkit.inventory.InventoryHolder; * Represents a VaultHolder to assist in detection of Player Vaults from * other plugins. */ -public class VaultHolder implements InventoryHolder{ +public class VaultHolder implements InventoryHolder { - private Inventory inventory; - private int vaultNumber = 0; + private Inventory inventory; + private int vaultNumber = 0; - /** - * Creates a new vault holder - * - * @param vaultNumber the vault number this holder is using - */ - public VaultHolder(int vaultNumber){ - this.vaultNumber = vaultNumber; - } + /** + * Creates a new vault holder + * + * @param vaultNumber the vault number this holder is using + */ + public VaultHolder(int vaultNumber) { + this.vaultNumber = vaultNumber; + } - /** - * Gets the vault number this holder is currently using - * - * @return the vault number - */ - public int getVaultNumber(){ - return vaultNumber; - } + /** + * Gets the vault number this holder is currently using + * + * @return the vault number + */ + public int getVaultNumber() { + return vaultNumber; + } - /** - * Sets the inventory this vault holder holds - * - * @param inventory the inventory, may be null - */ - public void setInventory(Inventory inventory){ - this.inventory = inventory; - } + /** + * Sets the inventory this vault holder holds + * + * @param inventory the inventory, may be null + */ + public void setInventory(Inventory inventory) { + this.inventory = inventory; + } - @Override - public Inventory getInventory(){ - return inventory; - } + @Override + 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 58e0435..ef81b4a 100644 --- a/src/main/java/com/drtshock/playervaults/util/VaultManager.java +++ b/src/main/java/com/drtshock/playervaults/util/VaultManager.java @@ -1,5 +1,8 @@ package com.drtshock.playervaults.util; +import com.drtshock.playervaults.PlayerVaults; +import com.drtshock.playervaults.commands.VaultViewInfo; + import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -12,9 +15,6 @@ import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.inventory.Inventory; -import com.drtshock.playervaults.PlayerVaults; -import com.drtshock.playervaults.commands.VaultViewInfo; - /** * A class for managing actual IO to the files, loading inventories, and saving them. */ @@ -41,13 +41,13 @@ public class VaultManager { if (size == 54) { yaml.set("vault" + number, null); } else { - for(int x = 0; x < 27; x++) { + for (int x = 0; x < 27; x++) { yaml.set("vault" + number + "." + x, null); } } List list = Serialization.toString(inventory); String[] ser = list.toArray(new String[list.size()]); - for(int x = 0; x < ser.length; x++) { + for (int x = 0; x < ser.length; x++) { if (!ser[x].equalsIgnoreCase("null")) { yaml.set("vault" + number + "." + x, ser[x]); } @@ -73,7 +73,7 @@ public class VaultManager { vaultHolder.setInventory(inv); } else { List data = new ArrayList(); - for(int x = 0; x < ((large) ? 54 : 27); x++) { + for (int x = 0; x < ((large) ? 54 : 27); x++) { String line = playerFile.getString("vault" + number + "." + x); if (line != null) { data.add(line); @@ -144,7 +144,7 @@ public class VaultManager { if (!file.exists()) { try { file.createNewFile(); - } catch(IOException e) { + } catch (IOException e) { // Who cares? } } diff --git a/src/main/java/org/json/JSONArray.java b/src/main/java/org/json/JSONArray.java index 6cba798..d86553c 100644 --- a/src/main/java/org/json/JSONArray.java +++ b/src/main/java/org/json/JSONArray.java @@ -105,7 +105,7 @@ public class JSONArray { } if (x.nextClean() != ']') { x.back(); - for(;;) { + for (;;) { if (x.nextClean() == ',') { x.back(); this.myArrayList.add(JSONObject.NULL); @@ -149,7 +149,7 @@ public class JSONArray { this.myArrayList = new ArrayList(); if (collection != null) { Iterator iter = collection.iterator(); - while(iter.hasNext()) { + while (iter.hasNext()) { this.myArrayList.add(JSONObject.wrap(iter.next())); } } @@ -163,7 +163,7 @@ public class JSONArray { this(); if (array.getClass().isArray()) { int length = Array.getLength(array); - for(int i = 0; i < length; i += 1) { + for (int i = 0; i < length; i += 1) { this.put(JSONObject.wrap(Array.get(array, i))); } } else { @@ -224,7 +224,7 @@ public class JSONArray { return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object); - } catch(Exception e) { + } catch (Exception e) { throw new JSONException("JSONArray[" + index + "] is not a number."); } @@ -243,7 +243,7 @@ public class JSONArray { return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object); - } catch(Exception e) { + } catch (Exception e) { throw new JSONException("JSONArray[" + index + "] is not a number."); } @@ -295,7 +295,7 @@ public class JSONArray { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); - } catch(Exception e) { + } catch (Exception e) { throw new JSONException("JSONArray[" + index + "] is not a number."); } @@ -336,7 +336,7 @@ public class JSONArray { int len = this.length(); StringBuffer sb = new StringBuffer(); - for(int i = 0; i < len; i += 1) { + for (int i = 0; i < len; i += 1) { if (i > 0) { sb.append(separator); } @@ -390,7 +390,7 @@ public class JSONArray { public boolean optBoolean(int index, boolean defaultValue) { try { return this.getBoolean(index); - } catch(Exception e) { + } catch (Exception e) { return defaultValue; } } @@ -419,7 +419,7 @@ public class JSONArray { public double optDouble(int index, double defaultValue) { try { return this.getDouble(index); - } catch(Exception e) { + } catch (Exception e) { return defaultValue; } } @@ -447,7 +447,7 @@ public class JSONArray { public int optInt(int index, int defaultValue) { try { return this.getInt(index); - } catch(Exception e) { + } catch (Exception e) { return defaultValue; } } @@ -499,7 +499,7 @@ public class JSONArray { public long optLong(int index, long defaultValue) { try { return this.getLong(index); - } catch(Exception e) { + } catch (Exception e) { return defaultValue; } } @@ -717,7 +717,7 @@ public class JSONArray { if (index < this.length()) { this.myArrayList.set(index, value); } else { - while(index != this.length()) { + while (index != this.length()) { this.put(JSONObject.NULL); } this.put(value); @@ -751,7 +751,7 @@ public class JSONArray { return null; } JSONObject jo = new JSONObject(); - for(int i = 0; i < names.length(); i += 1) { + for (int i = 0; i < names.length(); i += 1) { jo.put(names.getString(i), this.opt(i)); } return jo; @@ -771,7 +771,7 @@ public class JSONArray { public String toString() { try { return this.toString(0); - } catch(Exception e) { + } catch (Exception e) { return null; } } @@ -789,7 +789,7 @@ public class JSONArray { */ public String toString(int indentFactor) throws JSONException { StringWriter sw = new StringWriter(); - synchronized(sw.getBuffer()) { + synchronized (sw.getBuffer()) { return this.write(sw, indentFactor, 0).toString(); } } @@ -833,7 +833,7 @@ public class JSONArray { } else if (length != 0) { final int newindent = indent + indentFactor; - for(int i = 0; i < length; i += 1) { + for (int i = 0; i < length; i += 1) { if (commanate) { writer.write(','); } @@ -852,7 +852,7 @@ public class JSONArray { } writer.write(']'); return writer; - } catch(IOException e) { + } catch (IOException e) { throw new JSONException(e); } } diff --git a/src/main/java/org/json/JSONObject.java b/src/main/java/org/json/JSONObject.java index 8a4a81b..2828308 100644 --- a/src/main/java/org/json/JSONObject.java +++ b/src/main/java/org/json/JSONObject.java @@ -174,10 +174,10 @@ public class JSONObject { */ public JSONObject(JSONObject jo, String[] names) { this(); - for(int i = 0; i < names.length; i += 1) { + for (int i = 0; i < names.length; i += 1) { try { this.putOnce(names[i], jo.opt(names[i])); - } catch(Exception ignore) { + } catch (Exception ignore) { } } } @@ -196,7 +196,7 @@ public class JSONObject { if (x.nextClean() != '{') { throw x.syntaxError("A JSONObject text must begin with '{'"); } - for(;;) { + for (;;) { c = x.nextClean(); switch (c) { case 0: @@ -249,7 +249,7 @@ public class JSONObject { this.map = new HashMap(); if (map != null) { Iterator i = map.entrySet().iterator(); - while(i.hasNext()) { + while (i.hasNext()) { Map.Entry e = (Map.Entry) i.next(); Object value = e.getValue(); if (value != null) { @@ -297,11 +297,11 @@ public class JSONObject { public JSONObject(Object object, String names[]) { this(); Class c = object.getClass(); - for(int i = 0; i < names.length; i += 1) { + for (int i = 0; i < names.length; i += 1) { String name = names[i]; try { this.putOpt(name, c.getField(name).get(object)); - } catch(Exception ignore) { + } catch (Exception ignore) { } } } @@ -333,7 +333,7 @@ public class JSONObject { // Iterate through the keys in the bundle. Enumeration keys = bundle.getKeys(); - while(keys.hasMoreElements()) { + while (keys.hasMoreElements()) { Object key = keys.nextElement(); if (key instanceof String) { @@ -344,7 +344,7 @@ public class JSONObject { String[] path = ((String) key).split("\\."); int last = path.length - 1; JSONObject target = this; - for(int i = 0; i < last; i += 1) { + for (int i = 0; i < last; i += 1) { String segment = path[i]; JSONObject nextTarget = target.optJSONObject(segment); if (nextTarget == null) { @@ -433,7 +433,7 @@ public class JSONObject { String string = Double.toString(d); if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) { - while(string.endsWith("0")) { + while (string.endsWith("0")) { string = string.substring(0, string.length() - 1); } if (string.endsWith(".")) { @@ -498,7 +498,7 @@ public class JSONObject { return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object); - } catch(Exception e) { + } catch (Exception e) { throw new JSONException("JSONObject[" + quote(key) + "] is not a number."); } @@ -518,7 +518,7 @@ public class JSONObject { return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object); - } catch(Exception e) { + } catch (Exception e) { throw new JSONException("JSONObject[" + quote(key) + "] is not an int."); } @@ -572,7 +572,7 @@ public class JSONObject { return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object); - } catch(Exception e) { + } catch (Exception e) { throw new JSONException("JSONObject[" + quote(key) + "] is not a long."); } @@ -591,7 +591,7 @@ public class JSONObject { Iterator iterator = jo.keys(); String[] names = new String[length]; int i = 0; - while(iterator.hasNext()) { + while (iterator.hasNext()) { names[i] = (String) iterator.next(); i += 1; } @@ -614,7 +614,7 @@ public class JSONObject { return null; } String[] names = new String[length]; - for(int i = 0; i < length; i += 1) { + for (int i = 0; i < length; i += 1) { names[i] = fields[i].getName(); } return names; @@ -719,7 +719,7 @@ public class JSONObject { public JSONArray names() { JSONArray ja = new JSONArray(); Iterator keys = this.keys(); - while(keys.hasNext()) { + while (keys.hasNext()) { ja.put(keys.next()); } return ja.length() == 0 ? null : ja; @@ -743,7 +743,7 @@ public class JSONObject { String string = number.toString(); if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) { - while(string.endsWith("0")) { + while (string.endsWith("0")) { string = string.substring(0, string.length() - 1); } if (string.endsWith(".")) { @@ -786,7 +786,7 @@ public class JSONObject { public boolean optBoolean(String key, boolean defaultValue) { try { return this.getBoolean(key); - } catch(Exception e) { + } catch (Exception e) { return defaultValue; } } @@ -817,7 +817,7 @@ public class JSONObject { public double optDouble(String key, double defaultValue) { try { return this.getDouble(key); - } catch(Exception e) { + } catch (Exception e) { return defaultValue; } } @@ -848,7 +848,7 @@ public class JSONObject { public int optInt(String key, int defaultValue) { try { return this.getInt(key); - } catch(Exception e) { + } catch (Exception e) { return defaultValue; } } @@ -905,7 +905,7 @@ public class JSONObject { public long optLong(String key, long defaultValue) { try { return this.getLong(key); - } catch(Exception e) { + } catch (Exception e) { return defaultValue; } } @@ -945,7 +945,7 @@ public class JSONObject { Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods(); - for(int i = 0; i < methods.length; i += 1) { + for (int i = 0; i < methods.length; i += 1) { try { Method method = methods[i]; if (Modifier.isPublic(method.getModifiers())) { @@ -977,7 +977,7 @@ public class JSONObject { } } } - } catch(Exception ignore) { + } catch (Exception ignore) { } } } @@ -1140,10 +1140,10 @@ public class JSONObject { */ public static String quote(String string) { StringWriter sw = new StringWriter(); - synchronized(sw.getBuffer()) { + synchronized (sw.getBuffer()) { try { return quote(string, sw).toString(); - } catch(IOException ignored) { + } catch (IOException ignored) { // will never happen - we are writing to a string writer return ""; } @@ -1163,7 +1163,7 @@ public class JSONObject { int len = string.length(); w.write('"'); - for(i = 0; i < len; i += 1) { + for (i = 0; i < len; i += 1) { b = c; c = string.charAt(i); switch (c) { @@ -1265,7 +1265,7 @@ public class JSONObject { return myLong; } } - } catch(Exception ignore) { + } catch (Exception ignore) { } } return string; @@ -1305,7 +1305,7 @@ public class JSONObject { return null; } JSONArray ja = new JSONArray(); - for(int i = 0; i < names.length(); i += 1) { + for (int i = 0; i < names.length(); i += 1) { ja.put(this.opt(names.getString(i))); } return ja; @@ -1326,7 +1326,7 @@ public class JSONObject { public String toString() { try { return this.toString(0); - } catch(Exception e) { + } catch (Exception e) { return null; } } @@ -1345,7 +1345,7 @@ public class JSONObject { */ public String toString(int indentFactor) throws JSONException { StringWriter w = new StringWriter(); - synchronized(w.getBuffer()) { + synchronized (w.getBuffer()) { return this.write(w, indentFactor, 0).toString(); } } @@ -1379,7 +1379,7 @@ public class JSONObject { Object object; try { object = ((JSONString) value).toJSONString(); - } catch(Exception e) { + } catch (Exception e) { throw new JSONException(e); } if (object instanceof String) { @@ -1452,7 +1452,7 @@ public class JSONObject { return object.toString(); } return new JSONObject(object); - } catch(Exception exception) { + } catch (Exception exception) { return null; } } @@ -1493,7 +1493,7 @@ public class JSONObject { Object o; try { o = ((JSONString) value).toJSONString(); - } catch(Exception e) { + } catch (Exception e) { throw new JSONException(e); } writer.write(o != null ? o.toString() : quote(value.toString())); @@ -1504,7 +1504,7 @@ public class JSONObject { } static final void indent(Writer writer, int indent) throws IOException { - for(int i = 0; i < indent; i += 1) { + for (int i = 0; i < indent; i += 1) { writer.write(' '); } } @@ -1536,7 +1536,7 @@ public class JSONObject { writeValue(writer, this.map.get(key), indentFactor, indent); } else if (length != 0) { final int newindent = indent + indentFactor; - while(keys.hasNext()) { + while (keys.hasNext()) { Object key = keys.next(); if (commanate) { writer.write(','); @@ -1561,7 +1561,7 @@ public class JSONObject { } writer.write('}'); return writer; - } catch(IOException exception) { + } catch (IOException exception) { throw new JSONException(exception); } } diff --git a/src/main/java/org/json/JSONTokener.java b/src/main/java/org/json/JSONTokener.java index 5cd2d74..7c0f9ee 100644 --- a/src/main/java/org/json/JSONTokener.java +++ b/src/main/java/org/json/JSONTokener.java @@ -146,7 +146,7 @@ public class JSONTokener { } else { try { c = this.reader.read(); - } catch(IOException exception) { + } catch (IOException exception) { throw new JSONException(exception); } @@ -202,7 +202,7 @@ public class JSONTokener { char[] chars = new char[n]; int pos = 0; - while(pos < n) { + while (pos < n) { chars[pos] = this.next(); if (this.end()) { throw this.syntaxError("Substring bounds error"); @@ -218,7 +218,7 @@ public class JSONTokener { * @return A character, or 0 if there are no more characters. */ public char nextClean() throws JSONException { - for(;;) { + for (;;) { char c = this.next(); if (c == 0 || c > ' ') { return c; @@ -240,7 +240,7 @@ public class JSONTokener { public String nextString(char quote) throws JSONException { char c; StringBuffer sb = new StringBuffer(); - for(;;) { + for (;;) { c = this.next(); switch (c) { case 0: @@ -295,7 +295,7 @@ public class JSONTokener { */ public String nextTo(char delimiter) throws JSONException { StringBuffer sb = new StringBuffer(); - for(;;) { + for (;;) { char c = this.next(); if (c == delimiter || c == 0 || c == '\n' || c == '\r') { if (c != 0) { @@ -316,7 +316,7 @@ public class JSONTokener { public String nextTo(String delimiters) throws JSONException { char c; StringBuffer sb = new StringBuffer(); - for(;;) { + for (;;) { c = this.next(); if (delimiters.indexOf(c) >= 0 || c == 0 || c == '\n' || c == '\r') { @@ -362,7 +362,7 @@ public class JSONTokener { */ StringBuffer sb = new StringBuffer(); - while(c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { + while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { sb.append(c); c = this.next(); } @@ -398,8 +398,8 @@ public class JSONTokener { this.line = startLine; return c; } - } while(c != to); - } catch(IOException exc) { + } while (c != to); + } catch (IOException exc) { throw new JSONException(exc); }