Set up parameterized jdbc connection (#8)
All checks were successful
Build / Explore-Gitea-Actions (push) Successful in 42s

Co-authored-by: ThePindabaas <219561634+ThePindabaas@users.noreply.github.com>
Reviewed-on: #8
Reviewed-by: Ardakaz <ardakaz@duck.com>
Co-authored-by: ThePindabaas <thepindabaas@noreply.localhost>
Co-committed-by: ThePindabaas <thepindabaas@noreply.localhost>
This commit is contained in:
2026-07-03 11:07:53 +00:00
committed by Ardakaz
parent 4cd24ad467
commit 55881630bc
2 changed files with 6 additions and 3 deletions

View File

@@ -41,7 +41,6 @@ import java.util.stream.Collectors;
public class GriefAlert extends JavaPlugin implements Listener {
private static CoreProtectAPI coreProtectAPI;
private final String DB_FILE = "ignored_locations.db";
private Integer identicalAlerts = 1;
private String lastAlert;
private Set<Material> EXCLUDED_BLOCKS;
@@ -194,11 +193,13 @@ public class GriefAlert extends JavaPlugin implements Listener {
}
private void setupDatabase() {
String jdbcUrl = getConfig().getString("jdbc-url");
try {
connection = DriverManager.getConnection("jdbc:sqlite:" + getDataFolder().getAbsolutePath() + "/" + DB_FILE);
connection = DriverManager.getConnection(jdbcUrl);
Statement stmt = connection.createStatement();
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS ignored_locations (x INTEGER, y INTEGER, z INTEGER, world TEXT, PRIMARY KEY (x, y, z, world))");
stmt.close();
getLogger().info("Connected to "+jdbcUrl);
} catch (SQLException e) {
getLogger().severe("Could not set up SQLite database: " + e.getMessage());
}

View File

@@ -1,6 +1,8 @@
# Ignore all stealing?
allow-stealing: false
jdbc-url: ""
# Breaking these blocks don't cause alerts. (Material)
excluded-blocks:
- WHEAT