From 4711c7c8ab813259a11de13a1132f2fb646458e7 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 14 Jul 2015 07:19:20 +1000 Subject: [PATCH] Fixed PlotMe UUID caching without conversion --- PlotSquared/pom.xml | 2 +- .../intellectualcrafters/plot/BukkitMain.java | 24 ++++----- .../plotme/ClassicPlotMeConnector.java | 11 ++-- .../database/plotme/LikePlotMeConverter.java | 54 ++++++++++--------- .../database/plotme/PlotMeConnector_017.java | 11 ++-- 5 files changed, 53 insertions(+), 49 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 71a5a1fc6..2798001d1 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.12.4 + 2.12.5 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 8b5d05537..701c58d4f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -192,18 +192,18 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } else { log("&dUsing metrics will allow us to improve the plugin, please consider it :)"); } - File file = new File(this.getDirectory() + File.separator + "disabled.yml"); - if (file.exists()) { - try { - String[] split = new String(Files.readAllBytes(file.toPath())).split(","); - for (String plugin : split) { - loadPlugin(plugin); - } - } catch (IOException e) { - e.printStackTrace(); - } - file.delete(); - } +// File file = new File(this.getDirectory() + File.separator + "disabled.yml"); +// if (file.exists()) { +// file.delete(); +// try { +// String[] split = new String(Files.readAllBytes(file.toPath())).split(","); +// for (String plugin : split) { +// loadPlugin(plugin); +// } +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } List worlds = Bukkit.getWorlds(); if (worlds.size() > 0) { UUIDHandler.cacheAll(worlds.get(0).getName()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java index 74ab15b38..07dd93846 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/ClassicPlotMeConnector.java @@ -15,6 +15,7 @@ import org.bukkit.World; import com.intellectualcrafters.configuration.file.FileConfiguration; import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.SQLite; import com.intellectualcrafters.plot.object.Location; @@ -57,18 +58,18 @@ public class ClassicPlotMeConnector extends APlotMeConnector { stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "Plots`"); r = stmt.executeQuery(); boolean checkUUID = DBFunc.hasColumn(r, "ownerid"); - boolean merge = !plugin.equals("plotme"); + boolean merge = !plugin.equals("plotme") && Settings.CONVERT_PLOTME; while (r.next()) { final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ")); final String name = r.getString("owner"); final String world = LikePlotMeConverter.getWorld(r.getString("world")); if (!plots.containsKey(world)) { - int plot = PS.get().config.getInt("worlds." + world + ".plot.size"); - int path = PS.get().config.getInt("worlds." + world + ".road.width"); - plotWidth.put(world, plot); - roadWidth.put(world, path); plots.put(world, new HashMap()); if (merge) { + int plot = PS.get().config.getInt("worlds." + world + ".plot.size"); + int path = PS.get().config.getInt("worlds." + world + ".road.width"); + plotWidth.put(world, plot); + roadWidth.put(world, path); merges.put(world, new HashMap()); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/LikePlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/LikePlotMeConverter.java index 648a061d1..59d8d60fe 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/LikePlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/LikePlotMeConverter.java @@ -150,33 +150,35 @@ public class LikePlotMeConverter { sendMessage(" - " + dbPrefix + "Plots"); final Set worlds = getPlotMeWorlds(plotConfig); - sendMessage("Updating bukkit.yml"); - updateWorldYml(plugin, "bukkit.yml"); - updateWorldYml(plugin, "plugins/Multiverse-Core/worlds.yml"); - for (final String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) { - sendMessage("Copying config for: " + world); - try { - String actualWorldName = getWorld(world); - final Integer pathwidth = plotConfig.getInt("worlds." + world + ".PathWidth"); // - PS.get().config.set("worlds." + actualWorldName + ".road.width", pathwidth); - final Integer plotsize = plotConfig.getInt("worlds." + world + ".PlotSize"); // - PS.get().config.set("worlds." + actualWorldName + ".plot.size", plotsize); - final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); // - PS.get().config.set("worlds." + actualWorldName + ".wall.block", wallblock); - final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); // - PS.get().config.set("worlds." + actualWorldName + ".plot.floor", Arrays.asList(floor)); - final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); // - PS.get().config.set("worlds." + actualWorldName + ".plot.filling", Arrays.asList(filling)); - final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId"); - PS.get().config.set("worlds." + actualWorldName + ".road.block", road); - Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); // - if (height == null) { - height = 64; + if (!Settings.CONVERT_PLOTME) { + sendMessage("Updating bukkit.yml"); + updateWorldYml(plugin, "bukkit.yml"); + updateWorldYml(plugin, "plugins/Multiverse-Core/worlds.yml"); + for (final String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) { + sendMessage("Copying config for: " + world); + try { + String actualWorldName = getWorld(world); + final Integer pathwidth = plotConfig.getInt("worlds." + world + ".PathWidth"); // + PS.get().config.set("worlds." + actualWorldName + ".road.width", pathwidth); + final Integer plotsize = plotConfig.getInt("worlds." + world + ".PlotSize"); // + PS.get().config.set("worlds." + actualWorldName + ".plot.size", plotsize); + final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); // + PS.get().config.set("worlds." + actualWorldName + ".wall.block", wallblock); + final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); // + PS.get().config.set("worlds." + actualWorldName + ".plot.floor", Arrays.asList(floor)); + final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); // + PS.get().config.set("worlds." + actualWorldName + ".plot.filling", Arrays.asList(filling)); + final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId"); + PS.get().config.set("worlds." + actualWorldName + ".road.block", road); + Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); // + if (height == null) { + height = 64; + } + PS.get().config.set("worlds." + actualWorldName + ".road.height", height); + PS.get().config.save(PS.get().configFile); + } catch (final Exception e) { + sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); } - PS.get().config.set("worlds." + actualWorldName + ".road.height", height); - PS.get().config.save(PS.get().configFile); - } catch (final Exception e) { - sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConnector_017.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConnector_017.java index e23eeb75b..4765624b9 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConnector_017.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConnector_017.java @@ -12,6 +12,7 @@ import java.util.Map.Entry; import com.intellectualcrafters.configuration.file.FileConfiguration; import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.SQLite; import com.intellectualcrafters.plot.object.Location; @@ -56,18 +57,18 @@ public class PlotMeConnector_017 extends APlotMeConnector { stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "core_plots`"); r = stmt.executeQuery(); boolean checkUUID = DBFunc.hasColumn(r, "ownerID"); - boolean merge = !plugin.equals("plotme"); + boolean merge = !plugin.equals("plotme") && Settings.CONVERT_PLOTME; while (r.next()) { int key = r.getInt("plot_id"); PlotId id = new PlotId(r.getInt("plotX"), r.getInt("plotZ")); String name = r.getString("owner"); String world = LikePlotMeConverter.getWorld(r.getString("world")); if (!plots.containsKey(world)) { - int plot = PS.get().config.getInt("worlds." + world + ".plot.size"); - int path = PS.get().config.getInt("worlds." + world + ".road.width"); - plotWidth.put(world, plot); - roadWidth.put(world, path); if (merge) { + int plot = PS.get().config.getInt("worlds." + world + ".plot.size"); + int path = PS.get().config.getInt("worlds." + world + ".road.width"); + plotWidth.put(world, plot); + roadWidth.put(world, path); merges.put(world, new HashMap()); } }