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,31 +93,15 @@ 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()) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MainUtil.sendConsoleMessage(" - plotmeDenied");
|
MainUtil.sendConsoleMessage(" - plotmeDenied");
|
||||||
r = stmt.executeQuery("SELECT * FROM `plotmeDenied`");
|
stmt = connection.prepareStatement("SELECT * FROM `plotmeDenied`");
|
||||||
|
r = stmt.executeQuery();
|
||||||
|
|
||||||
while (r.next()) {
|
while (r.next()) {
|
||||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||||
@ -135,6 +121,35 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return plots;
|
return plots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,11 +83,7 @@ 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
|
|
||||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
try {
|
||||||
String dataFolder = getPlotMePath();
|
String dataFolder = getPlotMePath();
|
||||||
FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
||||||
@ -100,6 +96,7 @@ public class PlotMeConverter {
|
|||||||
|
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
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("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'");
|
||||||
@ -110,13 +107,11 @@ public class PlotMeConverter {
|
|||||||
|
|
||||||
sendMessage("Collecting plot data");
|
sendMessage("Collecting plot data");
|
||||||
sendMessage(" - plotmePlots");
|
sendMessage(" - plotmePlots");
|
||||||
|
|
||||||
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
||||||
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
||||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||||
plotCount += entry.getValue().size();
|
plotCount += entry.getValue().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Settings.CONVERT_PLOTME) {
|
if (!Settings.CONVERT_PLOTME) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -287,10 +282,9 @@ public class PlotMeConverter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
PlotSquared.log("&/end/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getWorld(final String world) {
|
public static String getWorld(final String world) {
|
||||||
for (final World newworld : Bukkit.getWorlds()) {
|
for (final World newworld : Bukkit.getWorlds()) {
|
||||||
|
@ -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