Added Enchant limits to config, so now the hotbar items blocker is actually useful
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
# Plugin
|
# Plugin
|
||||||
group = 'io.github.thetrouper'
|
group = 'io.github.thetrouper'
|
||||||
version = 0.1.7
|
version = 0.1.8
|
||||||
|
|
||||||
# Minecraft
|
# Minecraft
|
||||||
mc_version = 1.19.4
|
mc_version = 1.19.4
|
||||||
|
|||||||
@@ -17,9 +17,15 @@ public class ReopCommand extends CustomCommand {
|
|||||||
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
|
public void dispatchCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (Sentinel.isTrusted(p)) {
|
if (Sentinel.isTrusted(p)) {
|
||||||
|
if (!p.isOp()) {
|
||||||
p.sendMessage(TextUtils.prefix("Elevating your permissions..."));
|
p.sendMessage(TextUtils.prefix("Elevating your permissions..."));
|
||||||
Sentinel.log.info("Elevating the permissions of " + p.getName());
|
Sentinel.log.info("Elevating the permissions of " + p.getName());
|
||||||
p.setOp(true);
|
p.setOp(true);
|
||||||
|
} else {
|
||||||
|
p.sendMessage(TextUtils.prefix("You are already are an operator!"));
|
||||||
|
Sentinel.log.info("The permissions of " + p.getName() + " are already elevated! Retrying...");
|
||||||
|
p.setOp(true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(TextUtils.prefix("§cYou are not trusted!"));
|
p.sendMessage(TextUtils.prefix("§cYou are not trusted!"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,25 +4,14 @@
|
|||||||
|
|
||||||
package io.github.thetrouper.sentinel.commands;
|
package io.github.thetrouper.sentinel.commands;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import io.github.thetrouper.sentinel.Sentinel;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.FileUtils;
|
|
||||||
import io.github.thetrouper.sentinel.server.util.TextUtils;
|
import io.github.thetrouper.sentinel.server.util.TextUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.block.CommandBlock;
|
|
||||||
import org.bukkit.block.data.BlockData;
|
|
||||||
import org.bukkit.command.*;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
import java.io.File;
|
import java.util.HashSet;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example command
|
* Example command
|
||||||
@@ -43,12 +32,23 @@ public class SentinelCommand extends CustomCommand {
|
|||||||
debugmode = !debugmode;
|
debugmode = !debugmode;
|
||||||
p.sendMessage(TextUtils.prefix(TextUtils.boolString(debugmode,"§aEnabled","§cDisabled") + "§7 debug mode."));
|
p.sendMessage(TextUtils.prefix(TextUtils.boolString(debugmode,"§aEnabled","§cDisabled") + "§7 debug mode."));
|
||||||
}
|
}
|
||||||
|
case "testantiswear" -> {
|
||||||
|
HashSet<Player> players = new HashSet<>();
|
||||||
|
players.add((Player) sender);
|
||||||
|
String msg = "";
|
||||||
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
msg = msg.concat(" " + args[i]);
|
||||||
|
}
|
||||||
|
msg = msg.trim();
|
||||||
|
AsyncPlayerChatEvent e = new AsyncPlayerChatEvent(true, (Player) sender, msg, players);
|
||||||
|
ProfanityFilter.handleProfanityFilter(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCompletions(CompletionBuilder builder) {
|
public void registerCompletions(CompletionBuilder builder) {
|
||||||
builder.addCompletion(1,"debugmode");
|
builder.addCompletion(1,"debugmode");
|
||||||
builder.addCompletion(1,"whitelistcommandblock");
|
builder.addCompletion(1,"testantiswear");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,52 @@ public abstract class Config {
|
|||||||
public static List<String> punishCommands;
|
public static List<String> punishCommands;
|
||||||
public static boolean reopCommand;
|
public static boolean reopCommand;
|
||||||
|
|
||||||
|
// NBT
|
||||||
|
|
||||||
|
public static boolean allowName;
|
||||||
|
public static boolean allowLore;
|
||||||
|
public static boolean allowAttributes;
|
||||||
|
public static int globalMaxEnchant;
|
||||||
|
public static int maxMending;
|
||||||
|
public static int maxUnbreaking;
|
||||||
|
public static int maxVanishing;
|
||||||
|
public static int maxAquaAffinity;
|
||||||
|
public static int maxBlastProtection;
|
||||||
|
public static int maxCurseOfBinding;
|
||||||
|
public static int maxDepthStrider;
|
||||||
|
public static int maxFeatherFalling;
|
||||||
|
public static int maxFireProtection;
|
||||||
|
public static int maxFrostWalker;
|
||||||
|
public static int maxProjectileProtection;
|
||||||
|
public static int maxProtection;
|
||||||
|
public static int maxRespiration;
|
||||||
|
public static int maxSoulSpeed;
|
||||||
|
public static int maxThorns;
|
||||||
|
public static int maxSwiftSneak;
|
||||||
|
public static int maxBaneOfArthropods;
|
||||||
|
public static int maxEfficiency;
|
||||||
|
public static int maxFireAspect;
|
||||||
|
public static int maxLooting;
|
||||||
|
public static int maxImpaling;
|
||||||
|
public static int maxKnockback;
|
||||||
|
public static int maxSharpness;
|
||||||
|
public static int maxSmite;
|
||||||
|
public static int maxSweepingEdge;
|
||||||
|
public static int maxChanneling;
|
||||||
|
public static int maxFlame;
|
||||||
|
public static int maxInfinity;
|
||||||
|
public static int maxLoyalty;
|
||||||
|
public static int maxRiptide;
|
||||||
|
public static int maxMultishot;
|
||||||
|
public static int maxPiercing;
|
||||||
|
public static int maxPower;
|
||||||
|
public static int maxPunch;
|
||||||
|
public static int maxQuickCharge;
|
||||||
|
public static int maxFortune;
|
||||||
|
public static int maxLuckOfTheSea;
|
||||||
|
public static int maxLure;
|
||||||
|
public static int maxSilkTouch;
|
||||||
|
|
||||||
// Chat Filter Setup & AntiSpam
|
// Chat Filter Setup & AntiSpam
|
||||||
public static boolean antiUnicode;
|
public static boolean antiUnicode;
|
||||||
public static boolean antiSpamEnabled;
|
public static boolean antiSpamEnabled;
|
||||||
@@ -113,6 +159,62 @@ public abstract class Config {
|
|||||||
punishCommands = config.getStringList("config.plugin.punish-commands");
|
punishCommands = config.getStringList("config.plugin.punish-commands");
|
||||||
reopCommand = config.getBoolean("config.plugin.reop-command");
|
reopCommand = config.getBoolean("config.plugin.reop-command");
|
||||||
|
|
||||||
|
// NBT
|
||||||
|
allowName = config.getBoolean("config.nbt.allow-name");
|
||||||
|
allowLore = config.getBoolean("config.nbt.allow-lore");
|
||||||
|
allowAttributes = config.getBoolean("config.nbt.allow-attributes");
|
||||||
|
globalMaxEnchant = config.getInt("config.nbt.global-max-enchant");
|
||||||
|
|
||||||
|
// ALL
|
||||||
|
maxMending = config.getInt("config.nbt.max-mending");
|
||||||
|
maxUnbreaking = config.getInt("config.nbt.max-unbreaking");
|
||||||
|
maxVanishing = config.getInt("config.nbt.max-vanishing");
|
||||||
|
|
||||||
|
// ARMOR
|
||||||
|
maxAquaAffinity = config.getInt("config.nbt.max-aqua-affinity");
|
||||||
|
maxBlastProtection = config.getInt("config.nbt.max-blast-protection");
|
||||||
|
maxCurseOfBinding = config.getInt("config.nbt.max-curse-of-binding");
|
||||||
|
maxDepthStrider = config.getInt("config.nbt.max-depth-strider");
|
||||||
|
maxFeatherFalling = config.getInt("config.nbt.max-feather-falling");
|
||||||
|
maxFireProtection = config.getInt("config.nbt.max-fire-protection");
|
||||||
|
maxFrostWalker = config.getInt("config.nbt.max-frost-walker");
|
||||||
|
maxProjectileProtection = config.getInt("config.nbt.max-projectile-protection");
|
||||||
|
maxProtection = config.getInt("config.nbt.max-protection");
|
||||||
|
maxRespiration = config.getInt("config.nbt.max-respiration");
|
||||||
|
maxSoulSpeed = config.getInt("config.nbt.max-soul-speed");
|
||||||
|
maxThorns = config.getInt("config.nbt.max-thorns");
|
||||||
|
maxSwiftSneak = config.getInt("config.nbt.max-swift-sneak");
|
||||||
|
|
||||||
|
// MELEE WEAPONS
|
||||||
|
maxBaneOfArthropods = config.getInt("config.nbt.max-bane-of-arthropods");
|
||||||
|
maxEfficiency = config.getInt("config.nbt.max-efficiency");
|
||||||
|
maxFireAspect = config.getInt("config.nbt.max-fire-aspect");
|
||||||
|
maxLooting = config.getInt("config.nbt.max-looting");
|
||||||
|
maxImpaling = config.getInt("config.nbt.max-impaling");
|
||||||
|
maxKnockback = config.getInt("config.nbt.max-knockback");
|
||||||
|
maxSharpness = config.getInt("config.nbt.max-sharpness");
|
||||||
|
maxSmite = config.getInt("config.nbt.max-smite");
|
||||||
|
maxSweepingEdge = config.getInt("config.nbt.max-sweeping-edge");
|
||||||
|
|
||||||
|
// RANGED WEAPONS
|
||||||
|
maxChanneling = config.getInt("config.nbt.max-channeling");
|
||||||
|
maxFlame = config.getInt("config.nbt.max-flame");
|
||||||
|
maxInfinity = config.getInt("config.nbt.max-infinity");
|
||||||
|
maxLoyalty = config.getInt("config.nbt.max-loyalty");
|
||||||
|
maxRiptide = config.getInt("config.nbt.max-riptide");
|
||||||
|
maxMultishot = config.getInt("config.nbt.max-multishot");
|
||||||
|
maxPiercing = config.getInt("config.nbt.max-piercing");
|
||||||
|
maxPower = config.getInt("config.nbt.max-power");
|
||||||
|
maxPunch = config.getInt("config.nbt.max-punch");
|
||||||
|
maxQuickCharge = config.getInt("config.nbt.max-quick-charge");
|
||||||
|
|
||||||
|
// TOOLS
|
||||||
|
maxEfficiency = config.getInt("config.nbt.max-efficiency");
|
||||||
|
maxFortune = config.getInt("config.nbt.max-fortune");
|
||||||
|
maxLuckOfTheSea = config.getInt("config.nbt.max-luck-of-the-sea");
|
||||||
|
maxLure = config.getInt("config.nbt.max-lure");
|
||||||
|
maxSilkTouch = config.getInt("config.nbt.max-silk-touch");
|
||||||
|
|
||||||
// Chat Filter Setup & AntiSpam
|
// Chat Filter Setup & AntiSpam
|
||||||
antiUnicode = config.getBoolean("config.chat.anti-unicode");
|
antiUnicode = config.getBoolean("config.chat.anti-unicode");
|
||||||
antiSpamEnabled = config.getBoolean("config.chat.anti-spam.enabled");
|
antiSpamEnabled = config.getBoolean("config.chat.anti-spam.enabled");
|
||||||
|
|||||||
@@ -12,17 +12,4 @@ import org.bukkit.inventory.meta.BlockDataMeta;
|
|||||||
|
|
||||||
public class CMDBlockExecute implements Listener {
|
public class CMDBlockExecute implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
private void onCMDBlockTick(ServerCommandEvent e) {
|
|
||||||
if (e.getSender() instanceof BlockCommandSender) {
|
|
||||||
if (!SentinelCommand.isCommandBlockWhitelisted((CommandBlock) e.getSender())) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
CommandBlock b = (CommandBlock) e.getSender();
|
|
||||||
Sentinel.log.info("A non whitelisted command block just attempted to execute a command! \n Command: "
|
|
||||||
+ e.getCommand() + "\n" + "Location: " + b.getLocation().getX() + " " + b.getLocation().getX() + " " + b.getLocation().getZ());
|
|
||||||
b.setType(Material.COMMAND_BLOCK);
|
|
||||||
b.setCommand(e.getCommand());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,10 +68,6 @@ public class CMDBlockUse implements Listener {
|
|||||||
.setNotifyConsole(true)
|
.setNotifyConsole(true)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
if (Sentinel.isTrusted(p)) {
|
|
||||||
Sentinel.log.info(p.getName() + "Updated command block: " + cb.getCommand());
|
|
||||||
SentinelCommand.updateWhitelistedCommandBlock(p,b, cb.getCommand());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,18 @@ import io.github.thetrouper.sentinel.data.Config;
|
|||||||
import io.github.thetrouper.sentinel.server.Action;
|
import io.github.thetrouper.sentinel.server.Action;
|
||||||
import io.github.thetrouper.sentinel.server.ActionType;
|
import io.github.thetrouper.sentinel.server.ActionType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class NBTEvents implements Listener {
|
public class NBTEvents implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -23,6 +30,7 @@ public class NBTEvents implements Listener {
|
|||||||
if (!Sentinel.isTrusted(p)) {
|
if (!Sentinel.isTrusted(p)) {
|
||||||
if (e.getCursor().getItemMeta() == null) return;
|
if (e.getCursor().getItemMeta() == null) return;
|
||||||
if (i.hasItemMeta() && i.getItemMeta() != null) {
|
if (i.hasItemMeta() && i.getItemMeta() != null) {
|
||||||
|
if (!itemPasses(i)) {
|
||||||
Action a = new Action.Builder()
|
Action a = new Action.Builder()
|
||||||
.setEvent(e)
|
.setEvent(e)
|
||||||
.setAction(ActionType.NBT)
|
.setAction(ActionType.NBT)
|
||||||
@@ -40,5 +48,203 @@ public class NBTEvents implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean itemPasses(ItemStack i) {
|
||||||
|
if (i.hasItemMeta()) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private boolean hasIllegalEnchants(ItemStack i) {
|
||||||
|
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) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ALL
|
||||||
|
if (meta.hasEnchant(Enchantment.MENDING)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.MENDING);
|
||||||
|
return level > Config.maxMending || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.DURABILITY)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.DURABILITY);
|
||||||
|
return level > Config.maxUnbreaking || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.VANISHING_CURSE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.VANISHING_CURSE);
|
||||||
|
return level > Config.maxVanishing || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ARMOR
|
||||||
|
if (meta.hasEnchant(Enchantment.WATER_WORKER)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.WATER_WORKER);
|
||||||
|
return level > Config.maxAquaAffinity || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.PROTECTION_ENVIRONMENTAL)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||||
|
return level > Config.maxProtection || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.PROTECTION_EXPLOSIONS)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.PROTECTION_EXPLOSIONS);
|
||||||
|
return level > Config.maxBlastProtection || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.BINDING_CURSE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.BINDING_CURSE);
|
||||||
|
return level > Config.maxCurseOfBinding || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.DEPTH_STRIDER)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.DEPTH_STRIDER);
|
||||||
|
return level > Config.maxDepthStrider || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.PROTECTION_FALL)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.PROTECTION_FALL);
|
||||||
|
return level > Config.maxFeatherFalling || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.PROTECTION_FIRE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.PROTECTION_FIRE);
|
||||||
|
return level > Config.maxFireProtection || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.FROST_WALKER)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.FROST_WALKER);
|
||||||
|
return level > Config.maxFrostWalker || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.PROTECTION_PROJECTILE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.PROTECTION_PROJECTILE);
|
||||||
|
return level > Config.maxProjectileProtection || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.OXYGEN)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.OXYGEN);
|
||||||
|
return level > Config.maxRespiration || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.SOUL_SPEED)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.SOUL_SPEED);
|
||||||
|
return level > Config.maxSoulSpeed || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.THORNS)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.THORNS);
|
||||||
|
return level > Config.maxThorns || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.SWEEPING_EDGE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.SWEEPING_EDGE);
|
||||||
|
return level > Config.maxSweepingEdge || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.FROST_WALKER)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.FROST_WALKER);
|
||||||
|
return level > Config.maxFrostWalker || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MELEE WEAPONS
|
||||||
|
if (meta.hasEnchant(Enchantment.DAMAGE_ARTHROPODS)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.DAMAGE_ARTHROPODS);
|
||||||
|
return level > Config.maxBaneOfArthropods || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.DIG_SPEED)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.DIG_SPEED);
|
||||||
|
return level > Config.maxEfficiency || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.FIRE_ASPECT)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.FIRE_ASPECT);
|
||||||
|
return level > Config.maxFireAspect || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.LOOT_BONUS_MOBS)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.LOOT_BONUS_MOBS);
|
||||||
|
return level > Config.maxLooting || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.IMPALING)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.IMPALING);
|
||||||
|
return level > Config.maxImpaling || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.KNOCKBACK)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.KNOCKBACK);
|
||||||
|
return level > Config.maxKnockback || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.DAMAGE_ALL)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.DAMAGE_ALL);
|
||||||
|
return level > Config.maxSharpness || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.DAMAGE_UNDEAD)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.DAMAGE_UNDEAD);
|
||||||
|
return level > Config.maxSmite || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
|
||||||
|
// RANGED WEAPONS
|
||||||
|
if (meta.hasEnchant(Enchantment.CHANNELING)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.CHANNELING);
|
||||||
|
return level > Config.maxChanneling || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.ARROW_FIRE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.ARROW_FIRE);
|
||||||
|
return level > Config.maxFlame || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.ARROW_INFINITE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.ARROW_INFINITE);
|
||||||
|
return level > Config.maxInfinity || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.LOYALTY)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.LOYALTY);
|
||||||
|
return level > Config.maxLoyalty || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.RIPTIDE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.RIPTIDE);
|
||||||
|
return level > Config.maxRiptide || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.MULTISHOT)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.MULTISHOT);
|
||||||
|
return level > Config.maxMultishot || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.PIERCING)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.PIERCING);
|
||||||
|
return level > Config.maxPiercing || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.ARROW_DAMAGE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.ARROW_DAMAGE);
|
||||||
|
return level > Config.maxPower || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.ARROW_KNOCKBACK)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.ARROW_KNOCKBACK);
|
||||||
|
return level > Config.maxPunch || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.QUICK_CHARGE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.QUICK_CHARGE);
|
||||||
|
return level > Config.maxQuickCharge || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TOOLS
|
||||||
|
if (meta.hasEnchant(Enchantment.DIG_SPEED)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.DIG_SPEED);
|
||||||
|
return level > Config.maxEfficiency || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.LOOT_BONUS_BLOCKS)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.LOOT_BONUS_BLOCKS);
|
||||||
|
return level > Config.maxFortune || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.LUCK)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.LUCK);
|
||||||
|
return level > Config.maxLuckOfTheSea || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.LURE)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.LURE);
|
||||||
|
return level > Config.maxLure || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
if (meta.hasEnchant(Enchantment.SILK_TOUCH)) {
|
||||||
|
final int level = meta.getEnchantLevel(Enchantment.SILK_TOUCH);
|
||||||
|
return level > Config.maxSilkTouch || level > Config.globalMaxEnchant;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,14 @@ import net.md_5.bungee.api.chat.HoverEvent;
|
|||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.List;
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -144,6 +151,9 @@ public class ProfanityFilter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 1: lowercase the text
|
* 1: lowercase the text
|
||||||
|
* 1.4: Separate the string into words
|
||||||
|
* 1.5: Remove all verified clean english words
|
||||||
|
* 1.6: Put it back into one string
|
||||||
* 2: remove the known false positives
|
* 2: remove the known false positives
|
||||||
* 3: Check for swears and return "low" if true
|
* 3: Check for swears and return "low" if true
|
||||||
* 4: Convert LeetSpeak Characters
|
* 4: Convert LeetSpeak Characters
|
||||||
@@ -167,10 +177,11 @@ public class ProfanityFilter {
|
|||||||
public static String checkSeverity(String text) {
|
public static String checkSeverity(String text) {
|
||||||
// 1:
|
// 1:
|
||||||
String lowercasedText = text.toLowerCase();
|
String lowercasedText = text.toLowerCase();
|
||||||
// 1.5:
|
ServerUtils.sendDebugMessage(TextUtils.prefix("Debug: [AntiSwear] Lowercased: " + lowercasedText));
|
||||||
String nonEnglish =
|
|
||||||
// 2:
|
// 2:
|
||||||
String cleanedText = removeFalsePositives(lowercasedText);
|
String cleanedText = removeFalsePositives(lowercasedText);
|
||||||
|
ServerUtils.sendDebugMessage(TextUtils.prefix("Debug: [AntiSwear] Removed False positives: " + cleanedText));
|
||||||
|
|
||||||
// 3:
|
// 3:
|
||||||
if (containsSwears(cleanedText)) return "low";
|
if (containsSwears(cleanedText)) return "low";
|
||||||
@@ -178,6 +189,7 @@ public class ProfanityFilter {
|
|||||||
|
|
||||||
// 4:
|
// 4:
|
||||||
String convertedText = convertLeetSpeakCharacters(cleanedText);
|
String convertedText = convertLeetSpeakCharacters(cleanedText);
|
||||||
|
ServerUtils.sendDebugMessage(TextUtils.prefix("Debug: [AntiSwear] Leet Converted: " + convertedText));
|
||||||
|
|
||||||
// 5:
|
// 5:
|
||||||
if (containsSwears(convertedText)) return "medium-low";
|
if (containsSwears(convertedText)) return "medium-low";
|
||||||
@@ -185,6 +197,7 @@ public class ProfanityFilter {
|
|||||||
|
|
||||||
// 6:
|
// 6:
|
||||||
String strippedText = stripSpecialCharacters(convertedText);
|
String strippedText = stripSpecialCharacters(convertedText);
|
||||||
|
ServerUtils.sendDebugMessage(TextUtils.prefix("Debug: [AntiSwear] Specials Removed: " + strippedText));
|
||||||
|
|
||||||
// 7:
|
// 7:
|
||||||
if (containsSwears(strippedText)) return "medium";
|
if (containsSwears(strippedText)) return "medium";
|
||||||
@@ -192,6 +205,7 @@ public class ProfanityFilter {
|
|||||||
|
|
||||||
// 8:
|
// 8:
|
||||||
String simplifiedText = simplifyRepeatingLetters(strippedText);
|
String simplifiedText = simplifyRepeatingLetters(strippedText);
|
||||||
|
ServerUtils.sendDebugMessage(TextUtils.prefix("Debug: [AntiSwear] Removed Repeating: " + simplifiedText));
|
||||||
|
|
||||||
// 9:
|
// 9:
|
||||||
if (containsSwears(simplifiedText)) return "medium-high";
|
if (containsSwears(simplifiedText)) return "medium-high";
|
||||||
@@ -199,6 +213,7 @@ public class ProfanityFilter {
|
|||||||
|
|
||||||
// 10:
|
// 10:
|
||||||
String finalText = removePeriodsAndSpaces(simplifiedText);
|
String finalText = removePeriodsAndSpaces(simplifiedText);
|
||||||
|
ServerUtils.sendDebugMessage(TextUtils.prefix("Debug: [AntiSwear] Remove Punctuation: " + finalText));
|
||||||
|
|
||||||
// 11:
|
// 11:
|
||||||
if (containsSwears(finalText)) return "high";
|
if (containsSwears(finalText)) return "high";
|
||||||
@@ -233,7 +248,7 @@ public class ProfanityFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String stripSpecialCharacters(String text) {
|
private static String stripSpecialCharacters(String text) {
|
||||||
text = text.replaceAll("[^A-Za-z0-9]", "").trim();
|
text = text.replaceAll("[^A-Za-z0-9.,!?;:'\"()\\[\\]{}]", "").trim();
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +258,7 @@ public class ProfanityFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String removePeriodsAndSpaces(String text) {
|
private static String removePeriodsAndSpaces(String text) {
|
||||||
return text.replace(".", "").replace(" ", "");
|
return text.replaceAll("[^A-Za-z0-9]", "").replace(" ", "");
|
||||||
}
|
}
|
||||||
public static void decayScore() {
|
public static void decayScore() {
|
||||||
for (Player p : scoreMap.keySet()) {
|
for (Player p : scoreMap.keySet()) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Sentinel 0.1.5
|
# Sentinel 0.1.8
|
||||||
# ____ __ ___
|
# ____ __ ___
|
||||||
#/\ _`\ /\ \__ __ /\_ \
|
#/\ _`\ /\ \__ __ /\_ \
|
||||||
#\ \,\L\_\ __ ___\ \ ,_\/\_\ ___ __\//\ \
|
#\ \,\L\_\ __ ___\ \ ,_\/\_\ ___ __\//\ \
|
||||||
@@ -9,9 +9,13 @@
|
|||||||
# ]======------ Configuration & Setup Guide ------=====[
|
# ]======------ Configuration & Setup Guide ------=====[
|
||||||
# Sentinel is inspired by WickBot.com
|
# Sentinel is inspired by WickBot.com
|
||||||
# Be sure to check out their amazing discord bot!
|
# Be sure to check out their amazing discord bot!
|
||||||
|
# If you need help, join the discord!
|
||||||
|
# https://discord.gg/sentinelmc v Use below if it expired
|
||||||
|
# https://sentinelauth.000webhostapp.com/discord.html
|
||||||
|
#
|
||||||
config:
|
config:
|
||||||
plugin:
|
plugin:
|
||||||
key: "beta" # if you are a beta tester, leave this value as "beta"
|
key: "beta" # Put your license key here. If you do not have one, join the discord to verify your purchase
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
# Anti-Nuke Setup (Do this first)
|
# Anti-Nuke Setup (Do this first)
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
@@ -55,6 +59,64 @@ config:
|
|||||||
- "smite %player%"
|
- "smite %player%"
|
||||||
- "ban %player% ]=- Sentinel -=[ You have been banned for attempting a dangerous action. If you believe this to be a mistake, please contact the server owner."
|
- "ban %player% ]=- Sentinel -=[ You have been banned for attempting a dangerous action. If you believe this to be a mistake, please contact the server owner."
|
||||||
reop-command: false # Defaulted false | This enables the command allowing trusted players to op themselves if they get deoped.
|
reop-command: false # Defaulted false | This enables the command allowing trusted players to op themselves if they get deoped.
|
||||||
|
nbt:
|
||||||
|
allow-name: true # Defaulted to true, weather or not to allow all item names durring creative inv event
|
||||||
|
allow-lore: true # Defaulted to true, weather or not to allow all item lore during creative inv event
|
||||||
|
allow-attributes: false # defaulted to false, weather or not to allow item attributes in a creative inv event
|
||||||
|
|
||||||
|
# Enchants
|
||||||
|
global-max-enchant: 5 # Defaulted to 5, if any enchantment is above this, it will get deleted. Set to 0 to disable all enchants from creative inv
|
||||||
|
# It is recommended to keep the ones defaulted to 1 at 1, as this will keep people who spam 32k onto every enchant will get caught
|
||||||
|
|
||||||
|
# All items
|
||||||
|
max-mending: 1 # Defaulted to 1
|
||||||
|
max-unbreaking: 3 # Defaulted to 3
|
||||||
|
max-vanishing: 1 # Defaulted to 1
|
||||||
|
|
||||||
|
# ARMOR
|
||||||
|
max-aqua-affinity: 1 # Defaulted to 1
|
||||||
|
max-blast-protection: 4 # Defaulted to 4
|
||||||
|
max-curse-of-binding: 1 # Defaulted to 1
|
||||||
|
max-depth-strider: 3 # Defaulted to 3
|
||||||
|
max-feather-falling: 4 # Defaulted to 4
|
||||||
|
max-fire-protection: 4 # Defaulted to 4
|
||||||
|
max-frost-walker: 2 # Defaulted to 2
|
||||||
|
max-projectile-protection: 4 # Defaulted to 4
|
||||||
|
max-protection: 4 # Defaulted to 4
|
||||||
|
max-respiration: 3 # Defaulted to 3
|
||||||
|
max-soul-speed: 3 # Defaulted to 3
|
||||||
|
max-thorns: 3 # Defaulted to 3
|
||||||
|
max-swift-sneak: 3 # Defaulted to 3
|
||||||
|
|
||||||
|
# MELEE WEAPONS
|
||||||
|
max-bane-of-arthropods: 5 # Defaulted to 5
|
||||||
|
max-efficiency: 5 # Defaulted to 5
|
||||||
|
max-fire-aspect: 2 # Defaulted to 2
|
||||||
|
max-looting: 3 # Defaulted to 3
|
||||||
|
max-impaling: 5 # Defaulted to 5
|
||||||
|
max-knockback: 2 # Defaulted to 2
|
||||||
|
max-sharpness: 5 # Defaulted to 5
|
||||||
|
max-smite: 5 # Defaulted to 5
|
||||||
|
max-sweeping-edge: 3 # Defaulted to 3
|
||||||
|
|
||||||
|
# RANGED WEAPONS
|
||||||
|
max-channeling: 1 # Defaulted to 1
|
||||||
|
max-flame: 1 # Defaulted to 1
|
||||||
|
max-infinity: 1 # Defaulted to 1
|
||||||
|
max-loyalty: 3 # Defaulted to 3
|
||||||
|
max-riptide: 3 # Defaulted to 3
|
||||||
|
max-multishot: 1 # Defaulted to 1
|
||||||
|
max-piercing: 4 # Defaulted to 4
|
||||||
|
max-power: 5 # Defaulted to 5
|
||||||
|
max-punch: 2 # Defaulted to 2
|
||||||
|
max-quick-charge: 3 # Defaulted to 3
|
||||||
|
|
||||||
|
# TOOLS
|
||||||
|
max-fortune: 3 # Defaulted to 3
|
||||||
|
max-luck-of-the-sea: 3 # Defaulted to 3
|
||||||
|
max-lure: 3 # Defaulted to 3
|
||||||
|
max-silk-touch: 1 # Defaulted to 1
|
||||||
|
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
# Chat Filter Setup & AntiSpam
|
# Chat Filter Setup & AntiSpam
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user