mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
More work on unlinking
This commit is contained in:
parent
e792a85c00
commit
435e33d079
@ -410,11 +410,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean initPlotMeConverter() {
|
public boolean initPlotMeConverter() {
|
||||||
try {
|
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||||
new PlotMeConverter().runAsync(new ClassicPlotMeConnector());
|
@Override
|
||||||
} catch (final Exception e) {
|
public void run() {
|
||||||
e.printStackTrace();
|
new PlotMeConverter().run(new ClassicPlotMeConnector());
|
||||||
}
|
}
|
||||||
|
}, 20);
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ public class PlotSquared {
|
|||||||
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||||
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||||
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||||
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml@'");
|
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.database.plotme;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
@ -14,6 +15,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.database.MySQL;
|
||||||
import com.intellectualcrafters.plot.database.SQLite;
|
import com.intellectualcrafters.plot.database.SQLite;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
@ -31,6 +33,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
final String password = plotConfig.getString("mySQLpass");
|
final String password = plotConfig.getString("mySQLpass");
|
||||||
final String con = plotConfig.getString("mySQLconn");
|
final String con = plotConfig.getString("mySQLconn");
|
||||||
return DriverManager.getConnection(con, user, password);
|
return DriverManager.getConnection(con, user, password);
|
||||||
|
// return new MySQL(plotsquared, hostname, port, database, username, password)
|
||||||
} else {
|
} else {
|
||||||
return new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection();
|
return new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection();
|
||||||
}
|
}
|
||||||
@ -42,12 +45,11 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
@Override
|
@Override
|
||||||
public HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException {
|
public HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException {
|
||||||
ResultSet r;
|
ResultSet r;
|
||||||
Statement stmt;
|
PreparedStatement stmt;
|
||||||
final HashMap<String, Integer> plotSize = new HashMap<>();
|
final HashMap<String, Integer> plotSize = new HashMap<>();
|
||||||
final HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
|
final HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
|
||||||
stmt = connection.createStatement();
|
stmt = connection.prepareStatement("SELECT * FROM `plotmePlots`");
|
||||||
r = stmt.executeQuery("SELECT * FROM `plotmePlots`");
|
r = stmt.executeQuery();
|
||||||
|
|
||||||
boolean checkUUID = DBFunc.hasColumn(r, "ownerid");
|
boolean checkUUID = DBFunc.hasColumn(r, "ownerid");
|
||||||
|
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
@ -91,48 +93,61 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
final Plot plot = new Plot(id, owner, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
|
final Plot plot = new Plot(id, owner, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
|
||||||
plots.get(world).put(id, plot);
|
plots.get(world).put(id, plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
r.close();
|
r.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
|
||||||
stmt = connection.createStatement();
|
try {
|
||||||
r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`");
|
|
||||||
while (r.next()) {
|
MainUtil.sendConsoleMessage(" - plotmeDenied");
|
||||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
stmt = connection.prepareStatement("SELECT * FROM `plotmeDenied`");
|
||||||
final String name = r.getString("player");
|
r = stmt.executeQuery();
|
||||||
final String world = PlotMeConverter.getWorld(r.getString("world"));
|
|
||||||
UUID helper = UUIDHandler.getUUID(name);
|
while (r.next()) {
|
||||||
if (helper == null) {
|
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||||
if (name.equals("*")) {
|
final String name = r.getString("player");
|
||||||
helper = DBFunc.everyone;
|
final String world = PlotMeConverter.getWorld(r.getString("world"));
|
||||||
} else {
|
UUID denied = UUIDHandler.getUUID(name);
|
||||||
MainUtil.sendConsoleMessage("&6Could not identify helper for plot: " + id);
|
if (denied == null) {
|
||||||
continue;
|
if (name.equals("*")) {
|
||||||
|
denied = DBFunc.everyone;
|
||||||
|
} else {
|
||||||
|
MainUtil.sendConsoleMessage("&6Could not identify denied for plot: " + id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plots.get(world).containsKey(id)) {
|
||||||
|
plots.get(world).get(id).denied.add(denied);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plots.get(world).containsKey(id)) {
|
|
||||||
plots.get(world).get(id).helpers.add(helper);
|
stmt = connection.prepareStatement("SELECT * FROM `plotmeAllowed`");
|
||||||
|
r = stmt.executeQuery();
|
||||||
|
|
||||||
|
while (r.next()) {
|
||||||
|
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||||
|
final String name = r.getString("player");
|
||||||
|
final String world = PlotMeConverter.getWorld(r.getString("world"));
|
||||||
|
UUID helper = UUIDHandler.getUUID(name);
|
||||||
|
if (helper == null) {
|
||||||
|
if (name.equals("*")) {
|
||||||
|
helper = DBFunc.everyone;
|
||||||
|
} else {
|
||||||
|
MainUtil.sendConsoleMessage("&6Could not identify helper for plot: " + id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plots.get(world).containsKey(id)) {
|
||||||
|
plots.get(world).get(id).helpers.add(helper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.close();
|
||||||
|
stmt.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
|
||||||
MainUtil.sendConsoleMessage(" - plotmeDenied");
|
|
||||||
r = stmt.executeQuery("SELECT * FROM `plotmeDenied`");
|
|
||||||
|
|
||||||
while (r.next()) {
|
|
||||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
|
||||||
final String name = r.getString("player");
|
|
||||||
final String world = PlotMeConverter.getWorld(r.getString("world"));
|
|
||||||
UUID denied = UUIDHandler.getUUID(name);
|
|
||||||
if (denied == null) {
|
|
||||||
if (name.equals("*")) {
|
|
||||||
denied = DBFunc.everyone;
|
|
||||||
} else {
|
|
||||||
MainUtil.sendConsoleMessage("&6Could not identify denied for plot: " + id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (plots.get(world).containsKey(id)) {
|
|
||||||
plots.get(world).get(id).denied.add(denied);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return plots;
|
return plots;
|
||||||
|
@ -83,213 +83,207 @@ public class PlotMeConverter {
|
|||||||
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runAsync(final APlotMeConnector connector) throws Exception {
|
public void run(final APlotMeConnector connector) {
|
||||||
// We have to make it wait a couple of seconds
|
try {
|
||||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
String dataFolder = getPlotMePath();
|
||||||
@Override
|
FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
||||||
public void run() {
|
|
||||||
|
if (plotConfig == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder);
|
||||||
|
|
||||||
|
if (connection == null) {
|
||||||
|
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'");
|
||||||
|
sendMessage("Connecting to PlotMe DB");
|
||||||
|
|
||||||
|
int plotCount = 0;
|
||||||
|
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||||
|
|
||||||
|
sendMessage("Collecting plot data");
|
||||||
|
sendMessage(" - plotmePlots");
|
||||||
|
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
||||||
|
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
||||||
|
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||||
|
plotCount += entry.getValue().size();
|
||||||
|
}
|
||||||
|
if (!Settings.CONVERT_PLOTME) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage(" - plotmeAllowed");
|
||||||
|
|
||||||
|
sendMessage("Collected " + plotCount + " plots from PlotMe");
|
||||||
|
for (final String world : plots.keySet()) {
|
||||||
|
sendMessage("Copying config for: " + world);
|
||||||
try {
|
try {
|
||||||
String dataFolder = getPlotMePath();
|
final String plotMeWorldName = world.toLowerCase();
|
||||||
FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
final Integer pathwidth = plotConfig.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
|
||||||
if (plotConfig == null) {
|
final Integer plotsize = plotConfig.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||||
return;
|
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
|
||||||
|
final String wallblock = plotConfig.getString("worlds." + plotMeWorldName + ".WallBlockId"); //
|
||||||
|
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
|
||||||
|
final String floor = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFloorBlockId"); //
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
|
||||||
|
final String filling = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFillingBlockId"); //
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
|
||||||
|
final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId");
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.block", road);
|
||||||
|
Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||||
|
if (height == null) {
|
||||||
|
height = 64;
|
||||||
}
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.height", height);
|
||||||
Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder);
|
PlotSquared.config.save(PlotSquared.configFile);
|
||||||
|
} catch (final Exception e) {
|
||||||
if (connection == null) {
|
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
||||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
}
|
||||||
}
|
}
|
||||||
|
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||||
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'");
|
if (PLOTME_DG_FILE.exists()) {
|
||||||
sendMessage("Connecting to PlotMe DB");
|
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
||||||
|
try {
|
||||||
int plotCount = 0;
|
|
||||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
|
||||||
|
|
||||||
sendMessage("Collecting plot data");
|
|
||||||
sendMessage(" - plotmePlots");
|
|
||||||
|
|
||||||
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
|
||||||
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
|
||||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
|
||||||
plotCount += entry.getValue().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Settings.CONVERT_PLOTME) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sendMessage(" - plotmeAllowed");
|
|
||||||
|
|
||||||
sendMessage("Collected " + plotCount + " plots from PlotMe");
|
|
||||||
for (final String world : plots.keySet()) {
|
for (final String world : plots.keySet()) {
|
||||||
sendMessage("Copying config for: " + world);
|
final String plotMeWorldName = world.toLowerCase();
|
||||||
try {
|
Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||||
final String plotMeWorldName = world.toLowerCase();
|
if (pathwidth == null) {
|
||||||
final Integer pathwidth = plotConfig.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
pathwidth = 7;
|
||||||
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
|
}
|
||||||
final Integer plotsize = plotConfig.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
|
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||||
final String wallblock = plotConfig.getString("worlds." + plotMeWorldName + ".WallBlockId"); //
|
if (plotsize == null) {
|
||||||
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
|
plotsize = 32;
|
||||||
final String floor = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFloorBlockId"); //
|
}
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
|
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
|
||||||
final String filling = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFillingBlockId"); //
|
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
|
if (wallblock == null) {
|
||||||
final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId");
|
wallblock = "44";
|
||||||
PlotSquared.config.set("worlds." + world + ".road.block", road);
|
}
|
||||||
Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
|
||||||
if (height == null) {
|
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
|
||||||
|
if (floor == null) {
|
||||||
|
floor = "2";
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
|
||||||
|
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
||||||
|
if (filling == null) {
|
||||||
|
filling = "3";
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
|
||||||
|
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
||||||
|
if (road == null) {
|
||||||
|
road = "5";
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.block", road);
|
||||||
|
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||||
|
if ((height == null) || (height == 0)) {
|
||||||
|
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
||||||
|
if ((height == null) || (height == 0)) {
|
||||||
height = 64;
|
height = 64;
|
||||||
}
|
}
|
||||||
PlotSquared.config.set("worlds." + world + ".road.height", height);
|
|
||||||
PlotSquared.config.save(PlotSquared.configFile);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
|
||||||
}
|
}
|
||||||
}
|
PlotSquared.config.set("worlds." + world + ".road.height", height);
|
||||||
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
PlotSquared.config.set("worlds." + world + ".plot.height", height);
|
||||||
if (PLOTME_DG_FILE.exists()) {
|
PlotSquared.config.set("worlds." + world + ".wall.height", height);
|
||||||
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
|
||||||
try {
|
|
||||||
for (final String world : plots.keySet()) {
|
|
||||||
final String plotMeWorldName = world.toLowerCase();
|
|
||||||
Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
|
||||||
if (pathwidth == null) {
|
|
||||||
pathwidth = 7;
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
|
|
||||||
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
|
||||||
if (plotsize == null) {
|
|
||||||
plotsize = 32;
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
|
|
||||||
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
|
|
||||||
if (wallblock == null) {
|
|
||||||
wallblock = "44";
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
|
|
||||||
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
|
|
||||||
if (floor == null) {
|
|
||||||
floor = "2";
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
|
|
||||||
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
|
||||||
if (filling == null) {
|
|
||||||
filling = "3";
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
|
|
||||||
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
|
||||||
if (road == null) {
|
|
||||||
road = "5";
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".road.block", road);
|
|
||||||
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
|
||||||
if ((height == null) || (height == 0)) {
|
|
||||||
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
|
||||||
if ((height == null) || (height == 0)) {
|
|
||||||
height = 64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".road.height", height);
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.height", height);
|
|
||||||
PlotSquared.config.set("worlds." + world + ".wall.height", height);
|
|
||||||
PlotSquared.config.save(PlotSquared.configFile);
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (final String world : plots.keySet()) {
|
|
||||||
int duplicate = 0;
|
|
||||||
for (final Plot plot : plots.get(world).values()) {
|
|
||||||
if (!PlotSquared.getPlots(world).containsKey(plot.id)) {
|
|
||||||
createdPlots.add(plot);
|
|
||||||
} else {
|
|
||||||
duplicate++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (duplicate > 0) {
|
|
||||||
PlotSquared.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendMessage("Creating plot DB");
|
|
||||||
Thread.sleep(1000);
|
|
||||||
DBFunc.createPlotsAndData(createdPlots, new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
sendMessage("&aDatabase conversion is now complete!");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
sendMessage("Saving configuration...");
|
|
||||||
try {
|
|
||||||
PlotSquared.config.save(PlotSquared.configFile);
|
PlotSquared.config.save(PlotSquared.configFile);
|
||||||
} catch (final IOException e) {
|
|
||||||
sendMessage(" - &cFailed to save configuration.");
|
|
||||||
}
|
}
|
||||||
TaskManager.runTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
boolean MV = false;
|
|
||||||
boolean MW = false;
|
|
||||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
|
||||||
MV = true;
|
|
||||||
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
|
||||||
MW = true;
|
|
||||||
}
|
|
||||||
for (final String worldname : worlds) {
|
|
||||||
final World world = Bukkit.getWorld(getWorld(worldname));
|
|
||||||
if (world == null) {
|
|
||||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
|
||||||
}
|
|
||||||
final String actualWorldName = world.getName();
|
|
||||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
|
||||||
PlotSquared.removePlotWorld(actualWorldName);
|
|
||||||
if (MV) {
|
|
||||||
// unload world with MV
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (final InterruptedException ex) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
// load world with MV
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared");
|
|
||||||
} else if (MW) {
|
|
||||||
// unload world with MW
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (final InterruptedException ex) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
// load world with MW
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared");
|
|
||||||
} else {
|
|
||||||
// Load using Bukkit API
|
|
||||||
// - User must set generator manually
|
|
||||||
Bukkit.getServer().unloadWorld(world, true);
|
|
||||||
final World myworld = WorldCreator.name(actualWorldName).generator(new HybridGen()).createWorld();
|
|
||||||
myworld.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
sendMessage("&cPlease wait until database conversion is complete. You will be notified when this happens");
|
|
||||||
PlotSquared.log("&c - Stop the server");
|
|
||||||
PlotSquared.log("&c - Disable 'plotme-convert.enabled' in the settings.yml");
|
|
||||||
PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
|
||||||
PlotSquared.log("&c - Start the server");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20);
|
for (final String world : plots.keySet()) {
|
||||||
|
int duplicate = 0;
|
||||||
|
for (final Plot plot : plots.get(world).values()) {
|
||||||
|
if (!PlotSquared.getPlots(world).containsKey(plot.id)) {
|
||||||
|
createdPlots.add(plot);
|
||||||
|
} else {
|
||||||
|
duplicate++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (duplicate > 0) {
|
||||||
|
PlotSquared.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sendMessage("Creating plot DB");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
DBFunc.createPlotsAndData(createdPlots, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sendMessage("&aDatabase conversion is now complete!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sendMessage("Saving configuration...");
|
||||||
|
try {
|
||||||
|
PlotSquared.config.save(PlotSquared.configFile);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
sendMessage(" - &cFailed to save configuration.");
|
||||||
|
}
|
||||||
|
TaskManager.runTask(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
boolean MV = false;
|
||||||
|
boolean MW = false;
|
||||||
|
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||||
|
MV = true;
|
||||||
|
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||||
|
MW = true;
|
||||||
|
}
|
||||||
|
for (final String worldname : worlds) {
|
||||||
|
final World world = Bukkit.getWorld(getWorld(worldname));
|
||||||
|
if (world == null) {
|
||||||
|
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
||||||
|
}
|
||||||
|
final String actualWorldName = world.getName();
|
||||||
|
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||||
|
PlotSquared.removePlotWorld(actualWorldName);
|
||||||
|
if (MV) {
|
||||||
|
// unload world with MV
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (final InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
// load world with MV
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared");
|
||||||
|
} else if (MW) {
|
||||||
|
// unload world with MW
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (final InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
// load world with MW
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared");
|
||||||
|
} else {
|
||||||
|
// Load using Bukkit API
|
||||||
|
// - User must set generator manually
|
||||||
|
Bukkit.getServer().unloadWorld(world, true);
|
||||||
|
final World myworld = WorldCreator.name(actualWorldName).generator(new HybridGen()).createWorld();
|
||||||
|
myworld.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
|
||||||
|
} catch (final Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sendMessage("&cPlease wait until database conversion is complete. You will be notified when this happens");
|
||||||
|
PlotSquared.log("&c - Stop the server");
|
||||||
|
PlotSquared.log("&c - Disable 'plotme-convert.enabled' in the settings.yml");
|
||||||
|
PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||||
|
PlotSquared.log("&c - Start the server");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (final Exception e) {
|
||||||
|
PlotSquared.log("&/end/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getWorld(final String world) {
|
public static String getWorld(final String world) {
|
||||||
|
@ -420,7 +420,7 @@ public class MainUtil {
|
|||||||
if (ly) {
|
if (ly) {
|
||||||
if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
|
if (!plot.settings.getMerged(1) || !plot.settings.getMerged(2)) {
|
||||||
if (removeRoads) {
|
if (removeRoads) {
|
||||||
manager.removeRoadSouthEast(plotworld, plot);
|
MainUtil.removeRoadSouthEast(plotworld, plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ public class MainUtil {
|
|||||||
lesserPlot.settings.setMerged(2, true);
|
lesserPlot.settings.setMerged(2, true);
|
||||||
greaterPlot.settings.setMerged(0, true);
|
greaterPlot.settings.setMerged(0, true);
|
||||||
if (removeRoads) {
|
if (removeRoads) {
|
||||||
manager.removeRoadSouth(plotworld, lesserPlot);
|
MainUtil.removeRoadSouth(plotworld, lesserPlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -520,7 +520,7 @@ public class MainUtil {
|
|||||||
lesserPlot.settings.setMerged(1, true);
|
lesserPlot.settings.setMerged(1, true);
|
||||||
greaterPlot.settings.setMerged(3, true);
|
greaterPlot.settings.setMerged(3, true);
|
||||||
if (removeRoads) {
|
if (removeRoads) {
|
||||||
manager.removeRoadEast(plotworld, lesserPlot);
|
MainUtil.removeRoadEast(plotworld, lesserPlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user