sync
This commit is contained in:
parent
422bbcfdf4
commit
a7a77b9cc0
3 changed files with 62 additions and 3 deletions
|
|
@ -18,6 +18,10 @@ import java.util.Objects;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class BanIP implements CommandExecutor {
|
||||
|
||||
BanHammer plugin;
|
||||
|
|
@ -325,6 +329,27 @@ public class BanIP implements CommandExecutor {
|
|||
}
|
||||
}
|
||||
|
||||
private void createIPKickJob(IPBan b, String scope){
|
||||
final Gson gson = new Gson();
|
||||
try {
|
||||
Connection conn = plugin.db.getConnection();
|
||||
|
||||
JsonElement banObject = gson.toJsonTree(b);
|
||||
JsonObject wrapper = new JsonObject();
|
||||
wrapper.addProperty("ban_type", "ip");
|
||||
wrapper.addProperty("ban_scope", scope);
|
||||
wrapper.add("ban_data", banObject);
|
||||
String json = gson.toJson(wrapper);
|
||||
|
||||
PreparedStatement ps = conn.prepareStatement("SELECT pg_notify('ban_jobs', ?)");
|
||||
ps.setString(1, json);
|
||||
ps.execute();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
plugin.getLogger().severe(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private String resolveIpBanMessagePlaceholders(String s, String ipAddr, String scope, String reason, String operator) {
|
||||
return s.replace("{ipAddr}", ipAddr)
|
||||
.replace("{scope}", scope)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue