Sketch of proper KickPlayerAfterBan system
This commit is contained in:
parent
4e760a54bc
commit
422bbcfdf4
2 changed files with 19 additions and 0 deletions
|
|
@ -25,6 +25,7 @@ dependencies {
|
||||||
implementation 'org.postgresql:postgresql:42.7.7'
|
implementation 'org.postgresql:postgresql:42.7.7'
|
||||||
implementation 'org.flywaydb:flyway-core:10.7.2'
|
implementation 'org.flywaydb:flyway-core:10.7.2'
|
||||||
implementation 'org.flywaydb:flyway-database-postgresql:10.7.2'
|
implementation 'org.flywaydb:flyway-database-postgresql:10.7.2'
|
||||||
|
implementation 'com.google.code.gson:gson:2.11.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
|
||||||
public class Ban implements CommandExecutor {
|
public class Ban implements CommandExecutor {
|
||||||
|
|
||||||
BanHammer plugin;
|
BanHammer plugin;
|
||||||
|
|
@ -309,6 +312,21 @@ public class Ban implements CommandExecutor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void kickPlayer(PlayerBan b){
|
||||||
|
final Gson gson = new Gson();
|
||||||
|
try {
|
||||||
|
Connection conn = plugin.db.getConnection();
|
||||||
|
|
||||||
|
String preparedJson = gson.toJson(b);
|
||||||
|
PreparedStatement ps = conn.prepareStatement("SELECT pg_notify('ban_jobs', ?)");
|
||||||
|
ps.setString(1, preparedJson);
|
||||||
|
ps.execute();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
plugin.getLogger().severe(e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String resolveBanMessagePlaceholders(String s, String player, String scope, String reason, String operator) {
|
private String resolveBanMessagePlaceholders(String s, String player, String scope, String reason, String operator) {
|
||||||
return s.replace("{player}", player)
|
return s.replace("{player}", player)
|
||||||
.replace("{scope}", scope)
|
.replace("{scope}", scope)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue