minor conversion tweaks + fix plot sorting with empty worlds.

This commit is contained in:
boy0001 2015-09-15 00:24:25 +10:00
parent 4002ed4de1
commit b524d5fcfe
7 changed files with 45 additions and 9 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<artifactId>PlotSquared</artifactId>
<version>3.1.9</version>
<version>3.1.10</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View File

@ -559,7 +559,9 @@ public class PS {
}
final Set<Plot> result = new HashSet<>(size);
for (final Entry<String, ConcurrentHashMap<PlotId, Plot>> entry : plots.entrySet()) {
result.addAll(entry.getValue().values());
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
result.add(entry2.getValue());
}
}
return result;
}
@ -961,13 +963,13 @@ public class PS {
for (final String world : worlds) {
switch (type) {
case CREATION_DATE:
toReturn.addAll(sortPlotsByTemp(map.get(world)));
toReturn.addAll(sortPlotsByTemp(getPlotsInWorld(world)));
break;
case CREATION_DATE_TIMESTAMP:
toReturn.addAll(sortPlotsByTimestamp(map.get(world)));
toReturn.addAll(sortPlotsByTimestamp(getPlotsInWorld(world)));
break;
case DISTANCE_FROM_ORIGIN:
toReturn.addAll(sortPlotsByHash(map.get(world)));
toReturn.addAll(sortPlotsByHash(getPlotsInWorld(world)));
break;
default:
break;

View File

@ -27,10 +27,15 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
public class ClassicPlotMeConnector extends APlotMeConnector {
private String plugin;
private String prefix;
@Override
public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) {
this.plugin = plugin.toLowerCase();
prefix = plotConfig.getString("mySQLprefix");
if (prefix == null) {
prefix = plugin;
}
try {
if (plotConfig.getBoolean("usemySQL")) {
final String user = plotConfig.getString("mySQLuname");
@ -53,7 +58,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
final HashMap<String, Integer> roadWidth = new HashMap<>();
final HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
final HashMap<String, HashMap<PlotId, boolean[]>> merges = new HashMap<>();
stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "Plots`");
stmt = connection.prepareStatement("SELECT * FROM `" + prefix + "Plots`");
r = stmt.executeQuery();
String column = null;
final boolean checkUUID = DBFunc.hasColumn(r, "ownerid");
@ -166,8 +171,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
try {
MainUtil.sendConsoleMessage(" - " + plugin + "Denied");
stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "Denied`");
MainUtil.sendConsoleMessage(" - " + prefix + "Denied");
stmt = connection.prepareStatement("SELECT * FROM `" + prefix + "Denied`");
r = stmt.executeQuery();
while (r.next()) {
@ -267,6 +272,6 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
if (version == null) {
return true;
}
return PS.get().canUpdate(version, "0.17.0");
return PS.get().canUpdate(version, "0.17.0") || PS.get().canUpdate("0.999.999", version);
}
}

View File

@ -98,6 +98,24 @@ public class LikePlotMeConverter {
return plotConfig.getConfigurationSection("worlds").getKeys(false);
}
public void mergeWorldYml(final String plugin, FileConfiguration plotConfig) {
try {
File genConfig = new File("plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
if (genConfig.exists()) {
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
for (String key : yml.getKeys(true)) {
if (!plotConfig.contains(key)) {
plotConfig.set(key, yml.get(key));
}
}
genConfig.delete();
}
}
catch (Exception e) {
e.printStackTrace();
}
}
public void updateWorldYml(final String plugin, final String location) {
try {
final Path path = Paths.get(location);
@ -139,6 +157,9 @@ public class LikePlotMeConverter {
}
sendMessage(plugin + " conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'");
mergeWorldYml(plugin, plotConfig);
sendMessage("Connecting to " + plugin + " DB");
int plotCount = 0;
@ -256,6 +277,7 @@ public class LikePlotMeConverter {
@Override
public void run() {
if (done.get()) {
done();
sendMessage("&aDatabase conversion is now complete!");
PS.debug("&c - Stop the server");
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
@ -325,6 +347,7 @@ public class LikePlotMeConverter {
e.printStackTrace();
}
if (done.get()) {
done();
sendMessage("&aDatabase conversion is now complete!");
PS.debug("&c - Stop the server");
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
@ -342,4 +365,8 @@ public class LikePlotMeConverter {
}
return true;
}
public void done() {
PS.get().setAllPlotsRaw(DBFunc.getPlots());
}
}

View File

@ -24,10 +24,12 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
public class PlotMeConnector_017 extends APlotMeConnector {
private String plugin;
private String prefix;
@Override
public Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder) {
this.plugin = plugin.toLowerCase();
prefix = plugin + "core_";
try {
if (plotConfig.getBoolean("usemySQL")) {
final String user = plotConfig.getString("mySQLuname");

Binary file not shown.

Binary file not shown.