New config system implemented
This commit is contained in:
@@ -27,9 +27,11 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT"
|
||||
compileOnly 'org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT'
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation("club.minnced:discord-webhooks:0.8.4")
|
||||
implementation files("libs/PDK-1.3.3.jar")
|
||||
|
||||
}
|
||||
|
||||
def targetJavaVersion = 16
|
||||
|
||||
4
build.sh
4
build.sh
@@ -17,7 +17,7 @@ if [ $? -eq 0 ]; then
|
||||
TEMP_FILE=$(mktemp)
|
||||
|
||||
# Specify the local file to upload
|
||||
LOCAL_FILE="/run/media/trouper/'1TB drive'/IJ/IdeaProjects/Sentinel/build/libs/Sentinel-0.2.2.jar"
|
||||
LOCAL_FILE="/run/media/trouper/'1TB drive'/IJ/IdeaProjects/Sentinel/build/libs/Sentinel-0.2.4.jar"
|
||||
|
||||
# Write the SFTP commands to the temporary file
|
||||
echo "put $LOCAL_FILE $SFTP_REMOTE_DIR" > "$TEMP_FILE"
|
||||
@@ -39,7 +39,7 @@ EOF
|
||||
)
|
||||
|
||||
for cmd in "${SSH_COMMANDS[@]}"; do
|
||||
ssh -oStrictHostKeyChecking=no -oBatchMode=no "$SFTP_USER@$SFTP_HOST" "docker exec docker-mc-1 mc-send-to-console $cmd"
|
||||
ssh -oStrictHostKeyChecking=no -oBatchMode=no "$SFTP_USER@$SFTP_HOST" "docker exec docker_mc_1 mc-send-to-console $cmd"
|
||||
done
|
||||
|
||||
echo "Plugin reloaded."
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
# Plugin
|
||||
group = 'io.github.thetrouper'
|
||||
version = 0.2.2
|
||||
version = 0.2.4
|
||||
|
||||
# Minecraft
|
||||
mc_version = 1.19.4
|
||||
|
||||
@@ -1,46 +1,52 @@
|
||||
package io.github.thetrouper.sentinel;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
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.WebhookMessageBuilder;
|
||||
import io.github.itzispyder.pdk.PDK;
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
import io.github.thetrouper.sentinel.auth.Auth;
|
||||
import io.github.thetrouper.sentinel.cmds.*;
|
||||
import io.github.thetrouper.sentinel.data.config.*;
|
||||
import io.github.thetrouper.sentinel.events.*;
|
||||
import io.github.thetrouper.sentinel.server.config.*;
|
||||
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.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.io.File;
|
||||
import java.time.temporal.TemporalAccessor;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public final class Sentinel extends JavaPlugin {
|
||||
|
||||
|
||||
private static Sentinel instance;
|
||||
public static LanguageFile dict;
|
||||
private static final File cfgfile = new File("plugins/Sentinel/main-config.json");
|
||||
private static final File nbtcfg = new File("plugins/Sentinel/nbt-config.json");
|
||||
private static final File strctcfg = new File("plugins/Sentinel/strict.json");
|
||||
private static final File swrcfg = new File("plugins/Sentinel/swears.json");
|
||||
private static final File fpcfg = new File("plugins/Sentinel/false-positives.json");
|
||||
private static final File advcfg = new File("plugins/Sentinel/advanced-config.json");
|
||||
|
||||
public static MainConfig mainConfig = JsonSerializable.load(cfgfile, MainConfig.class, new MainConfig());
|
||||
public static FPConfig fpConfig = JsonSerializable.load(fpcfg, FPConfig.class, new FPConfig());
|
||||
public static SwearsConfig swearConfig = JsonSerializable.load(swrcfg, SwearsConfig.class, new SwearsConfig());
|
||||
public static StrictConfig strictConfig = JsonSerializable.load(strctcfg, StrictConfig.class, new StrictConfig());
|
||||
public static NBTConfig nbtConfig = JsonSerializable.load(nbtcfg, NBTConfig.class, new NBTConfig());
|
||||
public static AdvancedConfig advConfig = JsonSerializable.load(advcfg, AdvancedConfig.class, new AdvancedConfig());
|
||||
public static LanguageFile language;
|
||||
public static final PluginManager manager = Bukkit.getPluginManager();
|
||||
public static String prefix = "";
|
||||
public static String key = "";
|
||||
|
||||
public static final Logger log = Bukkit.getLogger();
|
||||
public static String identifier = "";
|
||||
public static boolean usesDynamicIP;
|
||||
public static WebhookClient webclient;
|
||||
|
||||
/**
|
||||
* Plugin startup logic
|
||||
@@ -53,22 +59,23 @@ public final class Sentinel extends JavaPlugin {
|
||||
instance = this;
|
||||
|
||||
log.info("Loading Config...");
|
||||
|
||||
loadConfig();
|
||||
log.info("Language Status: (" + dict.get("if-you-see-this-lang-is-broken") + ")");
|
||||
|
||||
log.info("Language Status: (" + language.get("if-you-see-this-lang-is-broken") + ")");
|
||||
|
||||
log.info("Initializing Server ID...");
|
||||
String serverID = Authenticator.getServerID();
|
||||
|
||||
key = mainConfig.plugin.license;
|
||||
identifier = serverID;
|
||||
String license = mainConfig.plugin.license;
|
||||
|
||||
log.info("Pre-load finished!\n]====---- Requesting Authentication ----====[ \n- License Key: " + key + " \n- Server ID: " + serverID);
|
||||
log.info("Pre-load finished!\n]====---- Requesting Authentication ----====[ \n- License Key: " + license + " \n- Server ID: " + serverID);
|
||||
log.info("Auth Requested...");
|
||||
String authStatus = "ERROR";
|
||||
String authstatus = "ERROR";
|
||||
try {
|
||||
authStatus = Authenticator.authorize(key, serverID);
|
||||
authstatus = Auth.authorize(key, serverID);
|
||||
authStatus = Authenticator.authorize(license, serverID);
|
||||
authstatus = Auth.authorize(license, serverID);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -79,13 +86,13 @@ public final class Sentinel extends JavaPlugin {
|
||||
case "AUTHORIZED" -> {
|
||||
log.info("\n]======----- Auth Success! -----======[");
|
||||
startup();
|
||||
authstatus = authstatus.replaceAll("ur a skid lmao","get out of here kiddo");
|
||||
}
|
||||
case "MINEHUT" -> {
|
||||
usesDynamicIP = true;
|
||||
String minehutStatus = Telemetry.loadTelemetryHook(serverID, key);
|
||||
String minehutStatus = Telemetry.loadTelemetryHook(serverID, license);
|
||||
switch (minehutStatus) {
|
||||
case "SUCCESS" -> {
|
||||
authstatus = authstatus.replaceAll("ur a skid lmao","get out of here kiddo");
|
||||
log.info("Dynamic IP auth Success! " + authstatus);
|
||||
startup();
|
||||
}
|
||||
@@ -100,15 +107,15 @@ public final class Sentinel extends JavaPlugin {
|
||||
manager.disablePlugin(this);
|
||||
}
|
||||
case "UNREGISTERED" -> {
|
||||
log.warning("Authentication Failure, YOU SHALL NOT PASS! License: " + key + " Server ID: " + serverID);
|
||||
log.warning("Authentication Failure, YOU SHALL NOT PASS! License: " + license + " Server ID: " + serverID);
|
||||
manager.disablePlugin(this);
|
||||
}
|
||||
case "ERROR" -> {
|
||||
log.warning("Hmmmmmm thats not right... License: " + key + " Server ID: " + serverID + "\nPlease report the above stacktrace.");
|
||||
log.warning("Hmmmmmm thats not right... License: " + license + " Server ID: " + serverID + "\nPlease report the above stacktrace.");
|
||||
manager.disablePlugin(this);
|
||||
}
|
||||
default -> {
|
||||
log.warning("Achievment unlocked:\n How did we get here? \nLicense: " + key + " Server ID: " + serverID + "\nPlease report the above stacktrace.");
|
||||
log.warning("Achievement unlocked:\n How did we get here? \nLicense: " + license + " Server ID: " + serverID + "\nPlease report the above stacktrace.");
|
||||
manager.disablePlugin(this);
|
||||
}
|
||||
}
|
||||
@@ -116,17 +123,17 @@ public final class Sentinel extends JavaPlugin {
|
||||
|
||||
public void startup() {
|
||||
log.info("\n]======----- Loading Sentinel! -----======[");
|
||||
loadConfig();
|
||||
|
||||
// Plugin startup logic
|
||||
log.info("Starting Up! (" + getDescription().getVersion() + ")...");
|
||||
|
||||
loadWebhook();
|
||||
|
||||
// Enable Functions
|
||||
AntiSpam.enableAntiSpam();
|
||||
ProfanityFilter.enableAntiSwear();
|
||||
|
||||
prefix = mainConfig.plugin.prefix;
|
||||
|
||||
// Commands -> BE SURE TO REGISTER ANY NEW COMMANDS IN PLUGIN.YML (src/main/java/resources/plugin.yml)!
|
||||
// Commands
|
||||
new SentinelCommand().register();
|
||||
new MessageCommand().register();
|
||||
new ReplyCommand().register();
|
||||
@@ -168,7 +175,6 @@ public final class Sentinel extends JavaPlugin {
|
||||
strictConfig = JsonSerializable.load(strctcfg,StrictConfig.class,new StrictConfig());
|
||||
swearConfig = JsonSerializable.load(swrcfg,SwearsConfig.class,new SwearsConfig());
|
||||
nbtConfig = JsonSerializable.load(nbtcfg,NBTConfig.class,new NBTConfig());
|
||||
dict = JsonSerializable.load(LanguageFile.PATH,LanguageFile.class,new LanguageFile());
|
||||
|
||||
// Save
|
||||
mainConfig.save();
|
||||
@@ -177,35 +183,29 @@ public final class Sentinel extends JavaPlugin {
|
||||
strictConfig.save();
|
||||
swearConfig.save();
|
||||
nbtConfig.save();
|
||||
dict.save();
|
||||
|
||||
try {
|
||||
InputStream langIn = Sentinel.class.getClassLoader().getResourceAsStream("lang/en_us.json");
|
||||
InputStreamReader langReader = new InputStreamReader(langIn);
|
||||
BufferedReader langBR = new BufferedReader(langReader);
|
||||
File langFile = LanguageFile.PATH;
|
||||
FileWriter langFW = new FileWriter(langFile,true);
|
||||
String line;
|
||||
while ((line = langBR.readLine()) != null) {
|
||||
langFW.write(line);
|
||||
}
|
||||
langFW.close();
|
||||
langIn.close();
|
||||
langReader.close();
|
||||
langBR.close();
|
||||
} catch (Exception ex) {
|
||||
log.warning("Error during config initialization: " + ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
log.info("Loading Dictionary (" + Sentinel.mainConfig.plugin.lang + ")...");
|
||||
|
||||
log.info("Verifying Config...");
|
||||
getConfig().options().copyDefaults();
|
||||
saveDefaultConfig();
|
||||
language = JsonSerializable.load(LanguageFile.PATH,LanguageFile.class,new LanguageFile());
|
||||
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
|
||||
*/
|
||||
@@ -214,7 +214,7 @@ public final class Sentinel extends JavaPlugin {
|
||||
// Plugin shutdown logic
|
||||
log.info("Sentinel has disabled! (" + getDescription().getVersion() + ") Your server is now no longer protected!");
|
||||
if (usesDynamicIP) {
|
||||
Telemetry.sendShutdownLog(identifier,key);
|
||||
Telemetry.sendShutdownLog(Authenticator.getServerID(), mainConfig.plugin.license);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ public class ChatClickCallback implements CustomCommand {
|
||||
switch (args.get(0).toString()) {
|
||||
case "fpreport" -> {
|
||||
if (fpReportCooldown.isOnCooldown(p.getUniqueId()) && !p.isOp()) {
|
||||
p.sendMessage(Text.prefix(Sentinel.dict.get("cooldown") + fpReportCooldown.getCooldown(p.getUniqueId())));
|
||||
p.sendMessage(Text.prefix(Sentinel.language.get("cooldown") + fpReportCooldown.getCooldown(p.getUniqueId())));
|
||||
} else {
|
||||
ReportFalsePositives.sendFalsePositiveReport(args.get(1).toString());
|
||||
p.sendMessage(Text.prefix(Sentinel.dict.get("false-positive-report-success")));
|
||||
p.sendMessage(Text.prefix(Sentinel.language.get("false-positive-report-success")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,11 @@ public class MessageCommand implements CustomCommand {
|
||||
Player p = (Player) sender;
|
||||
Player r = null;
|
||||
if (args.getSize() == 0) {
|
||||
p.sendMessage(Text.prefix(Sentinel.dict.get("no-online-player")));
|
||||
p.sendMessage(Text.prefix(Sentinel.language.get("no-online-player")));
|
||||
return;
|
||||
}
|
||||
if (args.getSize() == 1) {
|
||||
p.sendMessage(Text.prefix(Sentinel.dict.get("no-message-provided")));
|
||||
p.sendMessage(Text.prefix(Sentinel.language.get("no-message-provided")));
|
||||
return;
|
||||
}
|
||||
r = Bukkit.getPlayer(args.get(0).toString());
|
||||
@@ -37,8 +37,8 @@ public class MessageCommand implements CustomCommand {
|
||||
|
||||
if (p.hasPermission("sentinel.message") && r != null) {
|
||||
Message.messagePlayer(p,r,msg);
|
||||
} else if (r == null) p.sendMessage(Text.prefix((Sentinel.dict.get("no-online-player"))));
|
||||
else sender.sendMessage(Text.prefix(Sentinel.dict.get("no-permission")));
|
||||
} else if (r == null) p.sendMessage(Text.prefix((Sentinel.language.get("no-online-player"))));
|
||||
else sender.sendMessage(Text.prefix(Sentinel.language.get("no-permission")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,16 +17,16 @@ public class ReopCommand implements CustomCommand {
|
||||
Player p = (Player) sender;
|
||||
if (Sentinel.isTrusted(p)) {
|
||||
if (!p.isOp()) {
|
||||
p.sendMessage(Text.prefix(Sentinel.dict.get("elevating-perms")));
|
||||
Sentinel.log.info(Sentinel.dict.get("log-elevating-perms").formatted(p.getName()));
|
||||
p.sendMessage(Text.prefix(Sentinel.language.get("elevating-perms")));
|
||||
Sentinel.log.info(Sentinel.language.get("log-elevating-perms").formatted(p.getName()));
|
||||
p.setOp(true);
|
||||
} else {
|
||||
p.sendMessage(Text.prefix(Sentinel.dict.get("already-op")));
|
||||
Sentinel.log.info(Sentinel.dict.get("log-already-op").formatted(p.getName()));
|
||||
p.sendMessage(Text.prefix(Sentinel.language.get("already-op")));
|
||||
Sentinel.log.info(Sentinel.language.get("log-already-op").formatted(p.getName()));
|
||||
p.setOp(true);
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(Text.prefix(Sentinel.dict.get("no-trust")));
|
||||
p.sendMessage(Text.prefix(Sentinel.language.get("no-trust")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,19 +23,19 @@ public class ReplyCommand implements CustomCommand {
|
||||
Player p = sender.getServer().getPlayer(name);
|
||||
UUID senderID = p.getUniqueId();
|
||||
if (replyMap.get(senderID) == null) {
|
||||
p.sendMessage(Text.prefix(Sentinel.dict.get("no-user-reply")));
|
||||
p.sendMessage(Text.prefix(Sentinel.language.get("no-user-reply")));
|
||||
}
|
||||
Player r = sender.getServer().getPlayer(replyMap.get(senderID));
|
||||
UUID reciverID = r.getUniqueId();
|
||||
if (args.get(0).toString() == null) {
|
||||
p.sendMessage(Text.prefix(Sentinel.dict.get("no-message-provided")));
|
||||
p.sendMessage(Text.prefix(Sentinel.language.get("no-message-provided")));
|
||||
}
|
||||
String msg = args.getAll().toString();
|
||||
if (p.hasPermission("sentinel.message")) {
|
||||
Message.messagePlayer(p,r,msg);
|
||||
replyMap.put(senderID,reciverID);
|
||||
} else {
|
||||
sender.sendMessage(Text.prefix(Sentinel.dict.get("no-permission")));
|
||||
sender.sendMessage(Text.prefix(Sentinel.language.get("no-permission")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||
import io.github.thetrouper.sentinel.server.util.Text;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -46,7 +45,7 @@ public class SentinelCommand implements CustomCommand {
|
||||
io.github.thetrouper.sentinel.server.functions.AntiSpam.handleAntiSpam(e);
|
||||
}
|
||||
case "lang" -> {
|
||||
p.sendMessage(Sentinel.dict.get("exmaple-message"));
|
||||
p.sendMessage(Sentinel.language.get("exmaple-message"));
|
||||
}
|
||||
case "toggle" -> {
|
||||
debugMode = !debugMode;
|
||||
|
||||
@@ -24,10 +24,10 @@ public class SocialSpyCommand implements CustomCommand {
|
||||
Player p = sender.getServer().getPlayer(name);
|
||||
UUID senderID = p.getUniqueId();
|
||||
if (!spyMap.containsKey(senderID) || !spyMap.get(senderID)) {
|
||||
sender.sendMessage(Text.prefix(Sentinel.dict.get("spy-enabled")));
|
||||
sender.sendMessage(Text.prefix(Sentinel.language.get("spy-enabled")));
|
||||
spyMap.put(senderID,true);
|
||||
} else if (spyMap.get(senderID)) {
|
||||
sender.sendMessage(Text.prefix(Sentinel.dict.get("spy-disabled")));
|
||||
sender.sendMessage(Text.prefix(Sentinel.language.get("spy-disabled")));
|
||||
spyMap.put(senderID,false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.github.thetrouper.sentinel.server.config;
|
||||
package io.github.thetrouper.sentinel.data.config;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.github.thetrouper.sentinel.server.config;
|
||||
package io.github.thetrouper.sentinel.data.config;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package io.github.thetrouper.sentinel.data.config;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LanguageFile implements JsonSerializable<LanguageFile> {
|
||||
public static final File PATH = new File(Sentinel.getInstance().getDataFolder(), "/lang/" + Sentinel.mainConfig.plugin.lang);
|
||||
private final Map<String,String> dictionary = new HashMap<>() {{
|
||||
put("if-you-see-this-lang-is-broken", "Sentinel language is working!");
|
||||
put("no-permission", "§cInsufficient Permissions!");
|
||||
put("cooldown", "This action is on cooldown!");
|
||||
put("false-positive-report-success", "Successfully reported a false positive!");
|
||||
put("no-online-player", "§cYou must provide an online player to send a message to!");
|
||||
put("no-message-provided", "§cYou must provide a message to send!");
|
||||
put("elevating-perms", "Elevating your permissions...");
|
||||
put("log-elevating-perms", "Elevating the permissions of %s");
|
||||
put("already-op", "You are already a server operator!");
|
||||
put("log-already-op", "The permissions of %s are already elevated! Retrying...");
|
||||
put("no-trust", "You are not a trusted user!");
|
||||
put("no-user-reply", "§cYou have nobody to reply to!");
|
||||
put("spy-enabled", "SocialSpy is now enabled.");
|
||||
put("spy-disabled", "SocialSpy is now disabled.");
|
||||
put("action-automatic", "§7This action was preformed automatically\n§7by the §bSentinel Anti-Spam§7 algorithm.");
|
||||
put("action-automatic-reportable", "§7This action was preformed automatically \n§7by the §bSentinel Profanity Filter§7 algorithm!\n§8§o(Click to report false positive)");
|
||||
put("unicode-warn", "§cDo not send non-standard unicode in chat!");
|
||||
put("message-sent", "§d§lMessage §8» §b[§fYou §e>§f %1$s§b] §7%2$s");
|
||||
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-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("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() {}
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
return PATH;
|
||||
}
|
||||
public String get(String key) {
|
||||
return dictionary.getOrDefault(key,key);
|
||||
}
|
||||
public Map<String, String> getDictionary() {
|
||||
return dictionary;
|
||||
}
|
||||
public String format(String input) {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.github.thetrouper.sentinel.server.config;
|
||||
package io.github.thetrouper.sentinel.data.config;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package io.github.thetrouper.sentinel.server.config;
|
||||
package io.github.thetrouper.sentinel.data.config;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.FileValidationUtils;
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
||||
public class NBTConfig implements JsonSerializable<NBTConfig> {
|
||||
@Override
|
||||
@@ -18,6 +15,7 @@ public class NBTConfig implements JsonSerializable<NBTConfig> {
|
||||
public boolean allowName = true;
|
||||
public boolean allowLore = true;
|
||||
public boolean allowAttributes = false;
|
||||
public boolean allowPotions = false;
|
||||
public int globalMaxEnchant = 5;
|
||||
public int maxMending = 1;
|
||||
public int maxUnbreaking = 3;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.github.thetrouper.sentinel.server.config;
|
||||
package io.github.thetrouper.sentinel.data.config;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.github.thetrouper.sentinel.server.config;
|
||||
package io.github.thetrouper.sentinel.data.config;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
|
||||
@@ -12,6 +12,8 @@ import java.util.*;
|
||||
/**
|
||||
* Class used to execute Discord Webhooks with low effort
|
||||
*/
|
||||
|
||||
@Deprecated
|
||||
public class DiscordWebhook {
|
||||
|
||||
private final String url;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package io.github.thetrouper.sentinel.discord;
|
||||
|
||||
public class Webhook {
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.Action;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -33,6 +32,7 @@ public class CMDBlockPlace implements CustomListener {
|
||||
.setBlock(b)
|
||||
.setPlayer(p)
|
||||
.setDenied(true)
|
||||
.setDeoped(Sentinel.mainConfig.plugin.deop)
|
||||
.setPunished(Sentinel.mainConfig.plugin.cmdBlockPunish)
|
||||
.setnotifyDiscord(Sentinel.mainConfig.plugin.logCmdBlocks)
|
||||
.setNotifyTrusted(true)
|
||||
|
||||
@@ -4,7 +4,6 @@ import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.Action;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
@@ -4,7 +4,6 @@ import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.Action;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -4,7 +4,6 @@ import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.Action;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -32,6 +31,7 @@ public class CMDMinecartUse implements CustomListener {
|
||||
.setDenied(true)
|
||||
.setPunished(Sentinel.mainConfig.plugin.cmdBlockPunish)
|
||||
.setnotifyDiscord(Sentinel.mainConfig.plugin.logCmdBlocks)
|
||||
.setDeoped(Sentinel.mainConfig.plugin.deop)
|
||||
.setNotifyTrusted(true)
|
||||
.setNotifyConsole(true)
|
||||
.execute();
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.github.thetrouper.sentinel.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
||||
import io.github.thetrouper.sentinel.server.functions.AntiUnicode;
|
||||
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||
|
||||
@@ -4,7 +4,6 @@ import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.Action;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@@ -4,8 +4,6 @@ import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.Action;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.config.NBTConfig;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -127,6 +125,10 @@ public class NBTEvents implements CustomListener {
|
||||
ServerUtils.sendDebugMessage("NBT: No Pass L ");
|
||||
return false;
|
||||
}
|
||||
if (!Sentinel.nbtConfig.allowPotions && (i.getType().equals(Material.POTION) || i.getType().equals(Material.SPLASH_POTION) || i.getType().equals(Material.LINGERING_POTION))) {
|
||||
ServerUtils.sendDebugMessage("NBT: No pass P");
|
||||
return false;
|
||||
}
|
||||
if (!Sentinel.nbtConfig.allowAttributes && meta.hasAttributeModifiers()) {
|
||||
ServerUtils.sendDebugMessage("NBT: No pass A");
|
||||
return false;
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
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.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.data.Emojis;
|
||||
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.util.FileUtils;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import io.github.thetrouper.sentinel.server.util.Text;
|
||||
@@ -99,7 +102,7 @@ public class Action {
|
||||
public Action execute() {
|
||||
String actionTop = action.getMessageTop();
|
||||
String actionTitle = action.getMessageTitle();
|
||||
String itemLog = (item != null) ? FileUtils.createNBTLog(item.getItemMeta().getAsString()) : "";
|
||||
String itemLog = (item != null && item.hasItemMeta() && item.getItemMeta().getAsString() != null) ? FileUtils.createNBTLog(item) : "";
|
||||
String commandLog = (loggedCommand != null) ? FileUtils.createCommandLog(loggedCommand) : "";
|
||||
|
||||
final List<String> punishCommands = Sentinel.mainConfig.plugin.punishCommands;
|
||||
@@ -159,9 +162,7 @@ public class Action {
|
||||
}
|
||||
|
||||
if (notifyDiscord) {
|
||||
DiscordWebhook webhook = new DiscordWebhook(Sentinel.mainConfig.plugin.webhook);
|
||||
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
|
||||
webhook.setUsername("Sentinel Anti-Nuke | Logs");
|
||||
|
||||
String description = (player != null) ? Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\n" : "";
|
||||
description += (command != null) ? ((loggedCommand != null && loggedCommand.length() > 128) ? Emojis.rightSort + " **Command:** Too long to show here! " + Emojis.nuke + "\n | Saved to file: " + commandLog + "\n" : Emojis.rightSort + " **Command:** " + command + " " + Emojis.nuke + "\n") : "";
|
||||
description += (item != null) ? Emojis.rightSort + " **Item:** " + item.getType().toString().toLowerCase() + " " + Emojis.nuke + "\n" + Emojis.space + Emojis.rightDoubleArrow + "**NBT:** Uploaded to /Sentinel/LoggedNBT/" + itemLog : "";
|
||||
@@ -171,18 +172,24 @@ public class Action {
|
||||
actions += Emojis.rightSort + " **Punished:** " + (punished ? Emojis.success : Emojis.failure) + "\n";
|
||||
actions += (revertGM) ? Emojis.rightSort + " **GM Reverted:** " + Emojis.success + "\n" : "";
|
||||
actions += Emojis.rightSort + " **Logged:** " + Emojis.success;
|
||||
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
|
||||
.setAuthor(actionTop, "", "")
|
||||
.setTitle(actionTitle)
|
||||
.setDescription(description)
|
||||
.addField("Actions:", actions, false)
|
||||
.setThumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay")
|
||||
.setColor(action.getEmbedColor());
|
||||
webhook.addEmbed(embed);
|
||||
|
||||
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...");
|
||||
webhook.execute();
|
||||
} catch (IOException e) {
|
||||
Sentinel.webclient.send(message);
|
||||
} catch (Exception e) {
|
||||
ServerUtils.sendDebugMessage(Text.prefix("Epic webhook failure!!!"));
|
||||
Sentinel.log.info(e.toString());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
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.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Emojis;
|
||||
import io.github.thetrouper.sentinel.data.FAT;
|
||||
@@ -24,20 +28,20 @@ import static io.github.thetrouper.sentinel.server.functions.ProfanityFilter.*;
|
||||
|
||||
public class FilterAction {
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
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);
|
||||
|
||||
TextComponent warn = createTextComponent(Text.prefix(Sentinel.dict.get(type.getWarnTranslationKey())));
|
||||
warn.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("action-automatic-reportable"))));
|
||||
TextComponent warn = createTextComponent(Text.prefix(Sentinel.language.get(type.getWarnTranslationKey())));
|
||||
warn.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("action-automatic-reportable"))));
|
||||
warn.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + report));
|
||||
|
||||
TextComponent notif = createTextComponent(Text.prefix((type != FAT.SPAM_PUNISH && type != FAT.BLOCK_SPAM ?
|
||||
Sentinel.dict.get("severity-notification-hover").formatted(e.getMessage(), highlighted, severity.name().toLowerCase().replace("_"," ")) :
|
||||
Sentinel.dict.get("spam-notification-hover").formatted(e.getMessage(), lastMessageMap.get(offender), fs.format(similarity)))));
|
||||
notif.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("severity-notification-hover"))));
|
||||
Sentinel.language.get("severity-notification-hover").formatted(e.getMessage(), highlighted, severity.name().toLowerCase().replace("_"," ")) :
|
||||
Sentinel.language.get("spam-notification-hover").formatted(e.getMessage(), lastMessageMap.get(offender), fs.format(similarity)))));
|
||||
notif.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("severity-notification-hover"))));
|
||||
notif.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + report));
|
||||
|
||||
sendMessages(offender, warn, notif, type);
|
||||
@@ -51,7 +55,7 @@ public class FilterAction {
|
||||
private static void sendMessages(Player offender, TextComponent warn, TextComponent notif, FAT type) {
|
||||
offender.spigot().sendMessage(warn);
|
||||
|
||||
String notifText = Sentinel.dict.get(type.getNotifTranslationKey());
|
||||
String notifText = Sentinel.language.get(type.getNotifTranslationKey());
|
||||
notif.setText(Text.prefix((type != FAT.SPAM_PUNISH && type != FAT.BLOCK_SPAM ?
|
||||
notifText.formatted(offender.getName(), scoreMap.get(offender), Sentinel.mainConfig.chat.antiSwear.punishScore) :
|
||||
notifText.formatted(offender.getName(), heatMap.get(offender), Sentinel.mainConfig.chat.antiSpam.punishHeat))));
|
||||
@@ -74,75 +78,83 @@ public class FilterAction {
|
||||
|| (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) {
|
||||
String log = "]=-" + type.getTitle() + "-=[\n" +
|
||||
"Player: " + offender.getName() +
|
||||
(type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "> Score: `" + scoreMap.get(offender) + "/" + Sentinel.mainConfig.chat.antiSwear.punishScore :
|
||||
"> Heat: `" + heatMap.get(offender) + "/" + Sentinel.mainConfig.chat.antiSpam.punishHeat) + "\n" +
|
||||
"> UUID: " + offender.getUniqueId() + "\n" +
|
||||
(type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Message: " + e.getMessage() : "Previous: " + lastMessageMap.get(offender)) + "\n" +
|
||||
(type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Reduced: " + fullSimplify(e.getMessage()) : "Current: " + 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);
|
||||
StringBuilder log = new StringBuilder().append("\"]=-\" + type.getTitle() + \"-=[\\n\"");
|
||||
log.append("Player: " + offender.getName());
|
||||
log.append(type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "> Score: `" + scoreMap.get(offender) + "/" + Sentinel.mainConfig.chat.antiSwear.punishScore :
|
||||
"> 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.");
|
||||
|
||||
Sentinel.log.info(String.valueOf(log));
|
||||
}
|
||||
|
||||
private static void sendDiscordLog(Player offender, AsyncPlayerChatEvent e, FAT type) {
|
||||
String supertitle = type.getTitle();
|
||||
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.";
|
||||
|
||||
DiscordWebhook webhook = new DiscordWebhook(Sentinel.mainConfig.plugin.webhook);
|
||||
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
|
||||
webhook.setUsername("Sentinel Anti-Nuke | Logs");
|
||||
String description =
|
||||
Emojis.rightSort + "Player: " + offender.getName() + " " + Emojis.target + "\\n" +
|
||||
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";
|
||||
|
||||
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
|
||||
.setAuthor(supertitle, "", "")
|
||||
.setTitle(title)
|
||||
.setDescription(
|
||||
Emojis.rightSort + "Player: " + offender.getName() + " " + Emojis.target + "\\n" +
|
||||
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"
|
||||
)
|
||||
.addField((type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Message: " : "Previous: "),
|
||||
(type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? e.getMessage() : lastMessageMap.get(offender)) + Emojis.alarm, false)
|
||||
.addField((type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Reduced: " : "Current: "),
|
||||
(type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? highlightProfanity(e.getMessage(), "||", "||") : e.getMessage()) + " " + Emojis.noDM, false)
|
||||
.setColor(type.getColor())
|
||||
.setThumbnail("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay");
|
||||
String historyTitle = (type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Message: " : "Previous: ");
|
||||
String historyValue = (type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? e.getMessage() : lastMessageMap.get(offender)) + Emojis.alarm;
|
||||
|
||||
webhook.addEmbed(embed);
|
||||
String currentTitle = (type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? "Reduced: " : "Current: ");
|
||||
String currentValue = (type != FAT.BLOCK_SPAM && type != FAT.SPAM_PUNISH ? highlightProfanity(e.getMessage(), "||", "||") : e.getMessage()) + " " + Emojis.noDM;
|
||||
|
||||
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(description)
|
||||
.addField(new WebhookEmbed.EmbedField(false,historyTitle,historyValue))
|
||||
.addField(new WebhookEmbed.EmbedField(false,currentTitle,currentValue))
|
||||
.setThumbnailUrl("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay")
|
||||
.setColor(type.getColor().getRGB())
|
||||
.build())
|
||||
.build();
|
||||
|
||||
try {
|
||||
ServerUtils.sendDebugMessage("Executing webhook...");
|
||||
webhook.execute();
|
||||
} catch (IOException ex) {
|
||||
Sentinel.webclient.send(message);
|
||||
} catch (Exception ex) {
|
||||
ServerUtils.sendDebugMessage("Filter Actions: Epic webhook failure!!!");
|
||||
Sentinel.log.info(ex.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
public static void filterAction(Player offender, AsyncPlayerChatEvent e, String highlighted, String severity, Double similarity, 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.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("action-automatic-reportable"))));
|
||||
warn.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + report));
|
||||
|
||||
DecimalFormat fs = new DecimalFormat("##.#");
|
||||
fs.setRoundingMode(RoundingMode.DOWN);
|
||||
|
||||
TextComponent notif = new TextComponent();
|
||||
notif.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText((type != FAT.SPAM_PUNISH && type != FAT.BLOCK_SPAM ? Sentinel.dict.get("severity-notification-hover").formatted(e.getMessage(), highlighted, severity) : Sentinel.dict.get("spam-notification-hover").formatted(e.getMessage(),lastMessageMap.get(offender),fs.format(similarity))))));
|
||||
notif.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText((type != FAT.SPAM_PUNISH && type != FAT.BLOCK_SPAM ? Sentinel.language.get("severity-notification-hover").formatted(e.getMessage(), highlighted, severity) : Sentinel.language.get("spam-notification-hover").formatted(e.getMessage(),lastMessageMap.get(offender),fs.format(similarity))))));
|
||||
notif.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + report));
|
||||
|
||||
warn.setText(Text.prefix(Sentinel.dict.get(type.getWarnTranslationKey())));
|
||||
warn.setText(Text.prefix(Sentinel.language.get(type.getWarnTranslationKey())));
|
||||
offender.spigot().sendMessage(warn);
|
||||
|
||||
String notiftext = Sentinel.dict.get(type.getNotifTranslationKey());
|
||||
String notiftext = Sentinel.language.get(type.getNotifTranslationKey());
|
||||
|
||||
notif.setText(Text.prefix((type != FAT.SPAM_PUNISH && type != FAT.BLOCK_SPAM ? notiftext.formatted(offender.getName(), scoreMap.get(offender), Sentinel.mainConfig.chat.antiSwear.punishScore) : notiftext.formatted(offender.getName(),heatMap.get(offender),Sentinel.mainConfig.chat.antiSpam.punishHeat))));
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package io.github.thetrouper.sentinel.server.config;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class LanguageFile implements JsonSerializable<LanguageFile> {
|
||||
public static final File PATH = new File(Sentinel.getInstance().getDataFolder(), "/lang/" + Sentinel.mainConfig.plugin.lang);
|
||||
private final Map<String,String> dictionary = new HashMap<>();
|
||||
public LanguageFile() {}
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
return PATH;
|
||||
}
|
||||
public String get(String key) {
|
||||
return dictionary.getOrDefault(key,key);
|
||||
}
|
||||
public Map<String, String> getDictionary() {
|
||||
return dictionary;
|
||||
}
|
||||
public String format(String input) {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ public class AdvancedBlockers {
|
||||
|
||||
}
|
||||
if (nonAllowed.length() != 0) {
|
||||
e.getPlayer().sendMessage(Text.prefix(Sentinel.dict.get("unicode-warn")));
|
||||
e.getPlayer().sendMessage(Text.prefix(Sentinel.language.get("unicode-warn")));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,11 +82,11 @@ public class AntiSpam {
|
||||
DecimalFormat fs = new DecimalFormat("##.#");
|
||||
fs.setRoundingMode(RoundingMode.DOWN);
|
||||
TextComponent warning = new TextComponent();
|
||||
warning.setText(Text.prefix(Sentinel.dict.get("spam-warning")));
|
||||
warning.setText(Text.prefix(Sentinel.language.get("spam-warning")));
|
||||
warning.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("action-automatic")));
|
||||
p.spigot().sendMessage(warning);
|
||||
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(Sentinel.dict.get("spam-notification-hover").formatted(message1,message2,fs.format(similarity)))));
|
||||
text.setText(Text.prefix(Sentinel.language.get("spam-notification").formatted(p.getName(),heatMap.get(p),Config.punishHeat)));
|
||||
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("spam-notification-hover").formatted(message1,message2,fs.format(similarity)))));
|
||||
ServerUtils.forEachStaff(staff -> {
|
||||
staff.spigot().sendMessage(text);
|
||||
});
|
||||
@@ -99,11 +99,11 @@ public class AntiSpam {
|
||||
}
|
||||
ServerUtils.sendCommand(Config.spamPunishCommand.replace("%player%", p.getName()));
|
||||
TextComponent warning = new TextComponent();
|
||||
warning.setText(Text.prefix(Sentinel.dict.get("spam-punished")));
|
||||
warning.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.dict.get("action-automatic"))));
|
||||
warning.setText(Text.prefix(Sentinel.language.get("spam-punished")));
|
||||
warning.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("action-automatic"))));
|
||||
p.spigot().sendMessage(warning);
|
||||
TextComponent text = new TextComponent();
|
||||
text.setText(Text.prefix(Sentinel.dict.get("spam-punish-notification").formatted(p.getName(),heatMap.get(p),Config.punishHeat)));
|
||||
text.setText(Text.prefix(Sentinel.language.get("spam-punish-notification").formatted(p.getName(),heatMap.get(p),Config.punishHeat)));
|
||||
ServerUtils.forEachStaff(staff -> {
|
||||
staff.spigot().sendMessage(text);
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ public class AntiUnicode {
|
||||
|
||||
}
|
||||
if (nonAllowed.length() != 0) {
|
||||
e.getPlayer().sendMessage(Text.prefix(Sentinel.dict.get("unicode-warn")));
|
||||
e.getPlayer().sendMessage(Text.prefix(Sentinel.language.get("unicode-warn")));
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
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;
|
||||
|
||||
public class Authenticator {
|
||||
|
||||
public Authenticator() throws UnknownHostException {
|
||||
}
|
||||
private static final String ENCRYPTION_KEY = "lllIIlllIlSentinelAuthIllIllllII";
|
||||
private static final String ENCRYPTION_ALGORITHM = "AES";
|
||||
private static final String ENCRYPTION_MODE_PADDING = "AES/ECB/PKCS5Padding";
|
||||
static InetAddress IP;
|
||||
|
||||
static {
|
||||
public static String getServerID() {
|
||||
try {
|
||||
IP = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
return MathUtils.SHA512(getPublicIPAddress());
|
||||
} catch (IOException e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,31 +93,34 @@ public class Authenticator {
|
||||
|
||||
|
||||
|
||||
public static String getServerID() {
|
||||
return encrypt(IP.getHostAddress());
|
||||
}
|
||||
public static String getPublicIPAddress() throws IOException {
|
||||
String apiUrl = "http://checkip.amazonaws.com";
|
||||
|
||||
URL url = new URL(apiUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
public static String encrypt(String text) {
|
||||
try {
|
||||
SecretKeySpec secretKey = new SecretKeySpec(ENCRYPTION_KEY.getBytes(), ENCRYPTION_ALGORITHM);
|
||||
Cipher cipher = Cipher.getInstance(ENCRYPTION_MODE_PADDING);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||
connection.setRequestMethod("GET");
|
||||
|
||||
byte[] encryptedBytes = cipher.doFinal(text.getBytes());
|
||||
String encryptedText = bytesToHex(encryptedBytes);
|
||||
return encryptedText;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "ERR";
|
||||
}
|
||||
int responseCode = connection.getResponseCode();
|
||||
|
||||
private static String bytesToHex(byte[] bytes) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
StringBuilder response = new StringBuilder();
|
||||
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
}
|
||||
|
||||
reader.close();
|
||||
|
||||
return response.toString().trim();
|
||||
} else {
|
||||
throw new IOException("Failed to get public IP address. HTTP error code: " + responseCode);
|
||||
}
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.github.thetrouper.sentinel.server.functions;
|
||||
import io.github.itzispyder.pdk.utils.ServerUtils;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.cmds.SocialSpyCommand;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
@@ -28,8 +27,8 @@ public class Message {
|
||||
if (!Sentinel.isTrusted(sender) || !sender.hasPermission("sentinel.chat.antiunicode.bypass")) if (Sentinel.mainConfig.chat.antiUnicode) AntiUnicode.handleAntiUnicode(checkEvent);
|
||||
if (checkEvent.isCancelled()) return;
|
||||
|
||||
sender.sendMessage(Sentinel.dict.get("message-sent").formatted(receiver.getName(),message));
|
||||
receiver.sendMessage(Sentinel.dict.get("message-received").formatted(sender.getName(),message));
|
||||
sender.sendMessage(Sentinel.language.get("message-sent").formatted(receiver.getName(),message));
|
||||
receiver.sendMessage(Sentinel.language.get("message-received").formatted(sender.getName(),message));
|
||||
replyMap.put(receiver.getUniqueId(),sender.getUniqueId());
|
||||
sendSpy(sender,receiver,message);
|
||||
}
|
||||
@@ -37,8 +36,8 @@ public class Message {
|
||||
public static void sendSpy(Player sender, Player receiver, String message) {
|
||||
ServerUtils.forEachPlayer(player -> {
|
||||
if (SocialSpyCommand.spyMap.getOrDefault(player.getUniqueId(),false)) {
|
||||
TextComponent notification = new TextComponent(Sentinel.dict.get("spy-message").formatted(sender.getName(),receiver.getName()));
|
||||
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(Sentinel.dict.get("spy-message-hover").formatted(sender.getName(),receiver.getName(),message))));
|
||||
TextComponent notification = new TextComponent(Sentinel.language.get("spy-message").formatted(sender.getName(),receiver.getName()));
|
||||
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(Sentinel.language.get("spy-message-hover").formatted(sender.getName(),receiver.getName(),message))));
|
||||
player.spigot().sendMessage(notification);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -264,15 +264,15 @@ public class ProfanityFilter {
|
||||
ServerUtils.sendCommand(Config.swearPunishCommand.replace("%player%", player.getName()));
|
||||
String fpreport = ReportFalsePositives.generateReport(e);
|
||||
TextComponent offender = new TextComponent();
|
||||
String hoverPlayer = Sentinel.dict.get("action-automatic-reportable");
|
||||
offender.setText(Text.prefix(Sentinel.dict.get("profanity-mute-warn")));
|
||||
String hoverPlayer = Sentinel.language.get("action-automatic-reportable");
|
||||
offender.setText(Text.prefix(Sentinel.language.get("profanity-mute-warn")));
|
||||
offender.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hoverPlayer)));
|
||||
offender.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport));
|
||||
player.spigot().sendMessage(offender);
|
||||
|
||||
TextComponent text = new TextComponent();
|
||||
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(Sentinel.dict.get("filter-notification-hover").formatted(origMessage,highlightedMSG))));
|
||||
text.setText(Text.prefix(Sentinel.language.get("profanity-mute-notification").formatted(player.getName(),scoreMap.get(player),Config.punishScore)));
|
||||
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("filter-notification-hover").formatted(origMessage,highlightedMSG))));
|
||||
text.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport));
|
||||
|
||||
ServerUtils.forEachStaff(staff -> {
|
||||
@@ -288,14 +288,14 @@ public class ProfanityFilter {
|
||||
ServerUtils.sendCommand(Config.strictPunishCommand.replace("%player%", player.getName()));
|
||||
String fpreport = ReportFalsePositives.generateReport(e);
|
||||
TextComponent offender = new TextComponent();
|
||||
String hoverPlayer = Sentinel.dict.get("action-automatic-reportable");
|
||||
offender.setText(Text.prefix((Sentinel.dict.get("slur-mute-warn"))));
|
||||
String hoverPlayer = Sentinel.language.get("action-automatic-reportable");
|
||||
offender.setText(Text.prefix((Sentinel.language.get("slur-mute-warn"))));
|
||||
offender.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hoverPlayer)));
|
||||
offender.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport));
|
||||
player.spigot().sendMessage(offender);
|
||||
TextComponent text = new TextComponent();
|
||||
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(Sentinel.dict.get("filter-notification-hover").formatted(origMessage,highlightedMSG))));
|
||||
text.setText(Text.prefix(Sentinel.language.get("slur-mute-notification").formatted(player.getName(),scoreMap.get(player),Config.punishScore)));
|
||||
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("filter-notification-hover").formatted(origMessage,highlightedMSG))));
|
||||
text.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + fpreport));
|
||||
|
||||
ServerUtils.forEachStaff(staff -> {
|
||||
@@ -306,15 +306,15 @@ public class ProfanityFilter {
|
||||
public static void blockSwear(Player player, String highlightedMSG, String origMessage, String severity, AsyncPlayerChatEvent e) {
|
||||
String FPReport = ReportFalsePositives.generateReport(e);
|
||||
TextComponent offender = new TextComponent();
|
||||
String hover = Sentinel.dict.get("action-automatic-reportable");
|
||||
offender.setText(Text.prefix((Sentinel.dict.get("swear-block-warn"))));
|
||||
String hover = Sentinel.language.get("action-automatic-reportable");
|
||||
offender.setText(Text.prefix((Sentinel.language.get("swear-block-warn"))));
|
||||
offender.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
|
||||
offender.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + FPReport));
|
||||
player.spigot().sendMessage(offender);
|
||||
|
||||
TextComponent staff = new TextComponent();
|
||||
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(Sentinel.dict.get("severity-notification-hover").formatted(origMessage,highlightedMSG,severity))));
|
||||
staff.setText(Text.prefix(Sentinel.language.get("swear-block-notification").formatted(player.getName(),scoreMap.get(player),Config.punishScore)));
|
||||
staff.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(Sentinel.language.get("severity-notification-hover").formatted(origMessage,highlightedMSG,severity))));
|
||||
staff.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sentinelcallback fpreport " + FPReport));
|
||||
|
||||
ServerUtils.forEachStaff(staffmember -> {
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.github.thetrouper.sentinel.server.functions;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Emojis;
|
||||
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
|
||||
import io.github.thetrouper.sentinel.server.config.MainConfig;
|
||||
import io.github.thetrouper.sentinel.server.util.Randomizer;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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;
|
||||
import java.io.File;
|
||||
@@ -44,6 +46,36 @@ public class FileUtils {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public static String createNBTLog(ItemStack i) {
|
||||
ServerUtils.sendDebugMessage("FileUtils: Creating NBT log");
|
||||
|
||||
String item = i.getType().name().toLowerCase() + i.getItemMeta().getAsString();
|
||||
|
||||
String fileName = "nbt_log-" + Randomizer.generateID();
|
||||
|
||||
File dataFolder = Sentinel.getInstance().getDataFolder();
|
||||
|
||||
File loggedNBTFolder = new File(dataFolder,"LoggedNBT");
|
||||
if (!loggedNBTFolder.exists()) {
|
||||
loggedNBTFolder.mkdirs();
|
||||
}
|
||||
|
||||
File file = new File(loggedNBTFolder, fileName + ".txt");
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
|
||||
writer.append(item);
|
||||
writer.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public static String createCommandLog(String command) {
|
||||
String fileName = "command_log-" + Randomizer.generateID();
|
||||
File file = new File(Sentinel.getInstance().getDataFolder() + "/LoggedCommands/" + fileName + ".txt");
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package io.github.thetrouper.sentinel.server.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -20,4 +23,36 @@ public final class MathUtils {
|
||||
public static double round(double value, int nthPlace) {
|
||||
return Math.floor(value * nthPlace) / nthPlace;
|
||||
}
|
||||
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String SHA512(String input) {
|
||||
try {
|
||||
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
|
||||
|
||||
byte[] encodedHash = digest.digest(input.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
StringBuilder hexString = new StringBuilder(2 * encodedHash.length);
|
||||
for (byte b : encodedHash) {
|
||||
String hex = Integer.toHexString(0xff & b);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
|
||||
return hexString.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.github.thetrouper.sentinel.server.util;
|
||||
|
||||
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.server.config.AdvancedConfig;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
@@ -14,7 +13,7 @@ public class Text {
|
||||
return msg.replace('&', SECTION_SYMBOL);
|
||||
}
|
||||
public static String prefix(String text) {
|
||||
String prefix = Sentinel.prefix;
|
||||
String prefix = Sentinel.mainConfig.plugin.prefix;
|
||||
return color(prefix + text);
|
||||
}
|
||||
public static String removeFirstColor(String input) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
config:
|
||||
plugin:
|
||||
key: "beta" # Put your license key here. If you do not have one, join the discord to verify your purchase
|
||||
lang: "en_us.json" # Languages
|
||||
lang: "en-us.json" # Languages
|
||||
# --------------------------------
|
||||
# Anti-Nuke Setup (Do this first)
|
||||
# --------------------------------
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
"dictionary" : { // Comment!
|
||||
"if-you-see-this-lang-is-broken" : "Sentinel language is working!", // Comment!
|
||||
"no-permission" : "§cInsufficient Permissions!",
|
||||
"cooldown" : "This action is on cooldown!",
|
||||
"false-positive-report-success" : "Successfully reported a false positive!",
|
||||
"no-online-player" : "§cYou must provide an online player to send a message to!",
|
||||
"no-message-provided" : "§cYou must provide a message to send!",
|
||||
"elevating-perms" : "Elevating your permissions...",
|
||||
"log-elevating-perms" : "Elevating the permissions of %s",
|
||||
"already-op" : "You are already a server operator!",
|
||||
"log-already-op" : "The permissions of %s are already elevated! Retrying...",
|
||||
"no-trust" : "You are not a trusted user!",
|
||||
"no-user-reply" : "§cYou have nobody to reply to!",
|
||||
"spy-enabled" : "SocialSpy is now enabled.",
|
||||
"spy-disabled" : "SocialSpy is now disabled.",
|
||||
"action-automatic" : "§7This action was preformed automatically\n§7by the §bSentinel Anti-Spam§7 algorithm.",
|
||||
"action-automatic-reportable" : "§7This action was preformed automatically \n§7by the §bSentinel Profanity Filter§7 algorithm!\n§8§o(Click to report false positive)",
|
||||
"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-received" : "§d§lMessage §8» §b[§f%1$s §e>§f You§b] §7%2$s",
|
||||
"spy-message" : "§d§lSpy §8» §b§n%1$s§7 has messaged §b§n%2$s§7.",
|
||||
"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)",
|
||||
"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)",
|
||||
"slur-mute-warn" : "§cYou have been insta-punished by the anti-slur! §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-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)",
|
||||
"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-block-warn" : "Do not spam in chat! Please wait before sending another message.",
|
||||
"spam-mute-warn" : "§cYou have been auto-punished for violating the anti-spam repetitively!",
|
||||
"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)",
|
||||
"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)",
|
||||
"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)"
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
{ // Comment!
|
||||
"plugin": {
|
||||
"license": "beta", // Here is a comment!
|
||||
"prefix": "§d§lSentinel §8» §7", // Here is another one!
|
||||
"webhook": "https://discord.com/api/webhooks/id/token",
|
||||
"lang": "en-us.json",
|
||||
"trustedPlayers": [
|
||||
"049460f7-21cb-42f5-8059-d42752bf406f"
|
||||
],
|
||||
"blockSpecific": true,
|
||||
"preventNBT": true,
|
||||
"preventCmdBlockPlace": true,
|
||||
"preventCmdBlockUse": true,
|
||||
"preventCmdBlockChange": true,
|
||||
"preventCmdCartPlace": true,
|
||||
"preventCmdCartUse": true,
|
||||
"cmdBlockOpCheck": true,
|
||||
"dangerous": [
|
||||
"op",
|
||||
"deop",
|
||||
"stop",
|
||||
"restart",
|
||||
"execute",
|
||||
"sudo",
|
||||
"esudo",
|
||||
"fill",
|
||||
"setblock",
|
||||
"data",
|
||||
"whitelist"
|
||||
],
|
||||
"logDangerous": true,
|
||||
"logCmdBlocks": true,
|
||||
"logNBT": true,
|
||||
"logSpecific": false,
|
||||
"logged": [
|
||||
"give",
|
||||
"item"
|
||||
],
|
||||
"deop": true,
|
||||
"nbtPunish": false,
|
||||
"cmdBlockPunish": false,
|
||||
"commandPunish": false,
|
||||
"specificPunish": false,
|
||||
"punishCommands": [
|
||||
"smite %player%",
|
||||
"ban %player% ]\u003d- Sentinel -\u003d[ You have been banned for attempting a dangerous action. If you believe this to be a mistake, please contact the server owner."
|
||||
],
|
||||
"reopCommand": false
|
||||
},
|
||||
"chat": {
|
||||
"antiSwear": {
|
||||
"antiSwearEnabled": true,
|
||||
"lowScore": 0,
|
||||
"mediumLowScore": 1,
|
||||
"mediumScore": 3,
|
||||
"mediumHighScore": 5,
|
||||
"highScore": 7,
|
||||
"scoreDecay": 3,
|
||||
"punishScore": 20,
|
||||
"strictInstaPunish": true,
|
||||
"swearPunishCommand": "mute %player% 15m Do not attempt to bypass the Profanity Filter",
|
||||
"strictPunishCommand": "mute %player% 1h Discriminatory speech is not tolerated on this server!",
|
||||
"logSwears": true
|
||||
},
|
||||
"antiSpam": {
|
||||
"antiSpamEnabled": true,
|
||||
"defaultGain": 1,
|
||||
"lowGain": 2,
|
||||
"mediumGain": 4,
|
||||
"highGain": 6,
|
||||
"heatDecay": 1,
|
||||
"blockHeat": 10,
|
||||
"punishHeat": 25,
|
||||
"clearChat": true,
|
||||
"chatClearCommand": "cc",
|
||||
"spamPunishCommand": "mute %player% 1m Please refrain from spamming!",
|
||||
"logSpam": true
|
||||
},
|
||||
"antiUnicode": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user