예제 #1
0
 public void load() throws IOException {
   FileReader fr = new FileReader(logFile);
   Object injection = helper.load(fr);
   fr.close();
   if (injection instanceof HashMap) {
     cache.clear();
     HashMap<String, List<HashMap<String, String>>> superObject =
         (HashMap<String, List<HashMap<String, String>>>) injection;
     for (Map.Entry<String, List<HashMap<String, String>>> entry : superObject.entrySet()) {
       List<LogEntry> logEntries = new LinkedList<>();
       for (HashMap<String, String> dump : entry.getValue())
         logEntries.add(LogEntry.parseDump(dump));
       cache.put(Identity.deserializeIdentity(entry.getKey()).getUniqueId(), logEntries);
     }
   }
 }
예제 #2
0
        public void unload() throws IOException {
          HashMap<String, List<HashMap<String, String>>> superObject = new HashMap<>();
          for (Map.Entry<UUID, List<LogEntry>> entry : cache.entrySet()) {
            // For each player, build a list of HashMaps which each represent a LogEntry.
            // Build the list!
            List<HashMap<String, String>> logEntries = new LinkedList<>();
            for (LogEntry le : entry.getValue()) logEntries.add(le.toDump());
            superObject.put(
                Identity.serializeIdentity(Bukkit.getOfflinePlayer(entry.getKey())), logEntries);
          }

          // Write!
          FileWriter fw = new FileWriter(logFile);
          helper.dump(superObject, fw);
          fw.flush();
          fw.close();
        }