From 052019bb35143a8566388eabf01dc1bfefd3af71 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 13 Sep 2015 13:30:28 +1000 Subject: [PATCH] default to offline-mode uuid if owner isn't valid. --- .../database/plotme/ClassicPlotMeConnector.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java b/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java index d63f952a0..dad697765 100644 --- a/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java +++ b/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.Map.Entry; import java.util.UUID; +import com.google.common.base.Charsets; import com.intellectualcrafters.configuration.file.FileConfiguration; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.Settings; @@ -75,6 +76,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector column = "ownerId"; } final boolean merge = !plugin.equals("plotme") && Settings.CONVERT_PLOTME; + int missing = 0; while (r.next()) { final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); @@ -160,7 +162,11 @@ public class ClassicPlotMeConnector extends APlotMeConnector } if (owner == null) { + if (name.length() > 0) { + owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8)); + } MainUtil.sendConsoleMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); + missing++; continue; } } @@ -172,6 +178,12 @@ public class ClassicPlotMeConnector extends APlotMeConnector final Plot plot = new Plot(world, id, owner); plots.get(world).put(id, plot); } + if (missing > 0) { + MainUtil.sendConsoleMessage("&cSome names could not be identified:"); + MainUtil.sendConsoleMessage("&7 - Empty quotes mean PlotMe just stored an unowned plot in the database"); + MainUtil.sendConsoleMessage("&7 - Names you have never seen before could be from people mistyping commands"); + MainUtil.sendConsoleMessage("&7 - Converting from a non-uuid version of PlotMe can't identify owners if the playerdata files are deleted (these plots will remain unknown until the player connects)"); + } for (final Entry> entry : merges.entrySet()) {