diff --git a/src/core/DatabaseDriver.java b/src/core/DatabaseDriver.java index be95113..eb4d499 100644 --- a/src/core/DatabaseDriver.java +++ b/src/core/DatabaseDriver.java @@ -28,14 +28,22 @@ public class DatabaseDriver driver = null; } + // Makes sure a table exists with the specified name. + // The keyName specifies the key column label, and the valueName specifies the value column label. + public void EnsureTableExists(String tableName, String keyName, String valueName) + { + // Require a global table if it doesn't exist already + driver.ExecuteStatement("CREATE TABLE IF NOT EXISTS " + tableName + " (" + keyName + " text PRIMARY KEY, " + valueName + " text);", null); + } + // Set up and create a table in the database public boolean Connect() { driver = new JDBCDriverSQLite(); driver.Connect(); - // Require a global table if it doesn't exist already - driver.ExecuteStatement("CREATE TABLE IF NOT EXISTS " + globalTableName + " (" + globalKeyName + " text PRIMARY KEY, " + globalValueName + " text);", null); + // Verify tables we want to use exist + EnsureTableExists(globalTableName, globalKeyName, globalValueName); // General table. Do not remove. return true; } diff --git a/src/main/Superintendent.java b/src/main/Superintendent.java index 84da5fc..7a93c29 100644 --- a/src/main/Superintendent.java +++ b/src/main/Superintendent.java @@ -68,6 +68,17 @@ public class Superintendent return true; } + // Only called once per command. Good for lazily updating. + // Happens just before the command / plugin runs. + public static boolean PerCommandUpkeepPre() + { + // Upkeep localization system's file monitoring + LocStrings.Upkeep(); + LocCommands.Upkeep(); + + return true; + } + // This is for stuff that we need to do on a regular basis, but don't // necessarily want running at all points in time. // Happens just after the command / plugin runs. @@ -81,15 +92,4 @@ public class Superintendent return true; } - - // Only called once per command. Good for lazily updating. - // Happens just before the command / plugin runs. - public static boolean PerCommandUpkeepPre() - { - // Upkeep localization system's file monitoring - LocStrings.Upkeep(); - LocCommands.Upkeep(); - - return true; - } }