Updated a lot

This commit is contained in:
TheTelly1
2023-08-04 12:17:58 -05:00
parent 6fd3572953
commit cc553718cc
24 changed files with 611 additions and 826 deletions

View File

@@ -126,7 +126,7 @@ public final class Sentinel extends JavaPlugin {
* @return true if the command is logged, false otherwise
*/
public static boolean isLoggedCommand(String command) {
return Config.loggedCommands.contains(command);
return Config.logged.contains(command);
}
/**
@@ -135,7 +135,7 @@ public final class Sentinel extends JavaPlugin {
* @return true if the command is dangerous, false otherwise
*/
public static boolean isDangerousCommand(String command) {
return Config.dangerousCommands.contains(command);
return Config.dangerous.contains(command);
}
/**
* Returns an instance of this plugin

View File

@@ -4,10 +4,26 @@
package io.github.thetrouper.sentinel.commands;
import com.google.gson.Gson;
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 org.bukkit.Location;
import org.bukkit.Material;
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 java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.*;
/**
* Example command
*/
@@ -16,6 +32,7 @@ public class SentinelCommand extends CustomCommand {
public SentinelCommand() {
super("sentinel");
this.setPrintStacktrace(true);
}
@Override
@@ -26,13 +43,12 @@ public class SentinelCommand extends CustomCommand {
debugmode = !debugmode;
p.sendMessage(TextUtils.prefix(TextUtils.boolString(debugmode,"§aEnabled","§cDisabled") + "§7 debug mode."));
}
case "whitelistcommandblock" -> {
}
}
}
@Override
public void registerCompletions(CompletionBuilder builder) {
builder.addCompletion(1,"debugmode");
builder.addCompletion(1,"whitelistcommandblock");
}
}

View File

@@ -28,8 +28,7 @@ public class SocialSpyCommand extends CustomCommand {
if (!spyMap.containsKey(senderID) || !spyMap.get(senderID)) {
sender.sendMessage(TextUtils.prefix("SocialSpy is now enabled."));
spyMap.put(senderID,true);
}
if (spyMap.get(senderID)) {
} else if (spyMap.get(senderID)) {
sender.sendMessage(TextUtils.prefix("SocialSpy is now disabled."));
spyMap.put(senderID,false);
}

View File

@@ -32,25 +32,30 @@ public abstract class Config {
}
public static String webhook;
public static List<String> trustedPlayers;
public static boolean blockSpecificCommands;
public static boolean blockSpecific;
public static boolean preventNBT;
public static boolean logNBT;
public static boolean preventCmdBlocks;
public static boolean logCmdBlocks;
public static boolean preventCmdBlockPlace;
public static boolean preventCmdBlockUse;
public static boolean preventCmdBlockChange;
public static boolean preventCmdCartPlace;
public static boolean preventCmdCartUse;
public static boolean cmdBlockOpCheck;
public static List<String> dangerousCommands;
public static boolean logDangerousCommands;
public static List<String> loggedCommands;
public static List<String> dangerous;
public static boolean logDangerous;
public static boolean logCmdBlocks;
public static boolean logNBT;
public static boolean logSpecific;
public static List<String> logged;
public static boolean deop;
public static boolean nbtPunish;
public static boolean cmdBlockPunish;
public static boolean commandPunish;
public static boolean cmdblockPunish;
public static boolean specificPunish;
public static List<String> punishCommands;
public static boolean reopCommand;
public static boolean blockUnicode;
// Chat Filter Setup & AntiSpam
public static boolean antiUnicode;
public static boolean antiSpamEnabled;
public static int defaultGain;
public static int lowGain;
@@ -59,9 +64,9 @@ public abstract class Config {
public static int heatDecay;
public static int blockHeat;
public static int punishHeat;
public static String punishSpamCommand;
public static String clearChatCommand;
public static boolean clearChat;
public static String chatClearCommand;
public static String spamPunishCommand;
public static boolean logSpam;
public static boolean antiSwearEnabled;
public static int lowScore;
@@ -69,45 +74,47 @@ public abstract class Config {
public static int mediumScore;
public static int mediumHighScore;
public static int highScore;
public static int scoreDecay;
public static int punishScore;
public static boolean strictInstaPunish;
public static String swearPunishCommand;
public static boolean slurInstaPunish;
public static String slurPunishCommand;
public static Integer scoreDecay;
public static String strictPunishCommand;
public static boolean logSwear;
public static List<String> swearWhitelist;
public static List<String> swearBlacklist;
public static List<String> slurs;
public static Map<String, String> leetPatterns;
public static boolean logSwear;
public static void loadConfiguration() {
Sentinel.prefix = config.getString("config.plugin.prefix");
Sentinel.key = config.getString("config.plugin.key");
// antiNuke
webhook = config.getString("config.plugin.webhook");
trustedPlayers = config.getStringList("config.plugin.trusted");
blockSpecificCommands = config.getBoolean("config.plugin.block-specific");
blockSpecific = config.getBoolean("config.plugin.block-specific");
preventNBT = config.getBoolean("config.plugin.prevent-nbt");
logNBT = config.getBoolean("config.plugin.log-nbt");
preventCmdBlocks = config.getBoolean("config.plugin.prevent-cmdblocks");
logCmdBlocks = config.getBoolean("config.plugin.log-cmdblocks");
preventCmdBlockPlace = config.getBoolean("config.plugin.prevent-cmdblock-place");
preventCmdBlockUse = config.getBoolean("config.plugin.prevent-cmdblock-use");
preventCmdBlockChange = config.getBoolean("config.plugin.prevent-cmdblock-change");
preventCmdCartPlace = config.getBoolean("config.plugin.prevent-cmdcart-place");
preventCmdCartUse = config.getBoolean("config.plugin.prevent-cmdcart-use");
cmdBlockOpCheck = config.getBoolean("config.plugin.cmdblock-op-check");
dangerous = config.getStringList("config.plugin.dangerous");
logDangerous = config.getBoolean("config.plugin.log-dangerous");
logCmdBlocks = config.getBoolean("config.plugin.log-cmdblocks");
logNBT = config.getBoolean("config.plugin.log-nbt");
logSpecific = config.getBoolean("config.plugin.log-specific");
dangerousCommands = config.getStringList("config.plugin.dangerous");
logDangerousCommands = config.getBoolean("config.plugin.log-dangerous");
loggedCommands = config.getStringList("config.plugin.logged");
logged = config.getStringList("config.plugin.logged");
deop = config.getBoolean("config.plugin.deop");
nbtPunish = config.getBoolean("config.plugin.nbt-punish");
cmdBlockPunish = config.getBoolean("config.plugin.cmdblock-punish");
commandPunish = config.getBoolean("config.plugin.command-punish");
cmdblockPunish = config.getBoolean("config.plugin.cmdblock-punish");
specificPunish = config.getBoolean("config.plugin.punish-specific");
specificPunish = config.getBoolean("config.plugin.specific-punish");
punishCommands = config.getStringList("config.plugin.punish-commands");
reopCommand = config.getBoolean("config.plugin.reop-command");
// Chat
blockUnicode = config.getBoolean("config.chat.anti-unicode");
// antiSpam
// Chat Filter Setup & AntiSpam
antiUnicode = config.getBoolean("config.chat.anti-unicode");
antiSpamEnabled = config.getBoolean("config.chat.anti-spam.enabled");
defaultGain = config.getInt("config.chat.anti-spam.default-gain");
lowGain = config.getInt("config.chat.anti-spam.low-gain");
@@ -116,22 +123,22 @@ public abstract class Config {
heatDecay = config.getInt("config.chat.anti-spam.heat-decay");
blockHeat = config.getInt("config.chat.anti-spam.block-heat");
punishHeat = config.getInt("config.chat.anti-spam.punish-heat");
punishSpamCommand = config.getString("config.chat.anti-spam.punish-command");
clearChat = config.getBoolean("config.chat.anti-spam.clear-chat");
clearChatCommand = config.getString("config.chat.anti-spam.clear-chat-command");
logSpam = config.getBoolean("config.chat.anti-swear.log-swear");
// antiSwear
chatClearCommand = config.getString("config.chat.anti-spam.chat-clear-command");
spamPunishCommand = config.getString("config.chat.anti-spam.punish-command");
logSpam = config.getBoolean("config.chat.anti-spam.log-spam");
antiSwearEnabled = config.getBoolean("config.chat.anti-swear.enabled");
lowScore = config.getInt("config.chat.anti-swear.low-score");
mediumLowScore = config.getInt("config.chat.anti-swear.medium-low-score");
mediumScore = config.getInt("config.chat.anti-swear.medium-score");
mediumHighScore = config.getInt("config.chat.anti-swear.medium-high-score");
highScore = config.getInt("config.chat.anti-swear.high-score");
punishScore = config.getInt("config.chat.anti-swear.punish-score");
swearPunishCommand = config.getString("config.chat.anti-swear.punish-command");
slurInstaPunish = config.getBoolean("config.chat.anti-swear.strict-insta-punish");
slurPunishCommand = config.getString("config.chat.anti-swear.strict-command");
scoreDecay = config.getInt("config.chat.anti-swear.score-decay");
punishScore = config.getInt("config.chat.anti-swear.punish-score");
strictInstaPunish = config.getBoolean("config.chat.anti-swear.strict-insta-punish");
swearPunishCommand = config.getString("config.chat.anti-swear.punish-command");
strictPunishCommand = config.getString("config.chat.anti-swear.strict-command");
logSwear = config.getBoolean("config.chat.anti-swear.log-swear");
swearWhitelist = config.getStringList("config.chat.anti-swear.false-positives");
swearBlacklist = config.getStringList("config.chat.anti-swear.blacklisted");
slurs = config.getStringList("config.chat.anti-swear.strict");

View File

@@ -52,7 +52,7 @@ public class WebhookSender {
Emojis.rightSort + "Player: " + player.getName() + " " + Emojis.target + "\\n" +
Emojis.space + Emojis.arrowRight + "Heat: `" + finalHeat + "/" + Config.punishHeat + "`\\n" +
Emojis.space + Emojis.arrowRight + "UUID: `" + player.getUniqueId() + "`\\n" +
Emojis.rightSort + "Executed: " + Config.punishSpamCommand + " " + Emojis.mute + "\\n" +
Emojis.rightSort + "Executed: " + Config.spamPunishCommand + " " + Emojis.mute + "\\n" +
Emojis.space + Emojis.arrowRight + "Chat Cleared: " + successOrFail(chatCleared) + "\\n"
)
.addField("Previous Message", "||" + message1 + "|| " + Emojis.activity, false)
@@ -107,7 +107,7 @@ public class WebhookSender {
Emojis.rightSort + "Player: " + player.getName() + " " + Emojis.target + "\\n" +
Emojis.space + Emojis.arrowRight + "Score: `" + finalScore + "/" + Config.punishScore + "`\\n" +
Emojis.space + Emojis.arrowRight + "UUID: `" + player.getUniqueId() + "`\\n" +
Emojis.rightSort + "Executed: " + Config.slurPunishCommand + " " + Emojis.mute + "\\n"
Emojis.rightSort + "Executed: " + Config.strictPunishCommand + " " + Emojis.mute + "\\n"
)
.addField("Original Message", "||" + message + "|| " + Emojis.alarm, false)
.addField("Sanitized Message", ProfanityFilter.highlightProfanity(message,"||", "||") + " " + Emojis.noDM, false)

View File

@@ -1,16 +1,28 @@
package io.github.thetrouper.sentinel.events;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.commands.SentinelCommand;
import org.bukkit.Material;
import org.bukkit.block.CommandBlock;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.inventory.meta.BlockDataMeta;
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());
}
}
}
}

View File

@@ -2,7 +2,8 @@ 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.Action;
import io.github.thetrouper.sentinel.server.ActionType;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@@ -13,14 +14,24 @@ import org.bukkit.event.block.BlockPlaceEvent;
public class CMDBlockPlace implements Listener {
@EventHandler
private void onCMDBlockPlace(BlockPlaceEvent e) {
if (!Config.preventCmdBlocks) return;
if (!Config.preventCmdBlockPlace) 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();
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
TakeAction.placeBlock(e);
Action a = new Action.Builder()
.setAction(ActionType.PLACE_COMMAND_BLOCK)
.setEvent(e)
.setBlock(b)
.setPlayer(p)
.setDenied(true)
.setPunished(Config.cmdBlockPunish)
.setnotifyDiscord(Config.logCmdBlocks)
.setNotifyTrusted(true)
.setNotifyConsole(true)
.execute();
}
}
}

View File

@@ -1,17 +1,28 @@
package io.github.thetrouper.sentinel.events;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.commands.SentinelCommand;
import io.github.thetrouper.sentinel.data.Config;
import io.github.thetrouper.sentinel.server.TakeAction;
import io.github.thetrouper.sentinel.server.Action;
import io.github.thetrouper.sentinel.server.ActionType;
import io.github.thetrouper.sentinel.server.util.TextUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.CommandBlock;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import java.util.*;
public class CMDBlockUse implements Listener {
@EventHandler
private void onCMDBlockUse(PlayerInteractEvent e) {
if (!Config.preventCmdBlocks) return;
if (!Config.preventCmdBlockUse) return;
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
if (e.getClickedBlock() == null) return;
Block b = e.getClickedBlock();
@@ -19,7 +30,47 @@ public class CMDBlockUse implements Listener {
Player p = e.getPlayer();
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
TakeAction.useBlock(e);
Action a = new Action.Builder()
.setAction(ActionType.USE_COMMAND_BLOCK)
.setEvent(e)
.setBlock(b)
.setPlayer(p)
.setDenied(true)
.setPunished(Config.cmdBlockPunish)
.setnotifyDiscord(Config.logCmdBlocks)
.setNotifyTrusted(true)
.setNotifyConsole(true)
.execute();
}
}
}
@EventHandler
private void onCMDBlockChange(EntityChangeBlockEvent e) {
if (!(e.getEntity() instanceof Player p)) return;
if (!Config.preventCmdBlockUse) return;
if (Config.cmdBlockOpCheck && !p.isOp()) return;
Block b = e.getBlock();
if (b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK) {
BlockState state = b.getState();
CommandBlock cb = (CommandBlock) state;
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
Action a = new Action.Builder()
.setAction(ActionType.UPDATE_COMMAND_BLOCK)
.setEvent(e)
.setBlock(b)
.setCommand(cb.getCommand())
.setPlayer(p)
.setDenied(true)
.setPunished(Config.cmdBlockPunish)
.setnotifyDiscord(Config.logCmdBlocks)
.setNotifyTrusted(true)
.setNotifyConsole(true)
.execute();
}
if (Sentinel.isTrusted(p)) {
Sentinel.log.info(p.getName() + "Updated command block: " + cb.getCommand());
SentinelCommand.updateWhitelistedCommandBlock(p,b, cb.getCommand());
}
}
}

View File

@@ -2,20 +2,19 @@ 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.Action;
import io.github.thetrouper.sentinel.server.ActionType;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class CMDMinecartPlace implements Listener {
@EventHandler
private void onCMDMinecartPlace(PlayerInteractEvent e) {
if (!Config.preventCmdBlocks) {
if (!Config.preventCmdCartPlace) {
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
if (e.getItem() == null) return;
if (e.getClickedBlock() == null) return;
@@ -25,7 +24,18 @@ public class CMDMinecartPlace implements Listener {
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
p.getInventory().remove(Material.COMMAND_BLOCK_MINECART);
TakeAction.useBlock(e);
Action a = new Action.Builder()
.setAction(ActionType.PLACE_MINECART_COMMAND)
.setEvent(e)
.setPlayer(p)
.setBlock(e.getClickedBlock())
.setDenied(Config.preventCmdCartPlace)
.setPunished(Config.cmdBlockPunish)
.setDeoped(Config.deop)
.setNotifyConsole(true)
.setNotifyTrusted(true)
.setnotifyDiscord(Config.logCmdBlocks)
.execute();
}
}
}

View File

@@ -2,7 +2,8 @@ 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.Action;
import io.github.thetrouper.sentinel.server.ActionType;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -12,13 +13,22 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
public class CMDMinecartUse implements Listener {
@EventHandler
private void onCMDBlockMinecartUse(PlayerInteractEntityEvent e) {
if (!Config.preventCmdBlocks) return;
if (!Config.preventCmdCartUse) return;
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
if (e.getRightClicked().getType() == EntityType.MINECART_COMMAND) {
Player p = e.getPlayer();
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
TakeAction.useEntity(e);
Action a = new Action.Builder()
.setAction(ActionType.USE_MINECART_COMMAND)
.setEvent(e)
.setPlayer(p)
.setDenied(true)
.setPunished(Config.cmdBlockPunish)
.setnotifyDiscord(Config.logCmdBlocks)
.setNotifyTrusted(true)
.setNotifyConsole(true)
.execute();
}
}
}

View File

@@ -16,6 +16,6 @@ public class ChatEvent implements Listener {
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);
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antiunicode.bypass")) if (Config.blockUnicode) AntiUnicode.handleAntiUnicode(e);
if (!Sentinel.isTrusted(e.getPlayer()) || !e.getPlayer().hasPermission("sentinel.chat.antiunicode.bypass")) if (Config.antiUnicode) AntiUnicode.handleAntiUnicode(e);
}
}

View File

@@ -2,10 +2,8 @@ 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.Action;
import io.github.thetrouper.sentinel.server.ActionType;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import io.github.thetrouper.sentinel.server.util.TextUtils;
import org.bukkit.entity.Player;
@@ -25,22 +23,55 @@ public class CommandEvent implements Listener {
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
ServerUtils.sendDebugMessage(TextUtils.prefix("Command is canceled"));
TakeAction.command(e);
Action a = new Action.Builder()
.setAction(ActionType.DANGEROUS_COMMAND)
.setEvent(e)
.setPlayer(p)
.setCommand(command)
.setDenied(true)
.setDeoped(Config.deop)
.setPunished(Config.commandPunish)
.setnotifyDiscord(Config.logDangerous)
.setNotifyConsole(true)
.setNotifyTrusted(true)
.execute();
}
}
if (Config.blockSpecificCommands) {
if (Config.blockSpecific) {
ServerUtils.sendDebugMessage(TextUtils.prefix("Checking command for specific"));
if (command.contains(":")) {
ServerUtils.sendDebugMessage(TextUtils.prefix("Checking is specific"));
if (!Sentinel.isTrusted(p)) {
e.setCancelled(true);
ServerUtils.sendDebugMessage(TextUtils.prefix("Command is canceled"));
TakeAction.specific(e);
Action a = new Action.Builder()
.setAction(ActionType.SPECIFIC_COMMAND)
.setEvent(e)
.setPlayer(p)
.setCommand(command)
.setDenied(true)
.setDeoped(Config.deop)
.setPunished(Config.specificPunish)
.setnotifyDiscord(Config.logSpecific)
.setNotifyConsole(true)
.setNotifyTrusted(true)
.execute();
}
}
}
if (Sentinel.isLoggedCommand(command)) {
TakeAction.logged(e);
Action a = new Action.Builder()
.setAction(ActionType.LOGGED_COMMAND)
.setEvent(e)
.setPlayer(p)
.setCommand(command)
.setDenied(false)
.setDeoped(false)
.setPunished(false)
.setnotifyDiscord(true)
.setNotifyConsole(true)
.setNotifyTrusted(true)
.execute();
}
}
}

View File

@@ -1,7 +1,10 @@
package io.github.thetrouper.sentinel.events;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.server.TakeAction;
import io.github.thetrouper.sentinel.data.Config;
import io.github.thetrouper.sentinel.server.Action;
import io.github.thetrouper.sentinel.server.ActionType;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -11,16 +14,31 @@ import org.bukkit.inventory.ItemStack;
public class NBTEvents implements Listener {
@EventHandler
private void onNBTPull(InventoryCreativeEvent e) {
if (!(e.getWhoClicked() instanceof Player p)) {
return;
}
if (e.getCursor() == null) return;
ItemStack i = e.getCursor();
if (!Sentinel.isTrusted(p)) {
if (e.getCursor().getItemMeta() == null) return;
if (i.hasItemMeta() && i.getItemMeta() != null) {
TakeAction.NBT(e);
if (Config.preventNBT) {
if (!(e.getWhoClicked() instanceof Player p)) {
return;
}
if (e.getCursor() == null) return;
ItemStack i = e.getCursor();
if (!Sentinel.isTrusted(p)) {
if (e.getCursor().getItemMeta() == null) return;
if (i.hasItemMeta() && i.getItemMeta() != null) {
Action a = new Action.Builder()
.setEvent(e)
.setAction(ActionType.NBT)
.setPlayer(Bukkit.getPlayer(e.getWhoClicked().getName()))
.setItem(e.getCursor())
.setDenied(Config.preventNBT)
.setDeoped(Config.deop)
.setPunished(Config.nbtPunish)
.setRevertGM(Config.preventNBT)
.setNotifyConsole(true)
.setNotifyTrusted(true)
.setnotifyDiscord(Config.logNBT)
.execute();
}
}
}
}
}

View File

@@ -0,0 +1,277 @@
package io.github.thetrouper.sentinel.server;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.data.Config;
import io.github.thetrouper.sentinel.data.Emojis;
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
import io.github.thetrouper.sentinel.server.util.FileUtils;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import io.github.thetrouper.sentinel.server.util.TextUtils;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.hover.content.Text;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import java.io.IOException;
import java.util.List;
public class Action {
private Cancellable event;
private ActionType action;
private Player player;
private String command;
private String loggedCommand;
private ItemStack item;
private Block block;
private boolean denied;
private boolean deoped;
private boolean punished;
private boolean revertGM;
private boolean notifyDiscord;
private boolean notifyTrusted;
private boolean notifyConsole;
private Action(Cancellable event, ActionType action, Player player, String command, String loggedCommand, ItemStack item, Block block,boolean denied, boolean deoped, boolean punished, boolean revertedGM, boolean notifyDiscord, boolean notifyTrusted, boolean notifyConsole) {
this.event = event;
this.action = action;
this.player = player;
this.command = command;
this.loggedCommand = loggedCommand;
this.item = item;
this.block = block;
this.denied = denied;
this.deoped = deoped;
this.punished = punished;
this.revertGM = revertedGM;
this.notifyDiscord = notifyDiscord;
this.notifyTrusted = notifyTrusted;
this.notifyConsole = notifyConsole;
}
public static class Builder {
Cancellable event;
ActionType action;
private Player player;
private String command;
private String loggedCommand;
private ItemStack item;
private Block block;
private boolean denied;
private boolean deoped;
private boolean punished;
private boolean revertGM;
private boolean notifyDiscord;
private boolean notifyTrusted;
private boolean notifyConsole;
public Builder setEvent(Cancellable event) {
this.event = event;
return this;
}
public Builder setAction(ActionType action) {
this.action = action;
return this;
}
public Builder setPlayer(Player player) {
this.player = player;
return this;
}
public Builder setCommand(String command) {
this.command = command;
return this;
}
public Builder setLoggedCommand(String loggedCommand) {
this.loggedCommand = loggedCommand;
return this;
}
public Builder setItem(ItemStack item) {
this.item = item;
return this;
}
public Builder setBlock(Block block){
this.block = block;
return this;
}
public Builder setDenied(boolean denied) {
this.denied = denied;
return this;
}
public Builder setDeoped(boolean deoped) {
this.deoped = deoped;
return this;
}
public Builder setPunished(boolean punished) {
this.punished = punished;
return this;
}
public Builder setRevertGM(boolean revertGM) {
this.revertGM = revertGM;
return this;
}
public Builder setnotifyDiscord(boolean notifyDiscord) {
this.notifyDiscord= notifyDiscord;
return this;
}
public Builder setNotifyTrusted(boolean notifyTrusted) {
this.notifyTrusted = notifyTrusted;
return this;
}
public Builder setNotifyConsole(boolean notifyConsole) {
this.notifyConsole = notifyConsole;
return this;
}
public Action execute() {
String actionTop = "Generic Anti-Action has been triggered";
String actionTitle = "A generic action has been detected!";
String itemLog = "";
String commandLog = "";
actionTop = action.getMessageTop();
actionTitle = action.getMessageTitle();
final List<String> punishCommands = Config.getPunishCommands();
if (denied) event.setCancelled(true);
if (deoped) player.setOp(false);
if (punished) for (String command : punishCommands) {
ServerUtils.sendCommand(command);
}
if (revertGM) player.setGameMode(GameMode.SURVIVAL);
if (item != null) itemLog = FileUtils.createNBTLog(item.getItemMeta().getAsString());
if (loggedCommand != null) commandLog = FileUtils.createCommandLog(loggedCommand);
if (notifyConsole) {
String conNotif = "]=- Sentinel -=[";
conNotif += " " + actionTop;
conNotif += "\n" + actionTitle + "\n";
if (player != null) {
conNotif += "Player: " + player.getName() + "\n";
}
if (command != null) {
if (loggedCommand != null) {
if (loggedCommand.length() > 128) {
conNotif += "Command: Too long to show here!" + "\n";
conNotif += " | Saved to file: " + commandLog + "\n";
} else {
conNotif += "Command: " + command + "\n";
}
} else {
conNotif += "Command: " + command + "\n";
}
}
if (item != null) {
conNotif += "Item: /Sentinel/LoggedNBT/" + itemLog + "\n";
}
if (block != null) {
Location loc = block.getLocation();
conNotif += "Block: " + block.getType().toString().toLowerCase().replace("_", " ") + "\n";
conNotif += "Location: " + loc.getX() + " " + loc.getY() + " " + loc.getZ() + "\n";
}
conNotif += "Denied: " + (denied ? "\u2714" : "\u2718") + "\n";
if (deoped) {
player.setOp(false);
}
conNotif += "Deoped: " + (deoped ? "\u2714" : "\u2718") + "\n";
conNotif += "Punished: " + (punished ? "\u2714" : "\u2718") + "\n";
if (revertGM) conNotif += "RevertGM: " + "\u2714" + "\n";
conNotif += "Logged: " + (notifyDiscord ? "\u2714" : "\u2718");
Sentinel.log.info(conNotif);
}
if (notifyTrusted) {
TextComponent notification = new TextComponent();
notification.setText(TextUtils.prefix(" " + actionTop));
String body = "]=- Sentinel -=[ ";
body += "\n" + actionTitle + "\n";
if (player != null) {
body += "Player: " + 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";
} else {
body += "Command: " + command + "\n";
}
} else {
body += "Command: " + command + "\n";
}
}
if (item != null) {
body += "Item: /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 += "Denied: " + (denied ? "§a\u2714" : "§c\u2718") + "\n";
if (deoped) {
player.setOp(false);
}
body += "Deoped: " + (deoped ? "§a\u2714" : "§c\u2718") + "\n";
body += "Punished: " + (punished ? "§a\u2714" : "§c\u2718") + "\n";
if (revertGM) body += "RevertGM: " + "§a\u2714" + "\n";
body += "Logged: " + (notifyDiscord ? "§a\u2714" : "§c\u2718");
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(body)));
ServerUtils.forEachPlayer(trusted -> {
if (Sentinel.isTrusted(trusted)) {
trusted.spigot().sendMessage(notification);
}
});
}
if (notifyDiscord) {
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");
String description = "";
if (player != null) description += Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n";
if (command != null) {
if (loggedCommand != null) {
if (loggedCommand.length() > 128) {
description += Emojis.rightSort + " **Command:** Too long to show here!" + " " + Emojis.nuke + "\\n";
description += Emojis.space + Emojis.rightDoubleArrow + " | Saved to file: " + commandLog + "\n";
} else {
description += Emojis.rightSort + " **Command:** " + command + " " + Emojis.nuke + "\\n";
}
} else {
description += Emojis.rightSort + " **Command:** " + command + " " + Emojis.nuke + "\\n";
}
}
if (item != null) description += Emojis.rightSort + " **Item:** " + item.getType().toString().toLowerCase() + " " + Emojis.nuke + "\\n" +
Emojis.space + Emojis.rightDoubleArrow + "**NBT:** Uploaded to /Sentinel/LoggedNBT/" + itemLog;
if (block != null) {
description += Emojis.rightSort + " **Block:** " + block.getType().toString().toLowerCase() + " " + Emojis.nuke + "\\n" +
Emojis.space + Emojis.rightDoubleArrow + " **Location:** X: " + block.getX() + " Y: " + block.getY() + " Z: " + block.getZ() + "\\n";
}
String actions = "";
actions += Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n";
actions += Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n";
actions += Emojis.rightSort + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n";
if (revertGM) actions += Emojis.rightSort + " **GM Reverted:** " + Emojis.success + "\\n";
actions += Emojis.rightSort + " **Logged:** " + Emojis.success;
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
.setAuthor(actionTop,"","")
.setTitle(actionTitle)
.setDescription(description)
.addField("Actions:",actions, false)
.setThumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay")
.setColor(action.getEmbedColor());
webhook.addEmbed(embed);
try {
ServerUtils.sendDebugMessage("Executing webhook...");
webhook.execute();
} catch (IOException e) {
ServerUtils.sendDebugMessage(TextUtils.prefix("Epic webhook failure!!!"));
Sentinel.log.info(e.toString());
}
}
return new Action(event, action, player, command, loggedCommand, item, block, denied, deoped, punished, revertGM, notifyDiscord, notifyTrusted, notifyConsole);
}
}
}

View File

@@ -0,0 +1,34 @@
package io.github.thetrouper.sentinel.server;
import java.awt.*;
public enum ActionType {
SPECIFIC_COMMAND("Anti-Specific has been triggered","The use of a specific command has been detected!", Color.green),
LOGGED_COMMAND("General command log","A logged command has been executed.", Color.green),
DANGEROUS_COMMAND("Anti-Nuke has been triggered","The use of a dangerous command has been detected!", Color.red),
NBT("Anti-NBT has been triggered", "An NBT item has been caught!", Color.orange),
PLACE_COMMAND_BLOCK("Anti-Nuke has been triggered","The placing of a command block has been detected!", Color.orange),
USE_COMMAND_BLOCK("Anti-Nuke has been triggered","The use of a command block has been detected!", Color.red),
UPDATE_COMMAND_BLOCK("HoneyPot log","Caught a command block command!", Color.yellow),
PLACE_MINECART_COMMAND("Anti-Nuke has been triggered","The placing of a minecart command has been detected!", Color.red),
USE_MINECART_COMMAND("Anti-Nuke has been triggered", "The use of a command block has been detected!", Color.red),
UPDATE_MINECART_COMMAND("HoneyPot log","Caught a command block command!", Color.orange);
private final String messageTop;
private final String messageTitle;
private final Color embedColor;
ActionType(String messagetop, String messageTitle, Color embedColor) {
this.messageTop = messagetop;
this.messageTitle = messageTitle;
this.embedColor = embedColor;
}
public String getMessageTop() {
return messageTop;
}
public String getMessageTitle() {
return messageTitle;
}
public Color getEmbedColor() {
return embedColor;
}
}

View File

@@ -1,250 +0,0 @@
package io.github.thetrouper.sentinel.server;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.data.Config;
import io.github.thetrouper.sentinel.server.util.FileUtils;
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;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.inventory.InventoryCreativeEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.util.List;
public class TakeAction {
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.logSpecific) {
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 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);
denied = true;
}
}
}
if (Config.deop) {
e.getPlayer().setOp(false);
deoped = 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,punished,true);
}
NotifyConsole.command(e.getPlayer(),message,denied,deoped,punished,logged);
NotifyTrusted.command(e.getPlayer(),message,denied,deoped,punished,logged);
}
public static void logged(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.isLoggedCommand(command)) {
NotifyDiscord.logged(e.getPlayer(),message,denied,deoped,punished,true);
NotifyConsole.logged(e.getPlayer(),message,denied,deoped,punished,logged);
NotifyTrusted.logged(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 punished = false;
boolean logged = false;
boolean gms = false;
if (Config.preventNBT) {
e.setCancelled(true);
Bukkit.getScheduler().runTaskLater(Sentinel.getInstance(),() -> {
e.getCursor().setType(Material.AIR);
}, 1);
p.setGameMode(GameMode.SURVIVAL);
gms = true;
removed = true;
}
if (Config.deop) {
p.setOp(false);
deoped = 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,punished, true,FileUtils.createNBTLog(item.getType().toString().toLowerCase() + item.getItemMeta().getAsString()));
}
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 punished = false;
boolean logged = false;
if (Config.preventCmdBlocks) {
e.setCancelled(true);
p.getInventory().remove(Material.COMMAND_BLOCK);
p.getInventory().remove(Material.REPEATING_COMMAND_BLOCK);
p.getInventory().remove(Material.CHAIN_COMMAND_BLOCK);
deleted = true;
}
if (Config.deop) {
p.setOp(false);
deoped = 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,punished,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;
Player p = e.getPlayer();
Block b = e.getClickedBlock();
boolean denied = false;
boolean deoped = false;
boolean punished = false;
boolean logged = false;
if (Config.preventCmdBlocks) {
e.setCancelled(true);
denied = true;
}
if (Config.deop) {
p.setOp(false);
deoped = 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,punished,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;
Player p = e.getPlayer();
Entity ent = e.getRightClicked();
boolean denied = false;
boolean deoped = false;
boolean punished = false;
boolean logged = false;
if (Config.preventCmdBlocks) {
e.setCancelled(true);
denied = true;
}
if (Config.deop) {
p.setOp(false);
deoped = 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,punished,logged);
}
NotifyConsole.usedEntity(p,ent,denied,deoped,punished,logged);
NotifyTrusted.usedEntity(p,ent,denied,deoped,punished,logged);
}
}

View File

@@ -78,10 +78,10 @@ public class AntiSpam {
public static void punishSpam(Player player, String message1, String message2) {
boolean chatCleared = false;
if (Config.clearChat) {
ServerUtils.sendCommand(Config.clearChatCommand);
ServerUtils.sendCommand(Config.chatClearCommand);
chatCleared = true;
}
ServerUtils.sendCommand(Config.punishSpamCommand.replace("%player%", player.getName()));
ServerUtils.sendCommand(Config.spamPunishCommand.replace("%player%", player.getName()));
player.sendMessage(TextUtils.prefix("§cYou have been auto-punished for violating the anti-spam repetitively!"));
TextComponent text = new TextComponent();
text.setText(TextUtils.prefix(

View File

@@ -86,8 +86,8 @@ public class ProfanityFilter {
if (Config.logSwear) WebhookSender.sendSwearLog(player,origMessage,scoreMap.get(player));
}
public static void punishSlur(Player player, String highlightedMSG, String origMessage) {
if (!Config.slurInstaPunish) return;
ServerUtils.sendCommand(Config.slurPunishCommand.replace("%player%", player.getName()));
if (!Config.strictInstaPunish) return;
ServerUtils.sendCommand(Config.strictPunishCommand.replace("%player%", player.getName()));
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();
@@ -167,7 +167,8 @@ public class ProfanityFilter {
public static String checkSeverity(String text) {
// 1:
String lowercasedText = text.toLowerCase();
// 1.5:
String nonEnglish =
// 2:
String cleanedText = removeFalsePositives(lowercasedText);

View File

@@ -1,14 +1,33 @@
package io.github.thetrouper.sentinel.server.util;
import com.google.gson.reflect.TypeToken;
import io.github.thetrouper.sentinel.Sentinel;
import java.io.BufferedWriter;
import java.io.File;
import java.io.*;
import java.time.*;
import java.util.List;
import java.util.Random;
import com.google.gson.Gson;
import org.bukkit.Location;
import com.google.gson.Gson;
import java.io.FileReader;
import java.io.IOException;
import java.util.Map;
import java.io.FileWriter;
import java.io.IOException;
import java.time.*;
import java.util.Random;
import java.util.Map;
import java.util.UUID;
import com.google.gson.Gson;
import java.lang.reflect.Type;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.IOException;
import java.util.Map;
import java.util.List;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Location;
public class FileUtils {
public static boolean folderExists(String folderName) {
File folder = new File(Sentinel.getDF(), folderName);
@@ -37,4 +56,22 @@ public class FileUtils {
}
return fileName;
}
public static String createCommandLog(String command) {
String fileName = "command_log-" + Randomizer.generateID();
File file = new File(Sentinel.getDF() + "/LoggedCommands/" + fileName + ".txt");
try {
if (!file.exists()) {
file.createNewFile();
}
BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
writer.append(command);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
return fileName;
}
}

View File

@@ -1,104 +0,0 @@
package io.github.thetrouper.sentinel.server.util.Notifications;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.server.util.TextUtils;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.hover.content.Text;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class NotifyConsole {
public static void specific(Player p, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
final String log = (
"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,"\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 logged(Player p, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
final String log = (
"A logged command has been executed. \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 NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged) {
String log = (
"Sentinel caught a dangerous NBT! \n]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() +
"\nItemType: " + item.getType() +
"\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 punished, boolean logged) {
String log = (
"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,"\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 punished, boolean logged) {
String log = (
"]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() +
"\nBlockType: " + b.getType() +
"\nLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
"\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 punished, boolean logged) {
String log = (
"]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() +
"\nEntityType: " + e.getType() +
"\nLocation: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ() +
"\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

@@ -1,225 +0,0 @@
package io.github.thetrouper.sentinel.server.util.Notifications;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.data.Config;
import io.github.thetrouper.sentinel.data.Emojis;
import io.github.thetrouper.sentinel.discord.DiscordWebhook;
import io.github.thetrouper.sentinel.server.util.FileUtils;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import io.github.thetrouper.sentinel.server.util.TextUtils;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.awt.*;
import java.io.IOException;
public class NotifyDiscord {
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");
webhook.setUsername("Sentinel Anti-Nuke | Logs");
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
.setAuthor("Anti-Nuke has been triggered","","")
.setTitle("The use of a dangerous 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 logged(Player player, String command, boolean denied, boolean deoped, boolean punished, boolean logged) {
ServerUtils.sendDebugMessage("Creating logged 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("Sentinel Logged Commands","","")
.setTitle("General Command Log")
.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 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);
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 dangerous item has been detected!")
.setDescription(
Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n" +
Emojis.rightSort + " **Item:** " + item.getType().toString().toLowerCase() + " " + Emojis.nuke + "\\n" +
Emojis.space + Emojis.rightDoubleArrow + "**NBT:** Uploaded to /Sentinel/LoggedNBT/" + logFileName
)
.addField("Actions:",
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 + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.setColor(Color.BLUE);
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 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");
webhook.setUsername("Sentinel Anti-Nuke | Logs");
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
.setAuthor("Anti-Nuke has been triggered","","")
.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.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 + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.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 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");
webhook.setUsername("Sentinel Anti-Nuke | Logs");
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
.setAuthor("Anti-Nuke has been triggered","","")
.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.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 + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.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 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");
webhook.setUsername("Sentinel Anti-Nuke | Logs");
DiscordWebhook.EmbedObject embed = new DiscordWebhook.EmbedObject()
.setAuthor("Anti-Nuke has been triggered","","")
.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.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 + " **Punished:** " + TextUtils.boolString(punished,Emojis.success, Emojis.failure) + "\\n"+
Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
)
.setColor(Color.RED);
webhook.addEmbed(embed);
try {
ServerUtils.sendDebugMessage("Executing webhook...");
webhook.execute();
} catch (IOException ex) {
ServerUtils.sendDebugMessage(TextUtils.prefix("Epic webhook failure!!!"));
Sentinel.log.info(ex.toString());
}
}
}

View File

@@ -1,155 +0,0 @@
package io.github.thetrouper.sentinel.server.util.Notifications;
import io.github.thetrouper.sentinel.Sentinel;
import io.github.thetrouper.sentinel.server.util.ServerUtils;
import io.github.thetrouper.sentinel.server.util.TextUtils;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.hover.content.Text;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.server.ServerEvent;
import org.bukkit.inventory.ItemStack;
public class NotifyTrusted {
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(
"§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()) {
if (Sentinel.isTrusted(trustedPlayer)) {
trustedPlayer.spigot().sendMessage(notification);
}
}
}
public static void logged(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 executed a logged 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()) {
if (Sentinel.isTrusted(trustedPlayer)) {
trustedPlayer.spigot().sendMessage(notification);
}
}
}
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(
"§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)) {
trustedPlayer.spigot().sendMessage(notification);
}
}
}
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)) {
trustedPlayer.spigot().sendMessage(notification);
}
}
}
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)) {
trustedPlayer.spigot().sendMessage(notification);
}
}
}
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)) {
trustedPlayer.spigot().sendMessage(notification);
}
}
}
}