Selaa lähdekoodia

Properly calculate diff times for old user purge. Fixes #2541

t00thpick1 10 vuotta sitten
vanhempi
sitoutus
d8184fb298

+ 2 - 2
src/main/java/com/gmail/nossr50/database/DatabaseManager.java

@@ -11,8 +11,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
 import com.gmail.nossr50.datatypes.skills.SkillType;
 import com.gmail.nossr50.datatypes.skills.SkillType;
 
 
 public interface DatabaseManager {
 public interface DatabaseManager {
-    // One month in seconds
-    public final long PURGE_TIME = 2630000L * Config.getInstance().getOldUsersCutoff();
+    // One month in milliseconds
+    public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
     // During convertUsers, how often to output a status
     // During convertUsers, how often to output a status
     public final int progressInterval = 200;
     public final int progressInterval = 200;
 
 

+ 4 - 3
src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java

@@ -157,7 +157,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
 
 
     public void purgeOldUsers() {
     public void purgeOldUsers() {
         massUpdateLock.lock();
         massUpdateLock.lock();
-        mcMMO.p.getLogger().info("Purging inactive users older than " + (PURGE_TIME / 2630000L) + " months...");
+        mcMMO.p.getLogger().info("Purging inactive users older than " + (PURGE_TIME / 2630000000L) + " months...");
 
 
         Connection connection = null;
         Connection connection = null;
         Statement statement = null;
         Statement statement = null;
@@ -664,7 +664,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
                             + "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
                             + "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
                             + "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
                             + "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
                             + "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
                             + "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
-                            + "h.mobhealthbar, h.scoreboardtips, u.uuid "
+                            + "h.mobhealthbar, h.scoreboardtips, u.uuid, u.user "
                             + "FROM " + tablePrefix + "users u "
                             + "FROM " + tablePrefix + "users u "
                             + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
                             + "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
                             + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
                             + "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
@@ -678,10 +678,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
             if (resultSet.next()) {
             if (resultSet.next()) {
                 try {
                 try {
                     PlayerProfile profile = loadFromResult(playerName, resultSet);
                     PlayerProfile profile = loadFromResult(playerName, resultSet);
+                    String name = resultSet.getString(42); // TODO: Magic Number, make sure it stays updated
                     resultSet.close();
                     resultSet.close();
                     statement.close();
                     statement.close();
 
 
-                    if (!playerName.isEmpty() && !profile.getPlayerName().isEmpty()) {
+                    if (!playerName.isEmpty() && !playerName.equals(name)) {
                         statement = connection.prepareStatement(
                         statement = connection.prepareStatement(
                                 "UPDATE `" + tablePrefix + "users` "
                                 "UPDATE `" + tablePrefix + "users` "
                                         + "SET user = ?, uuid = ? "
                                         + "SET user = ?, uuid = ? "