Synced savequeue before rollback

This commit is contained in:
Robin Kupper
2011-06-30 03:11:39 +02:00
parent 99e56289ab
commit 8873ea84a9
2 changed files with 22 additions and 6 deletions

View File

@@ -428,10 +428,12 @@ public class CommandsHandler implements CommandExecutor
@Override
public void run() {
final Consumer consumer = logblock.getConsumer();
sender.sendMessage(ChatColor.DARK_AQUA + "Current queue size: " + consumer.getQueueSize());
while (consumer.getQueueSize() > 0)
consumer.run();
sender.sendMessage(ChatColor.GREEN + "Queue saved successfully");
if (consumer.getQueueSize() > 0) {
sender.sendMessage(ChatColor.DARK_AQUA + "Current queue size: " + consumer.getQueueSize());
while (consumer.getQueueSize() > 0)
consumer.run();
sender.sendMessage(ChatColor.GREEN + "Queue saved successfully");
}
}
}
@@ -475,7 +477,7 @@ public class CommandsHandler implements CommandExecutor
try {
if (logblock.getConsumer().getQueueSize() > 50)
try {
new CommandSaveQueue(sender, null, true);
new CommandSaveQueue(sender, null, false);
} catch (final Exception ex) {
sender.sendMessage(ChatColor.RED + ex.getMessage());
}

View File

@@ -35,6 +35,20 @@ class Updater
config.setProperty("lookup.toolBlockQuery", params + " silent");
config.setProperty("version", "1.10");
}
if (config.getString("version").compareTo("1.20") < 0) {
log.info("[LogBlock] Updating tables to 1.20 ...");
final Connection conn = logblock.getConnection();
try {
conn.setAutoCommit(true);
final Statement st = conn.createStatement();
for (final String table : logblock.getConfig().tables.values())
st.execute("ALTER TABLE `" + table + "-sign` MODIFY signtext VARCHAR(255) NOT NULL");
st.close();
conn.close();
} catch (final SQLException ex) {}
config.setProperty("version", "1.20");
}
config.save();
return true;
}
@@ -51,7 +65,7 @@ class Updater
if (dbm.getTables(null, null, table + "-chest", null).next() && state.executeQuery("SELECT * FROM `" + table + "-chest` LIMIT 1").getMetaData().getColumnCount() != 4) // Chest table update
state.execute("DROP TABLE `" + table + "-chest`");
createTable(dbm, state, table, "(id INT NOT NULL AUTO_INCREMENT, date DATETIME NOT NULL, playerid SMALLINT UNSIGNED NOT NULL, replaced TINYINT UNSIGNED NOT NULL, type TINYINT UNSIGNED NOT NULL, data TINYINT UNSIGNED NOT NULL, x SMALLINT NOT NULL, y TINYINT UNSIGNED NOT NULL, z SMALLINT NOT NULL, PRIMARY KEY (id), KEY coords (x, z, y), KEY date (date), KEY playerid (playerid))");
createTable(dbm, state, table + "-sign", "(id INT NOT NULL, signtext VARCHAR(255), PRIMARY KEY (id))");
createTable(dbm, state, table + "-sign", "(id INT NOT NULL, signtext VARCHAR(255) NOT NULL, PRIMARY KEY (id))");
createTable(dbm, state, table + "-chest", "(id INT NOT NULL, itemtype SMALLINT UNSIGNED NOT NULL, itemamount SMALLINT NOT NULL, itemdata TINYINT UNSIGNED NOT NULL, PRIMARY KEY (id))");
if (logblock.getConfig().logKills)
createTable(dbm, state, table + "-kills", "(id INT UNSIGNED NOT NULL AUTO_INCREMENT, date DATETIME NOT NULL, killer SMALLINT UNSIGNED, victim SMALLINT UNSIGNED NOT NULL, weapon SMALLINT UNSIGNED NOT NULL, PRIMARY KEY (id))");