set up parameterized jdbc connection
All checks were successful
Build / Explore-Gitea-Actions (push) Successful in 47s
All checks were successful
Build / Explore-Gitea-Actions (push) Successful in 47s
This commit is contained in:
@@ -41,7 +41,6 @@ import java.util.stream.Collectors;
|
|||||||
public class GriefAlert extends JavaPlugin implements Listener {
|
public class GriefAlert extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
private static CoreProtectAPI coreProtectAPI;
|
private static CoreProtectAPI coreProtectAPI;
|
||||||
private final String DB_FILE = "ignored_locations.db";
|
|
||||||
private Integer identicalAlerts = 1;
|
private Integer identicalAlerts = 1;
|
||||||
private String lastAlert;
|
private String lastAlert;
|
||||||
private Set<Material> EXCLUDED_BLOCKS;
|
private Set<Material> EXCLUDED_BLOCKS;
|
||||||
@@ -194,11 +193,13 @@ public class GriefAlert extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupDatabase() {
|
private void setupDatabase() {
|
||||||
|
String jdbcUrl = getConfig().getString("jdbc-url");
|
||||||
try {
|
try {
|
||||||
connection = DriverManager.getConnection("jdbc:sqlite:" + getDataFolder().getAbsolutePath() + "/" + DB_FILE);
|
connection = DriverManager.getConnection(jdbcUrl);
|
||||||
Statement stmt = connection.createStatement();
|
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.executeUpdate("CREATE TABLE IF NOT EXISTS ignored_locations (x INTEGER, y INTEGER, z INTEGER, world TEXT, PRIMARY KEY (x, y, z, world))");
|
||||||
stmt.close();
|
stmt.close();
|
||||||
|
getLogger().info("Connected to "+jdbcUrl);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
getLogger().severe("Could not set up SQLite database: " + e.getMessage());
|
getLogger().severe("Could not set up SQLite database: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# Ignore all stealing?
|
# Ignore all stealing?
|
||||||
allow-stealing: false
|
allow-stealing: false
|
||||||
|
|
||||||
|
jdbc-url: ""
|
||||||
|
|
||||||
# Breaking these blocks don't cause alerts. (Material)
|
# Breaking these blocks don't cause alerts. (Material)
|
||||||
excluded-blocks:
|
excluded-blocks:
|
||||||
- WHEAT
|
- WHEAT
|
||||||
|
|||||||
Reference in New Issue
Block a user