mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +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) {
|
catch (ClassNotFoundException | SQLException e) {
|
||||||
Logger.add(LogLevel.DANGER, "MySQL connection failed.");
|
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");
|
sendConsoleSenderMessage("&c[Plots] MySQL is not setup correctly. The plugin will disable itself.");
|
||||||
System.out.print("\u001B[36m==== Here is an ugly stacktrace if you are interested in those things ====\u001B[0m");
|
if (config==null || config.getBoolean("debug")) {
|
||||||
e.printStackTrace();
|
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);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,9 @@ public class DBFunc {
|
|||||||
* @param plots
|
* @param plots
|
||||||
*/
|
*/
|
||||||
public static void createPlots(ArrayList<Plot> plots) {
|
public static void createPlots(ArrayList<Plot> plots) {
|
||||||
|
|
||||||
|
// TODO collect list of plots to check if plot exists.
|
||||||
|
|
||||||
if (plots.size() == 0) {
|
if (plots.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -422,6 +425,7 @@ public class DBFunc {
|
|||||||
PlotId plot_id;
|
PlotId plot_id;
|
||||||
int id;
|
int id;
|
||||||
Plot p;
|
Plot p;
|
||||||
|
HashMap<String, Integer> noExist = new HashMap<String, Integer>();
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
|
||||||
id = r.getInt("id");
|
id = r.getInt("id");
|
||||||
@ -485,12 +489,18 @@ public class DBFunc {
|
|||||||
plots.put(worldname, map);
|
plots.put(worldname, map);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (PlotMain.config.getBoolean("debug" )) {
|
if (noExist.containsKey(worldname)) {
|
||||||
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!");
|
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();
|
stmt.close();
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
|
@ -7,8 +7,10 @@ import com.intellectualcrafters.plot.PlotMain;
|
|||||||
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.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -40,14 +42,32 @@ public class PlotMeConverter {
|
|||||||
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots =
|
ArrayList<com.intellectualcrafters.plot.Plot> createdPlots =
|
||||||
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();
|
||||||
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
int duplicate = 0;
|
||||||
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
HashMap<String, Plot> plots = PlotManager.getPlots(world);
|
||||||
if (plots != null) {
|
if (plots != null) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size()
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Processing '" + plots.size()
|
||||||
+ "' plots for world '" + world.getName() + "'");
|
+ "' plots for world '" + world.getName() + "'");
|
||||||
|
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting " + plots.size()
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Converting configuration...");
|
||||||
+ " plots for '" + world.toString() + "'...");
|
|
||||||
|
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()) {
|
for (Plot plot : plots.values()) {
|
||||||
ArrayList<UUID> psAdded = new ArrayList<>();
|
ArrayList<UUID> psAdded = new ArrayList<>();
|
||||||
ArrayList<UUID> psTrusted = new ArrayList<>();
|
ArrayList<UUID> psTrusted = new ArrayList<>();
|
||||||
@ -160,32 +180,42 @@ public class PlotMeConverter {
|
|||||||
new boolean[] { false, false, false, false });
|
new boolean[] { false, false, false, false });
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO createPlot doesn't add helpers /
|
|
||||||
// denied
|
|
||||||
// users
|
|
||||||
if (pl != null) {
|
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");
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating plot DB");
|
||||||
DBFunc.createPlots(createdPlots);
|
DBFunc.createPlots(createdPlots);
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB");
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Creating settings/helpers DB");
|
||||||
|
|
||||||
|
// TODO createPlot doesn't add denied users
|
||||||
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
||||||
stream.close();
|
stream.close();
|
||||||
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Conversion has finished");
|
PlotMain.sendConsoleSenderMessage("&3PlotMe&8->&3PlotSquared&8: &7Copying configuration");
|
||||||
// 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
|
|
||||||
|
|
||||||
|
// 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");
|
||||||
Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin);
|
Bukkit.getPluginManager().disablePlugin(PlotMeConverter.this.plugin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user