From 55881630bcdf15de65841a8e25e2da2520d95360 Mon Sep 17 00:00:00 2001 From: ThePindabaas Date: Fri, 3 Jul 2026 11:07:53 +0000 Subject: [PATCH] Set up parameterized jdbc connection (#8) Co-authored-by: ThePindabaas <219561634+ThePindabaas@users.noreply.github.com> Reviewed-on: https://git.ardakaz.net/ArdakazMC/GriefAlert/pulls/8 Reviewed-by: Ardakaz Co-authored-by: ThePindabaas Co-committed-by: ThePindabaas --- src/main/java/net/ardakaz/griefalert/GriefAlert.java | 7 ++++--- src/main/resources/config.yml | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/ardakaz/griefalert/GriefAlert.java b/src/main/java/net/ardakaz/griefalert/GriefAlert.java index b40c349..4037613 100644 --- a/src/main/java/net/ardakaz/griefalert/GriefAlert.java +++ b/src/main/java/net/ardakaz/griefalert/GriefAlert.java @@ -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 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()); } @@ -847,4 +848,4 @@ public class GriefAlert extends JavaPlugin implements Listener { return ((CoreProtect) plugin).getAPI(); } -} +} \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 8972c40..297ef10 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,6 +1,8 @@ # Ignore all stealing? allow-stealing: false +jdbc-url: "" + # Breaking these blocks don't cause alerts. (Material) excluded-blocks: - WHEAT