Added customization to the punishments, so its no longer just a ban, and also added location to the discord log of dangerous block usage.

This commit is contained in:
TheTelly1
2023-07-12 22:00:29 -05:00
parent cb669682be
commit 109eb3a43a
21 changed files with 447 additions and 237 deletions

View File

@@ -21,6 +21,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.util.List;
@@ -35,6 +36,7 @@ public final class Sentinel extends JavaPlugin {
public static final PluginManager manager = Bukkit.getPluginManager();
public static String prefix = "";
public static String key = "";
public static final Logger log = Bukkit.getLogger();
/**
@@ -42,25 +44,27 @@ public final class Sentinel extends JavaPlugin {
*/
@Override
public void onEnable() {
log.info("Your server ID is: " + Authenticator.getServerID());
switch (Authenticator.authorize(Config.license, Authenticator.getServerID())) {
case "AUTHORIZED" -> {
Config.loadConfiguration();
String serverID = Authenticator.getServerID();
log.info("Your license key is: " + key + " Your server ID is: " + serverID);
switch (Authenticator.authorize(key, serverID)) {
case "AUTHORIZED":
log.info("Authentication Success!");
}
case "INVALID-ID" -> {
break;
case "INVALID-ID":
log.info("Authentication Failure, You have not whitelisted this server ID yet.");
}
case "UNREGISTERED" -> {
log.info("YOU SHALL NOT PASS! License: " + Config.license + " Server ID: " + Authenticator.getServerID());
throw new IllegalStateException("YOU SHALL NOT PASS! License: " + Config.license + " Server ID: " + Authenticator.getServerID());
}
getServer().getPluginManager().disablePlugin(this);
break;
case "UNREGISTERED":
log.warning("Authentication Failure, YOU SHALL NOT PASS! License: " + key + " Server ID: " + serverID);
getServer().getPluginManager().disablePlugin(this);
return;
}
// Files
getConfig().options().copyDefaults();
saveDefaultConfig();
// Plugin startup logic
Config.loadConfiguration();
log.info("Sentinel has loaded! (" + getDescription().getVersion() + ")");
// Enable Functions

View File

@@ -29,7 +29,7 @@ public class InfoCommand implements TabExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
if (args.length == 0) {
sender.sendMessage(TextUtils.prefix("&cYou must specify an item to give."));
sender.sendMessage(TextUtils.prefix("§cYou must specify an option!"));
return true;
}
switch (args[0]) {

View File

@@ -18,6 +18,10 @@ import java.util.Map;
public abstract class Config {
private static final FileConfiguration config = Sentinel.getInstance().getConfig();
public static List<String> getPunishCommands() {
return punishCommands;
}
/**
* Config plugin section
*/
@@ -26,7 +30,6 @@ public abstract class Config {
return config.getString("config.plugin.prefix");
}
}
public static String license;
public static String webhook;
public static List<String> trustedPlayers;
public static boolean blockSpecificCommands;
@@ -34,11 +37,16 @@ public abstract class Config {
public static boolean logNBT;
public static boolean preventCmdBlocks;
public static boolean logCmdBlocks;
public static boolean cmdBlockOpCheck;
public static List<String> dangerousCommands;
public static boolean logDangerousCommands;
public static List<String> loggedCommands;
public static boolean deop;
public static boolean ban;
public static boolean nbtPunish;
public static boolean commandPunish;
public static boolean cmdblockPunish;
public static boolean specificPunish;
public static List<String> punishCommands;
public static boolean reopCommand;
public static boolean antiSpamEnabled;
@@ -73,7 +81,7 @@ public abstract class Config {
public static void loadConfiguration() {
Sentinel.prefix = config.getString("config.plugin.prefix");
license = config.getString("config.plugin.license");
Sentinel.key = config.getString("config.plugin.key");
// antiNuke
webhook = config.getString("config.plugin.webhook");
trustedPlayers = config.getStringList("config.plugin.trusted");
@@ -82,11 +90,16 @@ public abstract class Config {
logNBT = config.getBoolean("config.plugin.log-nbt");
preventCmdBlocks = config.getBoolean("config.plugin.prevent-cmdblocks");
logCmdBlocks = config.getBoolean("config.plugin.log-cmdblocks");
cmdBlockOpCheck = config.getBoolean("config.plugin.cmdblock-op-check");
dangerousCommands = config.getStringList("config.plugin.dangerous");
logDangerousCommands = config.getBoolean("config.plugin.log-dangerous");
loggedCommands = config.getStringList("config.plugin.logged");
deop = config.getBoolean("config.plugin.deop");
ban = config.getBoolean("config.plugin.ban");
nbtPunish = config.getBoolean("config.plugin.nbt-punish");
commandPunish = config.getBoolean("config.plugin.command-punish");
cmdblockPunish = config.getBoolean("config.plugin.cmdblock-punish");
specificPunish = config.getBoolean("config.plugin.punish-specific");
punishCommands = config.getStringList("config.plugin.punish-commands");
reopCommand = config.getBoolean("config.plugin.reop-command");
// antiSpam
antiSpamEnabled = config.getBoolean("config.chat.anti-spam.enabled");
@@ -132,4 +145,5 @@ public abstract class Config {
return dictionary;
}
}

View File

@@ -12,6 +12,7 @@ public class ChatEvent implements Listener {
@EventHandler
public static void onChat(AsyncPlayerChatEvent e) {
if (e.isCancelled()) return;
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antiswear.bypass")) if (Config.antiSwearEnabled) ProfanityFilter.handleProfanityFilter(e);
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antispam.bypass")) if (Config.antiSpamEnabled) AntiSpam.handleAntiSpam(e);
}

View File

@@ -17,6 +17,7 @@ public class CmdBlockEvents implements Listener {
@EventHandler
private void onCMDBlockUse(PlayerInteractEvent e) {
if (!Config.preventCmdBlocks) return;
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
if (e.getClickedBlock() == null) return;
Block b = e.getClickedBlock();
if (b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK) {
@@ -30,6 +31,7 @@ public class CmdBlockEvents implements Listener {
@EventHandler
private void onCMDBlockPlace(BlockPlaceEvent e) {
if (!Config.preventCmdBlocks) return;
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
Block b = e.getBlockPlaced();
if (b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK ) {
Player p = e.getPlayer();
@@ -42,6 +44,7 @@ public class CmdBlockEvents implements Listener {
@EventHandler
private void onCMDBlockMinecartUse(PlayerInteractEntityEvent e) {
if (!Config.preventCmdBlocks) return;
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
if (e.getRightClicked().getType() == EntityType.MINECART_COMMAND) {
Player p = e.getPlayer();
if (!Sentinel.isTrusted(p)) {
@@ -53,6 +56,7 @@ public class CmdBlockEvents implements Listener {
@EventHandler
private void onCMDBlockMinecartPlace(PlayerInteractEvent e) {
if (!Config.preventCmdBlocks) {
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
if (e.getItem() == null) return;
if (e.getClickedBlock() == null) return;
if (!e.getItem().getType().equals(Material.COMMAND_BLOCK_MINECART)) return;

View File

@@ -3,6 +3,9 @@ package io.github.thetrouper.sentinel.events;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.data.Config;
import io.github.thetrouper.sentinel.server.TakeAction;
import io.github.thetrouper.sentinel.server.util.Notifications.NotifyConsole;
import io.github.thetrouper.sentinel.server.util.Notifications.NotifyDiscord;
import io.github.thetrouper.sentinel.server.util.Notifications.NotifyTrusted;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import io.github.thetrouper.sentinel.server.util.TextUtils;
import org.bukkit.entity.Player;
@@ -32,9 +35,14 @@ public class CommandEvent implements Listener {
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
ServerUtils.sendDebugMessage(TextUtils.prefix("Command is canceled"));
TakeAction.command(e);
TakeAction.specific(e);
}
}
}
if (Sentinel.isLoggedCommand(command)) {
NotifyConsole.command(p,command,false,false,false,true);
NotifyDiscord.command(p,command,false,false,false,true);
NotifyTrusted.command(p,command,false,false,false,true);
}
}
}

View File

@@ -7,6 +7,7 @@ import io.github.thetrouper.sentinel.server.util.Notifications.NotifyConsole;
import io.github.thetrouper.sentinel.server.util.Notifications.NotifyDiscord;
import io.github.thetrouper.sentinel.server.util.Notifications.NotifyTrusted;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import io.github.thetrouper.sentinel.server.util.TextUtils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
@@ -20,11 +21,54 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class TakeAction {
// command nbt place useblock useentity
static List<String> punishCommands = Config.getPunishCommands();
public static void specific(PlayerCommandPreprocessEvent e) {
boolean deoped = false;
boolean punished = false;
boolean denied = false;
boolean logged = false;
Player p = e.getPlayer();
String message = e.getMessage();
String command = e.getMessage().substring(1).split(" ")[0];
if (Sentinel.isDangerousCommand(command)) {
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
denied = true;
}
}
if (Config.blockSpecificCommands) {
if (command.contains(":")) {
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
p.sendMessage(TextUtils.prefix("§cPlugin specific commands are disabled!"));
denied = true;
}
}
}
if (Config.deop) {
e.getPlayer().setOp(false);
deoped = true;
}
if (Config.specificPunish) {
for (String execute : punishCommands) {
Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
}
if (Config.logDangerousCommands) {
logged = true;
NotifyDiscord.specific(e.getPlayer(),message,denied,deoped,punished,true);
}
NotifyConsole.specific(e.getPlayer(),message,denied,deoped,punished,logged);
NotifyTrusted.specific(e.getPlayer(),message,denied,deoped,punished,logged);
}
public static void command(PlayerCommandPreprocessEvent e) {
boolean deoped = false;
boolean banned = false;
boolean punished = false;
boolean denied = false;
boolean logged = false;
Player p = e.getPlayer();
@@ -48,23 +92,26 @@ public class TakeAction {
e.getPlayer().setOp(false);
deoped = true;
}
if (Config.ban) {
ServerUtils.sendCommand("ban " + e.getPlayer().getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to use dangerous commands. Contact an administrator if you believe this to be a mistake.");
banned = true;
if (Config.commandPunish) {
for (String execute : punishCommands) {
Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
}
if (Config.logDangerousCommands) {
logged = true;
NotifyDiscord.command(e.getPlayer(),message,denied,deoped,banned,true);
NotifyDiscord.command(e.getPlayer(),message,denied,deoped,punished,true);
}
NotifyConsole.command(e.getPlayer(),message,denied,deoped,banned,logged);
NotifyTrusted.command(e.getPlayer(),message,denied,deoped,banned,logged);
NotifyConsole.command(e.getPlayer(),message,denied,deoped,punished,logged);
NotifyTrusted.command(e.getPlayer(),message,denied,deoped,punished,logged);
}
public static void NBT(InventoryCreativeEvent e) {
Player p = (Player) e.getWhoClicked();
final ItemStack item = e.getCursor();
boolean removed = false;
boolean deoped = false;
boolean banned = false;
boolean punished = false;
boolean logged = false;
boolean gms = false;
if (Config.preventNBT) {
@@ -80,23 +127,26 @@ public class TakeAction {
p.setOp(false);
deoped = true;
}
if (Config.ban) {
ServerUtils.sendCommand("ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to use dangerous items. Contact an administrator if you believe this to be a mistake.");
banned = true;
if (Config.nbtPunish) {
for (String execute : punishCommands) {
Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
}
if (Config.logNBT) {
logged = true;
NotifyDiscord.NBT(p,item,removed,deoped,gms,banned, true,FileUtils.createNBTLog(item.getType().toString().toLowerCase() + item.getItemMeta().getAsString()));
NotifyDiscord.NBT(p,item,removed,deoped,gms,punished, true,FileUtils.createNBTLog(item.getType().toString().toLowerCase() + item.getItemMeta().getAsString()));
}
NotifyConsole.NBT(p,item,removed,deoped,gms,banned,logged);
NotifyTrusted.NBT(p,item,removed,deoped,gms,banned,logged);
NotifyConsole.NBT(p,item,removed,deoped,gms,punished,logged);
NotifyTrusted.NBT(p,item,removed,deoped,gms,punished,logged);
}
public static void placeBlock(BlockPlaceEvent e) {
Block b = e.getBlock();
Player p = e.getPlayer();
boolean deleted = false;
boolean deoped = false;
boolean banned = false;
boolean punished = false;
boolean logged = false;
if (Config.preventCmdBlocks) {
e.setCancelled(true);
@@ -109,16 +159,19 @@ public class TakeAction {
p.setOp(false);
deoped = true;
}
if (Config.ban) {
ServerUtils.sendCommand("ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to place dangerous blocks. Contact an administrator if you believe this to be a mistake.");
banned = true;
if (Config.cmdblockPunish) {
for (String execute : punishCommands) {
Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
}
if (Config.logCmdBlocks) {
logged = true;
NotifyDiscord.placeBlock(p,b,deleted,deoped,banned,logged);
NotifyDiscord.placeBlock(p,b,deleted,deoped,punished,logged);
}
NotifyConsole.placeBlock(p,b,deleted,deoped,banned,logged);
NotifyTrusted.placeBlock(p,b,deleted,deoped,banned,logged);
NotifyConsole.placeBlock(p,b,deleted,deoped,punished,logged);
NotifyTrusted.placeBlock(p,b,deleted,deoped,punished,logged);
}
public static void useBlock(PlayerInteractEvent e) {
if (e.getClickedBlock() == null) return;
@@ -126,7 +179,7 @@ public class TakeAction {
Block b = e.getClickedBlock();
boolean denied = false;
boolean deoped = false;
boolean banned = false;
boolean punished = false;
boolean logged = false;
if (Config.preventCmdBlocks) {
e.setCancelled(true);
@@ -136,16 +189,19 @@ public class TakeAction {
p.setOp(false);
deoped = true;
}
if (Config.ban) {
ServerUtils.sendCommand("ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to use dangerous blocks. Contact an administrator if you believe this to be a mistake.");
banned = true;
if (Config.cmdblockPunish) {
for (String execute : punishCommands) {
Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
}
if (Config.logCmdBlocks) {
logged = true;
NotifyDiscord.usedBlock(p,b,denied,deoped,banned,logged);
NotifyDiscord.usedBlock(p,b,denied,deoped,punished,logged);
}
NotifyConsole.usedBlock(p,b,denied,deoped,banned,logged);
NotifyTrusted.usedBlock(p,b,denied,deoped,banned,logged);
NotifyConsole.usedBlock(p,b,denied,deoped,punished,logged);
NotifyTrusted.usedBlock(p,b,denied,deoped,punished,logged);
}
public static void useEntity(PlayerInteractEntityEvent e) {
if (e.getRightClicked() == null) return;
@@ -153,7 +209,7 @@ public class TakeAction {
Entity ent = e.getRightClicked();
boolean denied = false;
boolean deoped = false;
boolean banned = false;
boolean punished = false;
boolean logged = false;
if (Config.preventCmdBlocks) {
e.setCancelled(true);
@@ -163,15 +219,18 @@ public class TakeAction {
p.setOp(false);
deoped = true;
}
if (Config.ban) {
ServerUtils.sendCommand("ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to use dangerous entities. Contact an administrator if you believe this to be a mistake.");
banned = true;
if (Config.cmdblockPunish) {
for (String execute : punishCommands) {
Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
}
if (Config.logCmdBlocks) {
logged = true;
NotifyDiscord.usedEntity(p,ent,denied,deoped,banned,logged);
NotifyDiscord.usedEntity(p,ent,denied,deoped,punished,logged);
}
NotifyConsole.usedEntity(p,ent,denied,deoped,banned,logged);
NotifyTrusted.usedEntity(p,ent,denied,deoped,banned,logged);
NotifyConsole.usedEntity(p,ent,denied,deoped,punished,logged);
NotifyTrusted.usedEntity(p,ent,denied,deoped,punished,logged);
}
}

View File

@@ -64,12 +64,12 @@ public class AntiSpam {
public static void alertSpam(Player p, String message1, String message2) {
TextComponent text = new TextComponent();
p.sendMessage(TextUtils.prefix("Do not spam in chat! Please wait before sending another message."));
String hover = TextUtils.color("§8]==-- §d§lSentinel §8--==[" +
"\n&bPrevious: &f" + message2 +
"\n&bCurrent: &f" + message1 +
"\n&bSimilarity &f" + GPTUtils.calculateSimilarity(message1,message2 + "%"));
text.setText(TextUtils.prefix(TextUtils.color
("&b&n" + p.getName() + "&7 might be spamming! &8(&c" + heatMap.get(p) + "&7/&4" + Config.punishHeat + "&8)")));
String hover ="§8]==-- §d§lSentinel §8--==[" +
"\n§bPrevious: §f" + message2 +
"\n§bCurrent: §f" + message1 +
"\n§bSimilarity §f" + GPTUtils.calculateSimilarity(message1,message2 + "%");
text.setText(TextUtils.prefix(
"§b§n" + p.getName() + "§7 might be spamming! §8(§c" + heatMap.get(p) + "§7/§4" + Config.punishHeat + "§8)"));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
ServerUtils.forEachStaff(staff -> {
staff.spigot().sendMessage(text);
@@ -82,10 +82,10 @@ public class AntiSpam {
chatCleared = true;
}
ServerUtils.sendCommand(Config.punishSpamCommand.replace("%player%", player.getName()));
player.sendMessage(TextUtils.prefix(TextUtils.color("&cYou have been auto-punished for violating the anti-spam repetitively!")));
player.sendMessage(TextUtils.prefix("§cYou have been auto-punished for violating the anti-spam repetitively!"));
TextComponent text = new TextComponent();
text.setText(TextUtils.prefix(TextUtils.color
("&b&n" + player.getName() + "&7 has been auto-muted by the anti-spam! &8(&c" + heatMap.get(player) + "&7/&4" + Config.punishHeat + "&8)")));
text.setText(TextUtils.prefix(
"§b§n" + player.getName() + "§7 has been auto-muted by the anti-spam! §8(§c" + heatMap.get(player) + "§7/§4" + Config.punishHeat + "§8)"));
ServerUtils.forEachStaff(staff -> {
staff.spigot().sendMessage(text);
});

View File

@@ -12,7 +12,17 @@ import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public class Authenticator {
@@ -31,33 +41,65 @@ public class Authenticator {
}
}
public static String authorize(String license, String serverID) {
public static String authorize(String licenseKey, String serverID) {
String authStatus = "";
try {
URL url = new URL("https://sentinelauth.000webhostapp.com");
URL url = new URL("https://sentinelauth.000webhostapp.com/index.html");
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = reader.readLine()) != null) {
if (line.contains(license)) {
String[] parts = line.split(":");
if (parts.length > 1) {
String[] allowedIDs = parts[1].split("\\s+");
for (String id : allowedIDs) {
if (id.equals(serverID)) {
reader.close();
return "AUTHORIZED";
}
List<String> lines = readLines(reader);
for (String line : lines) {
if (line.contains("data-key")) {
String key = extractValue(line, "data-key");
String allowedIDs = extractValue(line, "data-allowed");
String[] allowedArr = allowedIDs.split(":");
if (key.equals(licenseKey)) {
if (Arrays.asList(allowedArr).contains(serverID)) {
authStatus = "AUTHORIZED";
} else {
authStatus = "INVALID-ID";
}
break;
}
reader.close();
return "INVALID-ID";
}
}
reader.close();
if (authStatus.isEmpty()) {
authStatus = "UNREGISTERED";
}
} catch (IOException e) {
e.printStackTrace();
}
return "UNREGISTERED";
return authStatus;
}
public static List<String> readLines(BufferedReader reader) {
try {
List<String> lines = new ArrayList<>();
String line = reader.readLine();
while (line != null) {
lines.add(line);
line = reader.readLine();
}
reader.close();
return lines;
} catch (Exception ex) {
ex.printStackTrace();
}
return new ArrayList<>();
}
public static String extractValue(String line, String attribute) {
int start = line.indexOf(attribute + "=\"") + attribute.length() + 2;
int end = line.indexOf("\"", start);
return line.substring(start, end);
}
public static String getServerID() {
return encrypt(IP.getHostAddress());
}

View File

@@ -72,11 +72,11 @@ public class ProfanityFilter {
}
public static void punishSwear(Player player, String highlightedMSG, String origMessage) {
ServerUtils.sendCommand(Config.swearPunishCommand.replace("%player%", player.getName()));
player.sendMessage(TextUtils.prefix(TextUtils.color("&cYou have been auto-muted for violating the anti-swear repetitively!")));
String hover = TextUtils.color("&bOriginal: &f" + origMessage + "\n&bSanitized: &f" + highlightedMSG + "\n&7&o(click to copy)");
player.sendMessage(TextUtils.prefix(("§cYou have been auto-muted for violating the anti-swear repetitively!")));
String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§7§o(click to copy)");
TextComponent text = new TextComponent();
text.setText(TextUtils.prefix(TextUtils.color
("&b&n" + player.getName() + "&7 has been auto-muted by the anti-swear! &8(&c" + scoreMap.get(player) + "&7/&4" + Config.punishScore + "&8)")));
text.setText(TextUtils.prefix(
("§b§n" + player.getName() + "§7 has been auto-muted by the anti-swear! §8(§c" + scoreMap.get(player) + "§7/§4" + Config.punishScore + "§8)")));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
text.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, origMessage));
@@ -88,11 +88,11 @@ public class ProfanityFilter {
public static void punishSlur(Player player, String highlightedMSG, String origMessage) {
if (!Config.slurInstaPunish) return;
ServerUtils.sendCommand(Config.slurPunishCommand.replace("%player%", player.getName()));
player.sendMessage(TextUtils.prefix(TextUtils.color("&cYou have been insta-muted for saying a slur!")));
String hover = TextUtils.color("&bOriginal: &f" + origMessage + "\n&bSanitized: &f" + highlightedMSG + "\n&7&o(click to copy)");
player.sendMessage(TextUtils.prefix(("§cYou have been insta-muted for saying a slur!")));
String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§7§o(click to copy)");
TextComponent text = new TextComponent();
text.setText(TextUtils.prefix(TextUtils.color
("&b&n" + player.getName() + "&7 has been insta-muted by the anti-swear! &8(&e" + scoreMap.get(player) + "&7/&4" + Config.punishScore + "&8)")));
text.setText(TextUtils.prefix(
("§b§n" + player.getName() + "§7 has been insta-muted by the anti-swear! §8(§e" + scoreMap.get(player) + "§7/§4" + Config.punishScore + "§8)")));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
text.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, origMessage));
@@ -102,11 +102,11 @@ public class ProfanityFilter {
if (Config.logSwear) WebhookSender.sendSlurLog(player,origMessage,scoreMap.get(player));
}
public static void blockSwear(Player player, String highlightedMSG, String origMessage, String severity) {
player.sendMessage(TextUtils.prefix(TextUtils.color("&cPlease do not swear in chat! Attempting to bypass this filter will result in a mute!")));
String hover = TextUtils.color("&bOriginal: &f" + origMessage + "\n&bSanitized: &f" + highlightedMSG + "\n&bSeverity" + severity + "\n&7&o(click to copy)");
player.sendMessage(TextUtils.prefix(("§cPlease do not swear in chat! Attempting to bypass this filter will result in a mute!")));
String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§bSeverity" + severity + "\n§7§o(click to copy)");
TextComponent text = new TextComponent();
text.setText(TextUtils.prefix(TextUtils.color
("&b&n" + player.getName() + "&7 has triggered the anti-swear! &8(&c" + scoreMap.get(player) + "&7/&4" + Config.punishScore + "&8)")));
text.setText(TextUtils.prefix(
("§b§n" + player.getName() + "§7 has triggered the anti-swear! §8(§c" + scoreMap.get(player) + "§7/§4" + Config.punishScore + "§8)")));
text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
text.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, origMessage));

View File

@@ -25,7 +25,7 @@ public final class ArrayUtils {
}
public static <T> String list2string(List<T> list) {
return TextUtils.color("&7[&e" + String.join("&7, &e", ArrayUtils.toNewList(list, Object::toString)) + "&7]");
return ("§7[§e" + String.join("§7, §e", ArrayUtils.toNewList(list, Object::toString)) + "§7]");
}
public static <T> List<T> bind(Iterable<T> tList, T... ts) {

View File

@@ -13,67 +13,79 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class NotifyConsole {
public static void command(Player p, String command, boolean denied, boolean deoped, boolean banned, boolean logged) {
public static void specific(Player p, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
final String log = (
"Sentinel caught a dangerous command! \n]==-- &d&lSentinel --==[" +
"Sentinel caught a specific command! \n]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() +
"\nCommand: " + command +
"\nDenied: " + TextUtils.boolString(denied,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
);
Sentinel.log.info(log);
}
public static void command(Player p, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
final String log = (
"Sentinel caught a dangerous command! \n]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() +
"\nCommand: " + command +
"\nDenied: " + TextUtils.boolString(denied,"","") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") +
"\nBanned: " + TextUtils.boolString(banned,"","") +
"\nLogged: " + TextUtils.boolString(logged,"","")
"\nDenied: " + TextUtils.boolString(denied,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
);
Sentinel.log.info(log);
}
public static void NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean banned, boolean logged) {
public static void NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged) {
String log = (
"Sentinel caught a dangerous NBT! \n]==-- &d&lSentinel --==[" +
"Sentinel caught a dangerous NBT! \n]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() +
"\nItemType: " + item.getType() +
"\nRemoved: " + TextUtils.boolString(removed,"","") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") +
"\nRevert GM: " + TextUtils.boolString(gms, "", "") +
"\nBanned: " + TextUtils.boolString(banned,"","") +
"\nLogged: " + TextUtils.boolString(logged,"","")
"\nRemoved: " + TextUtils.boolString(removed,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nRevert GM: " + TextUtils.boolString(gms, "\u2714","\u2718") +
"\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
);
Sentinel.log.info(log);
}
public static void placeBlock(Player p, Block b, boolean deleted, boolean deoped, boolean banned, boolean logged) {
public static void placeBlock(Player p, Block b, boolean deleted, boolean deoped, boolean punished, boolean logged) {
String log = (
"Sentinel has caught the placing of a dangerous block! \n]==-- &d&lSentinel --==[" +
"Sentinel has caught the placing of a dangerous block! \n]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() +
"\nBlockType: " + b.getType() +
"\nLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
"\nDeleted: " + TextUtils.boolString(deleted,"","") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") +
"\nBanned: " + TextUtils.boolString(banned,"","") +
"\nLogged: " + TextUtils.boolString(logged,"","")
"\nDeleted: " + TextUtils.boolString(deleted,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
);
Sentinel.log.info(log);
}
public static void usedBlock(Player p, Block b, boolean denied, boolean deoped, boolean banned, boolean logged) {
public static void usedBlock(Player p, Block b, boolean denied, boolean deoped, boolean punished, boolean logged) {
String log = (
"]==-- &d&lSentinel --==[" +
"]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() +
"\nBlockType: " + b.getType() +
"\nLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
"\nDenied: " + TextUtils.boolString(denied,"","") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") +
"\nBanned: " + TextUtils.boolString(banned,"","") +
"\nLogged: " + TextUtils.boolString(logged,"","")
"\nDenied: " + TextUtils.boolString(denied,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
);
Sentinel.log.info(log);
}
public static void usedEntity(Player p, Entity e, boolean denied, boolean deoped, boolean banned, boolean logged) {
public static void usedEntity(Player p, Entity e, boolean denied, boolean deoped, boolean punished, boolean logged) {
String log = (
"]==-- &d&lSentinel --==[" +
"]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() +
"\nEntityType: " + e.getType() +
"\nLocation: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ() +
"\nDenied: " + TextUtils.boolString(denied,"","") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") +
"\nBanned: " + TextUtils.boolString(banned,"","") +
"\nLogged: " + TextUtils.boolString(logged,"","")
"\nDenied: " + TextUtils.boolString(denied,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
);
Sentinel.log.info(log);
}

View File

@@ -16,7 +16,36 @@ import java.awt.*;
import java.io.IOException;
public class NotifyDiscord {
public static void command(Player player, String command, boolean denied, boolean deoped, boolean banned, boolean logged) {
public static void specific(Player player, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
ServerUtils.sendDebugMessage("Creating Specific Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
webhook.setUsername("Sentinel Anti-Nuke | Logs");
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
.setAuthor("Anti-Nuke has been triggered","","")
.setTitle("The use of a specific command has been detected!")
.setDescription(
Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n" +
Emojis.rightSort + " **Command:** " + command + " " + Emojis.nuke + "\\n"
)
.addField("Actions:",
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + "**Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.setThumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay")
.setColor(Color.RED);
webhook.addEmbed(embed);
try {
ServerUtils.sendDebugMessage("Executing webhook...");
webhook.execute();
} catch (IOException e) {
ServerUtils.sendDebugMessage(TextUtils.prefix("Epic webhook failure!!!"));
Sentinel.log.info(e.toString());
}
}
public static void command(Player player, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
ServerUtils.sendDebugMessage("Creating Command Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
@@ -31,7 +60,7 @@ public class NotifyDiscord {
.addField("Actions:",
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **Banned:** " + TextUtils.boolString(banned,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + "**Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.setThumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay")
@@ -45,7 +74,7 @@ public class NotifyDiscord {
Sentinel.log.info(e.toString());
}
}
public static void NBT(Player player, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean banned, boolean logged, String logFileName) {
public static void NBT(Player player, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged, String logFileName) {
ServerUtils.sendDebugMessage("Creating NBT Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
@@ -63,7 +92,7 @@ public class NotifyDiscord {
Emojis.rightSort + " **Removed:** " + TextUtils.boolString(removed,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **GM Reverted:** " + TextUtils.boolString(gms,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **Banned:** " + TextUtils.boolString(banned,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.setColor(Color.BLUE);
@@ -76,7 +105,7 @@ public class NotifyDiscord {
Sentinel.log.info(e.toString());
}
}
public static void placeBlock(Player player, Block b, boolean deleted, boolean deoped, boolean banned, boolean logged) {
public static void placeBlock(Player player, Block b, boolean deleted, boolean deoped, boolean punished, boolean logged) {
ServerUtils.sendDebugMessage("Creating placeBlock Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
@@ -86,12 +115,13 @@ public class NotifyDiscord {
.setTitle("The placing of a dangerous block has been detected!")
.setDescription(
Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n" +
Emojis.rightSort + " **Block:** " + b.getType().toString().toLowerCase() + " " + Emojis.nuke + "\\n"
Emojis.rightSort + " **Block:** " + b.getType().toString().toLowerCase() + " " + Emojis.nuke + "\\n" +
Emojis.space + Emojis.rightDoubleArrow + " **Location:** X: " + b.getX() + " Y: " + b.getY() + " Z: " + b.getZ() + "\\n"
)
.addField("Actions:",
Emojis.rightSort + " **Deleted:** " + TextUtils.boolString(deleted,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **Banned:** " + TextUtils.boolString(banned,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.setColor(Color.RED);
@@ -104,7 +134,7 @@ public class NotifyDiscord {
Sentinel.log.info(e.toString());
}
}
public static void usedBlock(Player player, Block b, boolean denied, boolean deoped, boolean banned, boolean logged) {
public static void usedBlock(Player player, Block b, boolean denied, boolean deoped, boolean punished, boolean logged) {
ServerUtils.sendDebugMessage("Creating useBlock Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
@@ -114,12 +144,13 @@ public class NotifyDiscord {
.setTitle("The use of a dangerous block has been detected!")
.setDescription(
Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n" +
Emojis.rightSort + " **Block:** " + b.getType() + " " + Emojis.nuke + "\\n"
Emojis.rightSort + " **Block:** " + b.getType() + " " + Emojis.nuke + "\\n" +
Emojis.space + Emojis.rightDoubleArrow + " **Location:** X: " + b.getX() + " Y: " + b.getY() + " Z: " + b.getZ() + "\\n"
)
.addField("Actions:",
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **Banned:** " + TextUtils.boolString(banned,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.setColor(Color.RED);
@@ -132,7 +163,7 @@ public class NotifyDiscord {
Sentinel.log.info(e.toString());
}
}
public static void usedEntity(Player player, Entity e, boolean denied, boolean deoped, boolean banned, boolean logged) {
public static void usedEntity(Player player, Entity e, boolean denied, boolean deoped, boolean punished, boolean logged) {
ServerUtils.sendDebugMessage("Creating useEntity Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
@@ -142,12 +173,13 @@ public class NotifyDiscord {
.setTitle("The use of a dangerous entity has been detected!")
.setDescription(
Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n" +
Emojis.rightSort + " **Entity:** " + e.getType() + " " + Emojis.nuke + "\\n"
Emojis.rightSort + " **Entity:** " + e.getType() + " " + Emojis.nuke + "\\n" +
Emojis.space + Emojis.rightDoubleArrow + " **Location:** X: " + e.getLocation().getX() + " Y: " + e.getLocation().getY() + " Z: " + e.getLocation().getZ() + "\\n"
)
.addField("Actions:",
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **Banned:** " + TextUtils.boolString(banned,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.setColor(Color.RED);

View File

@@ -15,18 +15,35 @@ import org.bukkit.event.server.ServerEvent;
import org.bukkit.inventory.ItemStack;
public class NotifyTrusted {
public static void command(Player p, String command, boolean denied, boolean deoped, boolean banned, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted a dangerous command!")));
public static void specific(Player p, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix("§b§n" + p.getName() + "§7 Has just attempted a specific command!"));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
TextUtils.color(
"&8]==-- &d&lSentinel &8--==[" +
"\n&bPlayer: &f" + p.getName() +
"\n&bCommand: &f" + command +
"\n&bDenied: " + TextUtils.boolString(denied,"&a✔","&c✘") +
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘")
)
"§8]==-- §d§lSentinel §8--==[" +
"\n§bPlayer: §f" + p.getName() +
"\n§bCommand: §f" + command +
"\n§bDenied: " + TextUtils.boolString(denied,"§a\u2714","§c\u2718") +
"\n§bDeoped: " + TextUtils.boolString(deoped,"§a\u2714","§c\u2718") +
"\n§bPunished: " + TextUtils.boolString(punished,"§a\u2714","§c\u2718") +
"\n§bLogged: " + TextUtils.boolString(logged,"§a\u2714","§c\u2718")
)));
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
if (Sentinel.isTrusted(trustedPlayer)) {
trustedPlayer.spigot().sendMessage(notification);
}
}
}
public static void command(Player p, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix("§b§n" + p.getName() + "§7 Has just attempted a dangerous command!"));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
"§8]==-- §d§lSentinel §8--==[" +
"\n§bPlayer: §f" + p.getName() +
"\n§bCommand: §f" + command +
"\n§bDenied: " + TextUtils.boolString(denied,"§a\u2714","§c\u2718") +
"\n§bDeoped: " + TextUtils.boolString(deoped,"§a\u2714","§c\u2718") +
"\n§bPunished: " + TextUtils.boolString(punished,"§a\u2714","§c\u2718") +
"\n§bLogged: " + TextUtils.boolString(logged,"§a\u2714","§c\u2718")
)));
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
@@ -35,21 +52,20 @@ public class NotifyTrusted {
}
}
}
public static void NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean banned, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted to use a dangerous NBT item!")));
public static void NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix("§b§n" + p.getName() + "§7 Has just attempted to use a dangerous NBT item!"));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
TextUtils.color(
"&8]==-- &d&lSentinel &8--==[" +
"\n&bPlayer: &f" + p.getName() +
"\n&bItemType: &f" + item.getType() +
"\n&bRemoved: " + TextUtils.boolString(removed,"&a✔","&c✘") +
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
"\n&bRevert GM: " + TextUtils.boolString(gms, "&a✔", "&c✘") +
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘") +
"\n&7(Click to copy NBT)"
"§8]==-- §d§lSentinel §8--==[" +
"\n§bPlayer: §f" + p.getName() +
"\n§bItemType: §f" + item.getType() +
"\n§bRemoved: " + TextUtils.boolString(removed,"§a\u2714","§c\u2718") +
"\n§bDeoped: " + TextUtils.boolString(deoped,"§a\u2714","§c\u2718") +
"\n§bRevert GM: " + TextUtils.boolString(gms, "§a\u2714","§c\u2718") +
"\n§bPunished: " + TextUtils.boolString(punished,"§a\u2714","§c\u2718") +
"\n§bLogged: " + TextUtils.boolString(logged,"§a\u2714","§c\u2718") +
"\n§7(Click to copy NBT)"
))));
)));
notification.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, new String(item.getType().toString().toLowerCase() + item.getItemMeta().getAsString())));
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
if (Sentinel.isTrusted(trustedPlayer)) {
@@ -57,19 +73,19 @@ public class NotifyTrusted {
}
}
}
public static void placeBlock(Player p, Block b, boolean removed, boolean deoped, boolean banned, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted to place a dangerous block!")));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(TextUtils.color(
"&8]==-- &d&lSentinel &8--==[" +
"\n&bPlayer: &f" + p.getName() +
"\n&bBlockType: &f" + b.getType() +
"\n&bLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
"\n&bRemoved: " + TextUtils.boolString(removed,"&a✔","&c✘") +
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘") +
"\n&7(Click to Teleport)"
))));
public static void placeBlock(Player p, Block b, boolean removed, boolean deoped, boolean punished, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix("§b§n" + p.getName() + "§7 Has just attempted to place a dangerous block!"));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
"§8]==-- §d§lSentinel §8--==[" +
"\n§bPlayer: §f" + p.getName() +
"\n§bBlockType: §f" + b.getType() +
"\n§bLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
"\n§bRemoved: " + TextUtils.boolString(removed,"§a\u2714","§c\u2718") +
"\n§bDeoped: " + TextUtils.boolString(deoped,"§a\u2714","§c\u2718") +
"\n§bPunished: " + TextUtils.boolString(punished,"§a\u2714","§c\u2718") +
"\n§bLogged: " + TextUtils.boolString(logged,"§a\u2714","§c\u2718") +
"\n§7(Click to Teleport)"
)));
notification.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "tp " + p.getName()));
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
if (Sentinel.isTrusted(trustedPlayer)) {
@@ -77,19 +93,19 @@ public class NotifyTrusted {
}
}
}
public static void usedBlock(Player p, Block b, boolean denied, boolean deoped, boolean banned, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted to use a dangerous block!")));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(TextUtils.color(
"&8]==-- &d&lSentinel &8--==[" +
"\n&bPlayer: &f" + p.getName() +
"\n&bBlockType: &f" + b.getType() +
"\n&bLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
"\n&bDenied: " + TextUtils.boolString(denied,"&a✔","&c✘") +
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘") +
"\n&7(Click to Teleport)"
))));
public static void usedBlock(Player p, Block b, boolean denied, boolean deoped, boolean punished, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix("§b§n" + p.getName() + "§7 Has just attempted to use a dangerous block!"));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
"§8]==-- §d§lSentinel §8--==[" +
"\n§bPlayer: §f" + p.getName() +
"\n§bBlockType: §f" + b.getType() +
"\n§bLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
"\n§bDenied: " + TextUtils.boolString(denied,"§a\u2714","§c\u2718") +
"\n§bDeoped: " + TextUtils.boolString(deoped,"§a\u2714","§c\u2718") +
"\n§bPunished: " + TextUtils.boolString(punished,"§a\u2714","§c\u2718") +
"\n§bLogged: " + TextUtils.boolString(logged,"§a\u2714","§c\u2718") +
"\n§7(Click to Teleport)"
)));
notification.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "tp " + p.getName()));
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
if (Sentinel.isTrusted(trustedPlayer)) {
@@ -97,19 +113,19 @@ public class NotifyTrusted {
}
}
}
public static void usedEntity(Player p, Entity e, boolean denied, boolean deoped, boolean banned, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted to use a dangerous entity!")));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(TextUtils.color(
"&8]==-- &d&lSentinel &8--==[" +
"\n&bPlayer: &f" + p.getName() +
"\n&bEntityType: &f" + e.getType() +
"\n&bLocation: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ() +
"\n&bDenied: " + TextUtils.boolString(denied,"&a✔","&c✘") +
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘") +
"\n&7(Click to Teleport)"
))));
public static void usedEntity(Player p, Entity e, boolean denied, boolean deoped, boolean punished, boolean logged) {
TextComponent notification = new TextComponent(TextUtils.prefix("§b§n" + p.getName() + "§7 Has just attempted to use a dangerous entity!"));
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
"§8]==-- §d§lSentinel §8--==[" +
"\n§bPlayer: §f" + p.getName() +
"\n§bEntityType: §f" + e.getType() +
"\n§bLocation: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ() +
"\n§bDenied: " + TextUtils.boolString(denied,"§a\u2714","§c\u2718") +
"\n§bDeoped: " + TextUtils.boolString(deoped,"§a\u2714","§c\u2718") +
"\n§bPunished: " + TextUtils.boolString(punished,"§a\u2714","§c\u2718") +
"\n§bLogged: " + TextUtils.boolString(logged,"§a\u2714","§c\u2718") +
"\n§7(Click to Teleport)"
)));
notification.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "tp " + p.getName()));
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
if (Sentinel.isTrusted(trustedPlayer)) {

View File

@@ -1,4 +1,4 @@
# Sentinel 0.0.2
# Sentinel 0.1.5
# ____ __ ___
#/\ _`\ /\ \__ __ /\_ \
#\ \,\L\_\ __ ___\ \ ,_\/\_\ ___ __\//\ \
@@ -11,7 +11,7 @@
# Be sure to check out their amazing discord bot!
config :
plugin:
license: "beta" # if you are a beta tester, leave this value as "beta"
key: "beta" # if you are a beta tester, leave this value as "beta"
# --------------------------------
# Anti-Nuke Setup (Do this first)
# --------------------------------
@@ -22,26 +22,34 @@ config :
block-specific: true # Defaulted true | Weather or not to block ALL plugin specific commands from non-trusted members (EX: minecraft:execute) these will not be logged.
prevent-nbt: true # Defaulted true | Should NBT items be blocked from the creative hotbar
prevent-cmdblocks: true # Defaulted true | Should all command block actions be blocked
cmdblock-op-check: true # Defaulted true | Will check if a player is op'd before preforming actions against command blocks (To prevent spam from non oped users attempting command blocks, which they cant by default)
dangerous: # These commands can only be run by "trusted" users
- "op"
- "deop"
- "stop"
- "restart"
- "execute" # Could run commands as a trusted player
- "sudo" # same as above
- "esudo" # WATCH OUT FOR ESSENTIALS ALIASES !!!
- "fill" # Most client side nukers use it
- "setblock" # could setblock a command block with anything
- "data" # Could modify a command block to whatever they wanted
- "whitelist" # Could add other players to the whitelist
log-dangerous: true # Default true | Weather or not to log to discord when a dangerous command is executed
log-cmdblocks: true # Defaulted true | Log attempts of command-block place-ery in discord
log-nbt: true # Defaulted true | Should items and their NBT's be logged to discord
log-specific: false # Default false | Weather or not to log to discord when a plugin specific command is executed
logged: # Commands that will always be logged to discord when executed.
- "gamemode"
- "give"
- "item"
deop: true # Defaulted true | This will remove an untrusted player's operator permissions whenever they attempt dangerous actions
ban: false # Default false | Weather or not to ban a player if they attempt something dangerous.
nbt-punish: false # Defaulted false | This will ban a player when they attempt to use an NBT item
cmdblock-punish: false # Defaulted false | This will ban a player when they attempt to use a command block
command-punish: true # Defaulted true | This will ban a player when they attempt to use a dangerous command
nbt-punish: false # Defaulted false | This will punish a player when they attempt to use an NBT item
cmdblock-punish: false # Defaulted false | This will punish a player when they attempt to use a command block
command-punish: false # Defaulted false | This will ban punish player when they attempt to use a dangerous command
specific-punish: false # Defaulted false | This will punish a player when they run a specific command (Not recomended)
punish-commands: # Commands to run when a dangerous action is to be punished. Use %player% for the punished player's name
- "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."
reop-command: false # Defaulted false | This enables the command allowing trusted players to op themselves if they get deoped.
# -------------------------------
# Chat Filter Setup & AntiSpam
@@ -108,7 +116,7 @@ config :
- grape
- grass
- harass
- hot water
- hotwater
- identit
- kassa
- kassi