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

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -1,7 +1,7 @@
# Plugin # Plugin
group = 'io.github.thetrouper' group = 'io.github.thetrouper'
version = 0.1.3 version = 0.1.5
# Minecraft # Minecraft
mc_version = 1.19.4 mc_version = 1.19.4

Binary file not shown.

View File

@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-rc-2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

40
gradlew vendored
View File

@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# #
# Copyright © 2015-2021 the original authors. # Copyright © 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@@ -32,10 +32,10 @@
# Busybox and similar reduced shells will NOT work, because this script # Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features: # requires all of these POSIX shell features:
# * functions; # * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»; # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»; # * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit». # * various built-in commands including «command», «set», and «ulimit».
# #
# Important for patching: # Important for patching:
# #
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,10 @@ do
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # This is normally unused
# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@@ -133,22 +130,29 @@ location of your Java installation."
fi fi
else else
JAVACMD=java JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in
@@ -205,6 +213,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

15
gradlew.bat vendored
View File

@@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

View File

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

View File

@@ -29,7 +29,7 @@ public class InfoCommand implements TabExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try { try {
if (args.length == 0) { 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; return true;
} }
switch (args[0]) { switch (args[0]) {

View File

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

View File

@@ -12,6 +12,7 @@ public class ChatEvent implements Listener {
@EventHandler @EventHandler
public static void onChat(AsyncPlayerChatEvent e) { 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.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.antispam.bypass")) if (Config.antiSpamEnabled) AntiSpam.handleAntiSpam(e);
} }

View File

@@ -17,6 +17,7 @@ public class CmdBlockEvents implements Listener {
@EventHandler @EventHandler
private void onCMDBlockUse(PlayerInteractEvent e) { private void onCMDBlockUse(PlayerInteractEvent e) {
if (!Config.preventCmdBlocks) return; if (!Config.preventCmdBlocks) return;
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
if (e.getClickedBlock() == null) return; if (e.getClickedBlock() == null) return;
Block b = e.getClickedBlock(); Block b = e.getClickedBlock();
if (b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK) { 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 @EventHandler
private void onCMDBlockPlace(BlockPlaceEvent e) { private void onCMDBlockPlace(BlockPlaceEvent e) {
if (!Config.preventCmdBlocks) return; if (!Config.preventCmdBlocks) return;
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
Block b = e.getBlockPlaced(); Block b = e.getBlockPlaced();
if (b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK ) { if (b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK ) {
Player p = e.getPlayer(); Player p = e.getPlayer();
@@ -42,6 +44,7 @@ public class CmdBlockEvents implements Listener {
@EventHandler @EventHandler
private void onCMDBlockMinecartUse(PlayerInteractEntityEvent e) { private void onCMDBlockMinecartUse(PlayerInteractEntityEvent e) {
if (!Config.preventCmdBlocks) return; if (!Config.preventCmdBlocks) return;
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
if (e.getRightClicked().getType() == EntityType.MINECART_COMMAND) { if (e.getRightClicked().getType() == EntityType.MINECART_COMMAND) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (!Sentinel.isTrusted(p)) { if (!Sentinel.isTrusted(p)) {
@@ -53,6 +56,7 @@ public class CmdBlockEvents implements Listener {
@EventHandler @EventHandler
private void onCMDBlockMinecartPlace(PlayerInteractEvent e) { private void onCMDBlockMinecartPlace(PlayerInteractEvent e) {
if (!Config.preventCmdBlocks) { if (!Config.preventCmdBlocks) {
if (Config.cmdBlockOpCheck && !e.getPlayer().isOp()) return;
if (e.getItem() == null) return; if (e.getItem() == null) return;
if (e.getClickedBlock() == null) return; if (e.getClickedBlock() == null) return;
if (!e.getItem().getType().equals(Material.COMMAND_BLOCK_MINECART)) 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.Sentinel;
import io.github.thetrouper.sentinel.data.Config; import io.github.thetrouper.sentinel.data.Config;
import io.github.thetrouper.sentinel.server.TakeAction; 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.ServerUtils;
import io.github.thetrouper.sentinel.server.util.TextUtils; import io.github.thetrouper.sentinel.server.util.TextUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -32,9 +35,14 @@ public class CommandEvent implements Listener {
if (!Sentinel.isTrusted(p)) { if (!Sentinel.isTrusted(p)) {
e.setCancelled(true); e.setCancelled(true);
ServerUtils.sendDebugMessage(TextUtils.prefix("Command is canceled")); 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.NotifyDiscord;
import io.github.thetrouper.sentinel.server.util.Notifications.NotifyTrusted; import io.github.thetrouper.sentinel.server.util.Notifications.NotifyTrusted;
import io.github.thetrouper.sentinel.server.util.ServerUtils; import io.github.thetrouper.sentinel.server.util.ServerUtils;
import io.github.thetrouper.sentinel.server.util.TextUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
@@ -20,11 +21,54 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.List;
public class TakeAction { 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) { public static void command(PlayerCommandPreprocessEvent e) {
boolean deoped = false; boolean deoped = false;
boolean banned = false; boolean punished = false;
boolean denied = false; boolean denied = false;
boolean logged = false; boolean logged = false;
Player p = e.getPlayer(); Player p = e.getPlayer();
@@ -48,23 +92,26 @@ public class TakeAction {
e.getPlayer().setOp(false); e.getPlayer().setOp(false);
deoped = true; deoped = true;
} }
if (Config.ban) { if (Config.commandPunish) {
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."); for (String execute : punishCommands) {
banned = true; Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
} }
if (Config.logDangerousCommands) { if (Config.logDangerousCommands) {
logged = true; 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); NotifyConsole.command(e.getPlayer(),message,denied,deoped,punished,logged);
NotifyTrusted.command(e.getPlayer(),message,denied,deoped,banned,logged); NotifyTrusted.command(e.getPlayer(),message,denied,deoped,punished,logged);
} }
public static void NBT(InventoryCreativeEvent e) { public static void NBT(InventoryCreativeEvent e) {
Player p = (Player) e.getWhoClicked(); Player p = (Player) e.getWhoClicked();
final ItemStack item = e.getCursor(); final ItemStack item = e.getCursor();
boolean removed = false; boolean removed = false;
boolean deoped = false; boolean deoped = false;
boolean banned = false; boolean punished = false;
boolean logged = false; boolean logged = false;
boolean gms = false; boolean gms = false;
if (Config.preventNBT) { if (Config.preventNBT) {
@@ -80,23 +127,26 @@ public class TakeAction {
p.setOp(false); p.setOp(false);
deoped = true; deoped = true;
} }
if (Config.ban) { if (Config.nbtPunish) {
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."); for (String execute : punishCommands) {
banned = true; Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
} }
if (Config.logNBT) { if (Config.logNBT) {
logged = true; 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); NotifyConsole.NBT(p,item,removed,deoped,gms,punished,logged);
NotifyTrusted.NBT(p,item,removed,deoped,gms,banned,logged); NotifyTrusted.NBT(p,item,removed,deoped,gms,punished,logged);
} }
public static void placeBlock(BlockPlaceEvent e) { public static void placeBlock(BlockPlaceEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
Player p = e.getPlayer(); Player p = e.getPlayer();
boolean deleted = false; boolean deleted = false;
boolean deoped = false; boolean deoped = false;
boolean banned = false; boolean punished = false;
boolean logged = false; boolean logged = false;
if (Config.preventCmdBlocks) { if (Config.preventCmdBlocks) {
e.setCancelled(true); e.setCancelled(true);
@@ -109,16 +159,19 @@ public class TakeAction {
p.setOp(false); p.setOp(false);
deoped = true; deoped = true;
} }
if (Config.ban) { if (Config.cmdblockPunish) {
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."); for (String execute : punishCommands) {
banned = true; Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
} }
if (Config.logCmdBlocks) { if (Config.logCmdBlocks) {
logged = true; 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); NotifyConsole.placeBlock(p,b,deleted,deoped,punished,logged);
NotifyTrusted.placeBlock(p,b,deleted,deoped,banned,logged); NotifyTrusted.placeBlock(p,b,deleted,deoped,punished,logged);
} }
public static void useBlock(PlayerInteractEvent e) { public static void useBlock(PlayerInteractEvent e) {
if (e.getClickedBlock() == null) return; if (e.getClickedBlock() == null) return;
@@ -126,7 +179,7 @@ public class TakeAction {
Block b = e.getClickedBlock(); Block b = e.getClickedBlock();
boolean denied = false; boolean denied = false;
boolean deoped = false; boolean deoped = false;
boolean banned = false; boolean punished = false;
boolean logged = false; boolean logged = false;
if (Config.preventCmdBlocks) { if (Config.preventCmdBlocks) {
e.setCancelled(true); e.setCancelled(true);
@@ -136,16 +189,19 @@ public class TakeAction {
p.setOp(false); p.setOp(false);
deoped = true; deoped = true;
} }
if (Config.ban) { if (Config.cmdblockPunish) {
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."); for (String execute : punishCommands) {
banned = true; Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
} }
if (Config.logCmdBlocks) { if (Config.logCmdBlocks) {
logged = true; 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); NotifyConsole.usedBlock(p,b,denied,deoped,punished,logged);
NotifyTrusted.usedBlock(p,b,denied,deoped,banned,logged); NotifyTrusted.usedBlock(p,b,denied,deoped,punished,logged);
} }
public static void useEntity(PlayerInteractEntityEvent e) { public static void useEntity(PlayerInteractEntityEvent e) {
if (e.getRightClicked() == null) return; if (e.getRightClicked() == null) return;
@@ -153,7 +209,7 @@ public class TakeAction {
Entity ent = e.getRightClicked(); Entity ent = e.getRightClicked();
boolean denied = false; boolean denied = false;
boolean deoped = false; boolean deoped = false;
boolean banned = false; boolean punished = false;
boolean logged = false; boolean logged = false;
if (Config.preventCmdBlocks) { if (Config.preventCmdBlocks) {
e.setCancelled(true); e.setCancelled(true);
@@ -163,15 +219,18 @@ public class TakeAction {
p.setOp(false); p.setOp(false);
deoped = true; deoped = true;
} }
if (Config.ban) { if (Config.cmdblockPunish) {
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."); for (String execute : punishCommands) {
banned = true; Sentinel.log.info("Dispatching a sentinel command! (" + execute.replace("%player%", p.getName()) + ")");
ServerUtils.sendCommand(execute.replace("%player%",p.getName()));
}
punished = true;
} }
if (Config.logCmdBlocks) { if (Config.logCmdBlocks) {
logged = true; 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); NotifyConsole.usedEntity(p,ent,denied,deoped,punished,logged);
NotifyTrusted.usedEntity(p,ent,denied,deoped,banned,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) { public static void alertSpam(Player p, String message1, String message2) {
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
p.sendMessage(TextUtils.prefix("Do not spam in chat! Please wait before sending another message.")); p.sendMessage(TextUtils.prefix("Do not spam in chat! Please wait before sending another message."));
String hover = TextUtils.color("§8]==-- §d§lSentinel §8--==[" + String hover ="§8]==-- §d§lSentinel §8--==[" +
"\n&bPrevious: &f" + message2 + "\n§bPrevious: §f" + message2 +
"\n&bCurrent: &f" + message1 + "\n§bCurrent: §f" + message1 +
"\n&bSimilarity &f" + GPTUtils.calculateSimilarity(message1,message2 + "%")); "\n§bSimilarity §f" + GPTUtils.calculateSimilarity(message1,message2 + "%");
text.setText(TextUtils.prefix(TextUtils.color text.setText(TextUtils.prefix(
("&b&n" + p.getName() + "&7 might be spamming! &8(&c" + heatMap.get(p) + "&7/&4" + Config.punishHeat + "&8)"))); "§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))); text.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
ServerUtils.forEachStaff(staff -> { ServerUtils.forEachStaff(staff -> {
staff.spigot().sendMessage(text); staff.spigot().sendMessage(text);
@@ -82,10 +82,10 @@ public class AntiSpam {
chatCleared = true; chatCleared = true;
} }
ServerUtils.sendCommand(Config.punishSpamCommand.replace("%player%", player.getName())); 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(); TextComponent text = new TextComponent();
text.setText(TextUtils.prefix(TextUtils.color 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)"))); "§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 -> { ServerUtils.forEachStaff(staff -> {
staff.spigot().sendMessage(text); staff.spigot().sendMessage(text);
}); });

View File

@@ -12,7 +12,17 @@ import java.net.InetAddress;
import java.net.URL; import java.net.URL;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; 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 { 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 { 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())); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line; List<String> lines = readLines(reader);
while ((line = reader.readLine()) != null) {
if (line.contains(license)) { for (String line : lines) {
String[] parts = line.split(":"); if (line.contains("data-key")) {
if (parts.length > 1) { String key = extractValue(line, "data-key");
String[] allowedIDs = parts[1].split("\\s+"); String allowedIDs = extractValue(line, "data-allowed");
for (String id : allowedIDs) { String[] allowedArr = allowedIDs.split(":");
if (id.equals(serverID)) {
reader.close(); if (key.equals(licenseKey)) {
return "AUTHORIZED"; if (Arrays.asList(allowedArr).contains(serverID)) {
authStatus = "AUTHORIZED";
} else {
authStatus = "INVALID-ID";
}
break;
} }
} }
} }
reader.close();
return "INVALID-ID"; if (authStatus.isEmpty()) {
authStatus = "UNREGISTERED";
} }
}
reader.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); 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() { public static String getServerID() {
return encrypt(IP.getHostAddress()); return encrypt(IP.getHostAddress());
} }

View File

@@ -72,11 +72,11 @@ public class ProfanityFilter {
} }
public static void punishSwear(Player player, String highlightedMSG, String origMessage) { public static void punishSwear(Player player, String highlightedMSG, String origMessage) {
ServerUtils.sendCommand(Config.swearPunishCommand.replace("%player%", player.getName())); 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!"))); player.sendMessage(TextUtils.prefix(("§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)"); String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§7§o(click to copy)");
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
text.setText(TextUtils.prefix(TextUtils.color 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)"))); ("§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.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
text.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, origMessage)); 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) { public static void punishSlur(Player player, String highlightedMSG, String origMessage) {
if (!Config.slurInstaPunish) return; if (!Config.slurInstaPunish) return;
ServerUtils.sendCommand(Config.slurPunishCommand.replace("%player%", player.getName())); ServerUtils.sendCommand(Config.slurPunishCommand.replace("%player%", player.getName()));
player.sendMessage(TextUtils.prefix(TextUtils.color("&cYou have been insta-muted for saying a slur!"))); player.sendMessage(TextUtils.prefix(("§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)"); String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§7§o(click to copy)");
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
text.setText(TextUtils.prefix(TextUtils.color 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)"))); ("§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.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
text.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, origMessage)); 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)); if (Config.logSwear) WebhookSender.sendSlurLog(player,origMessage,scoreMap.get(player));
} }
public static void blockSwear(Player player, String highlightedMSG, String origMessage, String severity) { 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!"))); player.sendMessage(TextUtils.prefix(("§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)"); String hover = ("§bOriginal: §f" + origMessage + "\n§bSanitized: §f" + highlightedMSG + "\n§bSeverity" + severity + "\n§7§o(click to copy)");
TextComponent text = new TextComponent(); TextComponent text = new TextComponent();
text.setText(TextUtils.prefix(TextUtils.color text.setText(TextUtils.prefix(
("&b&n" + player.getName() + "&7 has triggered the anti-swear! &8(&c" + scoreMap.get(player) + "&7/&4" + Config.punishScore + "&8)"))); ("§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.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(hover)));
text.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, origMessage)); 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) { 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) { 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; import org.bukkit.inventory.ItemStack;
public class NotifyConsole { 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 = ( final String log = (
"Sentinel caught a dangerous command! \n]==-- &d&lSentinel --==[" + "Sentinel caught a specific command! \n]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() + "\nPlayer: " + p.getName() +
"\nCommand: " + command + "\nCommand: " + command +
"\nDenied: " + TextUtils.boolString(denied,"","") + "\nDenied: " + TextUtils.boolString(denied,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") + "\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nBanned: " + TextUtils.boolString(banned,"","") + "\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"","") "\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
); );
Sentinel.log.info(log); 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 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 NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean punished, boolean logged) {
String log = ( String log = (
"Sentinel caught a dangerous NBT! \n]==-- &d&lSentinel --==[" + "Sentinel caught a dangerous NBT! \n]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() + "\nPlayer: " + p.getName() +
"\nItemType: " + item.getType() + "\nItemType: " + item.getType() +
"\nRemoved: " + TextUtils.boolString(removed,"","") + "\nRemoved: " + TextUtils.boolString(removed,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") + "\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nRevert GM: " + TextUtils.boolString(gms, "", "") + "\nRevert GM: " + TextUtils.boolString(gms, "\u2714","\u2718") +
"\nBanned: " + TextUtils.boolString(banned,"","") + "\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"","") "\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
); );
Sentinel.log.info(log); 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 = ( 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() + "\nPlayer: " + p.getName() +
"\nBlockType: " + b.getType() + "\nBlockType: " + b.getType() +
"\nLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() + "\nLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
"\nDeleted: " + TextUtils.boolString(deleted,"","") + "\nDeleted: " + TextUtils.boolString(deleted,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") + "\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nBanned: " + TextUtils.boolString(banned,"","") + "\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"","") "\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
); );
Sentinel.log.info(log); 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 = ( String log = (
"]==-- &d&lSentinel --==[" + "]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() + "\nPlayer: " + p.getName() +
"\nBlockType: " + b.getType() + "\nBlockType: " + b.getType() +
"\nLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() + "\nLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
"\nDenied: " + TextUtils.boolString(denied,"","") + "\nDenied: " + TextUtils.boolString(denied,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") + "\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nBanned: " + TextUtils.boolString(banned,"","") + "\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"","") "\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
); );
Sentinel.log.info(log); 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 = ( String log = (
"]==-- &d&lSentinel --==[" + "]==-- Sentinel --==[" +
"\nPlayer: " + p.getName() + "\nPlayer: " + p.getName() +
"\nEntityType: " + e.getType() + "\nEntityType: " + e.getType() +
"\nLocation: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ() + "\nLocation: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ() +
"\nDenied: " + TextUtils.boolString(denied,"","") + "\nDenied: " + TextUtils.boolString(denied,"\u2714","\u2718") +
"\nDeoped: " + TextUtils.boolString(deoped,"","") + "\nDeoped: " + TextUtils.boolString(deoped,"\u2714","\u2718") +
"\nBanned: " + TextUtils.boolString(banned,"","") + "\nPunished: " + TextUtils.boolString(punished,"\u2714","\u2718") +
"\nLogged: " + TextUtils.boolString(logged,"","") "\nLogged: " + TextUtils.boolString(logged,"\u2714","\u2718")
); );
Sentinel.log.info(log); Sentinel.log.info(log);
} }

View File

@@ -16,7 +16,36 @@ import java.awt.*;
import java.io.IOException; import java.io.IOException;
public class NotifyDiscord { 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..."); ServerUtils.sendDebugMessage("Creating Command Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook); DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png"); webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png");
@@ -31,7 +60,7 @@ public class NotifyDiscord {
.addField("Actions:", .addField("Actions:",
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" + 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 + " **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 Emojis.rightSort + "**Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
) )
.setThumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay") .setThumbnail("https://crafatar.com/avatars/" + player.getUniqueId() + "?size=64&&overlay")
@@ -45,7 +74,7 @@ public class NotifyDiscord {
Sentinel.log.info(e.toString()); 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..."); ServerUtils.sendDebugMessage("Creating NBT Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.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 + " **Removed:** " + TextUtils.boolString(removed,Emojis.success, Emojis.failure) + "\\n" +
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,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 + " **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 Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
) )
.setColor(Color.BLUE); .setColor(Color.BLUE);
@@ -76,7 +105,7 @@ public class NotifyDiscord {
Sentinel.log.info(e.toString()); 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..."); ServerUtils.sendDebugMessage("Creating placeBlock Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook); DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png"); 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!") .setTitle("The placing of a dangerous block has been detected!")
.setDescription( .setDescription(
Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n" + 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:", .addField("Actions:",
Emojis.rightSort + " **Deleted:** " + TextUtils.boolString(deleted,Emojis.success, Emojis.failure) + "\\n" + 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 + " **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 Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
) )
.setColor(Color.RED); .setColor(Color.RED);
@@ -104,7 +134,7 @@ public class NotifyDiscord {
Sentinel.log.info(e.toString()); 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..."); ServerUtils.sendDebugMessage("Creating useBlock Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook); DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png"); 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!") .setTitle("The use of a dangerous block has been detected!")
.setDescription( .setDescription(
Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n" + 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:", .addField("Actions:",
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" + 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 + " **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 Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
) )
.setColor(Color.RED); .setColor(Color.RED);
@@ -132,7 +163,7 @@ public class NotifyDiscord {
Sentinel.log.info(e.toString()); 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..."); ServerUtils.sendDebugMessage("Creating useEntity Webhook...");
DiscordWebhook webhook = new DiscordWebhook(Config.webhook); DiscordWebhook webhook = new DiscordWebhook(Config.webhook);
webhook.setAvatarUrl("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/3lwit5nt.png"); 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!") .setTitle("The use of a dangerous entity has been detected!")
.setDescription( .setDescription(
Emojis.rightSort + " **Player:** " + player.getName() + " " + Emojis.member + "\\n" + 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:", .addField("Actions:",
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" + 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 + " **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 Emojis.rightSort + " **Logged:** " + TextUtils.boolString(logged,Emojis.success, Emojis.failure), false
) )
.setColor(Color.RED); .setColor(Color.RED);

View File

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

View File

@@ -1,4 +1,4 @@
# Sentinel 0.0.2 # Sentinel 0.1.5
# ____ __ ___ # ____ __ ___
#/\ _`\ /\ \__ __ /\_ \ #/\ _`\ /\ \__ __ /\_ \
#\ \,\L\_\ __ ___\ \ ,_\/\_\ ___ __\//\ \ #\ \,\L\_\ __ ___\ \ ,_\/\_\ ___ __\//\ \
@@ -11,7 +11,7 @@
# Be sure to check out their amazing discord bot! # Be sure to check out their amazing discord bot!
config : config :
plugin: 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) # 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. 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-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 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 dangerous: # These commands can only be run by "trusted" users
- "op" - "op"
- "deop" - "deop"
- "stop" - "stop"
- "restart"
- "execute" # Could run commands as a trusted player - "execute" # Could run commands as a trusted player
- "sudo" # same as above - "sudo" # same as above
- "esudo" # WATCH OUT FOR ESSENTIALS ALIASES !!!
- "fill" # Most client side nukers use it - "fill" # Most client side nukers use it
- "setblock" # could setblock a command block with anything - "setblock" # could setblock a command block with anything
- "data" # Could modify a command block to whatever they wanted - "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-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-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-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. logged: # Commands that will always be logged to discord when executed.
- "gamemode"
- "give" - "give"
- "item"
deop: true # Defaulted true | This will remove an untrusted player's operator permissions whenever they attempt dangerous actions 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 punish a player when they attempt to use an NBT item
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 punish a player when they attempt to use a command block
cmdblock-punish: false # Defaulted false | This will ban 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
command-punish: true # Defaulted true | This will ban a 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. reop-command: false # Defaulted false | This enables the command allowing trusted players to op themselves if they get deoped.
# ------------------------------- # -------------------------------
# Chat Filter Setup & AntiSpam # Chat Filter Setup & AntiSpam
@@ -108,7 +116,7 @@ config :
- grape - grape
- grass - grass
- harass - harass
- hot water - hotwater
- identit - identit
- kassa - kassa
- kassi - kassi