Going to redo the language system

This commit is contained in:
TheTrouper
2024-02-22 16:12:21 -06:00
parent 78d6518bcd
commit 8dd82b1332
6 changed files with 58 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,14 @@
package io.github.thetrouper.sentinel.data;
import io.github.thetrouper.sentinel.Sentinel;
public record FilterActionType(String logTitle, String logName, String chatWarning, String chatWarningHover, String chatNotification, String chatNotificationHover, String punishmentCommand, int embedColor) {
public static final FilterActionType UNICODE_BLOCK = new FilterActionType("Sentinel Anti-Unicode Log","Anti-Unicode","unicode-warn","action-automatic-reportable","unicode-notification","unicode-notification-hover", null,0xFF0000);
public static final FilterActionType URL_BLOCK = new FilterActionType("Sentinel Anti-URL Log","Anti-URL","url-warn","action-automatic-reportable","url-notification","url-notification-hover", null,0xFF0000);
public static final FilterActionType SPAM_BLOCK = new FilterActionType("Sentinel Anti-Spam Log","Anti-Spam","spam-warn","action-automatic-reportable","spam-notification","spam-notification-hover", null,0xFF0000);
public static final FilterActionType SPAM_PUNISH = new FilterActionType("Sentinel Anti-Spam Log","Anti-Spam","spam-mute-warn","action-automatic-reportable","spam-mute-notification","spam-notification-hover", Sentinel.mainConfig.chat.antiSpam.spamPunishCommand,0xFF0000);
public static final FilterActionType SWEAR_BLOCK = new FilterActionType("Sentinel Profanity Filter Log","Anti-Swear","profanity-warn","action-automatic-reportable","profanity-notification","profanity-notification-hover", null,0xFF0000);
public static final FilterActionType SWEAR_PUNISH = new FilterActionType("Sentinel Profanity Filter Log","Anti-Swear","profanity-mute-warn","action-automatic-reportable","profanity-mute-notification","profanity-notification-hover", Sentinel.mainConfig.chat.antiSwear.swearPunishCommand,0xFF0000);
public static final FilterActionType SLUR_PUNISH = new FilterActionType("Sentinel Profanity Filter Log","Anti-Slur","slur-mute-warn","action-automatic-reportable","slur-mute-notification","profanity-notification-hover", Sentinel.mainConfig.chat.antiSwear.strictPunishCommand,0xFF0000);
public static final FilterActionType SAFE = new FilterActionType("ERROR",null,null,null,null,null,null,0x00AA00);
}

View File

@@ -30,17 +30,17 @@ 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-notification", "§b§n%1$s§7 has triggered the anti-swear! §8(§c%2$s§7/§4%3$s§8)");
put("profanity-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("profanity-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("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-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("url-warn", "§cDo not send urls in chat!");

View File

@@ -0,0 +1,39 @@
package io.github.thetrouper.sentinel.server;
import io.github.thetrouper.sentinel.data.FilterActionType;
import io.github.thetrouper.sentinel.data.FilterSeverity;
import io.github.thetrouper.sentinel.data.Report;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class NewFilterAction {
public static void takeAction(AsyncPlayerChatEvent e, FilterActionType type, Report report, double similarity, FilterSeverity severity) {
if (type.equals(FilterActionType.SAFE)) return;
sendWarnings(e.getPlayer(),type,report.id());
}
public static void sendConsoleLog(AsyncPlayerChatEvent e, FilterActionType type) {
}
public static void sendWarnings(Player offender, FilterActionType type, long report) {
TextComponent warning = Component.text(type.chatWarning())
.hoverEvent(Component.text(type.chatWarningHover()))
.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND,"sentinelcallback fpreport " + report));
TextComponent notification = Component.text(type.chatNotification())
.hoverEvent(Component.text(type.chatNotificationHover()))
.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND,"sentinelcallback fpreport " + report));
if (type.punishmentCommand() != null) {
ServerUtils.forEachStaff(staff->{
staff.sendMessage(notification);
});
}
offender.sendMessage(warning);
}
}

View File

@@ -24,7 +24,7 @@ public class ReportFalsePositives {
final long reportID = Randomizer.generateID();
LinkedHashMap<String,String> steps = new LinkedHashMap<>();
steps.put("Original Message", "`%s`".formatted(event.getMessage()));
SchedulerUtils.later(60000,()->{
SchedulerUtils.later(1200,()->{
reports.remove(reportID);
});
return new Report(reportID,event,steps);