From a04fabce9007783506cec2bda3bfc3ecd89fca00 Mon Sep 17 00:00:00 2001 From: Recursive G Date: Sat, 19 Nov 2016 21:15:19 -0600 Subject: [PATCH] fixes --- src/main/java/cat/nyaa/playtimetracker/DatabaseRecord.java | 2 +- src/main/java/cat/nyaa/playtimetracker/Main.java | 7 ++++--- src/main/java/cat/nyaa/playtimetracker/RecordManager.java | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/cat/nyaa/playtimetracker/DatabaseRecord.java b/src/main/java/cat/nyaa/playtimetracker/DatabaseRecord.java index 23fd97d..1d6fad0 100644 --- a/src/main/java/cat/nyaa/playtimetracker/DatabaseRecord.java +++ b/src/main/java/cat/nyaa/playtimetracker/DatabaseRecord.java @@ -71,7 +71,7 @@ public static DatabaseRecord deserialize_legacy(UUID id, String old_format_strin } public void serialize(ConfigurationSection sec) { - sec.set("last_seen", lastSeen); + sec.set("last_seen", lastSeen.toString()); sec.set("daily_play_time", dailyTime); sec.set("weekly_play_time", weeklyTime); sec.set("monthly_play_time", monthlyTime); diff --git a/src/main/java/cat/nyaa/playtimetracker/Main.java b/src/main/java/cat/nyaa/playtimetracker/Main.java index a87ea48..51ffae0 100644 --- a/src/main/java/cat/nyaa/playtimetracker/Main.java +++ b/src/main/java/cat/nyaa/playtimetracker/Main.java @@ -70,6 +70,7 @@ public void onEnable() { database = new DatabaseManager(newDataFile); } else { if (legacyDataFile.isFile()) { // migrate old db + getLogger().info("Updating old database... data.txt"); database = new DatabaseManager(newDataFile, legacyDataFile); } else { // no database getLogger().info("Creating database... database.yml"); @@ -149,7 +150,7 @@ private void notifyAcquire(Player p) { @Override public void run() { // Auto-save timer - Set affectedPlayers = updater.updateAllOnlinePlayers(); + updater.updateAllOnlinePlayers(); for (Player p : Bukkit.getOnlinePlayers()) { notifyAcquire(p); } @@ -255,7 +256,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if (sender.hasPermission("ptt.view.others")) { OfflinePlayer p = Bukkit.getOfflinePlayer(args[0]); if (p instanceof Player) { - updater.updateSingle((Player) p); + updater.updateSingle(p); } printStatistic(sender, p); } else { @@ -289,7 +290,7 @@ private void printStatistic(CommandSender s, OfflinePlayer p) { * @return set of rules, not null */ @NotNull - public Set getSatisfiedRules(UUID id) { + private Set getSatisfiedRules(UUID id) { Set ret = new HashSet<>(); SessionedRecord rec = updater.getFullRecord(id); if (rec.getSessionTime() > 0) { diff --git a/src/main/java/cat/nyaa/playtimetracker/RecordManager.java b/src/main/java/cat/nyaa/playtimetracker/RecordManager.java index be1efaa..5199ea4 100644 --- a/src/main/java/cat/nyaa/playtimetracker/RecordManager.java +++ b/src/main/java/cat/nyaa/playtimetracker/RecordManager.java @@ -88,7 +88,7 @@ public void updateSingle(OfflinePlayer p) { */ private UUID updateAccumulative(UUID id) { if (id == null) return null; - if (Main.isAFK(id)) updateNonAccumulative(id); + if (Main.isAFK(id)) return updateNonAccumulative(id); DatabaseRecord rec = db.getRecord(id); if (rec == null) { db.createRecord(id, ZonedDateTime.now()); @@ -218,5 +218,6 @@ public void markRuleAsApplied(UUID id, Rule rule) { break; } } + db.save(); } }