Set up parameterized jdbc connection #8

Merged
Ardakaz merged 1 commits from parameterized-jdbc-connection into main 2026-07-03 11:07:53 +00:00
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());
}
@@ -847,4 +848,4 @@ public class GriefAlert extends JavaPlugin implements Listener {
return ((CoreProtect) plugin).getAPI();
}
}
}

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