diff --git a/build.sh b/build.sh index dde8d98..ea309bc 100755 --- a/build.sh +++ b/build.sh @@ -8,9 +8,8 @@ if [ $? -eq 0 ]; then echo "Gradle build successful." # SFTP upload - SFTP_HOST="192.168.1.199" + SFTP_HOST="server" SFTP_USER="trouper" - SFTP_PASSWORD="Trouper12()1" SFTP_REMOTE_DIR="/home/trouper/docker/data/plugins/" # Create a temporary file with a unique name @@ -24,9 +23,7 @@ if [ $? -eq 0 ]; then echo "bye" >> "$TEMP_FILE" # Use sftp non-interactively with the specified commands - sftp -oStrictHostKeyChecking=no -oBatchMode=no -b "$TEMP_FILE" "$SFTP_USER@$SFTP_HOST" <{ - String superTitle = type.logTitle(); + String superTitle = type.logSuper(); String title = "%s has triggered the %s!".formatted(offender.getName(),type.logName()); boolean isSwear = type.equals(FilterActionType.SWEAR_BLOCK) || type.equals(FilterActionType.SWEAR_PUNISH) || type.equals(FilterActionType.SLUR_PUNISH); boolean isSpam = type.equals(FilterActionType.SPAM_BLOCK) || type.equals(FilterActionType.SPAM_PUNISH); @@ -156,7 +156,7 @@ public class FilterAction { public static void sendConsoleLog(FilterActionType type, Player offender, String message) { StringBuilder log = new StringBuilder(); - String superTitle = "\n]=- " + type.logTitle() + " -=["; + String superTitle = "\n]=- " + type.logSuper() + " -=["; String title = "\n%s has triggered the %s!\n".formatted(offender.getName(),type.logName()); boolean isSwear = type.equals(FilterActionType.SWEAR_BLOCK) || type.equals(FilterActionType.SWEAR_PUNISH) || type.equals(FilterActionType.SLUR_PUNISH); boolean isSpam = type.equals(FilterActionType.SPAM_BLOCK) || type.equals(FilterActionType.SPAM_PUNISH); diff --git a/src/main/java/io/github/thetrouper/sentinel/server/NewAction.java b/src/main/java/io/github/thetrouper/sentinel/server/NewAction.java index 2536030..8128f2c 100644 --- a/src/main/java/io/github/thetrouper/sentinel/server/NewAction.java +++ b/src/main/java/io/github/thetrouper/sentinel/server/NewAction.java @@ -1,6 +1,8 @@ package io.github.thetrouper.sentinel.server; +import io.github.itzispyder.pdk.plugin.builders.ItemBuilder; +import io.github.itzispyder.pdk.utils.SchedulerUtils; import io.github.itzispyder.pdk.utils.discord.DiscordEmbed; import io.github.itzispyder.pdk.utils.discord.DiscordWebhook; import io.github.thetrouper.sentinel.Sentinel; @@ -12,9 +14,13 @@ import io.github.thetrouper.sentinel.server.util.Text; import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.attribute.Attribute; import org.bukkit.block.Block; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import java.util.List; @@ -97,100 +103,7 @@ public class NewAction { return this; } public NewAction execute() { - String actionTop = action.getMessageTop(); - String actionTitle = action.getMessageTitle(); - String itemLog = (item != null && item.hasItemMeta() && item.getItemMeta().getAsString() != null) ? FileUtils.createNBTLog(item) : ""; - String commandLog = (loggedCommand != null) ? FileUtils.createCommandLog(loggedCommand) : ""; - final List punishCommands = Sentinel.mainConfig.plugin.punishCommands; - - if (denied) { - event.setCancelled(true); - } - - if (deoped) { - player.setOp(false); - } - - if (punished) { - for (String command : punishCommands) { - ServerUtils.sendCommand(command.replaceAll("%player%",player.getName())); - } - } - - if (revertGM) { - player.setGameMode(GameMode.SURVIVAL); - } - - if (notifyConsole) { - String conNotif = "]=- Sentinel -=[\n"; - conNotif += actionTop + "\n"; - conNotif += (player != null) ? "Player: " + player.getName() + "\n" : ""; - conNotif += (command != null) ? ((loggedCommand != null && loggedCommand.length() > 128) ? "Command: Too long to show here!\n | Saved to file: " + commandLog + "\n" : "Command: " + command + "\n") : ""; - conNotif += (item != null) ? "Item: /Sentinel/LoggedNBT/" + itemLog + "\n" : ""; - conNotif += (block != null) ? "Block: " + block.getType().toString().toLowerCase().replace("_", " ") + "\nLocation: " + block.getLocation().getX() + " " + block.getLocation().getY() + " " + block.getLocation().getZ() + "\n" : ""; - conNotif += "Denied: " + (denied ? "\u2714" : "\u2718") + "\n"; - conNotif += "Deoped: " + (deoped ? "\u2714" : "\u2718") + "\n"; - conNotif += "Punished: " + (punished ? "\u2714" : "\u2718") + "\n"; - conNotif += (revertGM) ? "RevertGM: \u2714\n" : ""; - conNotif += "Logged: " + (notifyDiscord ? "\u2714" : "\u2718"); - Sentinel.log.info(conNotif); - } - - if (notifyTrusted) { - TextComponent notification = new TextComponent(); - notification.setText(Text.prefix(" " + actionTop)); - String body = "&b]=- Sentinel -=[&f\n" + actionTitle + "&r\n"; - body += (player != null) ? "&fPlayer: &b" + player.getName() + "&r\n" : ""; - body += (command != null) ? ((loggedCommand != null && loggedCommand.length() > 64) ? "&fCommand: &cToo long to show here!&r\n &7&l| &fSaved to file: &b" + commandLog + "&r\n" : "&fCommand: &b" + command + "&r\n") : ""; - body += (item != null) ? "&fItem: &b/Sentinel/LoggedNBT/&b" + itemLog + "\n" : ""; - body += (block != null) ? "&fBlock: &b" + block.getType().toString().toLowerCase().replace("_", " ") + "\n&fLocation: &b" + block.getLocation().getX() + " " + block.getLocation().getY() + " " + block.getLocation().getZ() + "&r\n" : ""; - body += "&fDenied: &b" + (denied ? "&a\u2714" : "&c\u2718") + "&r\n"; - body += "&fDeoped: " + (deoped ? "&a\u2714" : "&c\u2718") + "&r\n"; - body += "&fPunished: " + (punished ? "&a\u2714" : "&c\u2718") + "&r\n"; - body += (revertGM) ? "&fRevertGM: &a\u2714\n" : ""; - body += "&fLogged: " + (notifyDiscord ? "&a\u2714" : "&c\u2718"); - notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new net.md_5.bungee.api.chat.hover.content.Text(Text.color(body)))); - ServerUtils.forEachPlayer(trusted -> { - if (Sentinel.isTrusted(trusted)) { - trusted.spigot().sendMessage(notification); - } - }); - } - - if (notifyDiscord) { - 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 : ""; - description += (block != null) ? Emojis.rightSort + " **Block:** " + block.getType().toString().toLowerCase() + " " + Emojis.nuke + "\n" + Emojis.space + Emojis.rightDoubleArrow + " **Location:** X: " + block.getX() + " Y: " + block.getY() + " Z: " + block.getZ() + "\n" : ""; - String actions = Emojis.rightSort + " **Denied:** " + (denied ? Emojis.success : Emojis.failure) + "\n"; - actions += Emojis.rightSort + " **De-oped:** " + (deoped ? Emojis.success : Emojis.failure) + "\n"; - 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; - - try { - String finalDescription = description; - String finalActions = actions; - CompletableFuture.runAsync(()->{ - ServerUtils.sendDebugMessage("Executing webhook..."); - DiscordWebhook.create() - .username("Sentinel Anti-Nuke | Logs") - .avatar("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png") - .addEmbed(DiscordEmbed.create() - .author(new DiscordEmbed.Author(actionTop,"https://builtbybit.com/resources/sentinel-anti-nuke.30130/",null)) - .title(actionTitle) - .desc(finalDescription) - .addField(new DiscordEmbed.Field("Actions:", finalActions,false)) - .thumbnail("https://crafatar.com/avatars/" + (player == null ? "049460f7-21cb-42f5-8059-d42752bf406f" : player.getUniqueId()) + "?size=64&&overlay") - .color(action.getEmbedColor()) - .build()).send(Sentinel.mainConfig.plugin.webhook); - }); - } catch (Exception e) { - ServerUtils.sendDebugMessage(Text.prefix("Epic webhook failure!!!")); - Sentinel.log.info(e.toString()); - } - } return new NewAction(event, action, player, command, loggedCommand, item, block, denied, deoped, punished, revertGM, notifyDiscord, notifyTrusted, notifyConsole); } diff --git a/src/main/java/io/github/thetrouper/sentinel/server/functions/ProfanityFilter.java b/src/main/java/io/github/thetrouper/sentinel/server/functions/ProfanityFilter.java index 138afcd..2b0422c 100644 --- a/src/main/java/io/github/thetrouper/sentinel/server/functions/ProfanityFilter.java +++ b/src/main/java/io/github/thetrouper/sentinel/server/functions/ProfanityFilter.java @@ -51,14 +51,6 @@ public class ProfanityFilter { }; } - private static FAT getFAT(FilterSeverity severity) { - return switch (severity) { - case SAFE -> FAT.SAFE; - case LOW, MEDIUM_LOW, MEDIUM, MEDIUM_HIGH, HIGH -> FAT.BLOCK_SWEAR; - case SLUR -> FAT.SLUR_PUNISH; - }; - } - public static String highlightProfanity(String text) { return highlightProfanity(text, "&e", "&f"); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3d5879c..2229c36 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -24,6 +24,9 @@ permissions: sentinel.chat.antiswear.bypass: description: Bypass the antiSwear default: op + sentinel.chat.antiswear.edit: + description: Add a false positive to the config + default: op sentinel.chat.antispam.flags: description: See antispam flags default: op