diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 683b7342b..0f8ab307b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -73,11 +73,14 @@ import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.sk89q.worldedit.WorldEdit; import java.io.File; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -91,10 +94,58 @@ import org.bukkit.event.Listener; import org.bukkit.generator.ChunkGenerator; import org.bukkit.metadata.MetadataValue; import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { + private static ConcurrentHashMap pluginMap; + + static { + { // Disable AWE as otherwise both fail to load + PluginManager manager = Bukkit.getPluginManager(); + try { + Settings.load(new File("plugins/PlotSquared/config/settings.yml")); + if (Settings.Enabled_Components.PLOTME_CONVERTER) { // Only disable PlotMe if conversion is enabled + Field pluginsField = manager.getClass().getDeclaredField("plugins"); + Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames"); + pluginsField.setAccessible(true); + lookupNamesField.setAccessible(true); + List plugins = (List) pluginsField.get(manager); + Iterator iter = plugins.iterator(); + while (iter.hasNext()) { + if (iter.next().getName().startsWith("PlotMe")) { + iter.remove(); + } + } + Map lookupNames = (Map) lookupNamesField.get(manager); + lookupNames.remove("PlotMe"); + lookupNames.remove("PlotMe-DefaultGenerator"); + pluginsField.set(manager, new ArrayList(plugins) { + @Override + public boolean add(Plugin plugin) { + if (plugin.getName().startsWith("PlotMe")) { + } else { + return super.add(plugin); + } + return false; + } + }); + pluginMap = new ConcurrentHashMap(lookupNames) { + @Override + public Plugin put(String key, Plugin plugin) { + if (!plugin.getName().startsWith("PlotMe")) { + return super.put(key, plugin); + } + return null; + } + }; + lookupNamesField.set(manager, pluginMap); + } + } catch (Throwable ignore) {} + } + } + public static WorldEdit worldEdit; private int[] version; @@ -123,6 +174,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain @Override public void onEnable() { + if (pluginMap != null) { + pluginMap.put("PlotMe-DefaultGenerator", this); + } this.name = getDescription().getName(); getServer().getName(); new PS(this, "Bukkit"); @@ -364,6 +418,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain @Override public final ChunkGenerator getDefaultWorldGenerator(String world, String id) { + if (Settings.Enabled_Components.PLOTME_CONVERTER) { + initPlotMeConverter(); + Settings.Enabled_Components.PLOTME_CONVERTER = false; + } IndependentPlotGenerator result = PS.get().IMP.getDefaultGenerator(); if (!PS.get().setupPlotWorld(world, id, result)) { return null; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java index 364868a35..ceefbf661 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java @@ -117,7 +117,7 @@ public class LikePlotMeConverter { PS.get().worlds.set("worlds." + world + ".plot.height", height); int plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize", 32); // PS.get().worlds.set("worlds." + world + ".plot.size", plotSize); - String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", plotmeDgYml.getString("worlds." + plotMeWorldName + ".UnclaimedBorder", "44")); // + String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".UnclaimedBorder", plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44")); // PS.get().worlds.set("worlds." + world + ".wall.block", wallblock); String claimed = plotmeDgYml.getString("worlds." + plotMeWorldName + ".ProtectedWallBlock", "44:1"); // PS.get().worlds.set("worlds." + world + ".wall.block_claimed", claimed); @@ -158,7 +158,7 @@ public class LikePlotMeConverter { return false; } - sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'"); + sendMessage("PlotMe conversion has started. To disable this, please set 'enabled-components -> plotme-converter' to false in the 'settings.yml'"); mergeWorldYml(plotConfig); @@ -261,7 +261,7 @@ public class LikePlotMeConverter { done(); sendMessage("&aDatabase conversion is now complete!"); PS.debug("&c - Stop the server"); - PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml"); + PS.debug("&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml"); PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly"); PS.debug("&c - Start the server"); PS.get().setPlots(DBFunc.getPlots()); @@ -339,7 +339,7 @@ public class LikePlotMeConverter { done(); sendMessage("&aDatabase conversion is now complete!"); PS.debug("&c - Stop the server"); - PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml"); + PS.debug("&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml"); PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly"); PS.debug("&c - Start the server"); } else { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 3dfc3917c..cee656cf1 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -416,7 +416,7 @@ public class PS { PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PlotMe!"); PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!"); PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); - PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the " + PS.log("&c - After the conversion is finished, please set 'plotme-converter' to false in the " + "'settings.yml'"); } Settings.Enabled_Components.PLOTME_CONVERTER = false;