From f97ba1e6942be95c4141eea0d726ddcfae01c11f Mon Sep 17 00:00:00 2001 From: drtshock Date: Mon, 27 Apr 2015 12:03:11 -0500 Subject: [PATCH] Reformat. --- .../drtshock/playervaults/PlayerVaults.java | 4 ++-- .../playervaults/commands/DeleteCommand.java | 4 ++-- .../playervaults/commands/VaultCommand.java | 4 ++-- .../converters/BackpackConverter.java | 23 ++++++++++++++----- .../playervaults/converters/Converter.java | 10 ++++---- .../playervaults/listeners/Listeners.java | 9 +------- .../playervaults/tasks/UUIDConversion.java | 4 +++- .../com/drtshock/playervaults/util/Lang.java | 5 ++-- .../drtshock/playervaults/util/Updater.java | 18 +++++++++------ .../vaultmanagement/UUIDVaultManager.java | 14 ++++++----- .../vaultmanagement/VaultManager.java | 13 +++++------ .../vaultmanagement/VaultOperations.java | 20 +++++++++++----- 12 files changed, 73 insertions(+), 55 deletions(-) diff --git a/src/main/java/com/drtshock/playervaults/PlayerVaults.java b/src/main/java/com/drtshock/playervaults/PlayerVaults.java index 7a338f0..0392c6a 100644 --- a/src/main/java/com/drtshock/playervaults/PlayerVaults.java +++ b/src/main/java/com/drtshock/playervaults/PlayerVaults.java @@ -237,9 +237,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/commands/DeleteCommand.java b/src/main/java/com/drtshock/playervaults/commands/DeleteCommand.java index bd77e82..b119678 100644 --- a/src/main/java/com/drtshock/playervaults/commands/DeleteCommand.java +++ b/src/main/java/com/drtshock/playervaults/commands/DeleteCommand.java @@ -12,8 +12,8 @@ import org.bukkit.entity.Player; public class DeleteCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(VaultOperations.isLocked()){ - sender.sendMessage(Lang.TITLE+Lang.LOCKED.toString()); + if (VaultOperations.isLocked()) { + sender.sendMessage(Lang.TITLE + Lang.LOCKED.toString()); return true; } diff --git a/src/main/java/com/drtshock/playervaults/commands/VaultCommand.java b/src/main/java/com/drtshock/playervaults/commands/VaultCommand.java index 29b424a..16b31ed 100644 --- a/src/main/java/com/drtshock/playervaults/commands/VaultCommand.java +++ b/src/main/java/com/drtshock/playervaults/commands/VaultCommand.java @@ -17,8 +17,8 @@ import org.bukkit.entity.Player; public class VaultCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(VaultOperations.isLocked()){ - sender.sendMessage(Lang.TITLE+Lang.LOCKED.toString()); + if (VaultOperations.isLocked()) { + sender.sendMessage(Lang.TITLE + Lang.LOCKED.toString()); return true; } diff --git a/src/main/java/com/drtshock/playervaults/converters/BackpackConverter.java b/src/main/java/com/drtshock/playervaults/converters/BackpackConverter.java index 7545f46..6f466bc 100644 --- a/src/main/java/com/drtshock/playervaults/converters/BackpackConverter.java +++ b/src/main/java/com/drtshock/playervaults/converters/BackpackConverter.java @@ -24,11 +24,15 @@ public class BackpackConverter implements Converter { @Override public int run(CommandSender initiator, ServiceProvider uuidProvider) { - if (uuidProvider == null) throw new IllegalArgumentException(); + if (uuidProvider == null) { + throw new IllegalArgumentException(); + } PlayerVaults plugin = PlayerVaults.getInstance(); File destination = new File(plugin.getDataFolder().getParentFile(), "Backpack" + File.separator + "backpacks"); - if (!destination.exists()) return -1; + if (!destination.exists()) { + return -1; + } int converted = 0; @@ -60,15 +64,20 @@ public class BackpackConverter implements Converter { UUID uuid = player.getUuid(); FileConfiguration yaml = YamlConfiguration.loadConfiguration(file); ConfigurationSection section = yaml.getConfigurationSection("backpack"); - if (section.getKeys(false).size() <= 0) continue; // No slots + if (section.getKeys(false).size() <= 0) { + continue; // No slots + } Inventory vault = vaults.getVault(uuid, intoVaultNum); - if (vault == null) + if (vault == null) { vault = plugin.getServer().createInventory(null, section.getKeys(false).size()); + } for (String key : section.getKeys(false)) { ConfigurationSection slotSection = section.getConfigurationSection(key); ItemStack item = slotSection.getItemStack("ItemStack"); - if (item == null) continue; + if (item == null) { + continue; + } // Overwrite vault.setItem(Integer.parseInt(key.split(" ")[1]), item); @@ -99,7 +108,9 @@ public class BackpackConverter implements Converter { public boolean canConvert() { PlayerVaults plugin = PlayerVaults.getInstance(); File expectedFolder = new File(plugin.getDataFolder().getParentFile(), "Backpack"); - if (!expectedFolder.exists()) return false; + if (!expectedFolder.exists()) { + return false; + } File backpackDir = new File(expectedFolder, "backpacks"); return backpackDir.exists(); } diff --git a/src/main/java/com/drtshock/playervaults/converters/Converter.java b/src/main/java/com/drtshock/playervaults/converters/Converter.java index 49cfda9..402cedb 100644 --- a/src/main/java/com/drtshock/playervaults/converters/Converter.java +++ b/src/main/java/com/drtshock/playervaults/converters/Converter.java @@ -4,8 +4,7 @@ import com.turt2live.uuid.ServiceProvider; import org.bukkit.command.CommandSender; /** - * Represents a simple converter for converting another plugin's content - * to PlayerVaults. + * Represents a simple converter for converting another plugin's content to PlayerVaults. * * @author turt2live */ @@ -17,14 +16,13 @@ public interface Converter { * @param initiator the initiator of the conversion. May be null * @param uuidProvider the UUID provider to use, cannot be null * - * @return the number of vaults converted. Returns 0 on none converted - * or -1 if no vaults were converted. + * @return the number of vaults converted. Returns 0 on none converted or -1 if no vaults were converted. */ public int run(CommandSender initiator, ServiceProvider uuidProvider); /** - * Determines if this converter is applicable for converting to PlayerVaults. - * This may check for the existance of a plugin, plugin folder, or otherwise. + * Determines if this converter is applicable for converting to PlayerVaults. This may check for the existance of a + * plugin, plugin folder, or otherwise. * * @return true if this converter can convert, false otherwise */ diff --git a/src/main/java/com/drtshock/playervaults/listeners/Listeners.java b/src/main/java/com/drtshock/playervaults/listeners/Listeners.java index 02207ab..bd8bf03 100644 --- a/src/main/java/com/drtshock/playervaults/listeners/Listeners.java +++ b/src/main/java/com/drtshock/playervaults/listeners/Listeners.java @@ -105,14 +105,7 @@ public class Listeners implements Listener { if (PlayerVaults.getInstance().getInVault().containsKey(player.getName())) { Block block = event.getClickedBlock(); // Different inventories that we don't want the player to open. - if (block.getType() == Material.CHEST - || block.getType() == Material.TRAPPED_CHEST - || block.getType() == Material.ENDER_CHEST - || block.getType() == Material.FURNACE - || block.getType() == Material.BURNING_FURNACE - || block.getType() == Material.BREWING_STAND - || block.getType() == Material.ENCHANTMENT_TABLE - || block.getType() == Material.BEACON) { + if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || block.getType() == Material.ENDER_CHEST || block.getType() == Material.FURNACE || block.getType() == Material.BURNING_FURNACE || block.getType() == Material.BREWING_STAND || block.getType() == Material.ENCHANTMENT_TABLE || block.getType() == Material.BEACON) { event.setCancelled(true); } } diff --git a/src/main/java/com/drtshock/playervaults/tasks/UUIDConversion.java b/src/main/java/com/drtshock/playervaults/tasks/UUIDConversion.java index b1c6f3a..cd63c5e 100644 --- a/src/main/java/com/drtshock/playervaults/tasks/UUIDConversion.java +++ b/src/main/java/com/drtshock/playervaults/tasks/UUIDConversion.java @@ -33,7 +33,9 @@ public final class UUIDConversion extends BukkitRunnable { logger.info(oldVaults.toString() + " will remain as a backup."); for (File file : oldVaults.listFiles()) { - if (file.isDirectory()) continue; // backups folder. + if (file.isDirectory()) { + continue; // backups folder. + } OfflinePlayer player = Bukkit.getOfflinePlayer(file.getName().replace(".yml", "")); if (player == null) { logger.warning("Unable to convert file because player never joined the server: " + file.getName()); diff --git a/src/main/java/com/drtshock/playervaults/util/Lang.java b/src/main/java/com/drtshock/playervaults/util/Lang.java index 7b769eb..88e79eb 100644 --- a/src/main/java/com/drtshock/playervaults/util/Lang.java +++ b/src/main/java/com/drtshock/playervaults/util/Lang.java @@ -58,7 +58,7 @@ public enum Lang { /** * Lang enum constructor. * - * @param path The string path. + * @param path The string path. * @param start The default string. */ Lang(String path, String start) { @@ -77,8 +77,9 @@ public enum Lang { @Override public String toString() { - if (this == TITLE) + if (this == TITLE) { return ChatColor.translateAlternateColorCodes('&', LANG.getString(this.path, def)) + " "; + } return ChatColor.translateAlternateColorCodes('&', LANG.getString(this.path, def)); } diff --git a/src/main/java/com/drtshock/playervaults/util/Updater.java b/src/main/java/com/drtshock/playervaults/util/Updater.java index 1c1cb1b..d1dc9bd 100644 --- a/src/main/java/com/drtshock/playervaults/util/Updater.java +++ b/src/main/java/com/drtshock/playervaults/util/Updater.java @@ -131,11 +131,11 @@ public class Updater { /** * Initialize the updater * - * @param plugin The plugin that is checking for an update. - * @param id The dev.bukkit.org id of the project - * @param file The file that the plugin is running from, get this by doing this.getFile() from within your main - * class. - * @param type Specify the type of update this will be. See {@link UpdateType} + * @param plugin The plugin that is checking for an update. + * @param id The dev.bukkit.org id of the project + * @param file The file that the plugin is running from, get this by doing this.getFile() from within your main + * class. + * @param type Specify the type of update this will be. See {@link UpdateType} * @param announce True if the program should announce the progress of new updates in console */ public Updater(Plugin plugin, int id, File file, Updater.UpdateType type, boolean announce) { @@ -263,7 +263,9 @@ public class Updater { byte[] data = new byte[BYTE_SIZE]; int count; - if (announce) plugin.getLogger().log(Level.INFO, "About to download a new update: {0}", versionName); + 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; @@ -285,7 +287,9 @@ public class Updater { // Unzip unzip(dFile.getCanonicalPath()); } - if (announce) plugin.getLogger().info("Finished updating."); + 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; diff --git a/src/main/java/com/drtshock/playervaults/vaultmanagement/UUIDVaultManager.java b/src/main/java/com/drtshock/playervaults/vaultmanagement/UUIDVaultManager.java index d33e41f..2cc5ca7 100644 --- a/src/main/java/com/drtshock/playervaults/vaultmanagement/UUIDVaultManager.java +++ b/src/main/java/com/drtshock/playervaults/vaultmanagement/UUIDVaultManager.java @@ -33,8 +33,8 @@ public class UUIDVaultManager { * 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. + * @param player The player of whose file to save to. + * @param number The vault number. * * @throws java.io.IOException Uh oh! */ @@ -132,8 +132,8 @@ public class UUIDVaultManager { * Get an inventory from file. Returns null if the inventory doesn't exist. SHOULD ONLY BE USED INTERNALLY * * @param playerFile the YamlConfiguration file. - * @param size the size of the vault. - * @param number the vault number. + * @param size the size of the vault. + * @param number the vault number. * * @return inventory if exists, otherwise null. */ @@ -162,7 +162,9 @@ public class UUIDVaultManager { YamlConfiguration playerFile = getPlayerVaultFile(holder); List data = playerFile.getStringList("vault" + number); OfflinePlayer player = Bukkit.getPlayer(holder); - if (player == null) return null; + if (player == null) { + return null; + } if (data == null) { VaultHolder vaultHolder = new VaultHolder(number); Inventory inv = Bukkit.createInventory(vaultHolder, VaultOperations.getMaxVaultSize(player), Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number)).replace("%p", player.getName())); @@ -234,7 +236,7 @@ public class UUIDVaultManager { * Save the players vault file. * * @param holder The vault holder of whose file to save. - * @param yaml The config to save. + * @param yaml The config to save. * * @throws IOException Uh oh! */ diff --git a/src/main/java/com/drtshock/playervaults/vaultmanagement/VaultManager.java b/src/main/java/com/drtshock/playervaults/vaultmanagement/VaultManager.java index 912a9d4..5aaf300 100644 --- a/src/main/java/com/drtshock/playervaults/vaultmanagement/VaultManager.java +++ b/src/main/java/com/drtshock/playervaults/vaultmanagement/VaultManager.java @@ -33,8 +33,7 @@ import java.util.List; /** * A class for managing actual IO to the files, loading inventories, and saving them. */ -@Deprecated -public class VaultManager { +@Deprecated public class VaultManager { public PlayerVaults plugin; @@ -48,8 +47,8 @@ public class VaultManager { * 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. + * @param player The player of whose file to save to. + * @param number The vault number. * * @throws IOException Uh oh! */ @@ -151,8 +150,8 @@ public class VaultManager { * Get an inventory from file. Returns null if the inventory doesn't exist. SHOULD ONLY BE USED INTERNALLY * * @param playerFile the YamlConfiguration file. - * @param size the size of the vault. - * @param number the vault number. + * @param size the size of the vault. + * @param number the vault number. * * @return inventory if exists, otherwise null. */ @@ -254,7 +253,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. + * @param yaml The config to save. * * @throws IOException Uh oh! */ diff --git a/src/main/java/com/drtshock/playervaults/vaultmanagement/VaultOperations.java b/src/main/java/com/drtshock/playervaults/vaultmanagement/VaultOperations.java index 4ceb159..090681f 100644 --- a/src/main/java/com/drtshock/playervaults/vaultmanagement/VaultOperations.java +++ b/src/main/java/com/drtshock/playervaults/vaultmanagement/VaultOperations.java @@ -42,8 +42,8 @@ public class VaultOperations { } /** - * Sets whether or not player vaults are locked. If set to true, this - * will kick anyone who is currently using their vaults out. + * Sets whether or not player vaults are locked. If set to true, this will kick anyone who is currently using their + * vaults out. * * @param locked true for locked, false otherwise */ @@ -111,7 +111,9 @@ public class VaultOperations { * @return Whether or not the player was allowed to open it. */ public static boolean openOwnVault(Player player, String arg) { - if (isLocked()) return false; + if (isLocked()) { + return false; + } int number; try { number = Integer.parseInt(arg); @@ -149,7 +151,9 @@ public class VaultOperations { * @return Whether or not the player was allowed to open it. */ public static boolean openOtherVault(Player player, Player holder, String arg) { - if (isLocked()) return false; + if (isLocked()) { + return false; + } if (player.hasPermission("playervaults.admin")) { int number = 0; try { @@ -181,7 +185,9 @@ public class VaultOperations { * @param arg The vault number to delete. */ public static void deleteOwnVault(Player player, String arg) { - if (isLocked()) return; + if (isLocked()) { + return; + } if (arg.matches("^[0-9]{1,2}$")) { int number = 0; try { @@ -214,7 +220,9 @@ public class VaultOperations { * @param arg The vault number to delete. */ public static void deleteOtherVault(CommandSender sender, Player holder, String arg) { - if (isLocked()) return; + if (isLocked()) { + return; + } if (sender.hasPermission("playervaults.delete")) { if (arg.matches("^[0-9]{1,2}$")) { int number = 0;