mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Streamline PlotMe conversion
Use reflection to disable PlotMe and forward DefaultGenerator to PlotSquared Fix border material copying from plotme config You no longer need to delete the PlotMe jar for conversion Fix some outdated messages
This commit is contained in:
parent
f1d581a8d8
commit
499120963a
@ -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<String, Plugin> 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<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
|
||||
Iterator<Plugin> iter = plugins.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (iter.next().getName().startsWith("PlotMe")) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
Map<String, Plugin> lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
|
||||
lookupNames.remove("PlotMe");
|
||||
lookupNames.remove("PlotMe-DefaultGenerator");
|
||||
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
|
||||
@Override
|
||||
public boolean add(Plugin plugin) {
|
||||
if (plugin.getName().startsWith("PlotMe")) {
|
||||
} else {
|
||||
return super.add(plugin);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
pluginMap = new ConcurrentHashMap<String, Plugin>(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;
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user