This commit is contained in:
GeorgH93 2020-10-12 20:08:08 +02:00
parent 3d5f29c1f6
commit 15950f3d04
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 6 additions and 6 deletions

View File

@ -36,7 +36,7 @@ public MySQL(@NotNull Minepacks plugin, @Nullable ConnectionProvider connectionP
} }
@Override @Override
protected void updateQuerysForDialect() protected void updateQueriesForDialect()
{ {
queryDeleteOldBackpacks = "DELETE FROM `{TableBackpacks}` WHERE `{FieldBPLastUpdate}` + INTERVAL {VarMaxAge} day < NOW()"; queryDeleteOldBackpacks = "DELETE FROM `{TableBackpacks}` WHERE `{FieldBPLastUpdate}` + INTERVAL {VarMaxAge} day < NOW()";
queryUpdateBp = queryUpdateBp.replaceAll("\\{NOW}", "NOW()"); queryUpdateBp = queryUpdateBp.replaceAll("\\{NOW}", "NOW()");

View File

@ -56,7 +56,7 @@ public SQL(@NotNull Minepacks plugin, @NotNull ConnectionProvider connectionProv
if(!dataSource.isAvailable()) throw new IllegalStateException("Failed to initialize database connection!"); if(!dataSource.isAvailable()) throw new IllegalStateException("Failed to initialize database connection!");
loadSettings(); loadSettings();
buildQuerys(); buildQueries();
checkDB(); checkDB();
checkUUIDs(); // Check if there are user accounts without UUID checkUUIDs(); // Check if there are user accounts without UUID
@ -181,7 +181,7 @@ public Connection getConnection() throws SQLException
protected abstract void checkDB(); protected abstract void checkDB();
protected final void buildQuerys() protected final void buildQueries()
{ {
// Build the SQL querys with placeholders for the table and field names // Build the SQL querys with placeholders for the table and field names
queryGetBP = "SELECT {FieldBPOwner},{FieldBPITS},{FieldBPVersion} FROM {TableBackpacks} INNER JOIN {TablePlayers} ON {TableBackpacks}.{FieldBPOwner}={TablePlayers}.{FieldPlayerID} WHERE {FieldUUID}=?;"; queryGetBP = "SELECT {FieldBPOwner},{FieldBPITS},{FieldBPVersion} FROM {TableBackpacks} INNER JOIN {TablePlayers} ON {TableBackpacks}.{FieldBPOwner}={TablePlayers}.{FieldPlayerID} WHERE {FieldUUID}=?;";
@ -203,7 +203,7 @@ protected final void buildQuerys()
queryFixUUIDs = "UPDATE {TablePlayers} SET {FieldUUID}=? WHERE {FieldPlayerID}=?;"; queryFixUUIDs = "UPDATE {TablePlayers} SET {FieldUUID}=? WHERE {FieldPlayerID}=?;";
queryDeleteOldCooldowns = "DELETE FROM {TableCooldowns} WHERE {FieldCDTime}<?;"; queryDeleteOldCooldowns = "DELETE FROM {TableCooldowns} WHERE {FieldCDTime}<?;";
updateQuerysForDialect(); updateQueriesForDialect();
setTableAndFieldNames(); setTableAndFieldNames();
} }
@ -224,7 +224,7 @@ protected void setTableAndFieldNames()
queryDeleteOldCooldowns = replacePlaceholders(queryDeleteOldCooldowns); queryDeleteOldCooldowns = replacePlaceholders(queryDeleteOldCooldowns);
} }
protected abstract void updateQuerysForDialect(); protected abstract void updateQueriesForDialect();
protected String replacePlaceholders(@Language("SQL") String query) protected String replacePlaceholders(@Language("SQL") String query)
{ {

View File

@ -68,7 +68,7 @@ protected void loadSettings()
} }
@Override @Override
protected void updateQuerysForDialect() protected void updateQueriesForDialect()
{ {
queryInsertBp = queryInsertBp.replaceAll("\\) VALUES \\(\\?,\\?,\\?", ",{FieldBPLastUpdate}) VALUES (?,?,?,DATE('now')"); queryInsertBp = queryInsertBp.replaceAll("\\) VALUES \\(\\?,\\?,\\?", ",{FieldBPLastUpdate}) VALUES (?,?,?,DATE('now')");
queryDeleteOldBackpacks = "DELETE FROM {TableBackpacks} WHERE {FieldBPLastUpdate} < DATE('now', '-{VarMaxAge} days')"; queryDeleteOldBackpacks = "DELETE FROM {TableBackpacks} WHERE {FieldBPLastUpdate} < DATE('now', '-{VarMaxAge} days')";