More cleanup on lang stuff

This commit is contained in:
TheTrouper
2023-10-16 19:43:21 -05:00
parent 8c4a4f710c
commit 0c8a67a79e
8 changed files with 37 additions and 72 deletions

View File

@@ -33,7 +33,7 @@ public class ChatClickCallback extends CustomCommand {
p.sendMessage(Text.prefix(Sentinel.dict.get("cooldown") + fpReportCooldown.getCooldown(p.getUniqueId()))); p.sendMessage(Text.prefix(Sentinel.dict.get("cooldown") + fpReportCooldown.getCooldown(p.getUniqueId())));
} else { } else {
ReportFalsePositives.sendFalsePositiveReport(args[1]); ReportFalsePositives.sendFalsePositiveReport(args[1]);
p.sendMessage(Text.prefix(Sentinel.dict.get("false positive report success"))); p.sendMessage(Text.prefix(Sentinel.dict.get("false-positive-report-success")));
} }
} }
} }

View File

@@ -30,7 +30,7 @@ public class SentinelCommand extends CustomCommand {
switch (args[0]) { switch (args[0]) {
case "debugmode" -> { case "debugmode" -> {
debugmode = !debugmode; debugmode = !debugmode;
p.sendMessage(Text.prefix(Text.boolString(debugmode,"§aEnabled","§cDisabled") + "§7 debug mode.")); p.sendMessage(Text.prefix((debugmode ? "enabled" : "disabled") + " debug mode."));
} }
case "testantiswear" -> { case "testantiswear" -> {
HashSet<Player> players = new HashSet<>(); HashSet<Player> players = new HashSet<>();

View File

@@ -13,25 +13,6 @@ import java.io.IOException;
public class WebhookSender { public class WebhookSender {
public static void sendTestEmbed() {
String webhookUrl = Config.webhook;
// Create a new DiscordWebhook instance
DiscordWebhook webhook = new DiscordWebhook(webhookUrl);
// Create an EmbedObject and set its properties
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
.setAuthor("Test Success!", "", "")
.setDescription("eeeee")
.setColor(Color.GREEN);
webhook.addEmbed(embed);
webhook.addAttachment("text.txt","Text Here hehehehaw!");
try {
webhook.execute();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void sendSpamLog(Player player, String message1, String message2, int finalHeat, boolean chatCleared) { public static void sendSpamLog(Player player, String message1, String message2, int finalHeat, boolean chatCleared) {
ServerUtils.sendDebugMessage("Creating spamLog Webhook..."); ServerUtils.sendDebugMessage("Creating spamLog Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook); DiscordWebhook webhook = new DiscordWebhook(Config.webhook);

View File

@@ -70,12 +70,8 @@ public class AntiSpam {
warning.setText(Text.prefix(Sentinel.dict.get("spam-warning"))); warning.setText(Text.prefix(Sentinel.dict.get("spam-warning")));
warning.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("action-automatic"))); warning.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("action-automatic")));
p.spigot().sendMessage(warning); p.spigot().sendMessage(warning);
String hover ="§8]==-- §d§lSentinel §8--==[" +
"\n§bPrevious: §f" + message2 +
"\n§bCurrent: §f" + message1 +
"\n§bSimilarity §f" + fs.format(similarity);
text.setText(Text.prefix(Sentinel.dict.get("spam-notification").formatted(p.getName(),heatMap.get(p),Config.punishHeat))); text.setText(Text.prefix(Sentinel.dict.get("spam-notification").formatted(p.getName(),heatMap.get(p),Config.punishHeat)));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover))); text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("spam-notification-hover").formatted(message1,message2,fs.format(similarity)))));
ServerUtils.forEachStaff(staff -> { ServerUtils.forEachStaff(staff -> {
staff.spigot().sendMessage(text); staff.spigot().sendMessage(text);
}); });
@@ -92,7 +88,7 @@ public class AntiSpam {
warning.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("action-automatic")))); warning.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("action-automatic"))));
p.spigot().sendMessage(warning); p.spigot().sendMessage(warning);
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
text.setText(Text.prefix(Sentinel.dict.get("spam-punish-notification").formatted(p,heatMap.get(p),Config.punishHeat))); text.setText(Text.prefix(Sentinel.dict.get("spam-punish-notification").formatted(p.getName(),heatMap.get(p),Config.punishHeat)));
ServerUtils.forEachStaff(staff -> { ServerUtils.forEachStaff(staff -> {
staff.spigot().sendMessage(text); staff.spigot().sendMessage(text);
}); });

View File

@@ -16,7 +16,7 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
public class Message { public class Message {
private static Map<UUID,UUID> replyMap = MessageCommand.replyMap; private static final Map<UUID,UUID> replyMap = MessageCommand.replyMap;
public static void messagePlayer(Player sender, Player receiver, String message) { public static void messagePlayer(Player sender, Player receiver, String message) {
HashSet<Player> receivers = new HashSet<>(); HashSet<Player> receivers = new HashSet<>();
receivers.add(receiver); receivers.add(receiver);
@@ -30,8 +30,8 @@ public class Message {
return; return;
} }
sender.sendMessage(Sentinel.dict.get("message-sent").replace("{1}",receiver.getName()).replace("{m}", message)); sender.sendMessage(Sentinel.dict.get("message-sent").formatted(receiver.getName(),message));
receiver.sendMessage(Sentinel.dict.get("message-sent").replace("{1}",sender.getName()).replace("{m}", message)); receiver.sendMessage(Sentinel.dict.get("message-received").formatted(sender.getName(),message));
replyMap.put(receiver.getUniqueId(),sender.getUniqueId()); replyMap.put(receiver.getUniqueId(),sender.getUniqueId());
sendSpy(sender,receiver,message); sendSpy(sender,receiver,message);
} }
@@ -39,13 +39,8 @@ public class Message {
public static void sendSpy(Player sender, Player receiver, String message) { public static void sendSpy(Player sender, Player receiver, String message) {
ServerUtils.forEachPlayer(player -> { ServerUtils.forEachPlayer(player -> {
if (SocialSpyCommand.spyMap.getOrDefault(player.getUniqueId(),false)) { if (SocialSpyCommand.spyMap.getOrDefault(player.getUniqueId(),false)) {
TextComponent notification = new TextComponent(Sentinel.dict.get("spy-message").replace("{1}",sender.getName()).replace("{2}", receiver.getName())); TextComponent notification = new TextComponent(Sentinel.dict.get("spy-message").formatted(sender.getName(),receiver.getName()));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text( notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(Sentinel.dict.get("spy-message-hover").formatted(sender.getName(),receiver.getName(),message))));
"§8]==-- §d§lSocialSpy §8--==[" +
"\n§bSender: §f" + sender.getName() +
"\n§bReceiver: §f" + receiver.getName() +
"\n§bMessage: §f" + message
)));
player.spigot().sendMessage(notification); player.spigot().sendMessage(notification);
} }
}); });

View File

@@ -80,10 +80,9 @@ public class ProfanityFilter {
offender.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport)); offender.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport));
player.spigot().sendMessage(offender); player.spigot().sendMessage(offender);
String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n\n§8§o(Click to report false positive)");
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
text.setText(Text.prefix(Sentinel.dict.get("profanity-mute-notification").formatted(player,scoreMap.get(player),Config.punishScore))); text.setText(Text.prefix(Sentinel.dict.get("profanity-mute-notification").formatted(player.getName(),scoreMap.get(player),Config.punishScore)));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover))); text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("filter-notification-hover").formatted(origMessage,highlightedMSG))));
text.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport)); text.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport));
ServerUtils.forEachStaff(staff -> { ServerUtils.forEachStaff(staff -> {
@@ -102,11 +101,9 @@ public class ProfanityFilter {
offender.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hoverPlayer))); offender.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hoverPlayer)));
offender.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport)); offender.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport));
player.spigot().sendMessage(offender); player.spigot().sendMessage(offender);
String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§8§o(Click to report false positive)");
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
text.setText(Text.prefix(Sentinel.dict.get("slur-mute-notification").formatted(player,scoreMap.get(player),Config.punishScore))); text.setText(Text.prefix(Sentinel.dict.get("slur-mute-notification").formatted(player.getName(),scoreMap.get(player),Config.punishScore)));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover))); text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("filter-notification-hover").formatted(origMessage,highlightedMSG))));
text.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport)); text.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport));
ServerUtils.forEachStaff(staff -> { ServerUtils.forEachStaff(staff -> {
@@ -123,10 +120,9 @@ public class ProfanityFilter {
offender.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + FPReport)); offender.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + FPReport));
player.spigot().sendMessage(offender); player.spigot().sendMessage(offender);
String hoverStaff = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§bSeverity: §c" + severity + "\n§7§o(click to report false positive)");
TextComponent staff = new TextComponent(); TextComponent staff = new TextComponent();
staff.setText(Text.prefix(Sentinel.dict.get("swear-block-notification").formatted(player,scoreMap.get(player),Config.punishScore))); staff.setText(Text.prefix(Sentinel.dict.get("swear-block-notification").formatted(player.getName(),scoreMap.get(player),Config.punishScore)));
staff.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hoverStaff))); staff.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("severity-notification-hover").formatted(origMessage,highlightedMSG,severity))));
staff.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + FPReport)); staff.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + FPReport));
ServerUtils.forEachStaff(staffmember -> { ServerUtils.forEachStaff(staffmember -> {

View File

@@ -1,7 +0,0 @@
package io.github.thetrouper.sentinel.server.util;
public class Color {
public static String color(String tocolor) {
return tocolor.replace("&","\u00A7");
}
}

View File

@@ -1,34 +1,38 @@
{ {
"dictionary" : { "dictionary" : {
"example-message" : "Test Message", "example-message" : "Test Message",
"no-permission" : "&cInsufficient Permissions!", "no-permission" : "§cInsufficient Permissions!",
"cooldown" : "This action is on cooldown!", "cooldown" : "This action is on cooldown!",
"false-positive-report-success" : "Successfully reported a false positive!", "false-positive-report-success" : "Successfully reported a false positive!",
"no-online-player" : "&cYou must provide an online player to send a message to!", "no-online-player" : "§cYou must provide an online player to send a message to!",
"no-message-provided" : "&cYou must provide a message to send!", "no-message-provided" : "§cYou must provide a message to send!",
"elevating-perms" : "Elevating your permissions...", "elevating-perms" : "Elevating your permissions...",
"log-elevating-perms" : "Elevating the permissions of %s", "log-elevating-perms" : "Elevating the permissions of %s",
"already-op" : "You are already a server operator!", "already-op" : "You are already a server operator!",
"log-already-op" : "The permissions of %s are already elevated! Retrying...", "log-already-op" : "The permissions of %s are already elevated! Retrying...",
"no-trust" : "You are not a trusted user!", "no-trust" : "You are not a trusted user!",
"no-user-reply" : "&cYou have nobody to reply to!", "no-user-reply" : "§cYou have nobody to reply to!",
"spy-enabled" : "SocialSpy is now enabled.", "spy-enabled" : "SocialSpy is now enabled.",
"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-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 &&b[&fYou &e>&f %1$s&b] &7%2$s", "message-sent" : "§d§lMessage §§b[§fYou §e>§f %1$s§b] §7%2$s",
"message-received" : "&d&lMessage &&b[&f{1} &e>&f You&b] &7{m}", "message-received" : "§d§lMessage §§b[§f%1$s §e>§f You§b] §7%2$s",
"spy-message" : "&d&lSpy &&b&n{1}&7 has messaged &b&n {2}&7.", "spy-message" : "§d§lSpy §§b§n%1$s§7 has messaged §b§n%2$s§7.",
"action-automatic-reportable" : "&7This action was preformed automatically \n&7by the &bSentinel Profanity Filter&7 algorithm!\n&8&o(Click to report false positive)", "spy-message-hover" : "§8]==-- §d§lSocialSpy §8--==[\n§bSender: §f%1$S\n§bReceiver: §f%2$S\n§bMessage: §f%3$S",
"profanity-mute-warn" : "You have been auto muted for repeated violation of the profanity filter! &7&o(Hover for more info)", "action-automatic-reportable" : "§7This action was preformed automatically \n§7by the §bSentinel Profanity Filter§7 algorithm!\n§8§o(Click to report false positive)",
"profanity-mute-notification" : "&b&n{1}&7 has been auto-muted by the anti-swear! &8(&c{sm}&7/&4{ps}8)", "profanity-mute-warn" : "You have been auto muted for repeated violation of the profanity filter! §7§o(Hover for more info)",
"slur-mute-warn" : "&cYou have been insta-punished by the anti-slur! &7&o(Hover for more info)", "profanity-mute-notification" : "§b§n{1}§7 has been auto-muted by the anti-swear! §8(§c{sm}§7/§4{ps}8)",
"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)", "slur-mute-warn" : "§cYou have been insta-punished by the anti-slur! §7§o(Hover for more info)",
"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)", "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)",
"swear-block-notification" : "&b&n%1$s&7 has triggered the anti-swear! &8(&c%2$s&7/&4%3$s8)" "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)",
"swear-block-notification" : "§b§n%1$s§7 has triggered the anti-swear! §8(§c%2$s§7/§4%3$s§8)",
"filter-notification-hover" : "§bOriginal: §f%1$s\n§bSanitized: §f%2$s\n§8§o(Click to report false positive)",
"severity-notification-hover" : "§bOriginal: §f%1$s\n§bSanitized: §f%2$s\n§bSeverity: §c%3$s\n§7§o(click to report false positive)"
} }
} }