Updated the ChatFilter & Spam Filter

This commit is contained in:
obvWolf
2024-02-01 22:58:41 -06:00
parent 781026ddd0
commit c4096ebacc
17 changed files with 201 additions and 149 deletions

View File

@@ -1,7 +1,5 @@
package io.github.thetrouper.sentinel;
import club.minnced.discord.webhook.WebhookClient;
import club.minnced.discord.webhook.WebhookClientBuilder;
import io.github.itzispyder.pdk.PDK;
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
import io.github.thetrouper.sentinel.auth.Auth;
@@ -12,6 +10,7 @@ import io.github.thetrouper.sentinel.server.functions.AntiSpam;
import io.github.thetrouper.sentinel.server.functions.Authenticator;
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
import io.github.thetrouper.sentinel.server.functions.Telemetry;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
@@ -91,7 +90,8 @@ public final class Sentinel extends JavaPlugin {
boolean minehutStatus = Telemetry.sendStartupLog();
if (minehutStatus) {
authstatus = authstatus.replaceAll("ur a skid lmao", "get out of here kiddo");
log.info("Dynamic IP auth Success! " + authstatus);
ServerUtils.sendDebugMessage(authstatus);
log.info("Dynamic IP auth Success! ");
startup();
} else {
log.info("Dynamic IP Failure. Webhook Error possible? Please contact obvWolf to fix this.");
@@ -123,8 +123,6 @@ public final class Sentinel extends JavaPlugin {
// Plugin startup logic
log.info("Starting Up! (" + getDescription().getVersion() + ")...");
loadWebhook();
// Enable Functions
AntiSpam.enableAntiSpam();
ProfanityFilter.enableAntiSwear();
@@ -186,21 +184,6 @@ public final class Sentinel extends JavaPlugin {
language.save();
}
public void loadWebhook() {
// Init Client
log.info("Loading Webhook...");
WebhookClientBuilder buildah = new WebhookClientBuilder(mainConfig.plugin.webhook);
buildah.setThreadFactory((job) -> {
Thread thread = new Thread(job);
thread.setName("WebhookThread");
thread.setDaemon(true);
return thread;
});
buildah.setWait(true);
webclient = buildah.build();
}
/**
* Plugin shutdown logic

View File

@@ -6,7 +6,6 @@ import io.github.itzispyder.pdk.commands.CustomCommand;
import io.github.itzispyder.pdk.commands.Permission;
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
import io.github.itzispyder.pdk.utils.ArrayUtils;
import io.github.itzispyder.pdk.utils.ServerUtils;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.server.functions.Message;
import io.github.thetrouper.sentinel.server.util.Text;
@@ -14,9 +13,6 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
@CommandRegistry(value = "sentinelmessage",permission = @Permission("sentinel.message"))
public class MessageCommand implements CustomCommand {
@Override

View File

@@ -3,7 +3,6 @@ package io.github.thetrouper.sentinel.cmds;
import io.github.itzispyder.pdk.commands.Args;
import io.github.itzispyder.pdk.commands.CommandRegistry;
import io.github.itzispyder.pdk.commands.CustomCommand;
import io.github.itzispyder.pdk.commands.Permission;
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.server.util.Text;

View File

@@ -18,7 +18,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.awt.*;
import java.util.HashSet;
@CommandRegistry(value = "sentinel",permission = @Permission("sentinel.debug"))
public class SentinelCommand implements CustomCommand {

View File

@@ -1,23 +1,21 @@
package io.github.thetrouper.sentinel.data;
import java.awt.*;
public enum ActionType {
SPECIFIC_COMMAND("Anti-Specific has been triggered","The use of a specific command has been detected!", Color.green),
LOGGED_COMMAND("General command log","A logged command has been executed.", Color.green),
DANGEROUS_COMMAND("Anti-Nuke has been triggered","The use of a dangerous command has been detected!", Color.red),
NBT("Anti-NBT has been triggered", "An NBT item has been caught!", Color.orange),
PLACE_COMMAND_BLOCK("Anti-Nuke has been triggered","The placing of a command block has been detected!", Color.orange),
USE_COMMAND_BLOCK("Anti-Nuke has been triggered","The use of a command block has been detected!", Color.red),
UPDATE_COMMAND_BLOCK("HoneyPot log","Caught a command block command!", Color.yellow),
PLACE_MINECART_COMMAND("Anti-Nuke has been triggered","The placing of a minecart command has been detected!", Color.red),
USE_MINECART_COMMAND("Anti-Nuke has been triggered", "The use of a command block has been detected!", Color.red),
UPDATE_MINECART_COMMAND("HoneyPot log","Caught a command block command!", Color.orange);
SPECIFIC_COMMAND("Anti-Specific has been triggered","The use of a specific command has been detected!", 0x00FF00),
LOGGED_COMMAND("General command log","A logged command has been executed.", 0x00FF00),
DANGEROUS_COMMAND("Anti-Nuke has been triggered","The use of a dangerous command has been detected!", 0xFF0000),
NBT("Anti-NBT has been triggered", "An NBT item has been caught!", 0xFFB000),
PLACE_COMMAND_BLOCK("Anti-Nuke has been triggered","The placing of a command block has been detected!", 0xFFB000),
USE_COMMAND_BLOCK("Anti-Nuke has been triggered","The use of a command block has been detected!", 0xFF0000),
UPDATE_COMMAND_BLOCK("HoneyPot log","Caught a command block command!", 0xF8FF00),
PLACE_MINECART_COMMAND("Anti-Nuke has been triggered","The placing of a minecart command has been detected!", 0xFF0000),
USE_MINECART_COMMAND("Anti-Nuke has been triggered", "The use of a command block has been detected!", 0xFF0000),
UPDATE_MINECART_COMMAND("HoneyPot log","Caught a command block command!", 0xFFB000);
private final String messageTop;
private final String messageTitle;
private final Color embedColor;
private final int embedColor;
ActionType(String messageTop, String messageTitle, Color embedColor) {
ActionType(String messageTop, String messageTitle, int embedColor) {
this.messageTop = messageTop;
this.messageTitle = messageTitle;
this.embedColor = embedColor;
@@ -28,7 +26,7 @@ public enum ActionType {
public String getMessageTitle() {
return messageTitle;
}
public Color getEmbedColor() {
public int getEmbedColor() {
return embedColor;
}
}

View File

@@ -2,23 +2,21 @@ package io.github.thetrouper.sentinel.data;
import io.github.thetrouper.sentinel.Sentinel;
import java.awt.*;
public enum FAT {
BLOCK_SWEAR("Sentinel Profanity Filter",null,"swear-block-warn", "swear-block-notification", null,null),
BLOCK_SPAM("Sentinel Anti-Spam", null, "spam-block-warn", "spam-notification",null,null),
SWEAR_PUNISH("Sentinel Anti-Swear Log","Anti-Swear", "profanity-mute-warn", "profanity-mute-notification", Sentinel.mainConfig.chat.antiSwear.swearPunishCommand, Color.orange),
SLUR_PUNISH("Sentinel Anti-Slur Log", "Anti-Slur", "slur-mute-warn", "slur-mute-notification", Sentinel.mainConfig.chat.antiSwear.strictPunishCommand, Color.red),
SPAM_PUNISH("Sentinel Anti-Spam Log", "Anti-Spam", "spam-mute-warn", "spam-mute-notification", Sentinel.mainConfig.chat.antiSpam.spamPunishCommand, Color.pink);
BLOCK_SWEAR("Sentinel Profanity Filter",null,"swear-block-warn", "swear-block-notification", null,0x000000),
BLOCK_SPAM("Sentinel Anti-Spam", null, "spam-block-warn", "spam-notification",null,0x000000),
SWEAR_PUNISH("Sentinel Anti-Swear Log","Anti-Swear", "profanity-mute-warn", "profanity-mute-notification", Sentinel.mainConfig.chat.antiSwear.swearPunishCommand, 0xFFB000),
SLUR_PUNISH("Sentinel Anti-Slur Log", "Anti-Slur", "slur-mute-warn", "slur-mute-notification", Sentinel.mainConfig.chat.antiSwear.strictPunishCommand, 0xFF0000),
SPAM_PUNISH("Sentinel Anti-Spam Log", "Anti-Spam", "spam-mute-warn", "spam-mute-notification", Sentinel.mainConfig.chat.antiSpam.spamPunishCommand, 0xFF8000);
private final String title;
private final String name;
private final String warnTranslationKey;
private final String notifTranslationKey;
private final String executedCommand;
private final Color embedColor;
private final int embedColor;
FAT(String title, String name, String warnTranslationKey, String notifTranslationKey, String executedCommand, Color embedColor) {
FAT(String title, String name, String warnTranslationKey, String notifTranslationKey, String executedCommand, int embedColor) {
this.title = title;
this.name = name;
this.warnTranslationKey = warnTranslationKey;
@@ -43,7 +41,7 @@ public enum FAT {
public String getExecutedCommand() {
return executedCommand;
}
public Color getColor() {
public int getColor() {
return embedColor;
}
}

View File

@@ -31,19 +31,19 @@ public class LanguageFile implements JsonSerializable<LanguageFile> {
put("message-received", "§d§lMessage §8» §b[§f%1$s §e>§f You§b] §7%2$s");
put("spy-message", "§d§lSpy §8» §b§n%1$s§7 has messaged §b§n%2$s§7.");
put("spy-message-hover", "§8]==-- §d§lSocialSpy §8--==[\n§bSender: §f%1$S\n§bReceiver: §f%2$S\n§bMessage: §f%3$S");
put("profanity-block-notification", "§b§n%1$s§7 has triggered the anti-swear! §8(§c%2$s§7/§4%3$s§8)");
put("profanity-block-warn", "§cPlease do not swear in chat! Attempting to bypass this filter will result in a mute! §7§o(Hover for more info)");
put("profanity-mute-warn", "You have been auto-muted for repeated violation of the profanity filter! §7§o(Hover for more info)");
put("profanity-mute-notification", "§b§n%1$s§7 has been auto-muted by the anti-swear! §8(§c%2$s§7/§4%3$s§8)");
put("profanity-filter-notification-hover", "§8]==-- §d§lSentinel §8--==[\n§bOriginal: §f%1$s\n§bSanitized: §f%2$s\n§8§o(Click to report false positive)");
put("severity-notification-hover", "§8]==-- §d§lSentinel §8--==[\n§bOriginal: §f%1$s\n§bSanitized: §f%2$s\n§bSeverity: §c%3$s\n§7§o(click to report false positive)");
put("slur-mute-warn", "§cYou have been insta-punished by the anti-slur! §7§o(Hover for more info)");
put("slur-mute-notification", "§b§n%1$s§7 has been insta-muted by the anti-swear! §8(§c%2$s§7/§4%3$s§8)");
put("swear-block-warn", "§cPlease do not swear in chat! Attempting to bypass this filter will result in a mute! §7§o(Hover for more info)");
put("swear-block-notification", "§b§n%1$s§7 has triggered the anti-swear! §8(§c%2$s§7/§4%3$s§8)");
put("spam-notification", "§b§n%1$s§7 might be spamming! §8(§c%2$s§7/§4%3$s§8)");
put("spam-notification-hover", "§8]==-- §d§lSentinel §8--==[\n§bPrevious: §f%1$s\n§bCurrent: §f%2$s\n§bSimilarity §f%3$s");
put("spam-block-warn", "Do not spam in chat! Please wait before sending another message.");
put("spam-mute-warn", "§cYou have been auto-punished for violating the anti-spam repetitively!");
put("spam-mute-notification", "§b§n%1$s§7 has been auto-muted by the anti spam! §8(§c%2$s§7/§4%3$s§8)");
put("filter-notification-hover", "§8]==-- §d§lSentinel §8--==[\n§bOriginal: §f%1$s\n§bSanitized: §f%2$s\n§8§o(Click to report false positive)");
put("severity-notification-hover", "§8]==-- §d§lSentinel §8--==[\n§bOriginal: §f%1$s\n§bSanitized: §f%2$s\n§bSeverity: §c%3$s\n§7§o(click to report false positive)");
}};
public LanguageFile() {}

View File

@@ -1,11 +1,7 @@
package io.github.thetrouper.sentinel.server;
import club.minnced.discord.webhook.send.WebhookEmbed;
import club.minnced.discord.webhook.send.WebhookEmbedBuilder;
import club.minnced.discord.webhook.send.WebhookMessage;
import club.minnced.discord.webhook.send.WebhookMessageBuilder;
import io.github.itzispyder.pdk.PDK;
import io.github.itzispyder.pdk.utils.discord.DiscordEmbed;
import io.github.itzispyder.pdk.utils.discord.DiscordWebhook;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.data.ActionType;
@@ -21,7 +17,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import java.io.IOException;
import java.util.List;
public class Action {
@@ -174,23 +169,19 @@ public class Action {
actions += (revertGM) ? Emojis.rightSort + " **GM Reverted:** " + Emojis.success + "\n" : "";
actions += Emojis.rightSort + " **Logged:** " + Emojis.success;
Webhook
WebhookMessage message = new WebhookMessageBuilder()
.setUsername("Sentinel Anti-Nuke | Logs")
.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png").
addEmbeds(new WebhookEmbedBuilder()
.setAuthor(new WebhookEmbed.EmbedAuthor(actionTop,null,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/"))
.setTitle(new WebhookEmbed.EmbedTitle(actionTitle,null))
.setDescription(description)
.addField(new WebhookEmbed.EmbedField(false,"Actions:", actions))
.setThumbnailUrl("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay")
.setColor(action.getEmbedColor().getRGB())
.build())
.build();
try {
ServerUtils.sendDebugMessage("Executing webhook...");
Sentinel.webclient.send(message);
DiscordWebhook.create()
.username("Sentinel Anti-Nuke | Logs")
.avatar("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png")
.addEmbed(DiscordEmbed.create()
.author(new DiscordEmbed.Author(actionTop,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null))
.title(actionTitle)
.desc(description)
.addField(new DiscordEmbed.Field("Actions:", actions,false))
.thumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay")
.color(action.getEmbedColor())
.build()).send(Sentinel.mainConfig.plugin.webhook);
} catch (Exception e) {
ServerUtils.sendDebugMessage(Text.prefix("Epic webhook failure!!!"));
Sentinel.log.info(e.toString());

View File

@@ -1,24 +1,21 @@
package io.github.thetrouper.sentinel.server;
import club.minnced.discord.webhook.send.WebhookEmbed;
import club.minnced.discord.webhook.send.WebhookEmbedBuilder;
import club.minnced.discord.webhook.send.WebhookMessage;
import club.minnced.discord.webhook.send.WebhookMessageBuilder;
import io.github.itzispyder.pdk.utils.discord.DiscordEmbed;
import io.github.itzispyder.pdk.utils.discord.DiscordWebhook;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.data.Emojis;
import io.github.thetrouper.sentinel.data.FAT;
import io.github.thetrouper.sentinel.data.FilterSeverity;
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
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 net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.io.IOException;
import java.math.RoundingMode;
import java.text.DecimalFormat;
@@ -28,7 +25,107 @@ import static io.github.thetrouper.sentinel.server.functions.ProfanityFilter.*;
public class FilterAction {
public static void filterAction(Player offender, AsyncPlayerChatEvent e, String highlighted, FilterSeverity severity, Double similarity, FAT type) {
public static void filterPunish(AsyncPlayerChatEvent e, FAT type, Double similarity, FilterSeverity severity) {
String report = ReportFalsePositives.generateReport(e);
TextComponent staffNotif = Component.text("");
TextComponent playerWarning = Component.text("");
Player offender = e.getPlayer();
switch (type) {
case BLOCK_SPAM -> {
staffNotif = Component
.text(Text.prefix(String.format(Sentinel.language.get("spam-notification"),
offender.getName(),
heatMap.get(offender),
Sentinel.mainConfig.chat.antiSpam.punishHeat
)))
.hoverEvent(Component.text(String.format(Sentinel.language.get("spam-notification-hover"),
lastMessageMap.get(offender),
e.getMessage(),
similarity
)));
playerWarning = Component.text(Text.prefix(Sentinel.language.get("spam-block-warn")))
.hoverEvent(Component.text(Sentinel.language.get("action-automatic-reportable")));
}
case SPAM_PUNISH -> {
staffNotif = Component.text(Text.prefix(String.format(Sentinel.language.get("spam-mute-notification"),
offender.getName(),
heatMap.get(offender),
Sentinel.mainConfig.chat.antiSpam.punishHeat
)))
.hoverEvent(Component.text(String.format(Sentinel.language.get("spam-notification-hover"),
lastMessageMap.get(offender),
e.getMessage(),
similarity
)));
playerWarning = Component.text(Sentinel.language.get("spam-mute-warn"))
.hoverEvent(Component.text(Sentinel.language.get("action-automatic-reportable")));
sendConsoleLog(offender,e,type);
sendDiscordLog(offender,e,type);
}
case BLOCK_SWEAR -> {
staffNotif = Component.text(Text.prefix(String.format(Sentinel.language.get("profanity-block-notification"),
offender.getName(),
scoreMap.get(offender),
Sentinel.mainConfig.chat.antiSwear.punishScore
)))
.hoverEvent(Component.text(String.format(Sentinel.language.get("severity-notification-hover"),
e.getMessage(),
highlightProfanity(fullSimplify(e.getMessage())),
severity.name()
)));
playerWarning = Component.text(Text.prefix(Sentinel.language.get("profanity-block-warn")))
.hoverEvent(Component.text(Sentinel.language.get("action-automatic-reportable")));
}
case SWEAR_PUNISH -> {
staffNotif = Component.text(Text.prefix(String.format(Sentinel.language.get("profanity-mute-notification"),
offender.getName(),
scoreMap.get(offender),
Sentinel.mainConfig.chat.antiSwear.punishScore
)))
.hoverEvent(Component.text(String.format(Sentinel.language.get("severity-notification-hover"),
e.getMessage(),
highlightProfanity(fullSimplify(e.getMessage())),
severity.name()
)));
playerWarning = Component.text(Text.prefix(Sentinel.language.get("profanity-mute-warn")))
.hoverEvent(Component.text(Sentinel.language.get("action-automatic-reportable")));
sendConsoleLog(offender,e,type);
sendDiscordLog(offender,e,type);
}
case SLUR_PUNISH -> {
staffNotif = Component.text(Text.prefix(String.format(Sentinel.language.get("slur-mute-notification"),
offender.getName(),
scoreMap.get(offender),
Sentinel.mainConfig.chat.antiSwear.punishScore
)))
.hoverEvent(Component.text(String.format(Sentinel.language.get("severity-notification-hover"),
e.getMessage(),
highlightProfanity(fullSimplify(e.getMessage())),
severity.name()
)));
playerWarning = Component.text(Text.prefix(Sentinel.language.get("slur-mute-warn")))
.hoverEvent(Component.text(Sentinel.language.get("action-automatic-reportable")));
sendConsoleLog(offender,e,type);
sendDiscordLog(offender,e,type);
}
}
if (type.getExecutedCommand() != null) {
ServerUtils.sendCommand(type.getExecutedCommand().replace("%player%", offender.getName()));
}
staffNotif = staffNotif.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, "/sentinelcallback fpreport " + report));
for (Player staff : ServerUtils.getStaff()) {
staff.sendMessage(staffNotif);
}
e.getPlayer().sendMessage(playerWarning);
}
/*public static void filterAction(Player offender, AsyncPlayerChatEvent e, String highlighted, FilterSeverity severity, Double similarity, FAT type) {
String report = ReportFalsePositives.generateReport(e);
DecimalFormat fs = new DecimalFormat("##.#");
fs.setRoundingMode(RoundingMode.DOWN);
@@ -70,7 +167,7 @@ public class FilterAction {
TextComponent component = new TextComponent();
component.setText(text);
return component;
}
}*/
private static boolean shouldLogSwears(FAT type) {
return (type == FAT.SWEAR_PUNISH || type == FAT.SLUR_PUNISH) && Sentinel.mainConfig.chat.antiSwear.logSwears
@@ -78,31 +175,31 @@ public class FilterAction {
}
public static void sendConsoleLog(Player offender, AsyncPlayerChatEvent e, FAT type) {
StringBuilder log = new StringBuilder().append("]=- %s -=[".formatted(type.getTitle()));
log.append("\nPlayer: %s".formatted(offender.getName()));
log.append("\n> UUID: %s".formatted(offender.getUniqueId()));
StringBuilder log = new StringBuilder().append(String.format("]=- %s -=[",type.getTitle()));
log.append(String.format("\nPlayer: %s",offender.getName()));
log.append(String.format("\n> UUID: %s",offender.getUniqueId()));
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())));
log.append(String.format("\n> Heat: %1$s/%2$s",heatMap.get(offender),Sentinel.mainConfig.chat.antiSpam.punishHeat));
log.append(String.format("\nMessage: %s", e.getMessage()));
log.append(String.format("\nReduced: %s",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()));
case SWEAR_PUNISH, SLUR_PUNISH -> {
log.append(String.format("\n> Score: %1$s/%2$s",heatMap.get(offender),Sentinel.mainConfig.chat.antiSwear.punishScore));
log.append(String.format("\nPrevious: %s",lastMessageMap.get(offender)));
log.append(String.format("\nCurrent: %s",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(String.format("\n> Heat: %1$s/%2$s",heatMap.get(offender),Sentinel.mainConfig.chat.antiSpam.punishHeat));
log.append(String.format("\nMessage: %s",e.getMessage()));
log.append(String.format("\nReduced: %s",fullSimplify(e.getMessage())));
log.append(String.format("\n> Score: %1$s/%2$s",heatMap.get(offender),Sentinel.mainConfig.chat.antiSwear.punishScore));
log.append(String.format("\nPrevious: %s",lastMessageMap.get(offender)));
log.append(String.format("\nCurrent: %s",e.getMessage()));
}
}
log.append("\nExecuted: %s".formatted(type.getExecutedCommand()));
log.append(String.format("\nExecuted: %s",type.getExecutedCommand()));
Sentinel.log.info(String.valueOf(log));
}
@@ -119,10 +216,10 @@ public class FilterAction {
String currentTitle = "Now go report it!";
String currentValue = ">:(";
description.append("%1$sPlayer: `%2$s` %3$s".formatted(Emojis.rightSort,offender.getName(),Emojis.target));
description.append(String.format("%1$sPlayer: `%2$s` %3$s",Emojis.rightSort,offender.getName(),Emojis.target));
switch (type) {
case SPAM_PUNISH -> {
description.append("\n%1$s%2$sHeat: `%3$s/%4$s`".formatted(
description.append(String.format("\n%1$s%2$sHeat: `%3$s/%4$s`",
Emojis.space,
Emojis.arrowRight,
heatMap.get(offender),
@@ -134,8 +231,8 @@ public class FilterAction {
currentTitle = "Current: ";
currentValue = e.getMessage();
}
case SWEAR_PUNISH -> {
description.append("\n%1$s%2$sScore: `%3$s/%4$s`".formatted(
case SWEAR_PUNISH, SLUR_PUNISH -> {
description.append(String.format("\n%1$s%2$sScore: `%3$s/%4$s`",
Emojis.space,
Emojis.arrowRight,
scoreMap.get(offender),
@@ -149,24 +246,22 @@ public class FilterAction {
}
}
WebhookMessage message = new WebhookMessageBuilder()
.setUsername("Sentinel Anti-Nuke | Logs")
.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png").
addEmbeds(new WebhookEmbedBuilder()
.setAuthor(new WebhookEmbed.EmbedAuthor(supertitle,null,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/"))
.setTitle(new WebhookEmbed.EmbedTitle(title,null))
.setDescription(String.valueOf(description))
.addField(new WebhookEmbed.EmbedField(true,historyTitle,historyValue))
.addField(new WebhookEmbed.EmbedField(true,currentTitle,currentValue))
.addField(new WebhookEmbed.EmbedField(false,"Executed: ", executed.replaceAll("%player%",offender.getName())))
.setThumbnailUrl("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay")
.setColor(type.getColor().getRGB())
.build())
.build();
try {
ServerUtils.sendDebugMessage("Executing webhook...");
Sentinel.webclient.send(message);
DiscordWebhook.create()
.username("Sentinel Anti-Nuke | Logs")
.avatar("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png")
.addEmbed(DiscordEmbed.create()
.author(new DiscordEmbed.Author(supertitle,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null))
.title(title)
.desc(String.valueOf(description))
.addField(new DiscordEmbed.Field(historyTitle,historyValue,true))
.addField(new DiscordEmbed.Field(currentTitle,currentValue,true))
.addField(new DiscordEmbed.Field("Executed: ", executed.replaceAll("%player%",offender.getName()),false))
.thumbnail("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay")
.color(type.getColor())
.build()).send(Sentinel.mainConfig.plugin.webhook);
} catch (Exception ex) {
ServerUtils.sendDebugMessage("Filter Actions: Epic webhook failure!!!");
Sentinel.log.info(ex.toString());

View File

@@ -53,13 +53,13 @@ public class AntiSpam {
if (heatMap.get(p) > Sentinel.mainConfig.chat.antiSpam.punishHeat) {
e.setCancelled(true);
FilterAction.filterAction(p,e,null,null, GPTUtils.calcSim(e.getMessage(),lastMessageMap.get(p)), FAT.SPAM_PUNISH);
FilterAction.filterPunish(e,FAT.SPAM_PUNISH,GPTUtils.calcSim(e.getMessage(),lastMessageMap.get(p)), null);
return;
}
if (heatMap.get(p) > Sentinel.mainConfig.chat.antiSpam.blockHeat) {
e.setCancelled(true);
FilterAction.filterAction(p,e,null,null, GPTUtils.calcSim(e.getMessage(),lastMessageMap.get(p)), FAT.BLOCK_SPAM);
FilterAction.filterPunish(e,FAT.BLOCK_SPAM, GPTUtils.calcSim(e.getMessage(),lastMessageMap.get(p)), null);
heatMap.put(p, heatMap.get(p) + Sentinel.mainConfig.chat.antiSpam.highGain);
return;
}

View File

@@ -2,18 +2,11 @@ package io.github.thetrouper.sentinel.server.functions;
import io.github.thetrouper.sentinel.server.util.MathUtils;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

View File

@@ -9,7 +9,6 @@ import io.github.thetrouper.sentinel.server.util.Text;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import javax.print.attribute.standard.Severity;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -27,7 +26,6 @@ public class ProfanityFilter {
public static void handleProfanityFilter(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
String message = Text.removeFirstColor(e.getMessage());
String highlighted = highlightProfanity(message);
FilterSeverity severity = ProfanityFilter.checkSeverity(message);
if (severity.equals(FilterSeverity.SAFE)) return;
@@ -37,7 +35,15 @@ public class ProfanityFilter {
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + severity.getScore());
e.setCancelled(true);
FilterAction.filterAction(p,e,highlighted,severity,null,getFAT(severity));
if (scoreMap.get(p)+severity.getScore() > Sentinel.mainConfig.chat.antiSwear.punishScore) {
scoreMap.put(p,scoreMap.get(p)+severity.getScore());
FilterAction.filterPunish(e,FAT.SWEAR_PUNISH,null,severity);
return;
}
scoreMap.put(p,scoreMap.get(p)+severity.getScore());
FilterAction.filterPunish(e,getFAT(severity),null,severity);
}
private static FAT getFAT(FilterSeverity severity) {

View File

@@ -1,7 +1,6 @@
package io.github.thetrouper.sentinel.server.functions;
import io.github.itzispyder.pdk.utils.SchedulerUtils;
import io.github.itzispyder.pdk.utils.discord.DiscordWebhook;
import io.github.thetrouper.sentinel.cmds.SocialSpyCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;

View File

@@ -1,11 +1,5 @@
package io.github.thetrouper.sentinel.server.functions;
import club.minnced.discord.webhook.WebhookClient;
import club.minnced.discord.webhook.WebhookClientBuilder;
import club.minnced.discord.webhook.send.WebhookEmbed;
import club.minnced.discord.webhook.send.WebhookEmbedBuilder;
import club.minnced.discord.webhook.send.WebhookMessage;
import club.minnced.discord.webhook.send.WebhookMessageBuilder;
import io.github.itzispyder.pdk.utils.discord.DiscordEmbed;
import io.github.itzispyder.pdk.utils.discord.DiscordWebhook;
import io.github.thetrouper.sentinel.Sentinel;
@@ -13,7 +7,6 @@ import io.github.thetrouper.sentinel.data.Emojis;
import io.github.thetrouper.sentinel.server.util.CipherUtils;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import java.awt.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;

View File

@@ -1,7 +1,6 @@
package io.github.thetrouper.sentinel.server.util;
import io.github.thetrouper.sentinel.Sentinel;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
import java.io.BufferedWriter;