mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-10 17:44:44 +02:00
Optimizations and a purge fix
This commit is contained in:
@ -15,7 +15,7 @@ import java.util.HashMap;
|
||||
|
||||
abstract class APlotMeConnector {
|
||||
|
||||
public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder);
|
||||
public abstract Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder);
|
||||
|
||||
public abstract HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException;
|
||||
|
||||
|
@ -30,16 +30,15 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
private String prefix;
|
||||
|
||||
@Override
|
||||
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = plugin.toLowerCase();
|
||||
this.prefix = plotConfig.getString("mySQLprefix", plugin.toLowerCase());
|
||||
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = this.plugin.toLowerCase();
|
||||
this.prefix = plotConfig.getString("mySQLprefix", this.plugin.toLowerCase());
|
||||
try {
|
||||
if (plotConfig.getBoolean("usemySQL")) {
|
||||
String user = plotConfig.getString("mySQLuname");
|
||||
String password = plotConfig.getString("mySQLpass");
|
||||
String con = plotConfig.getString("mySQLconn");
|
||||
return DriverManager.getConnection(con, user, password);
|
||||
// return new MySQL(plotsquared, hostname, port, database, username, password)
|
||||
} else {
|
||||
return new SQLite(dataFolder + File.separator + "plots.db").openConnection();
|
||||
}
|
||||
@ -110,17 +109,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
owner = DBFunc.everyone;
|
||||
} else {
|
||||
if (checkUUID || checkUUID2) {
|
||||
try {
|
||||
byte[] bytes = resultSet.getBytes(column);
|
||||
if (bytes != null) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long high = bb.getLong();
|
||||
long low = bb.getLong();
|
||||
owner = new UUID(high, low);
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
byte[] bytes = resultSet.getBytes(column);
|
||||
if (bytes != null) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long high = bb.getLong();
|
||||
long low = bb.getLong();
|
||||
owner = new UUID(high, low);
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
}
|
||||
if (name.isEmpty()) {
|
||||
@ -173,17 +168,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
if ("*".equals(name)) {
|
||||
denied = DBFunc.everyone;
|
||||
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
|
||||
try {
|
||||
byte[] bytes = resultSet.getBytes("playerid");
|
||||
if (bytes != null) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long mostSigBits = bb.getLong();
|
||||
long leastSigBits = bb.getLong();
|
||||
denied = new UUID(mostSigBits, leastSigBits);
|
||||
UUIDHandler.add(new StringWrapper(name), denied);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
byte[] bytes = resultSet.getBytes("playerid");
|
||||
if (bytes != null) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long mostSigBits = bb.getLong();
|
||||
long leastSigBits = bb.getLong();
|
||||
denied = new UUID(mostSigBits, leastSigBits);
|
||||
UUIDHandler.add(new StringWrapper(name), denied);
|
||||
}
|
||||
}
|
||||
if (denied == null) {
|
||||
@ -212,17 +203,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
if ("*".equals(name)) {
|
||||
helper = DBFunc.everyone;
|
||||
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
|
||||
try {
|
||||
byte[] bytes = resultSet.getBytes("playerid");
|
||||
if (bytes != null) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long mostSigBits = bb.getLong();
|
||||
long leastSigBits = bb.getLong();
|
||||
helper = new UUID(mostSigBits, leastSigBits);
|
||||
UUIDHandler.add(new StringWrapper(name), helper);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
byte[] bytes = resultSet.getBytes("playerid");
|
||||
if (bytes != null) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long mostSigBits = bb.getLong();
|
||||
long leastSigBits = bb.getLong();
|
||||
helper = new UUID(mostSigBits, leastSigBits);
|
||||
UUIDHandler.add(new StringWrapper(name), helper);
|
||||
}
|
||||
}
|
||||
if (helper == null) {
|
||||
|
@ -63,10 +63,10 @@ public class LikePlotMeConverter {
|
||||
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||
}
|
||||
|
||||
public void mergeWorldYml(String plugin, FileConfiguration plotConfig) {
|
||||
public void mergeWorldYml(FileConfiguration plotConfig) {
|
||||
try {
|
||||
File genConfig =
|
||||
new File("plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
new File("plugins" + File.separator + "PlotMe" + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
if (genConfig.exists()) {
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
|
||||
for (String key : yml.getKeys(true)) {
|
||||
@ -83,7 +83,7 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateWorldYml(String plugin, String location) {
|
||||
public void updateWorldYml(String location) {
|
||||
try {
|
||||
Path path = Paths.get(location);
|
||||
File file = new File(location);
|
||||
@ -92,7 +92,7 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
String content = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||
content = content.replaceAll(plugin, "PlotSquared");
|
||||
content = content.replaceAll("PlotMe", "PlotSquared");
|
||||
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException ignored) {
|
||||
//ignored
|
||||
@ -117,7 +117,7 @@ public class LikePlotMeConverter {
|
||||
|
||||
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
||||
|
||||
Connection connection = connector.getPlotMeConnection("PlotMe", plotConfig, dataFolder);
|
||||
Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder);
|
||||
|
||||
if (!connector.isValidConnection(connection)) {
|
||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||
@ -126,7 +126,7 @@ public class LikePlotMeConverter {
|
||||
|
||||
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||
|
||||
mergeWorldYml("PlotMe", plotConfig);
|
||||
mergeWorldYml(plotConfig);
|
||||
|
||||
sendMessage("Connecting to PlotMe DB");
|
||||
|
||||
@ -140,8 +140,8 @@ public class LikePlotMeConverter {
|
||||
|
||||
if (Settings.CONVERT_PLOTME) {
|
||||
sendMessage("Updating bukkit.yml");
|
||||
updateWorldYml("PlotMe", "bukkit.yml");
|
||||
updateWorldYml("PlotMe", "plugins/Multiverse-Core/worlds.yml");
|
||||
updateWorldYml("bukkit.yml");
|
||||
updateWorldYml("plugins/Multiverse-Core/worlds.yml");
|
||||
for (String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
|
||||
sendMessage("Copying config for: " + world);
|
||||
try {
|
||||
|
@ -26,8 +26,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
private String plugin;
|
||||
|
||||
@Override
|
||||
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = plugin.toLowerCase();
|
||||
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = this.plugin.toLowerCase();
|
||||
try {
|
||||
if (plotConfig.getBoolean("usemySQL")) {
|
||||
String user = plotConfig.getString("mySQLuname");
|
||||
@ -109,14 +109,10 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
owner = DBFunc.everyone;
|
||||
} else {
|
||||
if (checkUUID) {
|
||||
try {
|
||||
byte[] bytes = resultSet.getBytes("ownerid");
|
||||
if (bytes != null) {
|
||||
owner = UUID.nameUUIDFromBytes(bytes);
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
byte[] bytes = resultSet.getBytes("ownerid");
|
||||
if (bytes != null) {
|
||||
owner = UUID.nameUUIDFromBytes(bytes);
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
}
|
||||
if (owner == null) {
|
||||
|
Reference in New Issue
Block a user