this.issuedByUUID = issuedByUUID;
}
@Override
protected void execute() {
JSONObject response = this.request_JOBJ();
PlayerIPBanEvent ipBanEvent = new PlayerIPBanEvent(ip, issuedBy, issuedByUUID, reason);
plugin.getServer().getPluginManager().callEvent(ipBanEvent);
if (ipBanEvent.isCancelled()){
return;
}
issuedBy = ipBanEvent.getSenderName();
reason = ipBanEvent.getReason();
// Add default bukkit ipban
if (Util.isValidIP(ip)){
Bukkit.getServer().banIP(ip);
}
try {
if (response != null && response.has("result")){
final String result = response.getString("result").trim().toLowerCase(Locale.ENGLISH);
if (result.equals("y")){
//callback.setMessage(Util.color(msg))
callback.setBroadcastMessage(ChatColor.GREEN + _("ipBanSuccess", I18n.IP, this.ip, I18n.SENDER, this.issuedBy, I18n.REASON, this.reason));
callback.success();
kickPlayerByIP(this.ip, reason);
log.info("IP " + ip + " has been banned [" + reason + "] [" + issuedBy + "]!");
plugin.getServer().getPluginManager().callEvent(new PlayerIPBannedEvent(ip, issuedBy, issuedByUUID, reason));
}else if (result.equals("a")){
// equals("a") if already banned ip
callback.error(ChatColor.RED + _("ipBanAlready", I18n.IP, this.ip, I18n.SENDER, this.issuedBy, I18n.REASON, this.reason));
log.info(issuedBy + " tried to IPBan " + ip + "!");
}else if (result.equals("n")){
// equals("n") if banning ip is formatted improperly
callback.error(ChatColor.RED + _("invalidIP"));
log.info(issuedBy + " tried to IPBan " + ip + "!");
}else if (result.equals("e")){
// other error
callback.error(ChatColor.RED + _("invalidIP"));
log.info(issuedBy + " tried to IPBan " + ip + "!");
}else{
log.severe("Invalid response result: " + result);
}
}else{
callback.error(ChatColor.RED + "API appears to be down!");
}
} catch (JSONException ex) {
if (response.toString().contains("error")) {
if (response.toString().contains("Server Disabled")) {
ActionLog.getInstance().severe("Server Disabled by an MCBans Admin");
ActionLog.getInstance().severe("To appeal this decision, please file ticket on support.mcbans.com");
callback.error("This server disabled by MCBans Administration.");
return;