Decided the moment before update that some of my code could be simplified into generics so that will come first
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
package io.github.thetrouper.sentinel.server;
|
package io.github.thetrouper.sentinel.data;
|
||||||
|
|
||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
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.DiscordWebhook;
|
||||||
import io.github.thetrouper.sentinel.server.util.FileUtils;
|
import io.github.thetrouper.sentinel.server.util.FileUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package io.github.thetrouper.sentinel.server;
|
package io.github.thetrouper.sentinel.data;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
50
src/main/java/io/github/thetrouper/sentinel/data/FAT.java
Normal file
50
src/main/java/io/github/thetrouper/sentinel/data/FAT.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package io.github.thetrouper.sentinel.data;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public enum FAT {
|
||||||
|
// I couldn't miss the opportunity to call the "Filter Action Type" FAT
|
||||||
|
// Its rly just to make the tab completion of FilterAction easier
|
||||||
|
BLOCK_SWEAR("Sentinel Profanity Filter",null,"swear-block-warn", "swear-block-notification", null,null),
|
||||||
|
BLOCK_SPAM("Sentinel Anti-Spam", null, "spam-warning", "spam-notification",null,null),
|
||||||
|
SWEAR("Sentinel Anti-Swear Log","Anti-Swear", "profanity-mute-warn", "profanity-mute-notification", Config.swearPunishCommand, Color.orange),
|
||||||
|
SLUR("Sentinel Anti-Slur Log", "Anti-Slur", "slur-mute-warn", "slur-mute-notification", Config.strictPunishCommand, Color.red),
|
||||||
|
SPAM("Sentinel Anti-Spam Log", "Anti-Spam", "spam-mute-warn", "spam-mute-notification", Config.spamPunishCommand, Color.pink);
|
||||||
|
|
||||||
|
private final String title;
|
||||||
|
private final String name;
|
||||||
|
private final String warnTranslationKey;
|
||||||
|
private final String notifTranslationKey;
|
||||||
|
private final String executedCommand;
|
||||||
|
private final Color embedColor;
|
||||||
|
|
||||||
|
FAT(String title, String name, String warnTranslationKey, String notifTranslationKey, String executedCommand, Color embedColor) {
|
||||||
|
this.title = title;
|
||||||
|
this.name = name;
|
||||||
|
this.warnTranslationKey = warnTranslationKey;
|
||||||
|
this.notifTranslationKey = notifTranslationKey;
|
||||||
|
this.executedCommand = executedCommand;
|
||||||
|
this.embedColor = embedColor;
|
||||||
|
}
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public String getWarnTranslationKey() {
|
||||||
|
return warnTranslationKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotifTranslationKey() {
|
||||||
|
return notifTranslationKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExecutedCommand() {
|
||||||
|
return executedCommand;
|
||||||
|
}
|
||||||
|
public Color getColor() {
|
||||||
|
return embedColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package io.github.thetrouper.sentinel.data;
|
||||||
|
|
||||||
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
|
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
||||||
|
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.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static io.github.thetrouper.sentinel.server.functions.ProfanityFilter.fullSimplify;
|
||||||
|
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, FAT 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));
|
||||||
|
|
||||||
|
warn.setText(Text.prefix(Sentinel.dict.get(type.getWarnTranslationKey())));
|
||||||
|
offender.spigot().sendMessage(warn);
|
||||||
|
|
||||||
|
notif.setText(Text.prefix(Sentinel.dict.get(type.getNotifTranslationKey()).formatted(offender.getName(), scoreMap.get(offender), Config.punishScore)));
|
||||||
|
ServerUtils.forEachStaff(staffmember -> {
|
||||||
|
staffmember.spigot().sendMessage(notif);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (type.getExecutedCommand() != null) {
|
||||||
|
ServerUtils.sendCommand(type.getExecutedCommand().replace("%player%", offender.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == FAT.SWEAR && Config.logSwear) {
|
||||||
|
sendDiscordLog(offender,e,type);
|
||||||
|
sendConsoleLog(offender,e,type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == FAT.SLUR && Config.logSwear) {
|
||||||
|
sendDiscordLog(offender, e, type);
|
||||||
|
sendConsoleLog(offender, e, type);
|
||||||
|
}
|
||||||
|
if (type == FAT.SPAM && Config.logSpam) {
|
||||||
|
// BOOKMARK
|
||||||
|
// STATE: (bool?t:f) imp spam log for console & discord for prev/curr||Mess/Redu
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void sendConsoleLog(Player offender, AsyncPlayerChatEvent e, FAT type) {
|
||||||
|
String log = "]=-" + type.getTitle() + "-=[\n" +
|
||||||
|
"Player: " + offender.getName() +
|
||||||
|
"> Score: (" + scoreMap.get(offender) + "/" + Config.punishScore + ")\n" +
|
||||||
|
"> UUID: " + offender.getUniqueId() + "\n" +
|
||||||
|
"Message: " + e.getMessage() + "\n" +
|
||||||
|
"Reduced: " + fullSimplify(e.getMessage()) + "\n" +
|
||||||
|
(type.getExecutedCommand() != null ? "Executed: " + type.getExecutedCommand() : "Executed: Nothing, its a standard flag. You shouldn't be seeing this, please report it.");
|
||||||
|
Sentinel.log.info(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendDiscordLog(Player offender, AsyncPlayerChatEvent e, FAT type) {
|
||||||
|
String supertitle = type.getTitle();
|
||||||
|
String title = offender.getName() + " has triggered the " + type.getName() + "!";
|
||||||
|
Color color = Color.white;
|
||||||
|
String executed = type.getExecutedCommand() != null ? type.getExecutedCommand() : "Nothing, its a standard flag. You shouldn't be seeing this, please report it.";
|
||||||
|
|
||||||
|
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("Reduced 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,58 +41,4 @@ public class WebhookSender {
|
|||||||
Sentinel.log.info(e.toString());
|
Sentinel.log.info(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void sendSwearLog(Player player, String message, int finalScore) {
|
|
||||||
ServerUtils.sendDebugMessage("Creating swearLog Webhook...");
|
|
||||||
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("Anti-Swear Punishment","","")
|
|
||||||
.setTitle(player.getName() + " has triggered the anti-slur!")
|
|
||||||
.setDescription(
|
|
||||||
Emojis.rightSort + "Player: " + player.getName() + " " + Emojis.target + "\\n" +
|
|
||||||
Emojis.space + Emojis.arrowRight + "Score: `" + finalScore + "/" + Config.punishScore + "`\\n" +
|
|
||||||
Emojis.space + Emojis.arrowRight + "UUID: `" + player.getUniqueId() + "`\\n" +
|
|
||||||
Emojis.rightSort + "Executed: " + Config.swearPunishCommand + " " + Emojis.mute + "\\n"
|
|
||||||
)
|
|
||||||
.addField("Original Message", "||" + message + "|| " + Emojis.alarm, false)
|
|
||||||
.addField("Sanitized Message", ProfanityFilter.highlightProfanity(message,"||", "||") + " " + Emojis.noDM, false)
|
|
||||||
.setColor(Color.orange)
|
|
||||||
.setThumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay");
|
|
||||||
webhook.addEmbed(embed);
|
|
||||||
try {
|
|
||||||
ServerUtils.sendDebugMessage("Executing webhook...");
|
|
||||||
webhook.execute();
|
|
||||||
} catch (IOException e) {
|
|
||||||
ServerUtils.sendDebugMessage(Text.prefix("Epic webhook failure!!!"));
|
|
||||||
Sentinel.log.info(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static void sendSlurLog(Player player, String message, int finalScore) {
|
|
||||||
ServerUtils.sendDebugMessage("Creating swearLog Webhook...");
|
|
||||||
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("Anti-Slur Punishment","","")
|
|
||||||
.setTitle(player.getName() + " has triggered the anti-slur!")
|
|
||||||
.setDescription(
|
|
||||||
Emojis.rightSort + "Player: " + player.getName() + " " + Emojis.target + "\\n" +
|
|
||||||
Emojis.space + Emojis.arrowRight + "Score: `" + finalScore + "/" + Config.punishScore + "`\\n" +
|
|
||||||
Emojis.space + Emojis.arrowRight + "UUID: `" + player.getUniqueId() + "`\\n" +
|
|
||||||
Emojis.rightSort + "Executed: " + Config.strictPunishCommand + " " + Emojis.mute + "\\n"
|
|
||||||
)
|
|
||||||
.addField("Original Message", "||" + message + "|| " + Emojis.alarm, false)
|
|
||||||
.addField("Sanitized Message", ProfanityFilter.highlightProfanity(message,"||", "||") + " " + Emojis.noDM, false)
|
|
||||||
.setColor(Color.orange)
|
|
||||||
.setThumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay");
|
|
||||||
webhook.addEmbed(embed);
|
|
||||||
try {
|
|
||||||
ServerUtils.sendDebugMessage("Executing webhook...");
|
|
||||||
webhook.execute();
|
|
||||||
} catch (IOException e) {
|
|
||||||
ServerUtils.sendDebugMessage(Text.prefix("Epic webhook failure!!!"));
|
|
||||||
Sentinel.log.info(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package io.github.thetrouper.sentinel.events;
|
|||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.data.Config;
|
||||||
import io.github.thetrouper.sentinel.server.Action;
|
import io.github.thetrouper.sentinel.data.Action;
|
||||||
import io.github.thetrouper.sentinel.server.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package io.github.thetrouper.sentinel.events;
|
|||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.data.Config;
|
||||||
import io.github.thetrouper.sentinel.server.Action;
|
import io.github.thetrouper.sentinel.data.Action;
|
||||||
import io.github.thetrouper.sentinel.server.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package io.github.thetrouper.sentinel.events;
|
|||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.data.Config;
|
||||||
import io.github.thetrouper.sentinel.server.Action;
|
import io.github.thetrouper.sentinel.data.Action;
|
||||||
import io.github.thetrouper.sentinel.server.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package io.github.thetrouper.sentinel.events;
|
|||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.data.Config;
|
||||||
import io.github.thetrouper.sentinel.server.Action;
|
import io.github.thetrouper.sentinel.data.Action;
|
||||||
import io.github.thetrouper.sentinel.server.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package io.github.thetrouper.sentinel.events;
|
|||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.data.Config;
|
||||||
import io.github.thetrouper.sentinel.server.Action;
|
import io.github.thetrouper.sentinel.data.Action;
|
||||||
import io.github.thetrouper.sentinel.server.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
import io.github.thetrouper.sentinel.server.util.Text;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package io.github.thetrouper.sentinel.events;
|
|||||||
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
import io.github.thetrouper.sentinel.Sentinel;
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.data.Config;
|
||||||
import io.github.thetrouper.sentinel.server.Action;
|
import io.github.thetrouper.sentinel.data.Action;
|
||||||
import io.github.thetrouper.sentinel.server.ActionType;
|
import io.github.thetrouper.sentinel.data.ActionType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -13,9 +13,6 @@ import org.bukkit.event.inventory.InventoryCreativeEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class NBTEvents implements Listener {
|
public class NBTEvents implements Listener {
|
||||||
|
|||||||
@@ -1,119 +0,0 @@
|
|||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
package io.github.thetrouper.sentinel.server.functions;
|
package io.github.thetrouper.sentinel.server.functions;
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
|
||||||
import io.github.thetrouper.sentinel.data.Config;
|
import io.github.thetrouper.sentinel.data.Config;
|
||||||
import io.github.thetrouper.sentinel.discord.WebhookSender;
|
import io.github.thetrouper.sentinel.data.FilterAction;
|
||||||
|
import io.github.thetrouper.sentinel.data.FAT;
|
||||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||||
import io.github.thetrouper.sentinel.server.util.Text;
|
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.entity.Player;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
@@ -26,49 +23,60 @@ public class ProfanityFilter {
|
|||||||
public static void handleProfanityFilter(AsyncPlayerChatEvent e) {
|
public static void handleProfanityFilter(AsyncPlayerChatEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
String message = Text.removeFirstColor(e.getMessage());
|
String message = Text.removeFirstColor(e.getMessage());
|
||||||
if (!scoreMap.containsKey(p)) scoreMap.put(p, 0);
|
String highlighted = highlightProfanity(message);
|
||||||
if (scoreMap.get(p) > Config.punishScore) punishSwear(p,highlightProfanity(message),message,e);
|
|
||||||
String severity = ProfanityFilter.checkSeverity(message);
|
String severity = ProfanityFilter.checkSeverity(message);
|
||||||
|
if (!scoreMap.containsKey(p)) scoreMap.put(p, 0);
|
||||||
|
// Old: if (scoreMap.get(p) > Config.punishScore) punishSwear(p,highlighted,message,e);
|
||||||
|
if (scoreMap.get(p) > Config.punishScore) FilterAction.filterAction(p,e,highlighted,severity, FAT.SWEAR);
|
||||||
|
|
||||||
switch (severity) {
|
switch (severity) {
|
||||||
case "low" -> {
|
case "low" -> {
|
||||||
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.lowScore);
|
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.lowScore);
|
||||||
scoreMap.put(p, scoreMap.get(p) + Config.lowScore);
|
scoreMap.put(p, scoreMap.get(p) + Config.lowScore);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
blockSwear(p,highlightProfanity(message),message,severity,e);
|
// Old: blockSwear(p,highlighted,message,severity,e);
|
||||||
|
FilterAction.filterAction(p,e,highlighted,severity, FAT.BLOCK_SWEAR);
|
||||||
}
|
}
|
||||||
case "medium-low" -> {
|
case "medium-low" -> {
|
||||||
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.mediumLowScore);
|
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.mediumLowScore);
|
||||||
scoreMap.put(p, scoreMap.get(p) + Config.mediumLowScore);
|
scoreMap.put(p, scoreMap.get(p) + Config.mediumLowScore);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
blockSwear(p,highlightProfanity(message),message,severity,e);
|
// Old: blockSwear(p,highlighted,message,severity,e);
|
||||||
|
FilterAction.filterAction(p,e,highlighted,severity, FAT.BLOCK_SWEAR);
|
||||||
}
|
}
|
||||||
case "medium" -> {
|
case "medium" -> {
|
||||||
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.mediumScore);
|
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.mediumScore);
|
||||||
scoreMap.put(p, scoreMap.get(p) + Config.mediumScore);
|
scoreMap.put(p, scoreMap.get(p) + Config.mediumScore);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
blockSwear(p,highlightProfanity(message),message,severity,e);
|
// Old: blockSwear(p,highlighted,message,severity,e);
|
||||||
|
FilterAction.filterAction(p,e,highlighted,severity, FAT.BLOCK_SWEAR);
|
||||||
}
|
}
|
||||||
case "medium-high" -> {
|
case "medium-high" -> {
|
||||||
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.mediumHighScore);
|
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.mediumHighScore);
|
||||||
scoreMap.put(p, scoreMap.get(p) + Config.mediumHighScore);
|
scoreMap.put(p, scoreMap.get(p) + Config.mediumHighScore);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
blockSwear(p,highlightProfanity(message),message,severity,e);
|
// Old: blockSwear(p,highlighted,message,severity,e);
|
||||||
|
FilterAction.filterAction(p,e,highlighted,severity, FAT.BLOCK_SWEAR);
|
||||||
}
|
}
|
||||||
case "high" -> {
|
case "high" -> {
|
||||||
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.highScore);
|
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.highScore);
|
||||||
scoreMap.put(p, scoreMap.get(p) + Config.highScore);
|
scoreMap.put(p, scoreMap.get(p) + Config.highScore);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
blockSwear(p,highlightProfanity(message),message,severity,e);
|
// Old: blockSwear(p,highlighted,message,severity,e);
|
||||||
|
FilterAction.filterAction(p,e,highlighted,severity, FAT.BLOCK_SWEAR);
|
||||||
}
|
}
|
||||||
case "slur" -> {
|
case "slur" -> {
|
||||||
// Insta-Punish
|
// Insta-Punish
|
||||||
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.highScore);
|
ServerUtils.sendDebugMessage("AntiSwear Flag, Message: " + message + " Concentrated: " + fullSimplify(message) + " Severity: " + severity + " Previous Score: " + scoreMap.get(p) +" Adding Score: " + Config.highScore);
|
||||||
scoreMap.put(p, scoreMap.get(p) + Config.highScore);
|
scoreMap.put(p, scoreMap.get(p) + Config.highScore);
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
punishSlur(p,highlightProfanity(message),message,e);
|
// Old: punishSlur(p,highlighted,message,e);
|
||||||
|
FilterAction.filterAction(p,e,highlighted,severity, FAT.SLUR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
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()));
|
||||||
String fpreport = ReportFalsePositives.generateReport(e);
|
String fpreport = ReportFalsePositives.generateReport(e);
|
||||||
@@ -89,6 +97,8 @@ public class ProfanityFilter {
|
|||||||
});
|
});
|
||||||
if (Config.logSwear) WebhookSender.sendSwearLog(player,origMessage,scoreMap.get(player));
|
if (Config.logSwear) WebhookSender.sendSwearLog(player,origMessage,scoreMap.get(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void punishSlur(Player player, String highlightedMSG, String origMessage, AsyncPlayerChatEvent e) {
|
public static void punishSlur(Player player, String highlightedMSG, String origMessage, AsyncPlayerChatEvent e) {
|
||||||
if (!Config.strictInstaPunish) return;
|
if (!Config.strictInstaPunish) return;
|
||||||
|
|
||||||
@@ -128,7 +138,7 @@ public class ProfanityFilter {
|
|||||||
staffmember.spigot().sendMessage(staff);
|
staffmember.spigot().sendMessage(staff);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public static String highlightProfanity(String text) {
|
public static String highlightProfanity(String text) {
|
||||||
String highlightedSwears = highlightSwears(fullSimplify(text), "\u00a7e", "\u00a7f");
|
String highlightedSwears = highlightSwears(fullSimplify(text), "\u00a7e", "\u00a7f");
|
||||||
String highlightedText = highlightSlurs(highlightedSwears, "\u00a7c", "\u00a7f");
|
String highlightedText = highlightSlurs(highlightedSwears, "\u00a7c", "\u00a7f");
|
||||||
@@ -234,14 +244,14 @@ public class ProfanityFilter {
|
|||||||
return containsSwears(text) || containsSlurs(text);
|
return containsSwears(text) || containsSlurs(text);
|
||||||
}
|
}
|
||||||
private static boolean containsSwears(String text) {
|
private static boolean containsSwears(String text) {
|
||||||
ServerUtils.sendDebugMessage("Debug: [AntiSwear] Checking for swears: " + swearBlacklist.toString());
|
ServerUtils.sendDebugMessage("Debug: [AntiSwear] Checking for swears");
|
||||||
for (String swear : swearBlacklist) {
|
for (String swear : swearBlacklist) {
|
||||||
if (text.contains(swear)) return true;
|
if (text.contains(swear)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private static boolean containsSlurs(String text) {
|
private static boolean containsSlurs(String text) {
|
||||||
ServerUtils.sendDebugMessage("Debug: [AntiSwear] Checking for slurs: " + slurs.toString());
|
ServerUtils.sendDebugMessage("Debug: [AntiSwear] Checking for slurs");
|
||||||
for (String slur : slurs) {
|
for (String slur : slurs) {
|
||||||
if (text.contains(slur)) return true;
|
if (text.contains(slur)) return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
"spy-disabled" : "SocialSpy is now disabled.",
|
"spy-disabled" : "SocialSpy is now disabled.",
|
||||||
"spam-warning" : "Do not spam in chat! Please wait before sending another message.",
|
"spam-warning" : "Do not spam in chat! Please wait before sending another message.",
|
||||||
"action-automatic" : "§7This action was preformed automatically\n§7by the §bSentinel Anti-Spam§7 algorithm.",
|
"action-automatic" : "§7This action was preformed automatically\n§7by the §bSentinel Anti-Spam§7 algorithm.",
|
||||||
"spam-notification" : "§b§n%1$s§7 might be spamming! §8(§c%2$s§7/§4%3$s§&8)",
|
"spam-notification" : "§b§n%1$s§7 might be spamming! §8(§c%2$s§7/§4%3$s§8)",
|
||||||
"spam-notification-hover" : "§8]==-- §d§lSentinel §8--==[\n§bPrevious: §f%1$s\n§bCurrent: §f%2$s\n§bSimilarity §f%3$s",
|
"spam-notification-hover" : "§8]==-- §d§lSentinel §8--==[\n§bPrevious: §f%1$s\n§bCurrent: §f%2$s\n§bSimilarity §f%3$s",
|
||||||
"spam-punished" : "§cYou have been auto-punished for violating the anti-spam repetitively!",
|
"spam-punished" : "§cYou have been auto-punished for violating the anti-spam repetitively!",
|
||||||
"spam-punish-notification" : "§b§n%1$s§7 has been auto-muted by the anti spam! §8(§c%2$s§7/§4%3$s§&8)",
|
"spam-punish-notification" : "§b§n%1$s§7 has been auto-muted by the anti spam! §8(§c%2$s§7/§4%3$s§8)",
|
||||||
"unicode-warn" : "§cDo not send non standard unicode in chat!",
|
"unicode-warn" : "§cDo not send non standard unicode in chat!",
|
||||||
"message-sent" : "§d§lMessage §8» §b[§fYou §e>§f %1$s§b] §7%2$s",
|
"message-sent" : "§d§lMessage §8» §b[§fYou §e>§f %1$s§b] §7%2$s",
|
||||||
"message-received" : "§d§lMessage §8» §b[§f%1$s §e>§f You§b] §7%2$s",
|
"message-received" : "§d§lMessage §8» §b[§f%1$s §e>§f You§b] §7%2$s",
|
||||||
|
|||||||
Reference in New Issue
Block a user