Added base changes for database migration command (unfinished)

This commit is contained in:
Intelli 2024-09-29 18:35:27 -06:00
parent fc0c8ff9ac
commit de978fce2c
14 changed files with 95 additions and 73 deletions

5
.gitignore vendored
View File

@ -195,4 +195,7 @@ Desktop.ini
hs_err_pid*
# Documentation dev folder
docs/dev/
docs/dev/
# Extensions
extensions/

View File

@ -26,6 +26,7 @@ DATABASE_UNREACHABLE: "Database is unreachable. Discarding data and shutting dow
DEVELOPMENT_BRANCH: "Development branch detected, skipping patch scripts."
DIRT_BLOCK: "Placed a temporary safety block under you."
DISABLE_SUCCESS: "Success! Disabled {0}"
DONATION_KEY_REQUIRED: "A valid donation key is required for that command."
ENABLE_FAILED: "{0} was unable to start."
ENABLE_SUCCESS: "{0} has been successfully enabled!"
ENJOY_COREPROTECT: "Enjoy {0}? Join our Discord!"
@ -202,6 +203,7 @@ USER_OFFLINE: "The user \"{0}\" is not online."
USING_MYSQL: "Using MySQL for data storage."
USING_SQLITE: "Using SQLite for data storage."
VALID_DONATION_KEY: "Valid donation key."
VERSION_INCOMPATIBLE: "{0} {1} is not supported."
VERSION_NOTICE: "Version {0} is now available."
VERSION_REQUIRED: "{0} {1} or higher is required."
WORLD_NOT_FOUND: "World \"{0}\" not found."

View File

@ -196,6 +196,9 @@ public final class CoreProtect extends JavaPlugin {
Chat.console(Phrase.build(Phrase.FINISHING_LOGGING));
}
if (ConfigHandler.migrationRunning) {
ConfigHandler.purgeRunning = false;
}
while ((Consumer.isRunning() || ConfigHandler.converterRunning) && !ConfigHandler.purgeRunning) {
long time = System.currentTimeMillis();
if (time >= alertTime) {

View File

@ -1273,6 +1273,21 @@ public class CommandHandler implements CommandExecutor {
else if (corecommand.equals("network-debug")) {
NetworkDebugCommand.runCommand(user, permission, argumentArray);
}
else if (corecommand.equals("migrate-db")) {
if (!Util.validDonationKey()) {
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DONATION_KEY_REQUIRED));
}
else {
try {
Class.forName("net.coreprotect.extensions.DatabaseMigration");
net.coreprotect.extensions.DatabaseMigration.runCommand(user, argumentArray);
}
catch (Exception e) {
// plugin not compiled with extension
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + corecommand));
}
}
}
else {
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + corecommand));
}

View File

@ -50,7 +50,7 @@ public class PurgeCommand extends Consumer {
return;
}
if (ConfigHandler.converterRunning) {
if (ConfigHandler.converterRunning || ConfigHandler.migrationRunning) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
return;
}
@ -104,11 +104,6 @@ public class PurgeCommand extends Consumer {
int restrictCount = 0;
if (argBlocks.size() > 0) {
if (!Util.validDonationKey()) {
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.DONATION_KEY_REQUIRED));
return;
}
StringBuilder includeListMaterial = new StringBuilder();
StringBuilder includeListEntity = new StringBuilder();
@ -260,7 +255,7 @@ public class PurgeCommand extends Consumer {
}
}
Database.createDatabaseTables(purgePrefix, true);
Database.createDatabaseTables(purgePrefix, null, Config.getGlobal().MYSQL, true);
}
List<String> purgeTables = Arrays.asList("sign", "container", "item", "skull", "session", "chat", "command", "entity", "block");

View File

@ -55,6 +55,7 @@ public class ConfigHandler extends Queue {
public static String username = "root";
public static String password = "";
public static String prefix = "co_";
public static String prefixConfig = "co_";
public static int maximumPoolSize = 10;
public static HikariDataSource hikariDataSource = null;
@ -65,6 +66,7 @@ public class ConfigHandler extends Queue {
public static volatile boolean serverRunning = false;
public static volatile boolean converterRunning = false;
public static volatile boolean purgeRunning = false;
public static volatile boolean migrationRunning = false;
public static volatile boolean pauseConsumer = false;
public static volatile boolean worldeditEnabled = false;
public static volatile boolean databaseReachable = true;
@ -173,6 +175,7 @@ public class ConfigHandler extends Queue {
// Enforce "co_" table prefix if using SQLite.
if (!Config.getGlobal().MYSQL) {
ConfigHandler.prefixConfig = Config.getGlobal().PREFIX;
Config.getGlobal().PREFIX = "co_";
}
@ -259,7 +262,7 @@ public class ConfigHandler extends Queue {
ConfigHandler.hikariDataSource = new HikariDataSource(config);
}
Database.createDatabaseTables(ConfigHandler.prefix, false);
Database.createDatabaseTables(ConfigHandler.prefix, null, Config.getGlobal().MYSQL, false);
}
public static void loadTypes(Statement statement) {

View File

@ -100,7 +100,7 @@ public class Consumer extends Process implements Runnable, Thread.UncaughtExcept
private static void pauseConsumer(int process_id) {
try {
while ((ConfigHandler.serverRunning || ConfigHandler.converterRunning) && (Consumer.isPaused || ConfigHandler.pauseConsumer || ConfigHandler.purgeRunning || Consumer.consumer_id.get(process_id)[1] == 1)) {
while ((ConfigHandler.serverRunning || ConfigHandler.converterRunning || ConfigHandler.migrationRunning) && (Consumer.isPaused || ConfigHandler.pauseConsumer || ConfigHandler.purgeRunning || Consumer.consumer_id.get(process_id)[1] == 1)) {
pausedSuccess = true;
Thread.sleep(100);
}

View File

@ -10,6 +10,7 @@ import java.util.Map.Entry;
import org.bukkit.Material;
import net.coreprotect.config.Config;
import net.coreprotect.config.ConfigHandler;
import net.coreprotect.consumer.Consumer;
import net.coreprotect.database.Database;
@ -74,7 +75,7 @@ public class Process {
}
Statement statement = connection.createStatement();
Database.performCheckpoint(statement);
Database.performCheckpoint(statement, Config.getGlobal().MYSQL);
Consumer.isPaused = true;
ArrayList<Object[]> consumerData = Consumer.consumer.get(processId);
@ -91,7 +92,7 @@ public class Process {
return;
}
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
// Scan through usernames, ensure everything is loaded in memory.
for (Entry<Integer, String[]> entry : users.entrySet()) {
String[] data = entry.getValue();
@ -104,7 +105,7 @@ public class Process {
}
}
updateLockTable(statement, (lastRun ? 0 : 1));
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
// Create prepared statements
PreparedStatement preparedStmtSigns = Database.prepareStatement(connection, Database.SIGN, false);
@ -123,7 +124,7 @@ public class Process {
PreparedStatement preparedStmtBlockdata = Database.prepareStatement(connection, Database.BLOCKDATA, false);
// Scan through consumer data
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
for (int i = 0; i < consumerDataSize; i++) {
Object[] data = consumerData.get(i);
if (data != null) {
@ -242,7 +243,7 @@ public class Process {
if (Consumer.interrupt) {
commit(statement, preparedStmtSigns, preparedStmtBlocks, preparedStmtSkulls, preparedStmtContainers, preparedStmtItems, preparedStmtWorlds, preparedStmtChat, preparedStmtCommand, preparedStmtSession, preparedStmtEntities, preparedStmtMaterials, preparedStmtArt, preparedStmtEntity, preparedStmtBlockdata);
Thread.sleep(500);
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
}
}
catch (Exception e) {
@ -302,7 +303,7 @@ public class Process {
preparedStmtArt.executeBatch();
preparedStmtEntity.executeBatch();
preparedStmtBlockdata.executeBatch();
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
}
catch (Exception e) {
e.printStackTrace();

View File

@ -43,11 +43,11 @@ public class Database extends Queue {
public static final int BLOCKDATA = 12;
public static final int ITEM = 13;
public static void beginTransaction(Statement statement) {
public static void beginTransaction(Statement statement, boolean isMySQL) {
Consumer.transacting = true;
try {
if (Config.getGlobal().MYSQL) {
if (isMySQL) {
statement.executeUpdate("START TRANSACTION");
}
else {
@ -59,12 +59,12 @@ public class Database extends Queue {
}
}
public static void commitTransaction(Statement statement) throws Exception {
public static void commitTransaction(Statement statement, boolean isMySQL) throws Exception {
int count = 0;
while (true) {
try {
if (Config.getGlobal().MYSQL) {
if (isMySQL) {
statement.executeUpdate("COMMIT");
}
else {
@ -89,8 +89,8 @@ public class Database extends Queue {
}
}
public static void performCheckpoint(Statement statement) throws SQLException {
if (!Config.getGlobal().MYSQL) {
public static void performCheckpoint(Statement statement, boolean isMySQL) throws SQLException {
if (!isMySQL) {
statement.executeUpdate("PRAGMA wal_checkpoint(TRUNCATE)");
}
}
@ -338,13 +338,13 @@ public class Database extends Queue {
}
}
public static void createDatabaseTables(String prefix, boolean purge) {
public static void createDatabaseTables(String prefix, Connection forceConnection, boolean mySQL, boolean purge) {
ConfigHandler.databaseTables.clear();
ConfigHandler.databaseTables.addAll(Arrays.asList("art_map", "block", "chat", "command", "container", "item", "database_lock", "entity", "entity_map", "material_map", "blockdata_map", "session", "sign", "skull", "user", "username_log", "version", "world"));
if (Config.getGlobal().MYSQL) {
if (mySQL) {
boolean success = false;
try (Connection connection = Database.getConnection(true, true, true, 0)) {
try (Connection connection = (forceConnection != null ? forceConnection : Database.getConnection(true, true, true, 0))) {
if (connection != null) {
String index = "";
Statement statement = connection.createStatement();
@ -380,7 +380,7 @@ public class Database extends Queue {
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "version(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),time int,version varchar(16)) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
index = ", INDEX(id)";
statement.executeUpdate("CREATE TABLE IF NOT EXISTS " + prefix + "world(rowid int NOT NULL AUTO_INCREMENT,PRIMARY KEY(rowid),id int,world varchar(255)" + index + ") ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4");
if (!purge) {
if (!purge && forceConnection == null) {
initializeTables(prefix, statement);
}
statement.close();
@ -390,18 +390,18 @@ public class Database extends Queue {
catch (Exception e) {
e.printStackTrace();
}
if (!success) {
if (!success && forceConnection == null) {
Config.getGlobal().MYSQL = false;
}
}
if (!Config.getGlobal().MYSQL) {
try (Connection connection = Database.getConnection(true, 0)) {
if (!mySQL) {
try (Connection connection = (forceConnection != null ? forceConnection : Database.getConnection(true, 0))) {
Statement statement = connection.createStatement();
List<String> tableData = new ArrayList<>();
List<String> indexData = new ArrayList<>();
String attachDatabase = "";
if (purge) {
if (purge && forceConnection == null) {
String query = "ATTACH DATABASE '" + ConfigHandler.path + ConfigHandler.sqlite + ".tmp' AS tmp_db";
PreparedStatement preparedStmt = connection.prepareStatement(query);
preparedStmt.execute();
@ -478,94 +478,94 @@ public class Database extends Queue {
}
try {
if (!indexData.contains("art_map_id_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "art_map_id_index ON " + ConfigHandler.prefix + "art_map(id);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "art_map_id_index ON " + prefix + "art_map(id);");
}
if (!indexData.contains("block_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_index ON " + ConfigHandler.prefix + "block(wid,x,z,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_index ON " + prefix + "block(wid,x,z,time);");
}
if (!indexData.contains("block_user_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_user_index ON " + ConfigHandler.prefix + "block(user,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_user_index ON " + prefix + "block(user,time);");
}
if (!indexData.contains("block_type_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_type_index ON " + ConfigHandler.prefix + "block(type,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "block_type_index ON " + prefix + "block(type,time);");
}
if (!indexData.contains("blockdata_map_id_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "blockdata_map_id_index ON " + ConfigHandler.prefix + "blockdata_map(id);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "blockdata_map_id_index ON " + prefix + "blockdata_map(id);");
}
if (!indexData.contains("chat_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_index ON " + ConfigHandler.prefix + "chat(time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_index ON " + prefix + "chat(time);");
}
if (!indexData.contains("chat_user_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_user_index ON " + ConfigHandler.prefix + "chat(user,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_user_index ON " + prefix + "chat(user,time);");
}
if (!indexData.contains("chat_wid_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_wid_index ON " + ConfigHandler.prefix + "chat(wid,x,z,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "chat_wid_index ON " + prefix + "chat(wid,x,z,time);");
}
if (!indexData.contains("command_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_index ON " + ConfigHandler.prefix + "command(time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_index ON " + prefix + "command(time);");
}
if (!indexData.contains("command_user_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_user_index ON " + ConfigHandler.prefix + "command(user,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_user_index ON " + prefix + "command(user,time);");
}
if (!indexData.contains("command_wid_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_wid_index ON " + ConfigHandler.prefix + "command(wid,x,z,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "command_wid_index ON " + prefix + "command(wid,x,z,time);");
}
if (!indexData.contains("container_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "container_index ON " + ConfigHandler.prefix + "container(wid,x,z,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "container_index ON " + prefix + "container(wid,x,z,time);");
}
if (!indexData.contains("container_user_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "container_user_index ON " + ConfigHandler.prefix + "container(user,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "container_user_index ON " + prefix + "container(user,time);");
}
if (!indexData.contains("container_type_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "container_type_index ON " + ConfigHandler.prefix + "container(type,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "container_type_index ON " + prefix + "container(type,time);");
}
if (!indexData.contains("item_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_index ON " + ConfigHandler.prefix + "item(wid,x,z,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_index ON " + prefix + "item(wid,x,z,time);");
}
if (!indexData.contains("item_user_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_user_index ON " + ConfigHandler.prefix + "item(user,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_user_index ON " + prefix + "item(user,time);");
}
if (!indexData.contains("item_type_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_type_index ON " + ConfigHandler.prefix + "item(type,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "item_type_index ON " + prefix + "item(type,time);");
}
if (!indexData.contains("entity_map_id_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "entity_map_id_index ON " + ConfigHandler.prefix + "entity_map(id);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "entity_map_id_index ON " + prefix + "entity_map(id);");
}
if (!indexData.contains("material_map_id_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "material_map_id_index ON " + ConfigHandler.prefix + "material_map(id);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "material_map_id_index ON " + prefix + "material_map(id);");
}
if (!indexData.contains("session_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_index ON " + ConfigHandler.prefix + "session(wid,x,z,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_index ON " + prefix + "session(wid,x,z,time);");
}
if (!indexData.contains("session_action_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_action_index ON " + ConfigHandler.prefix + "session(action,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_action_index ON " + prefix + "session(action,time);");
}
if (!indexData.contains("session_user_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_user_index ON " + ConfigHandler.prefix + "session(user,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_user_index ON " + prefix + "session(user,time);");
}
if (!indexData.contains("session_time_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_time_index ON " + ConfigHandler.prefix + "session(time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "session_time_index ON " + prefix + "session(time);");
}
if (!indexData.contains("sign_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_index ON " + ConfigHandler.prefix + "sign(wid,x,z,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_index ON " + prefix + "sign(wid,x,z,time);");
}
if (!indexData.contains("sign_user_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_user_index ON " + ConfigHandler.prefix + "sign(user,time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_user_index ON " + prefix + "sign(user,time);");
}
if (!indexData.contains("sign_time_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_time_index ON " + ConfigHandler.prefix + "sign(time);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "sign_time_index ON " + prefix + "sign(time);");
}
if (!indexData.contains("user_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "user_index ON " + ConfigHandler.prefix + "user(user);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "user_index ON " + prefix + "user(user);");
}
if (!indexData.contains("uuid_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "uuid_index ON " + ConfigHandler.prefix + "user(uuid);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "uuid_index ON " + prefix + "user(uuid);");
}
if (!indexData.contains("username_log_uuid_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "username_log_uuid_index ON " + ConfigHandler.prefix + "username_log(uuid,user);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "username_log_uuid_index ON " + prefix + "username_log(uuid,user);");
}
if (!indexData.contains("world_id_index")) {
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "world_id_index ON " + ConfigHandler.prefix + "world(id);");
statement.executeUpdate("CREATE INDEX IF NOT EXISTS " + attachDatabase + "world_id_index ON " + prefix + "world(id);");
}
}
catch (Exception e) {
@ -574,7 +574,7 @@ public class Database extends Queue {
e.printStackTrace();
}
}
if (!purge) {
if (!purge && forceConnection == null) {
initializeTables(prefix, statement);
}
statement.close();

View File

@ -23,7 +23,7 @@ public class __2_15_0 {
String preparedQuery = "UPDATE " + ConfigHandler.prefix + "material_map SET material = ? WHERE rowid = ?";
PreparedStatement preparedStatement = statement.getConnection().prepareStatement(preparedQuery);
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
ResultSet rs = statement.executeQuery(query);
while (rs.next()) {
int rowid = rs.getInt("id");
@ -36,7 +36,7 @@ public class __2_15_0 {
}
}
rs.close();
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
try {
if (Config.getGlobal().MYSQL) {

View File

@ -53,7 +53,7 @@ public class __2_16_0 {
query = "SELECT rowid as id FROM " + ConfigHandler.prefix + "block WHERE type IN(" + idList + ") AND y='0'";
String preparedQueryDelete = "DELETE FROM " + ConfigHandler.prefix + "block WHERE rowid = ?";
PreparedStatement preparedStatementDelete = statement.getConnection().prepareStatement(preparedQueryDelete);
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
resultSet = statement.executeQuery(query);
while (resultSet.next()) {
int rowid = resultSet.getInt("id");
@ -61,7 +61,7 @@ public class __2_16_0 {
preparedStatementDelete.executeUpdate();
}
resultSet.close();
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
}
}
catch (Exception e) {
@ -78,7 +78,7 @@ public class __2_16_0 {
PreparedStatement preparedStatementSelect = statement.getConnection().prepareStatement(preparedQuerySelect);
PreparedStatement preparedStatementDelete = statement.getConnection().prepareStatement(preparedQueryDelete);
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
int rowid = resultSet.getInt("id");
@ -96,7 +96,7 @@ public class __2_16_0 {
}
}
resultSet.close();
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
}
catch (Exception e) {
e.printStackTrace();

View File

@ -57,7 +57,7 @@ public class __2_18_0 {
PreparedStatement preparedContainerStatement = statement.getConnection().prepareStatement(preparedContainerQuery);
PreparedStatement preparedContainerUpdateStatement = statement.getConnection().prepareStatement(preparedContainerUpdateQuery);
PreparedStatement preparedMaterialDeleteStatement = statement.getConnection().prepareStatement(preparedMaterialDeleteQuery);
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
try {
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
@ -163,7 +163,7 @@ public class __2_18_0 {
catch (Exception e) {
e.printStackTrace();
}
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
preparedBlockStatement.close();
preparedBlockUpdateStatement.close();

View File

@ -143,7 +143,7 @@ public class __2_19_0 {
String preparedQueryUpdate = "UPDATE " + ConfigHandler.prefix + "sign SET action = 1 WHERE rowid = ?";
PreparedStatement preparedSignStatement = statement.getConnection().prepareStatement(preparedSignQuery);
PreparedStatement preparedStatementUpdate = statement.getConnection().prepareStatement(preparedQueryUpdate);
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
ResultSet resultSet = statement.executeQuery(blockQuery);
while (resultSet.next()) {
@ -166,7 +166,7 @@ public class __2_19_0 {
preparedSignStatement.close();
preparedStatementUpdate.close();
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
}
catch (Exception e) {
e.printStackTrace();

View File

@ -61,7 +61,7 @@ public class __2_20_0 {
String entityQuery = "SELECT rowid, data FROM " + ConfigHandler.prefix + "block WHERE type = (SELECT id FROM " + ConfigHandler.prefix + "material_map WHERE material='minecraft:spawner' LIMIT 1) ORDER BY rowid ASC";
String preparedQueryUpdate = "UPDATE " + ConfigHandler.prefix + "block SET data = ? WHERE rowid = ?";
PreparedStatement preparedStatementUpdate = statement.getConnection().prepareStatement(preparedQueryUpdate);
Database.beginTransaction(statement);
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
ResultSet resultSet = statement.executeQuery(entityQuery);
while (resultSet.next()) {
@ -97,7 +97,7 @@ public class __2_20_0 {
resultSet.close();
preparedStatementUpdate.close();
Database.commitTransaction(statement);
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
}
catch (Exception e) {
e.printStackTrace();