mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 00:56:47 +01:00
Move OfflinePlayer lastPlayed checks to purge
This commit is contained in:
parent
bbf16d8058
commit
7d43e7eba5
@ -119,13 +119,16 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
while ((line = in.readLine()) != null) {
|
while ((line = in.readLine()) != null) {
|
||||||
String[] character = line.split(":");
|
String[] character = line.split(":");
|
||||||
String name = character[0];
|
String name = character[0];
|
||||||
long lastPlayed;
|
long lastPlayed = 0;
|
||||||
boolean rewrite = false;
|
boolean rewrite = false;
|
||||||
try {
|
try {
|
||||||
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
|
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
if (lastPlayed == 0) {
|
||||||
|
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||||
|
lastPlayed = player.getLastPlayed();
|
||||||
rewrite = true;
|
rewrite = true;
|
||||||
lastPlayed = System.currentTimeMillis();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentTime - lastPlayed > PURGE_TIME) {
|
if (currentTime - lastPlayed > PURGE_TIME) {
|
||||||
@ -624,14 +627,9 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
|||||||
// Making old-purge work with flatfile
|
// Making old-purge work with flatfile
|
||||||
// Version 1.4.00-dev
|
// Version 1.4.00-dev
|
||||||
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
|
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
|
||||||
String playerName = character[0];
|
|
||||||
// Try to get a accurate time, instead of "right now"
|
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(playerName);
|
newLine.append("0").append(":");
|
||||||
long time = player.getLastPlayed();
|
|
||||||
if (time == 0) {
|
|
||||||
time = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
newLine.append(time / Misc.TIME_CONVERSION_FACTOR).append(":");
|
|
||||||
announce = true; // TODO move this down
|
announce = true; // TODO move this down
|
||||||
if (oldVersion == null) oldVersion = "1.4.00";
|
if (oldVersion == null) oldVersion = "1.4.00";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user