Fixed all (I hope) the bugs, and pushed update to BBB
(False Positive Report + Lang File)
This commit is contained in:
@@ -180,40 +180,40 @@ public class Action {
|
||||
if (notifyTrusted) {
|
||||
TextComponent notification = new TextComponent();
|
||||
notification.setText(Text.prefix(" " + actionTop));
|
||||
String body = "]=- Sentinel -=[ ";
|
||||
String body = "\u00a78]==-- \u00a7d\u00a7lSentinel\u00a78--==[ ";
|
||||
body += "\n" + actionTitle + "\n";
|
||||
if (player != null) {
|
||||
body += "Player: " + player.getName() + "\n";
|
||||
body += "\u00a7bPlayer: \u00a77" + player.getName() + "\n";
|
||||
}
|
||||
if (command != null) {
|
||||
if (loggedCommand != null) {
|
||||
if (loggedCommand.length() > 64) {
|
||||
body += "Command: Too long to show here!" + "\n";
|
||||
body += " | Saved to file: " + commandLog + "\n";
|
||||
body += "\u00a7bCommand: \u00a7cToo long to show here!" + "\n";
|
||||
body += " \u00a78| \u00a7bSaved to file: \u00a7f" + commandLog + "\n";
|
||||
} else {
|
||||
body += "Command: " + command + "\n";
|
||||
body += "\u00a7bCommand: \u00a7f" + command + "\n";
|
||||
}
|
||||
} else {
|
||||
body += "Command: " + command + "\n";
|
||||
body += "\u00a7bCommand: \u00a7f" + command + "\n";
|
||||
}
|
||||
}
|
||||
if (item != null) {
|
||||
body += "Item: /Sentinel/LoggedNBT/" + itemLog + "\n";
|
||||
body += "\u00a7bItem: \u00a7f/Sentinel/LoggedNBT/" + itemLog + "\n";
|
||||
}
|
||||
if (block != null) {
|
||||
Location loc = block.getLocation();
|
||||
body += "Block: " + block.getType().toString().toLowerCase().replace("_", " ") + "\n";
|
||||
body += "Location: " + loc.getX() + " " + loc.getY() + " " + loc.getZ() + "\n";
|
||||
body += "\u00a7bBlock: \u00a7f" + block.getType().toString().toLowerCase().replace("_", " ") + "\n";
|
||||
body += "\u00a7bLocation: \u00a7f" + loc.getX() + " " + loc.getY() + " " + loc.getZ() + "\n";
|
||||
}
|
||||
body += "Denied: " + (denied ? "\u00a7a\u2714" : "\u00a7c\u2718") + "\n";
|
||||
body += "\u00a7bDenied: \u00a7f" + (denied ? "\u00a7a\u2714" : "\u00a7c\u2718") + "\n";
|
||||
if (deoped) {
|
||||
player.setOp(false);
|
||||
}
|
||||
body += "Deoped: " + (deoped ? "\u00a7a\u2714" : "\u00a7c\u2718") + "\n";
|
||||
body += "\u00a7bDeoped: \u00a7f" + (deoped ? "\u00a7a\u2714" : "\u00a7c\u2718") + "\n";
|
||||
|
||||
body += "Punished: " + (punished ? "\u00a7a\u2714" : "\u00a7c\u2718") + "\n";
|
||||
if (revertGM) body += "RevertGM: " + "\u00a7a\u2714" + "\n";
|
||||
body += "Logged: " + (notifyDiscord ? "\u00a7a\u2714" : "\u00a7c\u2718");
|
||||
body += "\u00a7bPunished: \u00a7f" + (punished ? "\u00a7a\u2714" : "\u00a7c\u2718") + "\n";
|
||||
if (revertGM) body += "\u00a7bRevertGM: \u00a7f" + "\u00a7a\u2714" + "\n";
|
||||
body += "\u00a7bLogged: \u00a7f" + (notifyDiscord ? "\u00a7a\u2714" : "\u00a7c\u2718");
|
||||
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new net.md_5.bungee.api.chat.hover.content.Text(body)));
|
||||
ServerUtils.forEachPlayer(trusted -> {
|
||||
if (Sentinel.isTrusted(trusted)) {
|
||||
|
||||
@@ -3,8 +3,6 @@ package io.github.thetrouper.sentinel.data;
|
||||
import java.awt.*;
|
||||
|
||||
public enum FAT {
|
||||
// I couldn't miss the opportunity to call the "Filter Action Type" FAT
|
||||
// Its rly just to make the tab completion of FilterAction easier
|
||||
BLOCK_SWEAR("Sentinel Profanity Filter",null,"swear-block-warn", "swear-block-notification", null,null),
|
||||
BLOCK_SPAM("Sentinel Anti-Spam", null, "spam-block-warn", "spam-notification",null,null),
|
||||
SWEAR("Sentinel Anti-Swear Log","Anti-Swear", "profanity-mute-warn", "profanity-mute-notification", Config.swearPunishCommand, Color.orange),
|
||||
|
||||
@@ -44,6 +44,7 @@ public class FilterAction {
|
||||
String notiftext = Sentinel.dict.get(type.getNotifTranslationKey());
|
||||
|
||||
notif.setText(Text.prefix((type != FAT.SPAM && type != FAT.BLOCK_SPAM ? notiftext.formatted(offender.getName(), scoreMap.get(offender), Config.punishScore) : notiftext.formatted(offender.getName(),heatMap.get(offender),Config.punishHeat))));
|
||||
|
||||
ServerUtils.forEachStaff(staffmember -> {
|
||||
staffmember.spigot().sendMessage(notif);
|
||||
});
|
||||
@@ -80,7 +81,6 @@ public class FilterAction {
|
||||
private static void sendDiscordLog(Player offender, AsyncPlayerChatEvent e, FAT type) {
|
||||
String supertitle = type.getTitle();
|
||||
String title = offender.getName() + " has triggered the " + type.getName() + "!";
|
||||
Color color = Color.white;
|
||||
String executed = type.getExecutedCommand() != null ? type.getExecutedCommand() : "Nothing, its a standard flag. You shouldn't be seeing this, please report it.";
|
||||
|
||||
DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
|
||||
@@ -91,14 +91,14 @@ public class FilterAction {
|
||||
.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) + "/" + Config.punishScore : "Heat: `" + heatMap.get(offender) + "/" + Config.punishHeat) + "`\n" +
|
||||
Emojis.space + Emojis.arrowRight + "UUID: `" + offender.getUniqueId() + "`\n" +
|
||||
Emojis.rightSort + "Executed: " + executed + " " + Emojis.mute + "\n"
|
||||
Emojis.rightSort + "Player: " + offender.getName() + " " + Emojis.target + "\\n" +
|
||||
Emojis.space + Emojis.arrowRight + (type != FAT.BLOCK_SPAM ? "Score: `" + scoreMap.get(offender) + "/" + Config.punishScore : "Heat: `" + heatMap.get(offender) + "/" + Config.punishHeat) + "`\\n" +
|
||||
Emojis.space + Emojis.arrowRight + "UUID: `" + offender.getUniqueId() + "`\\n" +
|
||||
Emojis.rightSort + "Executed: " + executed + " " + Emojis.mute + "\\n"
|
||||
)
|
||||
.addField((type != FAT.BLOCK_SPAM ? "Message: " : "Previous: "), (type != FAT.BLOCK_SPAM ? e.getMessage() : lastMessageMap.get(offender)) + Emojis.alarm, false)
|
||||
.addField((type != FAT.BLOCK_SPAM ? "Reduced: " : "Current: "), (type != FAT.BLOCK_SPAM ? highlightProfanity(e.getMessage(), "||", "||") : e.getMessage()) + " " + Emojis.noDM, false)
|
||||
.setColor(color)
|
||||
.addField((type != FAT.BLOCK_SPAM && type != FAT.SPAM ? "Message: " : "Previous: "), (type != FAT.BLOCK_SPAM && type != FAT.SPAM ? e.getMessage() : lastMessageMap.get(offender)) + Emojis.alarm, false)
|
||||
.addField((type != FAT.BLOCK_SPAM && type != FAT.SPAM ? "Reduced: " : "Current: "), (type != FAT.BLOCK_SPAM && type != FAT.SPAM ? highlightProfanity(e.getMessage(), "||", "||") : e.getMessage()) + " " + Emojis.noDM, false)
|
||||
.setColor(type.getColor())
|
||||
.setThumbnail("https://crafatar.com/avatars/" + offender.getUniqueId() + "?size=64&&overlay");
|
||||
|
||||
webhook.addEmbed(embed);
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Config;
|
||||
import io.github.thetrouper.sentinel.data.Action;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -14,12 +15,17 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
public class CMDBlockPlace implements Listener {
|
||||
@EventHandler
|
||||
private void onCMDBlockPlace(BlockPlaceEvent e) {
|
||||
ServerUtils.sendDebugMessage("CommandBlockPlace: Detected block place");
|
||||
if (!Config.preventCmdBlockPlace) return;
|
||||
ServerUtils.sendDebugMessage("CommandBlockPlace: Enabled");
|
||||
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
|
||||
ServerUtils.sendDebugMessage("CommandBlockPlace: Player is operator");
|
||||
Block b = e.getBlockPlaced();
|
||||
if (b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK ) {
|
||||
ServerUtils.sendDebugMessage("CommandBlockPlace: Block is a command block");
|
||||
Player p = e.getPlayer();
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
ServerUtils.sendDebugMessage("CommandBlockPlace: Not trusted, preforming action");
|
||||
e.setCancelled(true);
|
||||
Action a = new Action.Builder()
|
||||
.setAction(ActionType.PLACE_COMMAND_BLOCK)
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Config;
|
||||
import io.github.thetrouper.sentinel.data.Action;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@@ -17,13 +18,19 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
public class CMDBlockUse implements Listener {
|
||||
@EventHandler
|
||||
private void onCMDBlockUse(PlayerInteractEvent e) {
|
||||
ServerUtils.sendDebugMessage("CommandBlockUse: Detected Interaction");
|
||||
if (!Config.preventCmdBlockUse) return;
|
||||
ServerUtils.sendDebugMessage("CommandBlockUse: Enabled");
|
||||
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
|
||||
ServerUtils.sendDebugMessage("CommandBlockUse: Player is op");
|
||||
if (e.getClickedBlock() == null) return;
|
||||
ServerUtils.sendDebugMessage("CommandBlockUse: Block isn't null");
|
||||
Block b = e.getClickedBlock();
|
||||
if (b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK) {
|
||||
ServerUtils.sendDebugMessage("CommandBlockUse: Block is a command block");
|
||||
Player p = e.getPlayer();
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
ServerUtils.sendDebugMessage("CommandBlockUse: Not trusted, preforming action");
|
||||
e.setCancelled(true);
|
||||
Action a = new Action.Builder()
|
||||
.setAction(ActionType.USE_COMMAND_BLOCK)
|
||||
@@ -32,6 +39,7 @@ public class CMDBlockUse implements Listener {
|
||||
.setPlayer(p)
|
||||
.setDenied(true)
|
||||
.setPunished(Config.cmdBlockPunish)
|
||||
.setDeoped(Config.deop)
|
||||
.setnotifyDiscord(Config.logCmdBlocks)
|
||||
.setNotifyTrusted(true)
|
||||
.setNotifyConsole(true)
|
||||
@@ -41,14 +49,20 @@ public class CMDBlockUse implements Listener {
|
||||
}
|
||||
@EventHandler
|
||||
private void onCMDBlockChange(EntityChangeBlockEvent e) {
|
||||
ServerUtils.sendDebugMessage("CommandBlockChange: Detected change block");
|
||||
if (!(e.getEntity() instanceof Player p)) return;
|
||||
ServerUtils.sendDebugMessage("CommandBlockChange: Changer is a player");
|
||||
if (!Config.preventCmdBlockUse) return;
|
||||
ServerUtils.sendDebugMessage("CommandBlockChange: Enabled");
|
||||
if (Config.cmdBlockOpCheck && !p.isOp()) return;
|
||||
ServerUtils.sendDebugMessage("CommandBlockChange: Player is op");
|
||||
Block b = e.getBlock();
|
||||
if (b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK) {
|
||||
ServerUtils.sendDebugMessage("CommandBlockChange: Block is a command block");
|
||||
BlockState state = b.getState();
|
||||
CommandBlock cb = (CommandBlock) state;
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
ServerUtils.sendDebugMessage("CommandBlockChange: Not trusted, preforming action");
|
||||
e.setCancelled(true);
|
||||
Action a = new Action.Builder()
|
||||
.setAction(ActionType.UPDATE_COMMAND_BLOCK)
|
||||
@@ -58,6 +72,7 @@ public class CMDBlockUse implements Listener {
|
||||
.setPlayer(p)
|
||||
.setDenied(true)
|
||||
.setPunished(Config.cmdBlockPunish)
|
||||
.setDeoped(Config.deop)
|
||||
.setnotifyDiscord(Config.logCmdBlocks)
|
||||
.setNotifyTrusted(true)
|
||||
.setNotifyConsole(true)
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Config;
|
||||
import io.github.thetrouper.sentinel.data.Action;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -14,14 +15,22 @@ public class CMDMinecartPlace implements Listener {
|
||||
|
||||
@EventHandler
|
||||
private void onCMDMinecartPlace(PlayerInteractEvent e) {
|
||||
if (!Config.preventCmdCartPlace) {
|
||||
ServerUtils.sendDebugMessage("MinecartCommandPlace: Detected interaction");
|
||||
if (Config.preventCmdCartPlace) {
|
||||
ServerUtils.sendDebugMessage("MinecartCommandPlace: Enabled");
|
||||
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
|
||||
ServerUtils.sendDebugMessage("MinecartCommandPlace: Player is op");
|
||||
if (e.getItem() == null) return;
|
||||
ServerUtils.sendDebugMessage("MinecartCommandPlace: Item isn't null");
|
||||
if (e.getClickedBlock() == null) return;
|
||||
ServerUtils.sendDebugMessage("MinecartCommandPlace: Clicked block isn't null");
|
||||
if (!e.getItem().getType().equals(Material.COMMAND_BLOCK_MINECART)) return;
|
||||
ServerUtils.sendDebugMessage("MinecartCommandPlace: Item is a minecart command");
|
||||
if (e.getClickedBlock().getType() == Material.RAIL || e.getClickedBlock().getType() == Material.POWERED_RAIL || e.getClickedBlock().getType() == Material.ACTIVATOR_RAIL || e.getClickedBlock().getType() == Material.DETECTOR_RAIL) {
|
||||
ServerUtils.sendDebugMessage("MinecartCommandPlace: Clicked block is a rail");
|
||||
Player p = e.getPlayer();
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
ServerUtils.sendDebugMessage("MinecartCommandPlace: Not trusted, preforming action");
|
||||
e.setCancelled(true);
|
||||
p.getInventory().remove(Material.COMMAND_BLOCK_MINECART);
|
||||
Action a = new Action.Builder()
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Config;
|
||||
import io.github.thetrouper.sentinel.data.Action;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -13,11 +14,16 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
public class CMDMinecartUse implements Listener {
|
||||
@EventHandler
|
||||
private void onCMDBlockMinecartUse(PlayerInteractEntityEvent e) {
|
||||
ServerUtils.sendDebugMessage("MinecartCommandUse: Detected Interaction with entity");
|
||||
if (!Config.preventCmdCartUse) return;
|
||||
ServerUtils.sendDebugMessage("MinecartCommandUse: Enabled");
|
||||
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
|
||||
ServerUtils.sendDebugMessage("MinecartCommandUse: Player op");
|
||||
if (e.getRightClicked().getType() == EntityType.MINECART_COMMAND) {
|
||||
ServerUtils.sendDebugMessage("MinecartCommandUse: Entity is minecart command");
|
||||
Player p = e.getPlayer();
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
ServerUtils.sendDebugMessage("MinecartCommandUse: Not trusted, preforming action");
|
||||
e.setCancelled(true);
|
||||
Action a = new Action.Builder()
|
||||
.setAction(ActionType.USE_MINECART_COMMAND)
|
||||
|
||||
@@ -17,6 +17,7 @@ public class CommandEvent implements Listener {
|
||||
private void onCommand(PlayerCommandPreprocessEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
String command = e.getMessage().substring(1).split(" ")[0];
|
||||
String fullcommand = e.getMessage();
|
||||
ServerUtils.sendDebugMessage("CommandEvent: Checking command");
|
||||
if (Sentinel.isDangerousCommand(command)) {
|
||||
ServerUtils.sendDebugMessage("CommandEvent: Command is dangerous");
|
||||
@@ -27,7 +28,7 @@ public class CommandEvent implements Listener {
|
||||
.setAction(ActionType.DANGEROUS_COMMAND)
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.setCommand(command)
|
||||
.setCommand(fullcommand)
|
||||
.setDenied(true)
|
||||
.setDeoped(Config.deop)
|
||||
.setPunished(Config.commandPunish)
|
||||
@@ -40,10 +41,10 @@ public class CommandEvent implements Listener {
|
||||
if (Config.blockSpecific) {
|
||||
ServerUtils.sendDebugMessage("CommandEvent: Checking command for specific");
|
||||
if (command.contains(":")) {
|
||||
ServerUtils.sendDebugMessage("CommandEvent: Checking is specific");
|
||||
ServerUtils.sendDebugMessage("CommandEvent: Failed check");
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
e.setCancelled(true);
|
||||
ServerUtils.sendDebugMessage(("CommandEvent: Command is canceled"));
|
||||
ServerUtils.sendDebugMessage(("CommandEvent: Not trusted, preforming action"));
|
||||
Action a = new Action.Builder()
|
||||
.setAction(ActionType.SPECIFIC_COMMAND)
|
||||
.setEvent(e)
|
||||
@@ -60,6 +61,7 @@ public class CommandEvent implements Listener {
|
||||
}
|
||||
}
|
||||
if (Sentinel.isLoggedCommand(command)) {
|
||||
ServerUtils.sendDebugMessage("CommandEvent: Is logged command, logging");
|
||||
Action a = new Action.Builder()
|
||||
.setAction(ActionType.LOGGED_COMMAND)
|
||||
.setEvent(e)
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Config;
|
||||
import io.github.thetrouper.sentinel.data.Action;
|
||||
import io.github.thetrouper.sentinel.data.ActionType;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,16 +19,22 @@ import java.util.Map;
|
||||
public class NBTEvents implements Listener {
|
||||
@EventHandler
|
||||
private void onNBTPull(InventoryCreativeEvent e) {
|
||||
ServerUtils.sendDebugMessage("NBT: Detected creative mode action");
|
||||
if (Config.preventNBT) {
|
||||
if (!(e.getWhoClicked() instanceof Player p)) {
|
||||
return;
|
||||
}
|
||||
ServerUtils.sendDebugMessage("NBT: Enabled");
|
||||
if (!(e.getWhoClicked() instanceof Player p)) return;
|
||||
ServerUtils.sendDebugMessage("NBT: Clicker is a player");
|
||||
if (e.getCursor() == null) return;
|
||||
ServerUtils.sendDebugMessage("NBT: Cursor isn't null");
|
||||
ItemStack i = e.getCursor();
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
ServerUtils.sendDebugMessage("NBT: Not trusted");
|
||||
if (e.getCursor().getItemMeta() == null) return;
|
||||
ServerUtils.sendDebugMessage("NBT: Cursor has meta");
|
||||
if (i.hasItemMeta() && i.getItemMeta() != null) {
|
||||
ServerUtils.sendDebugMessage("NBT: Item has meta");
|
||||
if (!itemPasses(i)) {
|
||||
ServerUtils.sendDebugMessage("NBT: Item doesn't pass, preforming action");
|
||||
Action a = new Action.Builder()
|
||||
.setEvent(e)
|
||||
.setAction(ActionType.NBT)
|
||||
@@ -48,28 +55,52 @@ public class NBTEvents implements Listener {
|
||||
}
|
||||
|
||||
private boolean itemPasses(ItemStack i) {
|
||||
if (i.hasItemMeta()) {
|
||||
ServerUtils.sendDebugMessage("NBT: Checking if item passes: " + i.getItemMeta());
|
||||
if (i.getItemMeta() != null) {
|
||||
ServerUtils.sendDebugMessage("NBT: Item meta isn't null");
|
||||
ItemMeta meta = i.getItemMeta();
|
||||
if (!Config.allowName && meta.hasDisplayName()) return false;
|
||||
if (!Config.allowLore && meta.hasLore()) return false;
|
||||
if (!Config.allowAttributes && meta.hasAttributeModifiers()) return false;
|
||||
if (Config.globalMaxEnchant == 0 && hasIllegalEnchants(i)) return false;
|
||||
if (!Config.allowName && meta.hasDisplayName()) {
|
||||
ServerUtils.sendDebugMessage("NBT: No pass N");
|
||||
return false;
|
||||
} else if (!Config.allowLore && meta.hasLore()) {
|
||||
ServerUtils.sendDebugMessage("NBT: No Pass L ");
|
||||
return false;
|
||||
} else if (!Config.allowAttributes && meta.hasAttributeModifiers()) {
|
||||
ServerUtils.sendDebugMessage("NBT: No pass A");
|
||||
return false;
|
||||
} else if (Config.globalMaxEnchant != 0 && hasIllegalEnchants(i)) {
|
||||
ServerUtils.sendDebugMessage("NBT: No pass E");
|
||||
return false;
|
||||
}
|
||||
ServerUtils.sendDebugMessage("NBT: All checks passed");
|
||||
return true;
|
||||
} else {
|
||||
ServerUtils.sendDebugMessage("NBT: Item passes because of no meta");
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: Detected creative mode action
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: Enabled
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: Clicker is a player
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: Cursor isn't null
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: Not trusted
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: Cursor has meta
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: Item has meta
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: Checking if item passes: UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"italic":false,"color":"red","text":"Penguin's Flaming Fish!"}, lore=[{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"gray","text":"Penguin Almighty XXXMMDCCLXVII"}],"text":""}], enchants={FIRE_ASPECT=32767, KNOCKBACK=32767}, ItemFlags=[HIDE_ENCHANTS]}
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: Item meta isn't null
|
||||
[01:23:03 INFO]: [Sentinel] [DEBUG]: NBT: All checks passed
|
||||
*/
|
||||
private boolean hasIllegalEnchants(ItemStack i) {
|
||||
ServerUtils.sendDebugMessage("NBT: Checking for illegal enchants");
|
||||
if (i.hasItemMeta() && i.getItemMeta().hasEnchants()) {
|
||||
final ItemMeta meta = i.getItemMeta();
|
||||
final Map<Enchantment, Integer> enchantments = meta.getEnchants();
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
||||
Enchantment enchantment = entry.getKey();
|
||||
int level = entry.getValue();
|
||||
|
||||
if (level > Config.globalMaxEnchant) {
|
||||
for (Integer value : enchantments.values()) {
|
||||
if (value > Config.globalMaxEnchant) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ALL
|
||||
if (meta.hasEnchant(Enchantment.MENDING)) {
|
||||
final int level = meta.getEnchantLevel(Enchantment.MENDING);
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
public class AntiUnicode {
|
||||
public static void handleAntiUnicode(AsyncPlayerChatEvent e) {
|
||||
String message = Text.removeFirstColor(e.getMessage());
|
||||
String nonAllowed = message.replaceAll("[A-Za-z0-9\\[,./?><|\\]()*&^%$#@!~`{}:;'\"-_]", "").trim();
|
||||
String nonAllowed = message.replaceAll("[A-Za-z0-9\\[,./?><|\\]\u00A7()*&^%$#@!~`{}:;'\"-_]", "").trim();
|
||||
if (nonAllowed.length() != 0) {
|
||||
e.getPlayer().sendMessage(Text.prefix(Sentinel.dict.get("unicode-warn")));
|
||||
e.setCancelled(true);
|
||||
|
||||
@@ -11,6 +11,8 @@ import java.util.List;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.github.thetrouper.sentinel.server.util.Text.SECTION_SYMBOL;
|
||||
|
||||
public class ProfanityFilter {
|
||||
public static Map<Player, Integer> scoreMap;
|
||||
private static final List<String> swearBlacklist = Config.swearBlacklist;
|
||||
@@ -140,14 +142,14 @@ public class ProfanityFilter {
|
||||
}
|
||||
*/
|
||||
public static String highlightProfanity(String text) {
|
||||
String highlightedSwears = highlightSwears(fullSimplify(text), "\u00a7e", "\u00a7f");
|
||||
String highlightedText = highlightSlurs(highlightedSwears, "\u00a7c", "\u00a7f");
|
||||
return highlightedText;
|
||||
String highlightedSwears = highlightSwears(fullSimplify(text), "&e", "&f");
|
||||
String highlightedText = highlightSlurs(highlightedSwears, "&c", "&f");
|
||||
return Text.color(highlightedText);
|
||||
}
|
||||
public static String highlightProfanity(String text, String start, String end) {
|
||||
String highlightedSwears = highlightSwears(fullSimplify(text), start, end);
|
||||
String highlightedText = highlightSlurs(highlightedSwears, start, end);
|
||||
return highlightedText;
|
||||
return Text.color(highlightedText);
|
||||
}
|
||||
|
||||
private static String highlightSwears(String text, String start, String end) {
|
||||
|
||||
@@ -40,6 +40,7 @@ public class FileUtils {
|
||||
}
|
||||
}
|
||||
public static String createNBTLog(String contents) {
|
||||
ServerUtils.sendDebugMessage("FileUtils: Creating NBT log");
|
||||
String fileName = "nbt_log-" + Randomizer.generateID();
|
||||
File file = new File(Sentinel.getInstance().getDataFolder() + "/LoggedNBT/" + fileName + ".txt");
|
||||
try {
|
||||
|
||||
@@ -8,8 +8,10 @@ import java.util.Map;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
public class Text {
|
||||
public static String color(String s) {
|
||||
return s.replaceAll("&","\u00A7");
|
||||
public static final char SECTION_SYMBOL = (char)167;
|
||||
|
||||
public static String color(String msg) {
|
||||
return msg.replace('&', SECTION_SYMBOL);
|
||||
}
|
||||
public static String prefix(String text) {
|
||||
String prefix = Sentinel.prefix;
|
||||
|
||||
Reference in New Issue
Block a user