From 606a0d80a4bd7f1db805051683d5f36286c66cff Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 23 Oct 2015 13:13:30 +0200 Subject: [PATCH] Fix PersistentClientData --- .../util/playerdata/PersistentClientData.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistentClientData.java b/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistentClientData.java index fb2352b0c..4cfc9c644 100644 --- a/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistentClientData.java +++ b/src/main/java/ellpeck/actuallyadditions/util/playerdata/PersistentClientData.java @@ -87,9 +87,21 @@ public class PersistentClientData{ theFile = file; } + public static File getTheFile(){ + try{ + if(!theFile.exists()){ + theFile.createNewFile(); + } + } + catch(Exception e){ + ModUtil.LOGGER.fatal("Couldn't create Persistent Variables file!", e); + } + return theFile; + } + private static NBTTagCompound readCompound(){ try{ - return CompressedStreamTools.readCompressed(new FileInputStream(theFile)); + return CompressedStreamTools.readCompressed(new FileInputStream(getTheFile())); } catch(Exception e){ return new NBTTagCompound(); @@ -98,13 +110,11 @@ public class PersistentClientData{ private static void writeCompound(NBTTagCompound compound){ try{ - if(!theFile.exists()){ - theFile.createNewFile(); - } - CompressedStreamTools.writeCompressed(compound, new FileOutputStream(theFile)); + + CompressedStreamTools.writeCompressed(compound, new FileOutputStream(getTheFile())); } catch(Exception e){ - ModUtil.LOGGER.fatal("Couldn't write Persistant Variable!", e); + ModUtil.LOGGER.fatal("Couldn't write Persistent Variable!", e); } } }