From 5e27ff52b8f14fd802758b1a5eae7731e07dbfc1 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 20 Oct 2014 21:42:50 +1100 Subject: [PATCH] Finished new PlotMeConverter --- .../plot/PlotGenerator.java | 1 + .../intellectualcrafters/plot/PlotMain.java | 6 +++++ .../plot/commands/Purge.java | 3 +++ .../plot/commands/Setup.java | 4 --- .../plot/database/DBFunc.java | 12 ++++----- .../plot/database/PlotMeConverter.java | 26 ++++++++++++++----- 6 files changed, 35 insertions(+), 17 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotGenerator.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotGenerator.java index d485975f9..7d28a4470 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotGenerator.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotGenerator.java @@ -6,6 +6,7 @@ public abstract class PlotGenerator extends ChunkGenerator { public PlotGenerator(String world) { PlotMain.loadWorld(world, this); + System.out.print("LOADED"); } public abstract PlotWorld getNewPlotWorld(String world); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java index 956805999..d41e87936 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotMain.java @@ -1395,6 +1395,12 @@ public class PlotMain extends JavaPlugin { } } + public static void removePlotWorld(String world) { + plots.remove(world); + managers.remove(world); + worlds.remove(world); + } + public static HashMap> getAllPlotsRaw() { return plots; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Purge.java index c2c382519..97bdcaa0e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Purge.java @@ -48,6 +48,8 @@ public class Purge extends SubCommand { } PlotMain.getPlots(world).remove(id); DBFunc.purge(world, id); + PlayerFunctions.sendMessage(plr, "&aPurge of '"+args[0]+"' was successful!"); + return true; } catch (Exception e) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); @@ -66,6 +68,7 @@ public class Purge extends SubCommand { PlayerFunctions.sendMessage(plr, (C.NOT_CONSOLE)); return false; } + PlotMain.removePlotWorld(args[0]); DBFunc.purge(args[0]); PlayerFunctions.sendMessage(plr, (C.PURGE_SUCCESS)); return true; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java index d1e5a6f25..1d6c2efa3 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Setup.java @@ -96,7 +96,6 @@ public class Setup extends SubCommand implements Listener { + " plugin:" + object.plugin); } else { - for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { if (plugin.isEnabled()) { if (plugin.getDefaultWorldGenerator("world", "") != null) { @@ -112,9 +111,6 @@ public class Setup extends SubCommand implements Listener { } } - - object.getPlugin(); -// World world = WorldCreator.name("SkyWorld").generator(new object. ).createWorld(); } } sendMessage(plr, C.SETUP_FINISHED, object.world); diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java index 8d370b8c8..49e7f8d75 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/DBFunc.java @@ -483,12 +483,10 @@ public class DBFunc { plots.get(worldname).put((plot_id), p); } else { - if (worlds.contains(p.world)) { - HashMap map = new HashMap(); - map.put((plot_id), p); - plots.put(worldname, map); - } - else { + HashMap map = new HashMap(); + map.put((plot_id), p); + plots.put(worldname, map); + if (!worlds.contains(p.world)) { if (noExist.containsKey(worldname)) { noExist.put(worldname,noExist.get(worldname)+1); } @@ -499,7 +497,7 @@ public class DBFunc { } } for (String worldname: noExist.keySet()) { - PlotMain.sendConsoleSenderMessage("&4[WARNING] Found "+noExist.get(worldname)+" plots in DB for non existant world; '"+worldname+"'!!!\n&c - Please create this world, or remove the plots from the DB using the purge command!"); + PlotMain.sendConsoleSenderMessage("&c[WARNING] Found "+noExist.get(worldname)+" plots in DB for non existant world; '"+worldname+"'!!!\n&c - Please create this world, or remove the plots from the DB using the purge command!"); } stmt.close(); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java index 635df536a..bdd2fa284 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -219,7 +219,7 @@ public class PlotMeConverter { } if (pl != null) { - if (!PlotMain.getPlots(world).containsKey(pl.id)) { + if (!PlotMain.getPlots(world).containsKey(id)) { createdPlots.add(pl); } else { @@ -228,7 +228,7 @@ public class PlotMeConverter { } } if (duplicate>0) { - PlotMain.sendConsoleSenderMessage("&4[WARNING] Found "+duplicate+" duplicate plots already in DB for world: '"+world.getName()+"'. Have you run the converter already?"); + PlotMain.sendConsoleSenderMessage("&c[WARNING] Found "+duplicate+" duplicate plots already in DB for world: '"+world.getName()+"'. Have you run the converter already?"); } } } @@ -239,7 +239,7 @@ public class PlotMeConverter { // TODO createPlot doesn't add denied users DBFunc.createAllSettingsAndHelpers(createdPlots); stream.close(); - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: Saving configuration..."); + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Saving configuration..."); try { PlotMain.config.save(PlotMain.configFile); } catch (IOException e) { @@ -258,16 +258,29 @@ public class PlotMeConverter { for (String worldname : worlds) { World world = Bukkit.getWorld(worldname); - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: Reloading generator for world: '"+worldname+"'..."); + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Reloading generator for world: '"+worldname+"'..."); + + PlotMain.removePlotWorld(worldname); + if (MV) { // unload Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + worldname); + try { + Thread.sleep(1000); + } catch(InterruptedException ex) { + Thread.currentThread().interrupt(); + } // load Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + worldname + " normal -g PlotSquared"); } else if (MW) { // unload Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + worldname); + try { + Thread.sleep(1000); + } catch(InterruptedException ex) { + Thread.currentThread().interrupt(); + } // load Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + worldname+" plugin:PlotSquared"); } @@ -280,9 +293,10 @@ public class PlotMeConverter { PlotMain.setAllPlotsRaw(DBFunc.getPlots()); - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: Disabling PlotMe..."); + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Disabling PlotMe..."); Bukkit.getPluginManager().disablePlugin(plotMePlugin); - PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished"); + PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8:&7 Conversion has finished"); + PlotMain.sendConsoleSenderMessage("&cAlthough the server may be functional in it's current state, it is recommended that you restart the server and remove PlotMe to finalize the installation. Please make careful note of any warning messages that may have showed up during conversion."); } }); }