diff options
author | Draknyte1 <Draknyte1@hotmail.com> | 2016-03-19 18:07:29 +1000 |
---|---|---|
committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-03-19 18:07:29 +1000 |
commit | 7a41bde88f8c2164d1bc5b23bc695ea7bb5e9cda (patch) | |
tree | 280e902ab66a1cdd2bf72ca4dc6e000fdae5dcc6 /src/Java/miscutil/core | |
parent | 73a8779a5f46eeb449005840fdf1b9120816e380 (diff) | |
download | GT5-Unofficial-7a41bde88f8c2164d1bc5b23bc695ea7bb5e9cda.tar.gz GT5-Unofficial-7a41bde88f8c2164d1bc5b23bc695ea7bb5e9cda.tar.bz2 GT5-Unofficial-7a41bde88f8c2164d1bc5b23bc695ea7bb5e9cda.zip |
Updated null checks and error messages related to the init & creation of the PlayerCache.dat
Diffstat (limited to 'src/Java/miscutil/core')
-rw-r--r-- | src/Java/miscutil/core/util/PlayerCache.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Java/miscutil/core/util/PlayerCache.java b/src/Java/miscutil/core/util/PlayerCache.java index 40f44e003a..e247646562 100644 --- a/src/Java/miscutil/core/util/PlayerCache.java +++ b/src/Java/miscutil/core/util/PlayerCache.java @@ -19,12 +19,26 @@ public class PlayerCache { private static final File cache = new File("PlayerCache.dat"); + public static final void initCache() { + if (CORE.PlayerCache == null || CORE.PlayerCache.equals(null)){ + try { + CORE.PlayerCache = PlayerCache.readPropertiesFileAsMap(); + Utils.LOG_INFO("Loaded PlayerCache.dat"); + } catch (Exception e) { + Utils.LOG_INFO("Failed to initialise PlayerCache.dat"); + PlayerCache.createPropertiesFile("CACHE FILE - ", "THIS CONTAINS PLAYERDATA"); + //e.printStackTrace(); + } + } + } + public static void createPropertiesFile(String playerName, String playerUUIDasString) { try { Properties props = new Properties(); props.setProperty(playerName, playerUUIDasString); OutputStream out = new FileOutputStream(cache); props.store(out, "Player Cache."); + Utils.LOG_INFO("Created an empty PlayerCache.dat for future use."); } catch (Exception e ) { e.printStackTrace(); @@ -66,7 +80,7 @@ public class PlayerCache { * @return The Map that contains the key/value pairs. * @throws Exception */ - private static Map<String, String> readPropertiesFileAsMap() throws Exception { + public static Map<String, String> readPropertiesFileAsMap() throws Exception { String filename = cache.getName(); String delimiter = ":"; @SuppressWarnings({ "rawtypes", "unchecked" }) |