mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-10-22 08:00:56 +02:00
Added base changes for database migration command (unfinished)
This commit is contained in:
parent
fc0c8ff9ac
commit
de978fce2c
5
.gitignore
vendored
5
.gitignore
vendored
@ -195,4 +195,7 @@ Desktop.ini
|
|||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
# Documentation dev folder
|
# Documentation dev folder
|
||||||
docs/dev/
|
docs/dev/
|
||||||
|
|
||||||
|
# Extensions
|
||||||
|
extensions/
|
@ -26,6 +26,7 @@ DATABASE_UNREACHABLE: "Database is unreachable. Discarding data and shutting dow
|
|||||||
DEVELOPMENT_BRANCH: "Development branch detected, skipping patch scripts."
|
DEVELOPMENT_BRANCH: "Development branch detected, skipping patch scripts."
|
||||||
DIRT_BLOCK: "Placed a temporary safety block under you."
|
DIRT_BLOCK: "Placed a temporary safety block under you."
|
||||||
DISABLE_SUCCESS: "Success! Disabled {0}"
|
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_FAILED: "{0} was unable to start."
|
||||||
ENABLE_SUCCESS: "{0} has been successfully enabled!"
|
ENABLE_SUCCESS: "{0} has been successfully enabled!"
|
||||||
ENJOY_COREPROTECT: "Enjoy {0}? Join our Discord!"
|
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_MYSQL: "Using MySQL for data storage."
|
||||||
USING_SQLITE: "Using SQLite for data storage."
|
USING_SQLITE: "Using SQLite for data storage."
|
||||||
VALID_DONATION_KEY: "Valid donation key."
|
VALID_DONATION_KEY: "Valid donation key."
|
||||||
|
VERSION_INCOMPATIBLE: "{0} {1} is not supported."
|
||||||
VERSION_NOTICE: "Version {0} is now available."
|
VERSION_NOTICE: "Version {0} is now available."
|
||||||
VERSION_REQUIRED: "{0} {1} or higher is required."
|
VERSION_REQUIRED: "{0} {1} or higher is required."
|
||||||
WORLD_NOT_FOUND: "World \"{0}\" not found."
|
WORLD_NOT_FOUND: "World \"{0}\" not found."
|
@ -196,6 +196,9 @@ public final class CoreProtect extends JavaPlugin {
|
|||||||
Chat.console(Phrase.build(Phrase.FINISHING_LOGGING));
|
Chat.console(Phrase.build(Phrase.FINISHING_LOGGING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ConfigHandler.migrationRunning) {
|
||||||
|
ConfigHandler.purgeRunning = false;
|
||||||
|
}
|
||||||
while ((Consumer.isRunning() || ConfigHandler.converterRunning) && !ConfigHandler.purgeRunning) {
|
while ((Consumer.isRunning() || ConfigHandler.converterRunning) && !ConfigHandler.purgeRunning) {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
if (time >= alertTime) {
|
if (time >= alertTime) {
|
||||||
|
@ -1273,6 +1273,21 @@ public class CommandHandler implements CommandExecutor {
|
|||||||
else if (corecommand.equals("network-debug")) {
|
else if (corecommand.equals("network-debug")) {
|
||||||
NetworkDebugCommand.runCommand(user, permission, argumentArray);
|
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 {
|
else {
|
||||||
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + corecommand));
|
Chat.sendMessage(user, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.COMMAND_NOT_FOUND, Color.WHITE, "/co " + corecommand));
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class PurgeCommand extends Consumer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigHandler.converterRunning) {
|
if (ConfigHandler.converterRunning || ConfigHandler.migrationRunning) {
|
||||||
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
Chat.sendMessage(player, Color.DARK_AQUA + "CoreProtect " + Color.WHITE + "- " + Phrase.build(Phrase.UPGRADE_IN_PROGRESS));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,11 +104,6 @@ public class PurgeCommand extends Consumer {
|
|||||||
int restrictCount = 0;
|
int restrictCount = 0;
|
||||||
|
|
||||||
if (argBlocks.size() > 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 includeListMaterial = new StringBuilder();
|
||||||
StringBuilder includeListEntity = 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");
|
List<String> purgeTables = Arrays.asList("sign", "container", "item", "skull", "session", "chat", "command", "entity", "block");
|
||||||
|
@ -55,6 +55,7 @@ public class ConfigHandler extends Queue {
|
|||||||
public static String username = "root";
|
public static String username = "root";
|
||||||
public static String password = "";
|
public static String password = "";
|
||||||
public static String prefix = "co_";
|
public static String prefix = "co_";
|
||||||
|
public static String prefixConfig = "co_";
|
||||||
public static int maximumPoolSize = 10;
|
public static int maximumPoolSize = 10;
|
||||||
|
|
||||||
public static HikariDataSource hikariDataSource = null;
|
public static HikariDataSource hikariDataSource = null;
|
||||||
@ -65,6 +66,7 @@ public class ConfigHandler extends Queue {
|
|||||||
public static volatile boolean serverRunning = false;
|
public static volatile boolean serverRunning = false;
|
||||||
public static volatile boolean converterRunning = false;
|
public static volatile boolean converterRunning = false;
|
||||||
public static volatile boolean purgeRunning = false;
|
public static volatile boolean purgeRunning = false;
|
||||||
|
public static volatile boolean migrationRunning = false;
|
||||||
public static volatile boolean pauseConsumer = false;
|
public static volatile boolean pauseConsumer = false;
|
||||||
public static volatile boolean worldeditEnabled = false;
|
public static volatile boolean worldeditEnabled = false;
|
||||||
public static volatile boolean databaseReachable = true;
|
public static volatile boolean databaseReachable = true;
|
||||||
@ -173,6 +175,7 @@ public class ConfigHandler extends Queue {
|
|||||||
|
|
||||||
// Enforce "co_" table prefix if using SQLite.
|
// Enforce "co_" table prefix if using SQLite.
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
|
ConfigHandler.prefixConfig = Config.getGlobal().PREFIX;
|
||||||
Config.getGlobal().PREFIX = "co_";
|
Config.getGlobal().PREFIX = "co_";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,7 +262,7 @@ public class ConfigHandler extends Queue {
|
|||||||
ConfigHandler.hikariDataSource = new HikariDataSource(config);
|
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) {
|
public static void loadTypes(Statement statement) {
|
||||||
|
@ -100,7 +100,7 @@ public class Consumer extends Process implements Runnable, Thread.UncaughtExcept
|
|||||||
|
|
||||||
private static void pauseConsumer(int process_id) {
|
private static void pauseConsumer(int process_id) {
|
||||||
try {
|
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;
|
pausedSuccess = true;
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import net.coreprotect.config.Config;
|
||||||
import net.coreprotect.config.ConfigHandler;
|
import net.coreprotect.config.ConfigHandler;
|
||||||
import net.coreprotect.consumer.Consumer;
|
import net.coreprotect.consumer.Consumer;
|
||||||
import net.coreprotect.database.Database;
|
import net.coreprotect.database.Database;
|
||||||
@ -74,7 +75,7 @@ public class Process {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
Database.performCheckpoint(statement);
|
Database.performCheckpoint(statement, Config.getGlobal().MYSQL);
|
||||||
|
|
||||||
Consumer.isPaused = true;
|
Consumer.isPaused = true;
|
||||||
ArrayList<Object[]> consumerData = Consumer.consumer.get(processId);
|
ArrayList<Object[]> consumerData = Consumer.consumer.get(processId);
|
||||||
@ -91,7 +92,7 @@ public class Process {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.beginTransaction(statement);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
// Scan through usernames, ensure everything is loaded in memory.
|
// Scan through usernames, ensure everything is loaded in memory.
|
||||||
for (Entry<Integer, String[]> entry : users.entrySet()) {
|
for (Entry<Integer, String[]> entry : users.entrySet()) {
|
||||||
String[] data = entry.getValue();
|
String[] data = entry.getValue();
|
||||||
@ -104,7 +105,7 @@ public class Process {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateLockTable(statement, (lastRun ? 0 : 1));
|
updateLockTable(statement, (lastRun ? 0 : 1));
|
||||||
Database.commitTransaction(statement);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
|
|
||||||
// Create prepared statements
|
// Create prepared statements
|
||||||
PreparedStatement preparedStmtSigns = Database.prepareStatement(connection, Database.SIGN, false);
|
PreparedStatement preparedStmtSigns = Database.prepareStatement(connection, Database.SIGN, false);
|
||||||
@ -123,7 +124,7 @@ public class Process {
|
|||||||
PreparedStatement preparedStmtBlockdata = Database.prepareStatement(connection, Database.BLOCKDATA, false);
|
PreparedStatement preparedStmtBlockdata = Database.prepareStatement(connection, Database.BLOCKDATA, false);
|
||||||
|
|
||||||
// Scan through consumer data
|
// Scan through consumer data
|
||||||
Database.beginTransaction(statement);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
for (int i = 0; i < consumerDataSize; i++) {
|
for (int i = 0; i < consumerDataSize; i++) {
|
||||||
Object[] data = consumerData.get(i);
|
Object[] data = consumerData.get(i);
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
@ -242,7 +243,7 @@ public class Process {
|
|||||||
if (Consumer.interrupt) {
|
if (Consumer.interrupt) {
|
||||||
commit(statement, preparedStmtSigns, preparedStmtBlocks, preparedStmtSkulls, preparedStmtContainers, preparedStmtItems, preparedStmtWorlds, preparedStmtChat, preparedStmtCommand, preparedStmtSession, preparedStmtEntities, preparedStmtMaterials, preparedStmtArt, preparedStmtEntity, preparedStmtBlockdata);
|
commit(statement, preparedStmtSigns, preparedStmtBlocks, preparedStmtSkulls, preparedStmtContainers, preparedStmtItems, preparedStmtWorlds, preparedStmtChat, preparedStmtCommand, preparedStmtSession, preparedStmtEntities, preparedStmtMaterials, preparedStmtArt, preparedStmtEntity, preparedStmtBlockdata);
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
Database.beginTransaction(statement);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -302,7 +303,7 @@ public class Process {
|
|||||||
preparedStmtArt.executeBatch();
|
preparedStmtArt.executeBatch();
|
||||||
preparedStmtEntity.executeBatch();
|
preparedStmtEntity.executeBatch();
|
||||||
preparedStmtBlockdata.executeBatch();
|
preparedStmtBlockdata.executeBatch();
|
||||||
Database.commitTransaction(statement);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -43,11 +43,11 @@ public class Database extends Queue {
|
|||||||
public static final int BLOCKDATA = 12;
|
public static final int BLOCKDATA = 12;
|
||||||
public static final int ITEM = 13;
|
public static final int ITEM = 13;
|
||||||
|
|
||||||
public static void beginTransaction(Statement statement) {
|
public static void beginTransaction(Statement statement, boolean isMySQL) {
|
||||||
Consumer.transacting = true;
|
Consumer.transacting = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Config.getGlobal().MYSQL) {
|
if (isMySQL) {
|
||||||
statement.executeUpdate("START TRANSACTION");
|
statement.executeUpdate("START TRANSACTION");
|
||||||
}
|
}
|
||||||
else {
|
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;
|
int count = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
if (Config.getGlobal().MYSQL) {
|
if (isMySQL) {
|
||||||
statement.executeUpdate("COMMIT");
|
statement.executeUpdate("COMMIT");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -89,8 +89,8 @@ public class Database extends Queue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void performCheckpoint(Statement statement) throws SQLException {
|
public static void performCheckpoint(Statement statement, boolean isMySQL) throws SQLException {
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!isMySQL) {
|
||||||
statement.executeUpdate("PRAGMA wal_checkpoint(TRUNCATE)");
|
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.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"));
|
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;
|
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) {
|
if (connection != null) {
|
||||||
String index = "";
|
String index = "";
|
||||||
Statement statement = connection.createStatement();
|
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");
|
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)";
|
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");
|
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);
|
initializeTables(prefix, statement);
|
||||||
}
|
}
|
||||||
statement.close();
|
statement.close();
|
||||||
@ -390,18 +390,18 @@ public class Database extends Queue {
|
|||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success && forceConnection == null) {
|
||||||
Config.getGlobal().MYSQL = false;
|
Config.getGlobal().MYSQL = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!mySQL) {
|
||||||
try (Connection connection = Database.getConnection(true, 0)) {
|
try (Connection connection = (forceConnection != null ? forceConnection : Database.getConnection(true, 0))) {
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
List<String> tableData = new ArrayList<>();
|
List<String> tableData = new ArrayList<>();
|
||||||
List<String> indexData = new ArrayList<>();
|
List<String> indexData = new ArrayList<>();
|
||||||
String attachDatabase = "";
|
String attachDatabase = "";
|
||||||
|
|
||||||
if (purge) {
|
if (purge && forceConnection == null) {
|
||||||
String query = "ATTACH DATABASE '" + ConfigHandler.path + ConfigHandler.sqlite + ".tmp' AS tmp_db";
|
String query = "ATTACH DATABASE '" + ConfigHandler.path + ConfigHandler.sqlite + ".tmp' AS tmp_db";
|
||||||
PreparedStatement preparedStmt = connection.prepareStatement(query);
|
PreparedStatement preparedStmt = connection.prepareStatement(query);
|
||||||
preparedStmt.execute();
|
preparedStmt.execute();
|
||||||
@ -478,94 +478,94 @@ public class Database extends Queue {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!indexData.contains("art_map_id_index")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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")) {
|
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) {
|
catch (Exception e) {
|
||||||
@ -574,7 +574,7 @@ public class Database extends Queue {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!purge) {
|
if (!purge && forceConnection == null) {
|
||||||
initializeTables(prefix, statement);
|
initializeTables(prefix, statement);
|
||||||
}
|
}
|
||||||
statement.close();
|
statement.close();
|
||||||
|
@ -23,7 +23,7 @@ public class __2_15_0 {
|
|||||||
String preparedQuery = "UPDATE " + ConfigHandler.prefix + "material_map SET material = ? WHERE rowid = ?";
|
String preparedQuery = "UPDATE " + ConfigHandler.prefix + "material_map SET material = ? WHERE rowid = ?";
|
||||||
PreparedStatement preparedStatement = statement.getConnection().prepareStatement(preparedQuery);
|
PreparedStatement preparedStatement = statement.getConnection().prepareStatement(preparedQuery);
|
||||||
|
|
||||||
Database.beginTransaction(statement);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
ResultSet rs = statement.executeQuery(query);
|
ResultSet rs = statement.executeQuery(query);
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
int rowid = rs.getInt("id");
|
int rowid = rs.getInt("id");
|
||||||
@ -36,7 +36,7 @@ public class __2_15_0 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
Database.commitTransaction(statement);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Config.getGlobal().MYSQL) {
|
if (Config.getGlobal().MYSQL) {
|
||||||
|
@ -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'";
|
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 = ?";
|
String preparedQueryDelete = "DELETE FROM " + ConfigHandler.prefix + "block WHERE rowid = ?";
|
||||||
PreparedStatement preparedStatementDelete = statement.getConnection().prepareStatement(preparedQueryDelete);
|
PreparedStatement preparedStatementDelete = statement.getConnection().prepareStatement(preparedQueryDelete);
|
||||||
Database.beginTransaction(statement);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
resultSet = statement.executeQuery(query);
|
resultSet = statement.executeQuery(query);
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
int rowid = resultSet.getInt("id");
|
int rowid = resultSet.getInt("id");
|
||||||
@ -61,7 +61,7 @@ public class __2_16_0 {
|
|||||||
preparedStatementDelete.executeUpdate();
|
preparedStatementDelete.executeUpdate();
|
||||||
}
|
}
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
Database.commitTransaction(statement);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -78,7 +78,7 @@ public class __2_16_0 {
|
|||||||
PreparedStatement preparedStatementSelect = statement.getConnection().prepareStatement(preparedQuerySelect);
|
PreparedStatement preparedStatementSelect = statement.getConnection().prepareStatement(preparedQuerySelect);
|
||||||
PreparedStatement preparedStatementDelete = statement.getConnection().prepareStatement(preparedQueryDelete);
|
PreparedStatement preparedStatementDelete = statement.getConnection().prepareStatement(preparedQueryDelete);
|
||||||
|
|
||||||
Database.beginTransaction(statement);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
ResultSet resultSet = statement.executeQuery(query);
|
ResultSet resultSet = statement.executeQuery(query);
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
int rowid = resultSet.getInt("id");
|
int rowid = resultSet.getInt("id");
|
||||||
@ -96,7 +96,7 @@ public class __2_16_0 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultSet.close();
|
resultSet.close();
|
||||||
Database.commitTransaction(statement);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -57,7 +57,7 @@ public class __2_18_0 {
|
|||||||
PreparedStatement preparedContainerStatement = statement.getConnection().prepareStatement(preparedContainerQuery);
|
PreparedStatement preparedContainerStatement = statement.getConnection().prepareStatement(preparedContainerQuery);
|
||||||
PreparedStatement preparedContainerUpdateStatement = statement.getConnection().prepareStatement(preparedContainerUpdateQuery);
|
PreparedStatement preparedContainerUpdateStatement = statement.getConnection().prepareStatement(preparedContainerUpdateQuery);
|
||||||
PreparedStatement preparedMaterialDeleteStatement = statement.getConnection().prepareStatement(preparedMaterialDeleteQuery);
|
PreparedStatement preparedMaterialDeleteStatement = statement.getConnection().prepareStatement(preparedMaterialDeleteQuery);
|
||||||
Database.beginTransaction(statement);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
try {
|
try {
|
||||||
ResultSet resultSet = statement.executeQuery(query);
|
ResultSet resultSet = statement.executeQuery(query);
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
@ -163,7 +163,7 @@ public class __2_18_0 {
|
|||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Database.commitTransaction(statement);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
|
|
||||||
preparedBlockStatement.close();
|
preparedBlockStatement.close();
|
||||||
preparedBlockUpdateStatement.close();
|
preparedBlockUpdateStatement.close();
|
||||||
|
@ -143,7 +143,7 @@ public class __2_19_0 {
|
|||||||
String preparedQueryUpdate = "UPDATE " + ConfigHandler.prefix + "sign SET action = 1 WHERE rowid = ?";
|
String preparedQueryUpdate = "UPDATE " + ConfigHandler.prefix + "sign SET action = 1 WHERE rowid = ?";
|
||||||
PreparedStatement preparedSignStatement = statement.getConnection().prepareStatement(preparedSignQuery);
|
PreparedStatement preparedSignStatement = statement.getConnection().prepareStatement(preparedSignQuery);
|
||||||
PreparedStatement preparedStatementUpdate = statement.getConnection().prepareStatement(preparedQueryUpdate);
|
PreparedStatement preparedStatementUpdate = statement.getConnection().prepareStatement(preparedQueryUpdate);
|
||||||
Database.beginTransaction(statement);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
|
|
||||||
ResultSet resultSet = statement.executeQuery(blockQuery);
|
ResultSet resultSet = statement.executeQuery(blockQuery);
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
@ -166,7 +166,7 @@ public class __2_19_0 {
|
|||||||
preparedSignStatement.close();
|
preparedSignStatement.close();
|
||||||
preparedStatementUpdate.close();
|
preparedStatementUpdate.close();
|
||||||
|
|
||||||
Database.commitTransaction(statement);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -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 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 = ?";
|
String preparedQueryUpdate = "UPDATE " + ConfigHandler.prefix + "block SET data = ? WHERE rowid = ?";
|
||||||
PreparedStatement preparedStatementUpdate = statement.getConnection().prepareStatement(preparedQueryUpdate);
|
PreparedStatement preparedStatementUpdate = statement.getConnection().prepareStatement(preparedQueryUpdate);
|
||||||
Database.beginTransaction(statement);
|
Database.beginTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
|
|
||||||
ResultSet resultSet = statement.executeQuery(entityQuery);
|
ResultSet resultSet = statement.executeQuery(entityQuery);
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
@ -97,7 +97,7 @@ public class __2_20_0 {
|
|||||||
resultSet.close();
|
resultSet.close();
|
||||||
preparedStatementUpdate.close();
|
preparedStatementUpdate.close();
|
||||||
|
|
||||||
Database.commitTransaction(statement);
|
Database.commitTransaction(statement, Config.getGlobal().MYSQL);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user