Overall organize imports and format
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 + " <owner> <#>");
|
||||
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 + " <owner> <#>");
|
||||
return true;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 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<Graph> 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<Graph> 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() {
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Serialization {
|
||||
public static Map<String, Object> toMap(JSONObject object) throws JSONException {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Iterator<String> 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<Object> toList(JSONArray array) throws JSONException {
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
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<String> toString(Inventory inv) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<ConfigurationSerializable> items = new ArrayList<ConfigurationSerializable>();
|
||||
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<ItemStack> contents = new ArrayList<ItemStack>();
|
||||
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<String, Object> serialize(ConfigurationSerializable cs) {
|
||||
Map<String, Object> serialized = recreateMap(cs.serialize());
|
||||
for(Entry<String, Object> entry:serialized.entrySet()) {
|
||||
for (Entry<String, Object> entry : serialized.entrySet()) {
|
||||
if (entry.getValue() instanceof ConfigurationSerializable) {
|
||||
entry.setValue(serialize((ConfigurationSerializable) entry.getValue()));
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class Serialization {
|
||||
|
||||
public static Map<String, Object> recreateMap(Map<String, Object> original) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
for(Entry<String, Object> entry:original.entrySet()) {
|
||||
for (Entry<String, Object> 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<String, Object> map) {
|
||||
for(Entry<String, Object> entry:map.entrySet()) {
|
||||
for (Entry<String, Object> entry : map.entrySet()) {
|
||||
if (entry.getValue() instanceof Map && ((Map) entry.getValue()).containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) {
|
||||
entry.setValue(deserialize((Map) entry.getValue()));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String> 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<String> data = new ArrayList<String>();
|
||||
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?
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user