mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
New PlotMe converter... untested
This commit is contained in:
parent
794ef7a01e
commit
c57e518143
@ -224,9 +224,10 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All loaded plots
|
* List of all plots
|
||||||
|
* DO NOT USE EXCEPT FOR DATABASE PURPOSES
|
||||||
*/
|
*/
|
||||||
private static HashMap<String, HashMap<PlotId, Plot>> plots;
|
static HashMap<String, HashMap<PlotId, Plot>> plots;
|
||||||
/**
|
/**
|
||||||
* All loaded plot worlds
|
* All loaded plot worlds
|
||||||
*/
|
*/
|
||||||
@ -1394,4 +1395,12 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HashMap<String, HashMap<PlotId, Plot>> getAllPlotsRaw() {
|
||||||
|
return plots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAllPlotsRaw(HashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||||
|
PlotMain.plots = plots;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
@ -84,15 +86,37 @@ public class Setup extends SubCommand implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creating the worlds
|
// Creating the worlds
|
||||||
if (object.getPlugin().equals("Multiverse-Core")) {
|
if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world
|
||||||
+ " normal -g " + object.plugin);
|
+ " normal -g " + object.plugin);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
if (object.getPlugin().equals("MultiWorld")) {
|
if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world
|
||||||
+ " plugin:" + object.plugin);
|
+ " plugin:" + object.plugin);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||||
|
if (plugin.isEnabled()) {
|
||||||
|
if (plugin.getDefaultWorldGenerator("world", "") != null) {
|
||||||
|
String name = plugin.getDescription().getName();
|
||||||
|
if (object.plugin.equals(name)) {
|
||||||
|
ChunkGenerator generator = plugin.getDefaultWorldGenerator(world, "");
|
||||||
|
World myworld = WorldCreator.name(world).generator(generator).createWorld();
|
||||||
|
PlayerFunctions.sendMessage(plr, "&aLoaded world.");
|
||||||
|
plr.teleport(myworld.getSpawnLocation());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object.getPlugin();
|
||||||
|
// World world = WorldCreator.name("SkyWorld").generator(new object. ).createWorld();
|
||||||
|
}
|
||||||
|
}
|
||||||
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
sendMessage(plr, C.SETUP_FINISHED, object.world);
|
||||||
|
|
||||||
setupMap.remove(plrname);
|
setupMap.remove(plrname);
|
||||||
|
@ -1,22 +1,35 @@
|
|||||||
package com.intellectualcrafters.plot.database;
|
package com.intellectualcrafters.plot.database;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
import com.intellectualcrafters.plot.Configuration;
|
||||||
|
import com.intellectualcrafters.plot.ConfigurationNode;
|
||||||
|
import com.intellectualcrafters.plot.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.PlotHomePosition;
|
import com.intellectualcrafters.plot.PlotHomePosition;
|
||||||
import com.intellectualcrafters.plot.PlotId;
|
import com.intellectualcrafters.plot.PlotId;
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.generator.WorldGenerator;
|
||||||
import com.worldcretornica.plotme.PlayerList;
|
import com.worldcretornica.plotme.PlayerList;
|
||||||
import com.worldcretornica.plotme.Plot;
|
import com.worldcretornica.plotme.Plot;
|
||||||
import com.worldcretornica.plotme.PlotManager;
|
import com.worldcretornica.plotme.PlotManager;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,30 +56,55 @@ public class PlotMeConverter {
|
|||||||
new ArrayList<com.intellectualcrafters.plot.Plot>();
|
new ArrayList<com.intellectualcrafters.plot.Plot>();
|
||||||
boolean online = Bukkit.getServer().getOnlineMode();
|
boolean online = Bukkit.getServer().getOnlineMode();
|
||||||
|
|
||||||
FileConfiguration plotConfig = Bukkit.getPluginManager().getPlugin("PlotMe").getConfig();
|
Plugin plotMePlugin = Bukkit.getPluginManager().getPlugin("PlotMe");
|
||||||
|
FileConfiguration plotConfig = plotMePlugin.getConfig();
|
||||||
|
|
||||||
|
Set<String> worlds = new HashSet<String>();
|
||||||
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
int duplicate = 0;
|
int duplicate = 0;
|
||||||
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
||||||
if (plots != null) {
|
if (plots != null) {
|
||||||
|
|
||||||
|
worlds.add(world.getName());
|
||||||
|
|
||||||
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting configuration for world '"+world.getName()+"'...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size()
|
Integer pathwidth = plotConfig.getInt("worlds."+world.getName()+".PathWidth"); //
|
||||||
+ "' plots for world '" + world.getName() + "'");
|
PlotMain.config.set("worlds."+world.getName()+".road.width", pathwidth);
|
||||||
|
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting configuration...");
|
Integer plotsize = plotConfig.getInt("worlds."+world.getName()+".PlotSize"); //
|
||||||
|
PlotMain.config.set("worlds."+world.getName()+".plot.size", plotsize);
|
||||||
|
|
||||||
int pathwidth = plotConfig.getInt("worlds."+world.getName()+".PathWidth");
|
String wallblock = plotConfig.getString("worlds."+world.getName()+".WallBlockId"); //
|
||||||
int plotsize = plotConfig.getInt("worlds."+world.getName()+".PlotSize");
|
PlotMain.config.set("worlds."+world.getName()+".wall.block", wallblock);
|
||||||
int wallblock = Integer.parseInt(plotConfig.getString("worlds."+world.getName()+".WallBlockId"));
|
|
||||||
int floor = Integer.parseInt(plotConfig.getString("worlds."+world.getName()+".PlotFloorBlockId"));
|
|
||||||
int filling = Integer.parseInt(plotConfig.getString("worlds."+world.getName()+".PlotFillingBlockId"));
|
|
||||||
int road = Integer.parseInt(plotConfig.getString("worlds."+world.getName()+".RoadMainBlockId"));
|
|
||||||
int road_height = plotConfig.getInt("worlds."+world.getName()+".RoadHeight");
|
|
||||||
|
|
||||||
// PlotMain.config.
|
String floor = plotConfig.getString("worlds."+world.getName()+".PlotFloorBlockId"); //
|
||||||
|
PlotMain.config.set("worlds."+world.getName()+".plot.floor", Arrays.asList(new String[] {floor}));
|
||||||
|
|
||||||
|
String filling = plotConfig.getString("worlds."+world.getName()+".PlotFillingBlockId"); //
|
||||||
|
PlotMain.config.set("worlds."+world.getName()+".plot.filling", Arrays.asList(new String[] {filling}));
|
||||||
|
|
||||||
|
String road = plotConfig.getString("worlds."+world.getName()+".RoadMainBlockId");
|
||||||
|
PlotMain.config.set("worlds."+world.getName()+".road.block", road);
|
||||||
|
|
||||||
|
String road_stripe = plotConfig.getString("worlds."+world.getName()+".RoadStripeBlockId");
|
||||||
|
PlotMain.config.set("worlds."+world.getName()+".road.stripes", road_stripe);
|
||||||
|
|
||||||
|
Integer height = plotConfig.getInt("worlds."+world.getName()+".RoadHeight"); //
|
||||||
|
PlotMain.config.set("worlds."+world.getName()+".road.height", height);
|
||||||
|
|
||||||
|
Boolean auto_link = plotConfig.getBoolean("worlds."+world.getName()+".AutoLinkPlots"); //
|
||||||
|
PlotMain.config.set("worlds."+world.getName()+".plot.auto_merge", auto_link);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
PlotMain.sendConsoleSenderMessage(" - Failed to save configuration for world '"+world.getName()+"'. This will need to be done using the setup command or manually.");
|
||||||
|
}
|
||||||
|
|
||||||
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size() + "' plots for world '" + world.getName() + "'");
|
||||||
|
|
||||||
for (Plot plot : plots.values()) {
|
for (Plot plot : plots.values()) {
|
||||||
ArrayList<UUID> psAdded = new ArrayList<>();
|
ArrayList<UUID> psAdded = new ArrayList<>();
|
||||||
@ -201,22 +239,50 @@ public class PlotMeConverter {
|
|||||||
// TODO createPlot doesn't add denied users
|
// TODO createPlot doesn't add denied users
|
||||||
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
||||||
stream.close();
|
stream.close();
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Copying configuration");
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: Saving configuration...");
|
||||||
|
try {
|
||||||
|
PlotMain.config.save(PlotMain.configFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
PlotMain.sendConsoleSenderMessage(" - &cFailed to save configuration.");
|
||||||
|
}
|
||||||
|
|
||||||
// TODO
|
boolean MV = false;
|
||||||
|
boolean MW = false;
|
||||||
|
|
||||||
// copy over plotme config
|
if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||||
|
MV = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MW = true;
|
||||||
|
}
|
||||||
|
|
||||||
// disable PlotMe
|
for (String worldname : worlds) {
|
||||||
|
World world = Bukkit.getWorld(worldname);
|
||||||
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: Reloading generator for world: '"+worldname+"'...");
|
||||||
|
if (MV) {
|
||||||
|
// unload
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + worldname);
|
||||||
|
// 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);
|
||||||
|
// load
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + worldname+" plugin:PlotSquared");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Bukkit.getServer().unloadWorld(world, true);
|
||||||
|
World myworld = WorldCreator.name(worldname).generator(new WorldGenerator(worldname)).createWorld();
|
||||||
|
myworld.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// unload all plot worlds with MV or MW
|
PlotMain.setAllPlotsRaw(DBFunc.getPlots());
|
||||||
|
|
||||||
// import those worlds with MV or MW
|
|
||||||
|
|
||||||
// have server owner stop the server and delete PlotMe at some point
|
|
||||||
|
|
||||||
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: Disabling PlotMe...");
|
||||||
|
Bukkit.getPluginManager().disablePlugin(plotMePlugin);
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished");
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished");
|
||||||
Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user