From cb6d8392145070b56b74919f26f037816b4b4a0a Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 11 Jan 2017 07:21:36 +1100 Subject: [PATCH] Possible fix for #1476 Changes database load to prefer the latest entry over older ones. Some previous changes may fix connections dropping, which resulted in (incorrect) fixes being attempted by the plugin. --- .../plot/database/SQLManager.java | 23 +++++++++---------- .../plot/util/expiry/ExpireManager.java | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index 6ac643606..318165a87 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -1683,7 +1683,7 @@ public class SQLManager implements AbstractDB { try { time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(parsable).getTime(); } catch (ParseException e) { - PS.debug("Could not parse date for plot: " + id + " (" + parsable + ")"); + PS.debug("Could not parse date for plot: #" + id + "(" + areaid + ";" + plot_id + ") (" + parsable + ")"); time = System.currentTimeMillis() + id; } } @@ -1693,11 +1693,10 @@ public class SQLManager implements AbstractDB { if (map != null) { Plot last = map.put(p.getId(), p); if (last != null) { - map.put(last.getId(), last); if (Settings.Enabled_Components.DATABASE_PURGER) { - toDelete.add(id); + toDelete.add(last.temp); } else { - PS.debug("&cPLOT " + id + " in `" + this.prefix + PS.debug("&cPLOT #" + id + "(" + last + ") in `" + this.prefix + "plot` is a duplicate. Delete this plot or set `auto-purge: true` in the settings.yml."); } continue; @@ -1728,7 +1727,7 @@ public class SQLManager implements AbstractDB { } else if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(id); } else { - PS.debug("&cENTRY " + id + " in `plot_rating` does not exist. Create this plot or set `auto-purge: true` in the " + PS.debug("&cENTRY #" + id + "(" + plot + ") in `plot_rating` does not exist. Create this plot or set `auto-purge: true` in the " + "settings.yml."); } } @@ -1755,7 +1754,7 @@ public class SQLManager implements AbstractDB { } else if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(id); } else { - PS.debug("&cENTRY " + id + " in `plot_helpers` does not exist. Create this plot or set `auto-purge: true` in the settings" + PS.debug("&cENTRY #" + id + "(" + plot + ") in `plot_helpers` does not exist. Create this plot or set `auto-purge: true` in the settings" + ".yml."); } } @@ -1781,7 +1780,7 @@ public class SQLManager implements AbstractDB { } else if (Settings.Enabled_Components.DATABASE_PURGER) { toDelete.add(id); } else { - PS.debug("&cENTRY " + id + " in `plot_trusted` does not exist. Create this plot or set `auto-purge: true` in the settings" + PS.debug("&cENTRY #" + id + "(" + plot + ") in `plot_trusted` does not exist. Create this plot or set `auto-purge: true` in the settings" + ".yml."); } } @@ -1881,7 +1880,7 @@ public class SQLManager implements AbstractDB { } } if (exception) { - PS.debug("&cPlot " + id + " | " + plot + " had an invalid flag. A fix has been attempted."); + PS.debug("&cPlot #" + id + "(" + plot + ") | " + plot + " had an invalid flag. A fix has been attempted."); PS.debug("&c" + myflags); this.setFlags(plot, flags); } @@ -1890,7 +1889,7 @@ public class SQLManager implements AbstractDB { toDelete.add(id); } else { PS.debug( - "&cENTRY " + id + " in `plot_settings` does not exist. Create this plot or set `auto-purge: true` in the settings" + "&cENTRY #" + id + "(" + plot + ") in `plot_settings` does not exist. Create this plot or set `auto-purge: true` in the settings" + ".yml."); } } @@ -2608,7 +2607,7 @@ public class SQLManager implements AbstractDB { if (cluster != null) { cluster.helpers.add(user); } else { - PS.debug("&cCluster " + id + " in cluster_helpers does not exist. Please create the cluster or remove this entry."); + PS.debug("&cCluster #" + id + "(" + cluster + ") in cluster_helpers does not exist. Please create the cluster or remove this entry."); } } // Getting invited @@ -2625,7 +2624,7 @@ public class SQLManager implements AbstractDB { if (cluster != null) { cluster.invited.add(user); } else { - PS.debug("&cCluster " + id + " in cluster_invited does not exist. Please create the cluster or remove this entry."); + PS.debug("&cCluster #" + id + "(" + cluster + ") in cluster_invited does not exist. Please create the cluster or remove this entry."); } } resultSet = stmt.executeQuery("SELECT * FROM `" + this.prefix + "cluster_settings`"); @@ -2691,7 +2690,7 @@ public class SQLManager implements AbstractDB { } cluster.settings.flags = flags; } else { - PS.debug("&cCluster " + id + " in cluster_settings does not exist. Please create the cluster or remove this entry."); + PS.debug("&cCluster #" + id + "(" + cluster + ") in cluster_settings does not exist. Please create the cluster or remove this entry."); } } resultSet.close(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java index 22349a858..e03e59935 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java @@ -356,7 +356,7 @@ public class ExpireManager { PlotAnalysis changed = plot.getComplexity(null); int changes = changed == null ? 0 : changed.changes_sd; int modified = changed == null ? 0 : changed.changes; - PS.debug("$2[&5Expire&dManager$2] &cDeleted expired plot: " + plot + " : " + changes + " - " + modified); + PS.debug("$2[&5Expire&dManager$2] &cDeleted expired plot: " + plot + " User:" + plot.owner + " Delta:" + changes + "/" + modified); PS.debug("$4 - Area: " + plot.getArea()); if (plot.hasOwner()) { PS.debug("$4 - Owner: " + UUIDHandler.getName(plot.owner));