|
6 | 6 | import ac.grim.grimac.manager.init.ReloadableInitable; |
7 | 7 | import ac.grim.grimac.manager.init.start.StartableInitable; |
8 | 8 | import ac.grim.grimac.manager.violationdatabase.mysql.MySQLViolationDatabase; |
| 9 | +import ac.grim.grimac.manager.violationdatabase.postgresql.PostgresqlViolationDatabase; |
9 | 10 | import ac.grim.grimac.manager.violationdatabase.sqlite.SQLiteViolationDatabase; |
10 | 11 | import ac.grim.grimac.player.GrimPlayer; |
11 | 12 | import ac.grim.grimac.utils.anticheat.LogUtil; |
@@ -93,6 +94,28 @@ public void load() { |
93 | 94 | } |
94 | 95 | } |
95 | 96 |
|
| 97 | + case "POSTGRESQL" -> { |
| 98 | + String host = cfg.getStringElse("history.database.host", "localhost:3306"); |
| 99 | + String db = cfg.getStringElse("history.database.database", "grimac"); |
| 100 | + String user = cfg.getStringElse("history.database.username", "root"); |
| 101 | + String pwd = cfg.getStringElse("history.database.password", "password"); |
| 102 | + |
| 103 | + if (database instanceof PostgresqlViolationDatabase postgresql |
| 104 | + && postgresql.sameConfig(host, db, user, pwd)) { |
| 105 | + break; // nothing changed → keep pool |
| 106 | + } |
| 107 | + database.disconnect(); |
| 108 | + database = new PostgresqlViolationDatabase(host, db, user, pwd); |
| 109 | + try { |
| 110 | + database.connect(); |
| 111 | + loaded = true; |
| 112 | + } catch (SQLException e) { |
| 113 | + LogUtil.error(e); |
| 114 | + this.database = NoOpViolationDatabase.INSTANCE; |
| 115 | + loaded = false; |
| 116 | + } |
| 117 | + } |
| 118 | + |
96 | 119 | default -> { // NOOP or invalid |
97 | 120 | if (!(database instanceof NoOpViolationDatabase)) { |
98 | 121 | database.disconnect(); |
|
0 commit comments