diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java index 46dd281..87dea53 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Config.java @@ -19,7 +19,6 @@ import at.pcgamingfreaks.Bukkit.Configuration; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.plugin.java.JavaPlugin; diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java index 37bf1c3..1e3b9ca 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Database.java @@ -41,7 +41,8 @@ public abstract class Database implements Listener protected final Minepacks plugin; protected final InventorySerializer itsSerializer = new InventorySerializer(); - protected boolean useUUIDs, useUUIDSeparators; + protected final boolean useUUIDs; + protected boolean useUUIDSeparators; protected long maxAge; private final Map backpacks = new ConcurrentHashMap<>(); private final UnCacheStrategie unCacheStrategie; diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Files.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Files.java index 5f0b010..37ef6ab 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Files.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Files.java @@ -21,7 +21,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FilenameFilter; -import java.util.Date; import javax.swing.filechooser.FileFilter; @@ -82,7 +81,10 @@ private void checkFiles() { if(len <= 16) // It's a player name { - file.renameTo(new File(saveFolder, UUIDConverter.getUUIDFromName(file.getName().substring(0, len), true, useUUIDSeparators) + EXT)); + if(!file.renameTo(new File(saveFolder, UUIDConverter.getUUIDFromName(file.getName().substring(0, len), true, useUUIDSeparators) + EXT))) + { + plugin.getLogger().warning("Failed to rename file (" + file.getAbsolutePath() + ")."); + } } else // It's an UUID { @@ -90,14 +92,20 @@ private void checkFiles() { if(!useUUIDSeparators) { - file.renameTo(new File(saveFolder, file.getName().replaceAll("-", ""))); + if(!file.renameTo(new File(saveFolder, file.getName().replaceAll("-", "")))) + { + plugin.getLogger().warning("Failed to rename file (" + file.getAbsolutePath() + ")."); + } } } else { if(useUUIDSeparators) { - file.renameTo(new File(saveFolder, file.getName().replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})" + EXT_REGEX, "$1-$2-$3-$4-$5" + EXT))); + if(!file.renameTo(new File(saveFolder, file.getName().replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})" + EXT_REGEX, "$1-$2-$3-$4-$5" + EXT)))) + { + plugin.getLogger().warning("Failed to rename file (" + file.getAbsolutePath() + ")."); + } } } } @@ -170,7 +178,7 @@ public Backpack loadBackpack(OfflinePlayer player) private static class BackpackFileFilter extends FileFilter implements FilenameFilter { - String description, extension; + final String description, extension; public BackpackFileFilter() { diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/InventorySerializer.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/InventorySerializer.java index f38eb5e..e676fff 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/InventorySerializer.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/InventorySerializer.java @@ -27,7 +27,8 @@ public class InventorySerializer { - private ItemStackSerializer serializer, baseItemStackSerializer = new BukkitItemStackSerializer(); + private static final ItemStackSerializer BUKKIT_ITEM_STACK_SERIALIZER = new BukkitItemStackSerializer(); + private ItemStackSerializer serializer; private int usedSerializer = 1; public InventorySerializer() @@ -48,7 +49,7 @@ public InventorySerializer() if(serializer == null) { usedSerializer = 0; - serializer = baseItemStackSerializer; + serializer = BUKKIT_ITEM_STACK_SERIALIZER; } } @@ -68,7 +69,7 @@ public ItemStack[] deserialize(byte[] data, int usedSerializer) if(data == null) return null; switch(usedSerializer) { - case 0: return baseItemStackSerializer.deserialize(data); + case 0: return BUKKIT_ITEM_STACK_SERIALIZER.deserialize(data); default: return serializer.deserialize(data); } } diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/EventListener.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/EventListener.java index d788f41..8c21ee0 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/EventListener.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/EventListener.java @@ -33,9 +33,8 @@ public class EventListener implements Listener { - private Minepacks plugin; - - private Message messageOwnBackpackClose, messageOtherBackpackClose; + private final Minepacks plugin; + private final Message messageOwnBackpackClose, messageOtherBackpackClose; public EventListener(Minepacks mp) {