Reformat.

This commit is contained in:
drtshock
2015-04-27 12:03:11 -05:00
parent d690786803
commit f97ba1e694
12 changed files with 73 additions and 55 deletions
@@ -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;
}
@@ -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;
}
@@ -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();
}
@@ -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
*/
@@ -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);
}
}
@@ -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());
@@ -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));
}
@@ -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;
@@ -162,7 +162,9 @@ public class UUIDVaultManager {
YamlConfiguration playerFile = getPlayerVaultFile(holder);
List<String> 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()));
@@ -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;
@@ -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;