From 7e4188e7766d3828f45763a7e000aa9f3dc4c719 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 5 Feb 2013 17:09:20 -0500 Subject: [PATCH] ACTUALLY make removing powerless players work for Flatfile. Old users will only work from here forward - we never tracked login time before for FlatFile. --- .../com/gmail/nossr50/database/Leaderboard.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/database/Leaderboard.java b/src/main/java/com/gmail/nossr50/database/Leaderboard.java index d2d39e708..9b8a3dfd7 100644 --- a/src/main/java/com/gmail/nossr50/database/Leaderboard.java +++ b/src/main/java/com/gmail/nossr50/database/Leaderboard.java @@ -14,10 +14,8 @@ import org.bukkit.Bukkit; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; -import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.skills.utilities.SkillType; import com.gmail.nossr50.util.Misc; -import com.gmail.nossr50.util.Users; public final class Leaderboard { private static HashMap> playerStatHash = new HashMap>(); @@ -320,14 +318,8 @@ public final class Leaderboard { mcMMO.p.getLogger().info("Purging powerless users..."); int purgedUsers = 0; - for (McMMOPlayer player : Users.getPlayers().values()) { - String playerName = player.getPlayer().getName(); - - if (playerName == null || Bukkit.getOfflinePlayer(playerName).isOnline()) { - continue; - } - - if (getPlayerRank(playerName)[1] == 0 && removeFlatFileUser(playerName)) { + for (PlayerStat stat : powerLevels) { + if (stat.statVal == 0 && removeFlatFileUser(stat.name) && !Bukkit.getOfflinePlayer(stat.name).isOnline()) { purgedUsers++; } } @@ -359,7 +351,8 @@ public final class Leaderboard { while ((line = in.readLine()) != null) { /* Write out the same file but when we get to the player we want to remove, we skip his line. */ - if (currentTime - (Misc.getLong(line.split(":")[37]) * 1000) <= purgeTime) { + String[] splitLine = line.split(":"); + if (splitLine.length > 37 && currentTime - (Misc.getLong(line.split(":")[37]) * 1000) <= purgeTime) { writer.append(line).append("\r\n"); } else {