mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Working on PlotMeConverter
Re-organized some debug messages to display messages in a better format.
This commit is contained in:
parent
92178ee696
commit
27c011f488
@ -592,9 +592,13 @@ public class PlotMain extends JavaPlugin {
|
||||
}
|
||||
catch (ClassNotFoundException | SQLException e) {
|
||||
Logger.add(LogLevel.DANGER, "MySQL connection failed.");
|
||||
System.out.print("\u001B[31m[Plots] MySQL is not setup correctly. The plugin will disable itself.\u001B[0m");
|
||||
System.out.print("\u001B[36m==== Here is an ugly stacktrace if you are interested in those things ====\u001B[0m");
|
||||
e.printStackTrace();
|
||||
sendConsoleSenderMessage("&c[Plots] MySQL is not setup correctly. The plugin will disable itself.");
|
||||
if (config==null || config.getBoolean("debug")) {
|
||||
sendConsoleSenderMessage("&d==== Here is an ugly stacktrace if you are interested in those things ====");
|
||||
e.printStackTrace();
|
||||
sendConsoleSenderMessage("&d==== End of stacktrace ====");
|
||||
sendConsoleSenderMessage("&6Please go to the PlotSquared 'storage.yml' and configure MySQL correctly.");
|
||||
}
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
@ -163,6 +163,9 @@ public class DBFunc {
|
||||
* @param plots
|
||||
*/
|
||||
public static void createPlots(ArrayList<Plot> plots) {
|
||||
|
||||
// TODO collect list of plots to check if plot exists.
|
||||
|
||||
if (plots.size() == 0) {
|
||||
return;
|
||||
}
|
||||
@ -422,6 +425,7 @@ public class DBFunc {
|
||||
PlotId plot_id;
|
||||
int id;
|
||||
Plot p;
|
||||
HashMap<String, Integer> noExist = new HashMap<String, Integer>();
|
||||
while (r.next()) {
|
||||
plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
||||
id = r.getInt("id");
|
||||
@ -485,12 +489,18 @@ public class DBFunc {
|
||||
plots.put(worldname, map);
|
||||
}
|
||||
else {
|
||||
if (PlotMain.config.getBoolean("debug" )) {
|
||||
PlotMain.sendConsoleSenderMessage("&cPlot '" + p.id + "' in DB for world '" + p.world + "' does not exist! Please create this world, or remove the plots from the DB!");
|
||||
}
|
||||
if (noExist.containsKey(worldname)) {
|
||||
noExist.put(worldname,noExist.get(worldname)+1);
|
||||
}
|
||||
else {
|
||||
noExist.put(worldname,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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!");
|
||||
}
|
||||
stmt.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
|
@ -7,8 +7,10 @@ import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.worldcretornica.plotme.PlayerList;
|
||||
import com.worldcretornica.plotme.Plot;
|
||||
import com.worldcretornica.plotme.PlotManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.Field;
|
||||
@ -40,14 +42,32 @@ public class PlotMeConverter {
|
||||
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots =
|
||||
new ArrayList<com.intellectualcrafters.plot.Plot>();
|
||||
boolean online = Bukkit.getServer().getOnlineMode();
|
||||
|
||||
FileConfiguration plotConfig = Bukkit.getPluginManager().getPlugin("PlotMe").getConfig();
|
||||
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
int duplicate = 0;
|
||||
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
||||
if (plots != null) {
|
||||
|
||||
|
||||
|
||||
|
||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size()
|
||||
+ "' plots for world '" + world.getName() + "'");
|
||||
|
||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting " + plots.size()
|
||||
+ " plots for '" + world.toString() + "'...");
|
||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting configuration...");
|
||||
|
||||
int pathwidth = plotConfig.getInt("worlds."+world.getName()+".PathWidth");
|
||||
int plotsize = plotConfig.getInt("worlds."+world.getName()+".PlotSize");
|
||||
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.
|
||||
|
||||
for (Plot plot : plots.values()) {
|
||||
ArrayList<UUID> psAdded = new ArrayList<>();
|
||||
ArrayList<UUID> psTrusted = new ArrayList<>();
|
||||
@ -160,32 +180,42 @@ public class PlotMeConverter {
|
||||
new boolean[] { false, false, false, false });
|
||||
}
|
||||
|
||||
// TODO createPlot doesn't add helpers /
|
||||
// denied
|
||||
// users
|
||||
if (pl != null) {
|
||||
createdPlots.add(pl);
|
||||
if (!PlotMain.getPlots(world).containsKey(pl.id)) {
|
||||
createdPlots.add(pl);
|
||||
}
|
||||
else {
|
||||
duplicate++;
|
||||
}
|
||||
}
|
||||
}
|
||||
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("&3PlotMe&8->&3PlotSquared&8: &7Creating plot DB");
|
||||
DBFunc.createPlots(createdPlots);
|
||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB");
|
||||
|
||||
// TODO createPlot doesn't add denied users
|
||||
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
||||
stream.close();
|
||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Copying configuration");
|
||||
|
||||
// TODO
|
||||
|
||||
// copy over plotme config
|
||||
|
||||
// disable PlotMe
|
||||
|
||||
// unload all plot worlds with MV or MW
|
||||
|
||||
// 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: &7Conversion has finished");
|
||||
// TODO disable PlotMe -> Unload all plot worlds, change
|
||||
// the
|
||||
// generator, restart the server automatically
|
||||
// Possibly use multiverse / multiworld if it's to
|
||||
// difficult
|
||||
// modifying a world's generator while the server is
|
||||
// running
|
||||
// Should really do that? Would seem pretty bad from our
|
||||
// side +
|
||||
// bukkit wouldn't approve
|
||||
|
||||
Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user