forked from LogBlock/LogBlock
Updated updater
This commit is contained in:
@@ -66,6 +66,8 @@ public class LogBlock extends JavaPlugin
|
||||
log.info("[LogBlock] Connecting to " + config.user + "@" + config.url + "...");
|
||||
pool = new MySQLConnectionPool(config.url, config.user, config.password);
|
||||
getConnection().close();
|
||||
if (updater.update())
|
||||
config = new Config(this);
|
||||
updater.checkTables();
|
||||
} catch (final Exception ex) {
|
||||
log.log(Level.SEVERE, "[LogBlock] Error while loading: ", ex);
|
||||
|
@@ -8,6 +8,7 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
class Updater
|
||||
{
|
||||
@@ -19,6 +20,25 @@ class Updater
|
||||
log = logblock.getServer().getLogger();
|
||||
}
|
||||
|
||||
boolean update() {
|
||||
final Configuration config = logblock.getConfiguration();
|
||||
config.load();
|
||||
if (config.getString("version").compareTo(logblock.getDescription().getVersion()) >= 0)
|
||||
return false;
|
||||
if (config.getString("version").compareTo("1.10") < 0) {
|
||||
log.info("Updating config to 1.10 ...");
|
||||
String params = config.getString("lookup.toolQuery");
|
||||
if (!params.contains("silent"))
|
||||
config.setProperty("lookup.toolQuery", params + " silent");
|
||||
params = config.getString("lookup.toolBlockQuery");
|
||||
if (!params.contains("silent"))
|
||||
config.setProperty("lookup.toolBlockQuery", params + " silent");
|
||||
config.setProperty("version", "1.10");
|
||||
}
|
||||
config.save();
|
||||
return true;
|
||||
}
|
||||
|
||||
void checkTables() throws SQLException {
|
||||
final Connection conn = logblock.getConnection();
|
||||
if (conn == null)
|
||||
|
Reference in New Issue
Block a user