mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 12:35:15 +01:00
Minor conversion tweaks
This commit is contained in:
parent
cf93cfc4c1
commit
3000aa371f
@ -2,12 +2,14 @@ package com.intellectualcrafters.plot.database.plotme;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
@ -28,6 +30,30 @@ public abstract class APlotMeConnector {
|
|||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValidConnection(Connection connection) {
|
||||||
|
return connection != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void copyConfig(FileConfiguration plotConfig, String world, String actualWorldName) {
|
||||||
|
final Integer pathwidth = plotConfig.getInt("worlds." + world + ".PathWidth"); //
|
||||||
|
PS.get().config.set("worlds." + actualWorldName + ".road.width", pathwidth);
|
||||||
|
final Integer plotsize = plotConfig.getInt("worlds." + world + ".PlotSize"); //
|
||||||
|
PS.get().config.set("worlds." + actualWorldName + ".plot.size", plotsize);
|
||||||
|
final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); //
|
||||||
|
PS.get().config.set("worlds." + actualWorldName + ".wall.block", wallblock);
|
||||||
|
final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); //
|
||||||
|
PS.get().config.set("worlds." + actualWorldName + ".plot.floor", Arrays.asList(floor));
|
||||||
|
final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); //
|
||||||
|
PS.get().config.set("worlds." + actualWorldName + ".plot.filling", Arrays.asList(filling));
|
||||||
|
final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId");
|
||||||
|
PS.get().config.set("worlds." + actualWorldName + ".road.block", road);
|
||||||
|
Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
|
||||||
|
if (height == null) {
|
||||||
|
height = 64;
|
||||||
|
}
|
||||||
|
PS.get().config.set("worlds." + actualWorldName + ".road.height", height);
|
||||||
|
}
|
||||||
|
|
||||||
public Location getPlotTopLocAbs(int path, int plot, final PlotId plotid) {
|
public Location getPlotTopLocAbs(int path, int plot, final PlotId plotid) {
|
||||||
final int px = plotid.x;
|
final int px = plotid.x;
|
||||||
final int pz = plotid.y;
|
final int pz = plotid.y;
|
||||||
|
@ -6,6 +6,7 @@ import java.sql.DriverManager;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -133,7 +133,7 @@ public class LikePlotMeConverter {
|
|||||||
|
|
||||||
Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
|
Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
|
||||||
|
|
||||||
if (connection == null) {
|
if (!connector.isValidConnection(connection)) {
|
||||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -158,23 +158,7 @@ public class LikePlotMeConverter {
|
|||||||
sendMessage("Copying config for: " + world);
|
sendMessage("Copying config for: " + world);
|
||||||
try {
|
try {
|
||||||
String actualWorldName = getWorld(world);
|
String actualWorldName = getWorld(world);
|
||||||
final Integer pathwidth = plotConfig.getInt("worlds." + world + ".PathWidth"); //
|
connector.copyConfig(plotConfig, world, actualWorldName);
|
||||||
PS.get().config.set("worlds." + actualWorldName + ".road.width", pathwidth);
|
|
||||||
final Integer plotsize = plotConfig.getInt("worlds." + world + ".PlotSize"); //
|
|
||||||
PS.get().config.set("worlds." + actualWorldName + ".plot.size", plotsize);
|
|
||||||
final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); //
|
|
||||||
PS.get().config.set("worlds." + actualWorldName + ".wall.block", wallblock);
|
|
||||||
final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); //
|
|
||||||
PS.get().config.set("worlds." + actualWorldName + ".plot.floor", Arrays.asList(floor));
|
|
||||||
final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); //
|
|
||||||
PS.get().config.set("worlds." + actualWorldName + ".plot.filling", Arrays.asList(filling));
|
|
||||||
final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId");
|
|
||||||
PS.get().config.set("worlds." + actualWorldName + ".road.block", road);
|
|
||||||
Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
|
|
||||||
if (height == null) {
|
|
||||||
height = 64;
|
|
||||||
}
|
|
||||||
PS.get().config.set("worlds." + actualWorldName + ".road.height", height);
|
|
||||||
PS.get().config.save(PS.get().configFile);
|
PS.get().config.save(PS.get().configFile);
|
||||||
} catch (final Exception e) {
|
} 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");
|
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
||||||
|
@ -6,6 +6,7 @@ import java.sql.DriverManager;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -195,5 +196,4 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
|||||||
}
|
}
|
||||||
return !PS.get().canUpdate(version, "0.17");
|
return !PS.get().canUpdate(version, "0.17");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user