Set up parameterized jdbc connection (#8)
All checks were successful
Build / Explore-Gitea-Actions (push) Successful in 42s
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:
@@ -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());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
# Ignore all stealing?
|
||||
allow-stealing: false
|
||||
|
||||
jdbc-url: ""
|
||||
|
||||
# Breaking these blocks don't cause alerts. (Material)
|
||||
excluded-blocks:
|
||||
- WHEAT
|
||||
|
||||
Reference in New Issue
Block a user