From eeb72ed1bb9196dd808ad60045935dfc344b58a3 Mon Sep 17 00:00:00 2001 From: vemacs Date: Fri, 26 Jun 2015 11:22:23 -0400 Subject: [PATCH] Only update if already in map --- .../java/com/drtshock/playervaults/util/Updater.java | 3 ++- .../playervaults/vaultmanagement/UUIDVaultManager.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/drtshock/playervaults/util/Updater.java b/src/main/java/com/drtshock/playervaults/util/Updater.java index d1dc9bd..6d5beb6 100644 --- a/src/main/java/com/drtshock/playervaults/util/Updater.java +++ b/src/main/java/com/drtshock/playervaults/util/Updater.java @@ -24,7 +24,8 @@ import java.util.zip.ZipFile; * AT ALL.
If you fail to include this option in your config, your plugin will be REJECTED when you * attempt to submit it to dev.bukkit.org. *

- * An example of a good configuration option would be something similar to 'auto-update: true' - if this value is set to + * An example of a good configuration option would be something similar to 'auto-update: true' - if this value is set + * to * false you may NOT run the auto-updater.
If you are unsure about these rules, please read the plugin submission * guidelines: http://goo.gl/8iU5l * diff --git a/src/main/java/com/drtshock/playervaults/vaultmanagement/UUIDVaultManager.java b/src/main/java/com/drtshock/playervaults/vaultmanagement/UUIDVaultManager.java index 745ee2f..3475fa0 100644 --- a/src/main/java/com/drtshock/playervaults/vaultmanagement/UUIDVaultManager.java +++ b/src/main/java/com/drtshock/playervaults/vaultmanagement/UUIDVaultManager.java @@ -39,6 +39,7 @@ public class UUIDVaultManager { * @param inventory The inventory to be saved. * @param player The player of whose file to save to. * @param number The vault number. + * * @throws java.io.IOException Uh oh! */ public void saveVault(Inventory inventory, UUID player, int number) throws IOException { @@ -148,6 +149,7 @@ public class UUIDVaultManager { * @param playerFile the YamlConfiguration file. * @param size the size of the vault. * @param number the vault number. + * * @return inventory if exists, otherwise null. */ private Inventory getInventory(YamlConfiguration playerFile, int size, int number, String title) { @@ -168,6 +170,7 @@ public class UUIDVaultManager { * * @param holder The holder of the vault. * @param number The vault number. + * * @return The inventory of the specified holder and vault number. */ public Inventory getVault(UUID holder, int number) { @@ -198,6 +201,7 @@ public class UUIDVaultManager { * @param sender The sender of whom to send messages to. * @param holder The vault holder. * @param number The vault number. + * * @throws IOException Uh oh! */ public void deleteVault(CommandSender sender, final UUID holder, final int number) throws IOException { @@ -245,6 +249,7 @@ public class UUIDVaultManager { * Get the holder's vault file. Create if doesn't exist. * * @param holder The vault holder. + * * @return The holder's vault config file. */ public YamlConfiguration getPlayerVaultFile(UUID holder) { @@ -274,10 +279,11 @@ public class UUIDVaultManager { * * @param holder The vault holder of whose file to save. * @param yaml The config to save. + * * @throws IOException Uh oh! */ public void saveFile(final UUID holder, final YamlConfiguration yaml) { - if (Bukkit.getPlayer(holder) != null) { + if (cachedVaultFiles.containsKey(holder)) { cachedVaultFiles.put(holder, yaml); } final boolean backups = PlayerVaults.getInstance().isBackupsEnabled(); @@ -298,7 +304,7 @@ public class UUIDVaultManager { } public void saveFileSync(final UUID holder, final YamlConfiguration yaml) { - if (Bukkit.getPlayer(holder) != null) { + if (cachedVaultFiles.containsKey(holder)) { cachedVaultFiles.put(holder, yaml); } final boolean backups = PlayerVaults.getInstance().isBackupsEnabled();