FilterAction still needs a bit of work
This commit is contained in:
@@ -27,7 +27,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT'
|
||||||
implementation 'com.google.code.gson:gson:2.10.1'
|
implementation 'com.google.code.gson:gson:2.10.1'
|
||||||
implementation("club.minnced:discord-webhooks:0.8.4")
|
implementation("club.minnced:discord-webhooks:0.8.4")
|
||||||
implementation files("libs/PDK-1.3.3.jar")
|
implementation files("libs/PDK-1.3.3.jar")
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import static io.github.thetrouper.sentinel.server.functions.ProfanityFilter.*;
|
|||||||
|
|
||||||
public class FilterAction {
|
public class FilterAction {
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void filterAction(Player offender, AsyncPlayerChatEvent e, String highlighted, FilterSeverity severity, Double similarity, FAT type) {
|
public static void filterAction(Player offender, AsyncPlayerChatEvent e, String highlighted, FilterSeverity severity, Double similarity, FAT type) {
|
||||||
String report = ReportFalsePositives.generateReport(e);
|
String report = ReportFalsePositives.generateReport(e);
|
||||||
DecimalFormat fs = new DecimalFormat("##.#");
|
DecimalFormat fs = new DecimalFormat("##.#");
|
||||||
@@ -78,16 +77,32 @@ public class FilterAction {
|
|||||||
|| (type == FAT.SPAM_PUNISH && Sentinel.mainConfig.chat.antiSpam.logSpam);
|
|| (type == FAT.SPAM_PUNISH && Sentinel.mainConfig.chat.antiSpam.logSpam);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ToDo
|
|
||||||
* Optimize this junk
|
|
||||||
* Prolly put it all in one function with switching type
|
|
||||||
*/
|
|
||||||
public static void sendConsoleLog(Player offender, AsyncPlayerChatEvent e, FAT type) {
|
public static void sendConsoleLog(Player offender, AsyncPlayerChatEvent e, FAT type) {
|
||||||
StringBuilder log = new StringBuilder().append("\"]=-\" + type.getTitle() + \"-=[\\n\"");
|
StringBuilder log = new StringBuilder().append("]=- %s -=[".formatted(type.getTitle()));
|
||||||
log.append("Player: " + offender.getName());
|
log.append("\nPlayer: %s".formatted(offender.getName()));
|
||||||
log.append(type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "> Score: `" + scoreMap.get(offender) + "/" + Sentinel.mainConfig.chat.antiSwear.punishScore :
|
log.append("\n> UUID: %s".formatted(offender.getUniqueId()));
|
||||||
"> Heat: `" + heatMap.get(offender) + "/" + Sentinel.mainConfig.chat.antiSpam.punishHeat).append("\n").append("> UUID: ").append(offender.getUniqueId()).append("\n").append(type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Message: " + e.getMessage() : "Previous: " + lastMessageMap.get(offender)).append("\n").append(type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Reduced: " + fullSimplify(e.getMessage()) : "Current: " + e.getMessage()).append("\n").append(type.getExecutedCommand() != null ? "Executed: " + type.getExecutedCommand() : "Executed: Nothing, its a standard flag. You shouldn't be seeing this, please report it.");
|
switch (type) {
|
||||||
|
case SPAM_PUNISH -> {
|
||||||
|
log.append("\n> Heat: %1$s/%2$s".formatted(heatMap.get(offender),Sentinel.mainConfig.chat.antiSpam.punishHeat));
|
||||||
|
log.append("\nMessage: %s".formatted(e.getMessage()));
|
||||||
|
log.append("\nReduced: %s".formatted(fullSimplify(e.getMessage())));
|
||||||
|
}
|
||||||
|
case SWEAR_PUNISH -> {
|
||||||
|
log.append("\n> Score: %1$s/%2$s".formatted(heatMap.get(offender),Sentinel.mainConfig.chat.antiSwear.punishScore));
|
||||||
|
log.append("\nPrevious: %s".formatted(lastMessageMap.get(offender)));
|
||||||
|
log.append("\nCurrent: %s".formatted(e.getMessage()));
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
log.append("\nYou shouldn't be seeing this! Please report this message, and the context surrounding it!");
|
||||||
|
log.append("\n> Heat: %1$s/%2$s".formatted(heatMap.get(offender),Sentinel.mainConfig.chat.antiSpam.punishHeat));
|
||||||
|
log.append("\nMessage: %s".formatted(e.getMessage()));
|
||||||
|
log.append("\nReduced: %s".formatted(fullSimplify(e.getMessage())));
|
||||||
|
log.append("\n> Score: %1$s/%2$s".formatted(heatMap.get(offender),Sentinel.mainConfig.chat.antiSwear.punishScore));
|
||||||
|
log.append("\nPrevious: %s".formatted(lastMessageMap.get(offender)));
|
||||||
|
log.append("\nCurrent: %s".formatted(e.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.append("\nExecuted: %s".formatted(type.getExecutedCommand()));
|
||||||
Sentinel.log.info(String.valueOf(log));
|
Sentinel.log.info(String.valueOf(log));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,20 +111,43 @@ public class FilterAction {
|
|||||||
String title = offender.getName() + " has triggered the " + type.getName() + "!";
|
String title = offender.getName() + " has triggered the " + type.getName() + "!";
|
||||||
|
|
||||||
String executed = type.getExecutedCommand() != null ? type.getExecutedCommand() : "Nothing, its a standard flag. You shouldn't be seeing this, please report it.";
|
String executed = type.getExecutedCommand() != null ? type.getExecutedCommand() : "Nothing, its a standard flag. You shouldn't be seeing this, please report it.";
|
||||||
|
StringBuilder description = new StringBuilder();
|
||||||
|
|
||||||
String description =
|
String historyTitle = "You found a bug! :D";
|
||||||
Emojis.rightSort + "Player: " + offender.getName() + " " + Emojis.target + "\\n" +
|
String historyValue = "Congratulations.";
|
||||||
Emojis.space + Emojis.arrowRight + (type != FAT.BLOCK_SPAM ?
|
|
||||||
"Score: `" + scoreMap.get(offender) + "/" + Sentinel.mainConfig.chat.antiSwear.punishScore :
|
|
||||||
"Heat: `" + heatMap.get(offender) + "/" + Sentinel.mainConfig.chat.antiSpam.punishHeat) + "`\\n" +
|
|
||||||
Emojis.space + Emojis.arrowRight + "UUID: `" + offender.getUniqueId() + "`\\n" +
|
|
||||||
Emojis.rightSort + "Executed: " + executed + " " + Emojis.mute + "\\n";
|
|
||||||
|
|
||||||
String historyTitle = (type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Message: " : "Previous: ");
|
String currentTitle = "Now go report it!";
|
||||||
String historyValue = (type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? e.getMessage() : lastMessageMap.get(offender)) + Emojis.alarm;
|
String currentValue = ">:(";
|
||||||
|
|
||||||
String currentTitle = (type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Reduced: " : "Current: ");
|
description.append("%1$sPlayer: `%2$s` %3$s".formatted(Emojis.rightSort,offender.getName(),Emojis.target));
|
||||||
String currentValue = (type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? highlightProfanity(e.getMessage(), "||", "||") : e.getMessage()) + " " + Emojis.noDM;
|
switch (type) {
|
||||||
|
case SPAM_PUNISH -> {
|
||||||
|
description.append("%1$s%2$sHeat: `%3$s/%4$s`".formatted(
|
||||||
|
Emojis.space,
|
||||||
|
Emojis.arrowRight,
|
||||||
|
heatMap.get(offender),
|
||||||
|
Sentinel.mainConfig.chat.antiSpam.punishHeat
|
||||||
|
));
|
||||||
|
historyTitle = "Previous: ";
|
||||||
|
historyValue = lastMessageMap.get(offender);
|
||||||
|
|
||||||
|
currentTitle = "Current: ";
|
||||||
|
currentValue = e.getMessage();
|
||||||
|
}
|
||||||
|
case SWEAR_PUNISH -> {
|
||||||
|
description.append("%1$s%2$sScore: `%3$s/%4$s`".formatted(
|
||||||
|
Emojis.space,
|
||||||
|
Emojis.arrowRight,
|
||||||
|
scoreMap.get(offender),
|
||||||
|
Sentinel.mainConfig.chat.antiSwear.punishScore
|
||||||
|
));
|
||||||
|
historyTitle = "Message: ";
|
||||||
|
historyValue = e.getMessage();
|
||||||
|
|
||||||
|
currentTitle = "Reduced: ";
|
||||||
|
currentValue = highlightProfanity(e.getMessage(),"||", "||");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WebhookMessage message = new WebhookMessageBuilder()
|
WebhookMessage message = new WebhookMessageBuilder()
|
||||||
.setUsername("Sentinel Anti-Nuke | Logs")
|
.setUsername("Sentinel Anti-Nuke | Logs")
|
||||||
@@ -117,9 +155,10 @@ public class FilterAction {
|
|||||||
addEmbeds(new WebhookEmbedBuilder()
|
addEmbeds(new WebhookEmbedBuilder()
|
||||||
.setAuthor(new WebhookEmbed.EmbedAuthor(supertitle,null,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/"))
|
.setAuthor(new WebhookEmbed.EmbedAuthor(supertitle,null,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/"))
|
||||||
.setTitle(new WebhookEmbed.EmbedTitle(title,null))
|
.setTitle(new WebhookEmbed.EmbedTitle(title,null))
|
||||||
.setDescription(description)
|
.setDescription(String.valueOf(description))
|
||||||
.addField(new WebhookEmbed.EmbedField(false,historyTitle,historyValue))
|
.addField(new WebhookEmbed.EmbedField(true,historyTitle,historyValue))
|
||||||
.addField(new WebhookEmbed.EmbedField(false,currentTitle,currentValue))
|
.addField(new WebhookEmbed.EmbedField(true,currentTitle,currentValue))
|
||||||
|
.addField(new WebhookEmbed.EmbedField(false,"Executed: ", executed))
|
||||||
.setThumbnailUrl("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay")
|
.setThumbnailUrl("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay")
|
||||||
.setColor(type.getColor().getRGB())
|
.setColor(type.getColor().getRGB())
|
||||||
.build())
|
.build())
|
||||||
|
|||||||
Reference in New Issue
Block a user