Optimizing the chat filter punishment and logging system
This commit is contained in:
@@ -26,7 +26,7 @@ public class WebhookSender {
|
|||||||
Emojis.space + Emojis.arrowRight + "Heat: `" + finalHeat + "/" + Config.punishHeat + "`\\n" +
|
Emojis.space + Emojis.arrowRight + "Heat: `" + finalHeat + "/" + Config.punishHeat + "`\\n" +
|
||||||
Emojis.space + Emojis.arrowRight + "UUID: `" + player.getUniqueId() + "`\\n" +
|
Emojis.space + Emojis.arrowRight + "UUID: `" + player.getUniqueId() + "`\\n" +
|
||||||
Emojis.rightSort + "Executed: " + Config.spamPunishCommand + " " + Emojis.mute + "\\n" +
|
Emojis.rightSort + "Executed: " + Config.spamPunishCommand + " " + Emojis.mute + "\\n" +
|
||||||
Emojis.space + Emojis.arrowRight + "Chat Cleared: " + successOrFail(chatCleared) + "\\n"
|
Emojis.space + Emojis.arrowRight + "Chat Cleared: " + (chatCleared ? Emojis.success : Emojis.failure) + "\\n"
|
||||||
)
|
)
|
||||||
.addField("Previous Message", "||" + message1 + "|| " + Emojis.activity, false)
|
.addField("Previous Message", "||" + message1 + "|| " + Emojis.activity, false)
|
||||||
.addField("Current Message", "||" + message2 + "|| " + Emojis.alarm, false)
|
.addField("Current Message", "||" + message2 + "|| " + Emojis.alarm, false)
|
||||||
@@ -48,7 +48,7 @@ public class WebhookSender {
|
|||||||
webhook.setUsername("Sentinel Anti-Nuke | Logs");
|
webhook.setUsername("Sentinel Anti-Nuke | Logs");
|
||||||
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
|
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
|
||||||
.setAuthor("Anti-Swear Punishment","","")
|
.setAuthor("Anti-Swear Punishment","","")
|
||||||
.setTitle("Punish Report:")
|
.setTitle(player.getName() + " has triggered the anti-slur!")
|
||||||
.setDescription(
|
.setDescription(
|
||||||
Emojis.rightSort + "Player: " + player.getName() + " " + Emojis.target + "\\n" +
|
Emojis.rightSort + "Player: " + player.getName() + " " + Emojis.target + "\\n" +
|
||||||
Emojis.space + Emojis.arrowRight + "Score: `" + finalScore + "/" + Config.punishScore + "`\\n" +
|
Emojis.space + Emojis.arrowRight + "Score: `" + finalScore + "/" + Config.punishScore + "`\\n" +
|
||||||
@@ -95,13 +95,4 @@ public class WebhookSender {
|
|||||||
Sentinel.log.info(e.toString());
|
Sentinel.log.info(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String successOrFail(boolean bool) {
|
|
||||||
if (bool) {
|
|
||||||
return Emojis.success;
|
|
||||||
} else {
|
|
||||||
return Emojis.failure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,9 +249,9 @@ public class Action {
|
|||||||
Emojis.space + Emojis.rightDoubleArrow + " **Location:** X: " + block.getX() + " Y: " + block.getY() + " Z: " + block.getZ() + "\\n";
|
Emojis.space + Emojis.rightDoubleArrow + " **Location:** X: " + block.getX() + " Y: " + block.getY() + " Z: " + block.getZ() + "\\n";
|
||||||
}
|
}
|
||||||
String actions = "";
|
String actions = "";
|
||||||
actions += Emojis.rightSort + " **Denied:** " + Text.boolString(denied,Emojis.success, Emojis.failure) + "\\n";
|
actions += Emojis.rightSort + " **Denied:** " + (denied ? Emojis.success : Emojis.failure) + "\\n";
|
||||||
actions += Emojis.rightSort + " **De-oped:** " + Text.boolString(deoped,Emojis.success, Emojis.failure) + "\\n";
|
actions += Emojis.rightSort + " **De-oped:** " + (deoped ? Emojis.success : Emojis.failure) + "\\n";
|
||||||
actions += Emojis.rightSort + " **Punished:** " + Text.boolString(punished,Emojis.success, Emojis.failure) + "\\n";
|
actions += Emojis.rightSort + " **Punished:** " + (punished ? Emojis.success : Emojis.failure) + "\\n";
|
||||||
if (revertGM) actions += Emojis.rightSort + " **GM Reverted:** " + Emojis.success + "\\n";
|
if (revertGM) actions += Emojis.rightSort + " **GM Reverted:** " + Emojis.success + "\\n";
|
||||||
actions += Emojis.rightSort + " **Logged:** " + Emojis.success;
|
actions += Emojis.rightSort + " **Logged:** " + Emojis.success;
|
||||||
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
|
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
|
||||||
|
|||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package io.github.thetrouper.sentinel.server;
|
||||||
|
|
||||||
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
|
import io.github.thetrouper.sentinel.data.Config;
|
||||||
|
import io.github.thetrouper.sentinel.data.Emojis;
|
||||||
|
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
||||||
|
import io.github.thetrouper.sentinel.discord.WebhookSender;
|
||||||
|
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||||
|
import io.github.thetrouper.sentinel.server.functions.ReportFalsePositives;
|
||||||
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.github.thetrouper.sentinel.server.functions.ProfanityFilter.scoreMap;
|
||||||
|
|
||||||
|
public class FilterAction {
|
||||||
|
|
||||||
|
public static void filterAction(Player offender, AsyncPlayerChatEvent e, String highlighted, String severity,String type) {
|
||||||
|
String report = ReportFalsePositives.generateReport(e);
|
||||||
|
|
||||||
|
TextComponent warn = new TextComponent();
|
||||||
|
warn.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("action-automatic-reportable"))));
|
||||||
|
warn.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + report));
|
||||||
|
|
||||||
|
TextComponent notif = new TextComponent();
|
||||||
|
notif.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("severity-notification-hover").formatted(e.getMessage(),highlighted,severity))));
|
||||||
|
notif.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + report));
|
||||||
|
switch (type) {
|
||||||
|
case "BLOCK" -> {
|
||||||
|
warn.setText(Text.prefix((Sentinel.dict.get("swear-block-warn"))));
|
||||||
|
offender.spigot().sendMessage(warn);
|
||||||
|
|
||||||
|
notif.setText(Text.prefix(Sentinel.dict.get("swear-block-notification").formatted(offender.getName(),scoreMap.get(offender),Config.punishScore)));
|
||||||
|
ServerUtils.forEachStaff(staffmember -> {
|
||||||
|
staffmember.spigot().sendMessage(notif);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
case "SWEAR" -> {
|
||||||
|
ServerUtils.sendCommand(Config.swearPunishCommand.replace("%player%", offender.getName()));
|
||||||
|
warn.setText(Text.prefix(Sentinel.dict.get("profanity-mute-warn")));
|
||||||
|
|
||||||
|
offender.spigot().sendMessage(warn);
|
||||||
|
|
||||||
|
notif.setText(Text.prefix(Sentinel.dict.get("profanity-mute-notification").formatted(offender.getName(),scoreMap.get(offender),Config.punishScore)));
|
||||||
|
ServerUtils.forEachStaff(staff -> {
|
||||||
|
staff.spigot().sendMessage(notif);
|
||||||
|
});
|
||||||
|
if (Config.logSwear) WebhookSender.sendSwearLog(offender,e.getMessage(),scoreMap.get(offender));
|
||||||
|
}
|
||||||
|
case "SLUR" -> {
|
||||||
|
ServerUtils.sendCommand(Config.strictPunishCommand.replace("%player%", offender.getName()));
|
||||||
|
warn.setText(Text.prefix((Sentinel.dict.get("slur-mute-warn"))));
|
||||||
|
|
||||||
|
offender.spigot().sendMessage(warn);
|
||||||
|
|
||||||
|
notif.setText(Text.prefix(Sentinel.dict.get("slur-mute-notification").formatted(offender.getName(),scoreMap.get(offender),Config.punishScore)));
|
||||||
|
ServerUtils.forEachStaff(staff -> {
|
||||||
|
staff.spigot().sendMessage(notif);
|
||||||
|
});
|
||||||
|
if (Config.logSwear) {
|
||||||
|
sendLog(offender,e,type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendLog(Player offender, AsyncPlayerChatEvent e, String type) {
|
||||||
|
String supertitle = "Chat filter Punishment";
|
||||||
|
String title = offender.getName() + " has triggered the chat filter auto-punish!";
|
||||||
|
Color color = Color.white;
|
||||||
|
String executed = "Generic mute command not implemented yet! (report this please, you shouldn't be seeing this)";
|
||||||
|
switch (type) {
|
||||||
|
case "SWEAR" -> {
|
||||||
|
supertitle = "Anti-Swear Punishment";
|
||||||
|
title = offender.getName() + " has triggered the anti-swear!";
|
||||||
|
color = Color.orange;
|
||||||
|
executed = Config.swearPunishCommand;
|
||||||
|
}
|
||||||
|
case "SLUR" -> {
|
||||||
|
supertitle = "Anti-Slur Punishment";
|
||||||
|
title = offender.getName() + " has triggered the anti-slur!";
|
||||||
|
color = Color.red;
|
||||||
|
executed = Config.strictPunishCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
|
||||||
|
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
|
||||||
|
webhook.setUsername("Sentinel Anti-Nuke | Logs");
|
||||||
|
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
|
||||||
|
.setAuthor(supertitle,"","")
|
||||||
|
.setTitle(title)
|
||||||
|
.setDescription(
|
||||||
|
Emojis.rightSort + "Player: " + offender.getName() + " " + Emojis.target + "\\n" +
|
||||||
|
Emojis.space + Emojis.arrowRight + "Score: `" + scoreMap.get(offender) + "/" + Config.punishScore + "`\\n" +
|
||||||
|
Emojis.space + Emojis.arrowRight + "UUID: `" + offender.getUniqueId() + "`\\n" +
|
||||||
|
Emojis.rightSort + "Executed: " + executed + " " + Emojis.mute + "\\n"
|
||||||
|
)
|
||||||
|
.addField("Original Message", "||" + e.getMessage() + "|| " + Emojis.alarm, false)
|
||||||
|
.addField("Sanitized Message", ProfanityFilter.highlightProfanity(e.getMessage(),"||", "||") + " " + Emojis.noDM, false)
|
||||||
|
.setColor(color)
|
||||||
|
.setThumbnail("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay");
|
||||||
|
webhook.addEmbed(embed);
|
||||||
|
try {
|
||||||
|
ServerUtils.sendDebugMessage("Executing webhook...");
|
||||||
|
webhook.execute();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ServerUtils.sendDebugMessage(Text.prefix("Epic webhook failure!!!"));
|
||||||
|
Sentinel.log.info(ex.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,7 +71,6 @@ public class ProfanityFilter {
|
|||||||
}
|
}
|
||||||
public static void punishSwear(Player player, String highlightedMSG, String origMessage, AsyncPlayerChatEvent e) {
|
public static void punishSwear(Player player, String highlightedMSG, String origMessage, AsyncPlayerChatEvent e) {
|
||||||
ServerUtils.sendCommand(Config.swearPunishCommand.replace("%player%", player.getName()));
|
ServerUtils.sendCommand(Config.swearPunishCommand.replace("%player%", player.getName()));
|
||||||
ServerUtils.sendCommand(Config.strictPunishCommand.replace("%player%", player.getName()));
|
|
||||||
String fpreport = ReportFalsePositives.generateReport(e);
|
String fpreport = ReportFalsePositives.generateReport(e);
|
||||||
TextComponent offender = new TextComponent();
|
TextComponent offender = new TextComponent();
|
||||||
String hoverPlayer = Sentinel.dict.get("action-automatic-reportable");
|
String hoverPlayer = Sentinel.dict.get("action-automatic-reportable");
|
||||||
|
|||||||
@@ -66,7 +66,4 @@ public class Text {
|
|||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
public static String boolString(boolean bool, String caseTrue, String caseFalse) {
|
|
||||||
return bool ? caseTrue : caseFalse;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user