From c4d328455e0595688456ec885ce43e7860fb79ff Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 1 Oct 2014 19:35:11 +1000 Subject: [PATCH] PlotMe converter changes --- .../plot/database/DBFunc.java | 68 +++++++++++++++++++ .../plot/database/PlotMeConverter.java | 9 ++- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java index 75bd06172..415c756ca 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java @@ -64,7 +64,75 @@ public class DBFunc { } }); } + + public static void createAllSettings() { + final ArrayList ids = new ArrayList(); + try { + PreparedStatement stmt = connection.prepareStatement("SELECT `id` FROM `plot`"); + ResultSet result = stmt.executeQuery(); + while (result.next()) { + int id = result.getInt("id"); + ids.add(id); + } + } catch (SQLException e) { + e.printStackTrace(); + } + if (ids.size()==0) { + System.out.print("ERROR: No plots found"); + return; + } + final StringBuilder statement = new StringBuilder("INSERT INTO `plot_settings`(`plot_plot_id`) values "); + for (int i = 0; i plots) { + if (plots.size()==0) { + return; + } + StringBuilder statement = new StringBuilder("INSERT INTO `plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`) values "); + + for (int i = 0; i createdPlots = new ArrayList(); + ArrayList createdIds = new ArrayList(); for (World world : Bukkit.getWorlds()) { HashMap plots = PlotManager.getPlots(world); if (plots!=null) { @@ -85,11 +88,13 @@ public class PlotMeConverter { // TODO createPlot doesn't add helpers / denied users - DBFunc.createPlot(pl); - DBFunc.createPlotSettings(DBFunc.getId(world.getName(), pl.id), pl); + createdPlots.add(pl); } } } + PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Saving to DB"); + DBFunc.createPlots(createdPlots); + DBFunc.createAllSettings(); stream.close(); PlotMain.sendConsoleSenderMessage("PlotMe->PlotSquared Conversion has finished");