Remove Deprecated Action Handling and Notification logic. As well as implementing a rudimentary authentication system for licensing.
This commit is contained in:
@@ -12,6 +12,7 @@ import io.github.thetrouper.sentinel.events.CmdBlockEvents;
|
||||
import io.github.thetrouper.sentinel.events.CommandEvent;
|
||||
import io.github.thetrouper.sentinel.events.NBTEvents;
|
||||
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
||||
import io.github.thetrouper.sentinel.server.functions.Authenticator;
|
||||
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@@ -21,6 +22,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -40,7 +42,15 @@ public final class Sentinel extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
log.info("Your server ID is: " + Authenticator.getServerID());
|
||||
try {
|
||||
if (!Authenticator.hasPaid()) {
|
||||
log.info("Open a ticket with this message if the plugin doesnt work. " + Authenticator.getServerID());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.info("Open a ticket with this message if the plugin doesnt work. " + Authenticator.getServerID());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// Files
|
||||
getConfig().options().copyDefaults();
|
||||
saveDefaultConfig();
|
||||
|
||||
@@ -8,6 +8,7 @@ import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Config;
|
||||
import io.github.thetrouper.sentinel.discord.WebhookSender;
|
||||
import io.github.thetrouper.sentinel.exceptions.CmdExHandler;
|
||||
import io.github.thetrouper.sentinel.server.TakeAction;
|
||||
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
||||
import io.github.thetrouper.sentinel.server.util.FileUtils;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
@@ -15,6 +16,7 @@ import io.github.thetrouper.sentinel.server.util.TextUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,7 +39,7 @@ public class InfoCommand implements TabExecutor {
|
||||
}
|
||||
case "webhooktest" -> {
|
||||
sender.sendMessage(TextUtils.prefix("Testing the webhook..."));
|
||||
WebhookSender.sendEmbedWarning(sender.getName(), "/sentinel webhooktest",true,true,false);
|
||||
TakeAction.command(new PlayerCommandPreprocessEvent((Player) sender,"hehehehaw"));
|
||||
}
|
||||
case "checkheat" -> {
|
||||
sender.sendMessage(TextUtils.prefix("Your heat is §e" + AntiSpam.heatMap.get(sender).toString()));
|
||||
@@ -46,9 +48,6 @@ public class InfoCommand implements TabExecutor {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say " + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting a dangerous command. Contact an administrator if you believe this to be a mistake.");
|
||||
ServerUtils.sendCommand("say test complete!");
|
||||
}
|
||||
case "pastebintest" -> {
|
||||
WebhookSender.sendTestEmbed();
|
||||
}
|
||||
case "filetest" -> {
|
||||
sender.sendMessage(TextUtils.prefix("testing file stuff"));
|
||||
if (!FileUtils.folderExists("/LoggedNBT")) {
|
||||
@@ -74,7 +73,6 @@ public class InfoCommand implements TabExecutor {
|
||||
"webhooktest",
|
||||
"checkheat",
|
||||
"dispatchtest",
|
||||
"pastebintest",
|
||||
"filetest"
|
||||
}).build();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ public abstract class Config {
|
||||
}
|
||||
}
|
||||
public static String webhook;
|
||||
public static String pbapikey;
|
||||
public static List<String> trustedPlayers;
|
||||
public static boolean blockSpecificCommands;
|
||||
public static boolean preventNBT;
|
||||
@@ -75,7 +74,6 @@ public abstract class Config {
|
||||
Sentinel.prefix = config.getString("config.plugin.prefix");
|
||||
// antiNuke
|
||||
webhook = config.getString("config.plugin.webhook");
|
||||
pbapikey = config.getString("config.plugin.pbapikey");
|
||||
trustedPlayers = config.getStringList("config.plugin.trusted");
|
||||
blockSpecificCommands = config.getBoolean("config.plugin.block-specific");
|
||||
preventNBT = config.getBoolean("config.plugin.prevent-nbt");
|
||||
|
||||
@@ -131,86 +131,4 @@ public class WebhookSender {
|
||||
return Emojis.failure;
|
||||
}
|
||||
}
|
||||
public static void sendEmbedWarning(String player, String command, boolean denied, boolean removedOp, boolean banned) {
|
||||
ServerUtils.sendDebugMessage("Creating Command Webhook...");
|
||||
final String description =
|
||||
Emojis.rightSort + " **Player:** " + player + " " + Emojis.member + "\\n" +
|
||||
Emojis.rightSort + " **Command:** " + command + " " + Emojis.nuke + "\\n" +
|
||||
Emojis.rightSort + " **Denied:** " + successOrFail(denied) + "\\n" +
|
||||
Emojis.rightSort + " **Removed OP:** " + successOrFail(removedOp) + "\\n" +
|
||||
Emojis.rightSort + " **Banned:** " + successOrFail(banned) + "\\n";
|
||||
|
||||
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(description)
|
||||
.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 sendEmbedWarning(String player, Block b, boolean denied, boolean removedOp, boolean banned) {
|
||||
ServerUtils.sendDebugMessage("Creating Block Webhook...");
|
||||
final String description =
|
||||
Emojis.rightSort + " **Player:** " + player + " " + Emojis.member + "\\n" +
|
||||
Emojis.rightSort + " **Block:** " + b.getType() + " " + Emojis.nuke + "\\n" +
|
||||
Emojis.rightSort + " **Denied:** " + successOrFail(denied) + "\\n" +
|
||||
Emojis.rightSort + " **Removed OP:** " + successOrFail(removedOp) + "\\n" +
|
||||
Emojis.rightSort + " **Banned:** " + successOrFail(banned) + "\\n";
|
||||
|
||||
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(description)
|
||||
.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 sendEmbedWarning(String player, ItemStack item, boolean denied, boolean removedOp, boolean banned) {
|
||||
Bukkit.getScheduler().runTaskLater(Sentinel.getInstance(),() -> {
|
||||
ServerUtils.sendDebugMessage("Creating Webhook...");
|
||||
final String description =
|
||||
Emojis.rightSort + " **Player:** " + player + " " + Emojis.member + "\\n" +
|
||||
Emojis.rightSort + " **Item:** " + item.getType().toString().toLowerCase() + " " + Emojis.nuke + "\\n" +
|
||||
Emojis.space + Emojis.rightDoubleArrow + "**NBT:** Uploaded to /Sentinel/LoggedNBT/" + FileUtils.createNBTLog(item.getItemMeta().getAsString()) + " \\n" +
|
||||
Emojis.rightSort + " **Denied:** " + successOrFail(denied) + "\\n" +
|
||||
Emojis.rightSort + " **Removed OP:** " + successOrFail(removedOp) + "\\n" +
|
||||
Emojis.rightSort + " **Banned:** " + successOrFail(banned) + "\\n";
|
||||
|
||||
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(description)
|
||||
.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());
|
||||
}
|
||||
},10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ 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.util.DeniedActions;
|
||||
import io.github.thetrouper.sentinel.server.TakeAction;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -23,7 +23,7 @@ public class CmdBlockEvents implements Listener {
|
||||
Player p = e.getPlayer();
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
e.setCancelled(true);
|
||||
DeniedActions.handleDeniedAction(p,b);
|
||||
TakeAction.useBlock(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public class CmdBlockEvents implements Listener {
|
||||
Player p = e.getPlayer();
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
e.setCancelled(true);
|
||||
DeniedActions.handleDeniedAction(p,b);
|
||||
TakeAction.placeBlock(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,8 +46,23 @@ public class CmdBlockEvents implements Listener {
|
||||
Player p = e.getPlayer();
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
e.setCancelled(true);
|
||||
Block b = p.getLocation().getBlock();
|
||||
DeniedActions.handleDeniedAction(p,b);
|
||||
TakeAction.useEntity(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onCMDBlockMinecartPlace(PlayerInteractEvent e) {
|
||||
if (!Config.preventCmdBlocks) {
|
||||
if (e.getItem() == null) return;
|
||||
if (e.getClickedBlock() == null) return;
|
||||
if (!e.getItem().getType().equals(Material.COMMAND_BLOCK_MINECART)) return;
|
||||
if (e.getClickedBlock().getType() == Material.RAIL || e.getClickedBlock().getType() == Material.POWERED_RAIL || e.getClickedBlock().getType() == Material.ACTIVATOR_RAIL || e.getClickedBlock().getType() == Material.DETECTOR_RAIL) {
|
||||
Player p = e.getPlayer();
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
e.setCancelled(true);
|
||||
p.getInventory().remove(Material.COMMAND_BLOCK_MINECART);
|
||||
TakeAction.useBlock(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ 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.util.DeniedActions;
|
||||
import io.github.thetrouper.sentinel.server.TakeAction;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import io.github.thetrouper.sentinel.server.util.TextUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -22,7 +22,7 @@ public class CommandEvent implements Listener {
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
e.setCancelled(true);
|
||||
ServerUtils.sendDebugMessage(TextUtils.prefix("Command is canceled"));
|
||||
DeniedActions.handleDeniedAction(p,e.getMessage());
|
||||
TakeAction.command(e);
|
||||
}
|
||||
}
|
||||
if (Config.blockSpecificCommands) {
|
||||
@@ -32,7 +32,7 @@ public class CommandEvent implements Listener {
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
e.setCancelled(true);
|
||||
ServerUtils.sendDebugMessage(TextUtils.prefix("Command is canceled"));
|
||||
DeniedActions.handleDeniedAction(p,command);
|
||||
TakeAction.command(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.github.thetrouper.sentinel.events;
|
||||
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.server.util.DeniedActions;
|
||||
import io.github.thetrouper.sentinel.server.TakeAction;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -14,13 +14,12 @@ public class NBTEvents implements Listener {
|
||||
if (!(e.getWhoClicked() instanceof Player p)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getCursor() == null) return;
|
||||
ItemStack i = e.getCursor();
|
||||
|
||||
if (!Sentinel.isTrusted(p)) {
|
||||
if (i != null && i.hasItemMeta()) {
|
||||
e.setCancelled(true);
|
||||
DeniedActions.handleDeniedAction(p,i);
|
||||
if (e.getCursor().getItemMeta() == null) return;
|
||||
if (i.hasItemMeta() && i.getItemMeta() != null) {
|
||||
TakeAction.NBT(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
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 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;
|
||||
|
||||
public class TakeAction {
|
||||
// command nbt place useblock useentity
|
||||
public static void command(PlayerCommandPreprocessEvent e) {
|
||||
boolean deoped = false;
|
||||
boolean banned = 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.ban) {
|
||||
ServerUtils.sendCommand("ban " + e.getPlayer().getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to use dangerous commands. Contact an administrator if you believe this to be a mistake.");
|
||||
banned = true;
|
||||
}
|
||||
if (Config.logDangerousCommands) {
|
||||
logged = true;
|
||||
NotifyDiscord.command(e.getPlayer(),message,denied,deoped,banned,true);
|
||||
}
|
||||
NotifyConsole.command(e.getPlayer(),message,denied,deoped,banned,logged);
|
||||
NotifyTrusted.command(e.getPlayer(),message,denied,deoped,banned,logged);
|
||||
}
|
||||
public static void NBT(InventoryCreativeEvent e) {
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
final ItemStack item = e.getCursor();
|
||||
boolean removed = false;
|
||||
boolean deoped = false;
|
||||
boolean banned = false;
|
||||
boolean 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.ban) {
|
||||
ServerUtils.sendCommand("ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to use dangerous items. Contact an administrator if you believe this to be a mistake.");
|
||||
banned = true;
|
||||
}
|
||||
if (Config.logNBT) {
|
||||
logged = true;
|
||||
NotifyDiscord.NBT(p,item,removed,deoped,gms,banned, true,FileUtils.createNBTLog(item.getType().toString().toLowerCase() + item.getItemMeta().getAsString()));
|
||||
}
|
||||
NotifyConsole.NBT(p,item,removed,deoped,gms,banned,logged);
|
||||
NotifyTrusted.NBT(p,item,removed,deoped,gms,banned,logged);
|
||||
}
|
||||
public static void placeBlock(BlockPlaceEvent e) {
|
||||
Block b = e.getBlock();
|
||||
Player p = e.getPlayer();
|
||||
boolean deleted = false;
|
||||
boolean deoped = false;
|
||||
boolean banned = 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.ban) {
|
||||
ServerUtils.sendCommand("ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to place dangerous blocks. Contact an administrator if you believe this to be a mistake.");
|
||||
banned = true;
|
||||
}
|
||||
if (Config.logCmdBlocks) {
|
||||
logged = true;
|
||||
NotifyDiscord.placeBlock(p,b,deleted,deoped,banned,logged);
|
||||
}
|
||||
NotifyConsole.placeBlock(p,b,deleted,deoped,banned,logged);
|
||||
NotifyTrusted.placeBlock(p,b,deleted,deoped,banned,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 banned = false;
|
||||
boolean logged = false;
|
||||
if (Config.preventCmdBlocks) {
|
||||
e.setCancelled(true);
|
||||
denied = true;
|
||||
}
|
||||
if (Config.deop) {
|
||||
p.setOp(false);
|
||||
deoped = true;
|
||||
}
|
||||
if (Config.ban) {
|
||||
ServerUtils.sendCommand("ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to use dangerous blocks. Contact an administrator if you believe this to be a mistake.");
|
||||
banned = true;
|
||||
}
|
||||
if (Config.logCmdBlocks) {
|
||||
logged = true;
|
||||
NotifyDiscord.usedBlock(p,b,denied,deoped,banned,logged);
|
||||
}
|
||||
NotifyConsole.usedBlock(p,b,denied,deoped,banned,logged);
|
||||
NotifyTrusted.usedBlock(p,b,denied,deoped,banned,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 banned = false;
|
||||
boolean logged = false;
|
||||
if (Config.preventCmdBlocks) {
|
||||
e.setCancelled(true);
|
||||
denied = true;
|
||||
}
|
||||
if (Config.deop) {
|
||||
p.setOp(false);
|
||||
deoped = true;
|
||||
}
|
||||
if (Config.ban) {
|
||||
ServerUtils.sendCommand("ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to use dangerous entities. Contact an administrator if you believe this to be a mistake.");
|
||||
banned = true;
|
||||
}
|
||||
if (Config.logCmdBlocks) {
|
||||
logged = true;
|
||||
NotifyDiscord.usedEntity(p,ent,denied,deoped,banned,logged);
|
||||
}
|
||||
NotifyConsole.usedEntity(p,ent,denied,deoped,banned,logged);
|
||||
NotifyTrusted.usedEntity(p,ent,denied,deoped,banned,logged);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package io.github.thetrouper.sentinel.server.functions;
|
||||
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.server.util.ArrayUtils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Authenticator {
|
||||
|
||||
public Authenticator() throws UnknownHostException {
|
||||
}
|
||||
private static final String ENCRYPTION_KEY = "lllIIlllIlSentinelAuthIllIllllII";
|
||||
private static final String ENCRYPTION_ALGORITHM = "AES";
|
||||
private static final String ENCRYPTION_MODE_PADDING = "AES/ECB/PKCS5Padding";
|
||||
static InetAddress IP;
|
||||
|
||||
static {
|
||||
try {
|
||||
IP = InetAddress.getLocalHost();
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
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 List<String> serverIDS(List<String> strings) {
|
||||
return strings.stream().filter(string -> string.contains("<p>")).toList();
|
||||
}
|
||||
public static boolean hasPaid() throws IOException {
|
||||
try {
|
||||
URL url = new URL("https://thetrouper.github.io/CUSTOMERS.html");
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream()));
|
||||
List<String> ids = serverIDS(readLines(bufferedReader));
|
||||
ids = ArrayUtils.toNewList(ids, string -> string.replaceAll("</p>", "").replaceAll("<p>", "").trim());
|
||||
if (!ids.contains(getServerID())) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("YOU SHALL NOT PASS! " + getServerID());
|
||||
}
|
||||
}
|
||||
public static String getServerID() {
|
||||
return encrypt(IP.getHostAddress());
|
||||
}
|
||||
|
||||
|
||||
public static String encrypt(String text) {
|
||||
try {
|
||||
SecretKeySpec secretKey = new SecretKeySpec(ENCRYPTION_KEY.getBytes(), ENCRYPTION_ALGORITHM);
|
||||
Cipher cipher = Cipher.getInstance(ENCRYPTION_MODE_PADDING);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||
|
||||
byte[] encryptedBytes = cipher.doFinal(text.getBytes());
|
||||
String encryptedText = bytesToHex(encryptedBytes);;
|
||||
return encryptedText;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "ERR";
|
||||
}
|
||||
|
||||
private static String bytesToHex(byte[] bytes) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
package io.github.thetrouper.sentinel.server.util;
|
||||
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.Config;
|
||||
import io.github.thetrouper.sentinel.discord.WebhookSender;
|
||||
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.Player;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class DeniedActions {
|
||||
private static String logMessage;
|
||||
private static boolean banned;
|
||||
private static boolean opRemoved;
|
||||
private static boolean denied;
|
||||
|
||||
public static void logPunishment(Player p, String type, String reason) {
|
||||
|
||||
}
|
||||
|
||||
public static void handleDeniedAction(Player p, String command) {
|
||||
ServerUtils.sendDebugMessage(TextUtils.prefix("Handling denied command..."));
|
||||
if (!Config.logDangerousCommands) return;
|
||||
ServerUtils.sendDebugMessage(TextUtils.prefix("LDC is enabled"));
|
||||
logMessage = "]==-- Sentinel --==[\n" +
|
||||
"A Dangerous command has been attempted!\n" +
|
||||
"Player: " + p.getName() + "\n" +
|
||||
"Command: " + command + "\n";
|
||||
if (Config.deop) {
|
||||
ServerUtils.sendDebugMessage(TextUtils.prefix("Deoping player"));
|
||||
p.setOp(false);
|
||||
logMessage = logMessage + "Operator Removed: ✔\n";
|
||||
opRemoved = true;
|
||||
} else {
|
||||
logMessage = logMessage + "Operator Removed: ✘\n";
|
||||
opRemoved = false;
|
||||
}
|
||||
if (Config.ban) {
|
||||
ServerUtils.sendDebugMessage(TextUtils.prefix("Banning player"));
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting a dangerous command. Contact an administrator if you believe this to be a mistake.");
|
||||
logMessage = logMessage + "Banned: ✔\n";
|
||||
banned = true;
|
||||
} else {
|
||||
logMessage = logMessage + "Banned: ✘\n";
|
||||
banned = false;
|
||||
}
|
||||
ServerUtils.sendDebugMessage(TextUtils.prefix("Sending log"));
|
||||
logMessage = logMessage + "Denied: ✔";
|
||||
denied = true;
|
||||
Sentinel.log.info(logMessage);
|
||||
notifyTrusted(p, command);
|
||||
WebhookSender.sendEmbedWarning(p.getName(),command,denied,opRemoved,banned);
|
||||
}
|
||||
public static void handleDeniedAction(Player p, Block block) {
|
||||
if (!Config.logCmdBlocks) return;
|
||||
logMessage = "]==-- Sentinel --==[\n" +
|
||||
"A Dangerous block usage has been detected!\n" +
|
||||
"Player: " + p.getName() + "\n" +
|
||||
"BlockType: " + block.getType() + "\n";
|
||||
if (Config.deop) {
|
||||
p.setOp(false);
|
||||
logMessage = logMessage + "Operator Removed: ✔\n";
|
||||
opRemoved = true;
|
||||
} else {
|
||||
logMessage = logMessage + "Operator Removed: ✘\n";
|
||||
opRemoved = false;
|
||||
}
|
||||
if (Config.ban) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "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.");
|
||||
logMessage = logMessage + "Banned: ✔\n";
|
||||
banned = true;
|
||||
} else {
|
||||
logMessage = logMessage + "Banned: ✘\n";
|
||||
banned = false;
|
||||
}
|
||||
logMessage = logMessage + "Denied: ✔";
|
||||
denied = true;
|
||||
Sentinel.log.info(logMessage);
|
||||
notifyTrusted(p, block);
|
||||
WebhookSender.sendEmbedWarning(p.getName(),block,denied,opRemoved,banned);
|
||||
}
|
||||
public static void handleDeniedAction(Player p, ItemStack i) {
|
||||
if (!Config.logNBT) return;
|
||||
logMessage = "]==-- Sentinel --==[\n" +
|
||||
"A Dangerous item has been detected!\n" +
|
||||
"Player: " + p.getName() + "\n" +
|
||||
"ItemType: " + i.getType() + "\n";
|
||||
if (Config.deop) {
|
||||
p.setOp(false);
|
||||
logMessage = logMessage + "Operator Removed: ✔\n";
|
||||
opRemoved = true;
|
||||
} else {
|
||||
logMessage = logMessage + "Operator Removed: ✘\n";
|
||||
opRemoved = false;
|
||||
}
|
||||
if (Config.ban) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "ban " + p.getName() + " ]=- Sentinel Anti-Grief -=[ You have been banned for attempting to use an NBT item. Contact an administrator if you believe this to be a mistake.");
|
||||
logMessage = logMessage + "Banned: ✔\n";
|
||||
banned = true;
|
||||
} else {
|
||||
logMessage = logMessage + "Banned: ✘\n";
|
||||
banned = false;
|
||||
}
|
||||
logMessage = logMessage + "Denied: ✔";
|
||||
denied = true;
|
||||
Sentinel.log.info(logMessage);
|
||||
notifyTrusted(p, i);
|
||||
WebhookSender.sendEmbedWarning(p.getName(),i,denied,opRemoved,banned);
|
||||
}
|
||||
private static void notifyTrusted(Player p, String command) {
|
||||
TextComponent message = new TextComponent(TextUtils.prefix(p.getName() + " has attempted a dangerous command!"));
|
||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
"§8]==-- §d§lSentinel §8--==[\n" +
|
||||
"§7Player: §b" + p.getName() + "\n" +
|
||||
"§7Command: §b" + command + "\n" +
|
||||
"§7Trusted: §cfalse\n" +
|
||||
"§7Denied: §atrue")));
|
||||
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (Sentinel.isTrusted(trustedPlayer)) {
|
||||
trustedPlayer.spigot().sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void notifyTrusted(Player p, Block b) {
|
||||
TextComponent message = new TextComponent(TextUtils.prefix(p.getName() + " has attempted to use a dangerous block!"));
|
||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
"§8]==-- §d§lSentinel §8--==[\n" +
|
||||
"§7Player: §b" + p.getName() + "\n" +
|
||||
"§7BlockType: §b" + b.getType() + "\n" +
|
||||
"§7Trusted: §cfalse\n" +
|
||||
"§7Denied: §atrue")));
|
||||
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (Sentinel.isTrusted(trustedPlayer)) {
|
||||
trustedPlayer.spigot().sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void notifyTrusted(Player p, ItemStack i) {
|
||||
TextComponent message = new TextComponent(TextUtils.prefix(p.getName() + " has attempted to use a dangerous item"));
|
||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
"§8]==-- §d§lSentinel §8--==[\n" +
|
||||
"§7Player: §b" + p.getName() + "\n" +
|
||||
"§7ItemType: §b" + i.getType() + "\n" +
|
||||
"§7Trusted: §cfalse\n" +
|
||||
"§7Denied: §atrue\n" +
|
||||
"§8(Click to copy ItemMeta)")));
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, new String(
|
||||
i.getItemMeta().toString()
|
||||
)));
|
||||
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (Sentinel.isTrusted(trustedPlayer)) {
|
||||
trustedPlayer.spigot().sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
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 command(Player p, String command, boolean denied, boolean deoped, boolean banned, boolean logged) {
|
||||
final String log = (
|
||||
"Sentinel caught a dangerous command! \n]==-- &d&lSentinel --==[" +
|
||||
"\nPlayer: " + p.getName() +
|
||||
"\nCommand: " + command +
|
||||
"\nDenied: " + TextUtils.boolString(denied,"✔","✘") +
|
||||
"\nDeoped: " + TextUtils.boolString(deoped,"✔","✘") +
|
||||
"\nBanned: " + TextUtils.boolString(banned,"✔","✘") +
|
||||
"\nLogged: " + TextUtils.boolString(logged,"✔","✘")
|
||||
);
|
||||
Sentinel.log.info(log);
|
||||
}
|
||||
public static void NBT(Player p, ItemStack item, boolean removed, boolean deoped, boolean gms, boolean banned, boolean logged) {
|
||||
String log = (
|
||||
"Sentinel caught a dangerous NBT! \n]==-- &d&lSentinel --==[" +
|
||||
"\nPlayer: " + p.getName() +
|
||||
"\nItemType: " + item.getType() +
|
||||
"\nRemoved: " + TextUtils.boolString(removed,"✔","✘") +
|
||||
"\nDeoped: " + TextUtils.boolString(deoped,"✔","✘") +
|
||||
"\nRevert GM: " + TextUtils.boolString(gms, "✔", "✘") +
|
||||
"\nBanned: " + TextUtils.boolString(banned,"✔","✘") +
|
||||
"\nLogged: " + TextUtils.boolString(logged,"✔","✘")
|
||||
);
|
||||
Sentinel.log.info(log);
|
||||
}
|
||||
public static void placeBlock(Player p, Block b, boolean deleted, boolean deoped, boolean banned, boolean logged) {
|
||||
String log = (
|
||||
"Sentinel has caught the placing of a dangerous block! \n]==-- &d&lSentinel --==[" +
|
||||
"\nPlayer: " + p.getName() +
|
||||
"\nBlockType: " + b.getType() +
|
||||
"\nLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
|
||||
"\nDeleted: " + TextUtils.boolString(deleted,"✔","✘") +
|
||||
"\nDeoped: " + TextUtils.boolString(deoped,"✔","✘") +
|
||||
"\nBanned: " + TextUtils.boolString(banned,"✔","✘") +
|
||||
"\nLogged: " + TextUtils.boolString(logged,"✔","✘")
|
||||
);
|
||||
Sentinel.log.info(log);
|
||||
}
|
||||
public static void usedBlock(Player p, Block b, boolean denied, boolean deoped, boolean banned, boolean logged) {
|
||||
String log = (
|
||||
"]==-- &d&lSentinel --==[" +
|
||||
"\nPlayer: " + p.getName() +
|
||||
"\nBlockType: " + b.getType() +
|
||||
"\nLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
|
||||
"\nDenied: " + TextUtils.boolString(denied,"✔","✘") +
|
||||
"\nDeoped: " + TextUtils.boolString(deoped,"✔","✘") +
|
||||
"\nBanned: " + TextUtils.boolString(banned,"✔","✘") +
|
||||
"\nLogged: " + TextUtils.boolString(logged,"✔","✘")
|
||||
);
|
||||
Sentinel.log.info(log);
|
||||
}
|
||||
public static void usedEntity(Player p, Entity e, boolean denied, boolean deoped, boolean banned, boolean logged) {
|
||||
String log = (
|
||||
"]==-- &d&lSentinel --==[" +
|
||||
"\nPlayer: " + p.getName() +
|
||||
"\nEntityType: " + e.getType() +
|
||||
"\nLocation: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ() +
|
||||
"\nDenied: " + TextUtils.boolString(denied,"✔","✘") +
|
||||
"\nDeoped: " + TextUtils.boolString(deoped,"✔","✘") +
|
||||
"\nBanned: " + TextUtils.boolString(banned,"✔","✘") +
|
||||
"\nLogged: " + TextUtils.boolString(logged,"✔","✘")
|
||||
);
|
||||
Sentinel.log.info(log);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
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 command(Player player, String command, boolean denied, boolean deoped, boolean banned, 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 + " **Banned:** " + TextUtils.boolString(banned,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 banned, 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 + " **Banned:** " + TextUtils.boolString(banned,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 banned, 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"
|
||||
)
|
||||
.addField("Actions:",
|
||||
Emojis.rightSort + " **Deleted:** " + TextUtils.boolString(deleted,Emojis.success, Emojis.failure) + "\\n" +
|
||||
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
|
||||
Emojis.rightSort + " **Banned:** " + TextUtils.boolString(banned,Emojis.success, Emojis.failure) + "\\n"+
|
||||
Emojis.rightSort + " **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 banned, 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"
|
||||
)
|
||||
.addField("Actions:",
|
||||
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" +
|
||||
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
|
||||
Emojis.rightSort + " **Banned:** " + TextUtils.boolString(banned,Emojis.success, Emojis.failure) + "\\n"+
|
||||
Emojis.rightSort + " **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 banned, 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"
|
||||
)
|
||||
.addField("Actions:",
|
||||
Emojis.rightSort + " **Denied:** " + TextUtils.boolString(denied,Emojis.success, Emojis.failure) + "\\n" +
|
||||
Emojis.rightSort + " **De-oped:** " + TextUtils.boolString(deoped,Emojis.success, Emojis.failure) + "\\n" +
|
||||
Emojis.rightSort + " **Banned:** " + TextUtils.boolString(banned,Emojis.success, Emojis.failure) + "\\n"+
|
||||
Emojis.rightSort + " **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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
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 command(Player p, String command, boolean denied, boolean deoped, boolean banned, boolean logged) {
|
||||
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted a dangerous command!")));
|
||||
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
TextUtils.color(
|
||||
"&8]==-- &d&lSentinel &8--==[" +
|
||||
"\n&bPlayer: &f" + p.getName() +
|
||||
"\n&bCommand: &f" + command +
|
||||
"\n&bDenied: " + TextUtils.boolString(denied,"&a✔","&c✘") +
|
||||
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
|
||||
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
|
||||
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘")
|
||||
)
|
||||
)));
|
||||
|
||||
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 banned, boolean logged) {
|
||||
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted to use a dangerous NBT item!")));
|
||||
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
TextUtils.color(
|
||||
"&8]==-- &d&lSentinel &8--==[" +
|
||||
"\n&bPlayer: &f" + p.getName() +
|
||||
"\n&bItemType: &f" + item.getType() +
|
||||
"\n&bRemoved: " + TextUtils.boolString(removed,"&a✔","&c✘") +
|
||||
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
|
||||
"\n&bRevert GM: " + TextUtils.boolString(gms, "&a✔", "&c✘") +
|
||||
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
|
||||
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘") +
|
||||
"\n&7(Click to copy NBT)"
|
||||
|
||||
))));
|
||||
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 banned, boolean logged) {
|
||||
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted to place a dangerous block!")));
|
||||
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(TextUtils.color(
|
||||
"&8]==-- &d&lSentinel &8--==[" +
|
||||
"\n&bPlayer: &f" + p.getName() +
|
||||
"\n&bBlockType: &f" + b.getType() +
|
||||
"\n&bLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
|
||||
"\n&bRemoved: " + TextUtils.boolString(removed,"&a✔","&c✘") +
|
||||
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
|
||||
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
|
||||
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘") +
|
||||
"\n&7(Click to Teleport)"
|
||||
))));
|
||||
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 banned, boolean logged) {
|
||||
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted to use a dangerous block!")));
|
||||
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(TextUtils.color(
|
||||
"&8]==-- &d&lSentinel &8--==[" +
|
||||
"\n&bPlayer: &f" + p.getName() +
|
||||
"\n&bBlockType: &f" + b.getType() +
|
||||
"\n&bLocation: " + b.getX() + " " + b.getY() + " " + b.getZ() +
|
||||
"\n&bDenied: " + TextUtils.boolString(denied,"&a✔","&c✘") +
|
||||
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
|
||||
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
|
||||
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘") +
|
||||
"\n&7(Click to Teleport)"
|
||||
))));
|
||||
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 banned, boolean logged) {
|
||||
TextComponent notification = new TextComponent(TextUtils.prefix(TextUtils.color("&b&n" + p.getName() + "&7 Has just attempted to use a dangerous entity!")));
|
||||
notification.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(TextUtils.color(
|
||||
"&8]==-- &d&lSentinel &8--==[" +
|
||||
"\n&bPlayer: &f" + p.getName() +
|
||||
"\n&bEntityType: &f" + e.getType() +
|
||||
"\n&bLocation: " + e.getLocation().getX() + " " + e.getLocation().getY() + " " + e.getLocation().getZ() +
|
||||
"\n&bDenied: " + TextUtils.boolString(denied,"&a✔","&c✘") +
|
||||
"\n&bDeoped: " + TextUtils.boolString(deoped,"&a✔","&c✘") +
|
||||
"\n&bBanned: " + TextUtils.boolString(banned,"&a✔","&c✘") +
|
||||
"\n&bLogged: " + TextUtils.boolString(logged,"&a✔","&c✘") +
|
||||
"\n&7(Click to Teleport)"
|
||||
))));
|
||||
notification.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "tp " + p.getName()));
|
||||
for (Player trustedPlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (Sentinel.isTrusted(trustedPlayer)) {
|
||||
trustedPlayer.spigot().sendMessage(notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,4 +56,11 @@ public class TextUtils {
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
public static String boolString(boolean bool, String caseTrue, String caseFalse) {
|
||||
if (bool) {
|
||||
return caseTrue;
|
||||
} else {
|
||||
return caseFalse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,26 +16,28 @@ config :
|
||||
# --------------------------------
|
||||
prefix: "§d§lSentinel §8» §7" # Prefix of the plugin. Line below is the discord webhook for logs to be sent to
|
||||
webhook: "https://discord.com/api/webhooks/1126363806147289088/UfWz9jdmXpZ4f2kqqsKK6mx4NmZyknhHNzGuAHYSx30iSLCPwqf66AiToZn2rItAmAym"
|
||||
pbapikey: "Sar3RgGOxMhps71H3JDWKPeCaMIDbS_g" # Put your pastebin.com API key here (they are free), if you wish for NBT logs to work
|
||||
trusted: # List the UUIDs of players who are trusted, will bypass the plugin and be immune to logs and are able to re-op themeselves
|
||||
- "049460f7-21cb-42f5-8059-d42752bf406f" # obvWolf
|
||||
block-specific: true # Defaulted true | Weather or not to block ALL plugin specific commands from non-trusted members (EX: minecraft:ban) 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-cmdblocks: true # Defaulted true | Should all command block actions be blocked
|
||||
dangerous: # These commands can only be run by "trusted" users
|
||||
- "op"
|
||||
- "deop"
|
||||
- "stop"
|
||||
- "execute"
|
||||
- "sudo"
|
||||
log-dangerous: true # Default true | Weather or not to log when a dangerous command is executed
|
||||
log-cmdblocks: true # Defaulted true | Log attempts of command-block place-ery
|
||||
log-nbt: true # Defaulted true | Should items and their NBT's be logged
|
||||
logged: # Commands that will always be logged when executed.
|
||||
- "execute" # Could run commands as a trusted player
|
||||
- "sudo" # same as above
|
||||
- "fill" # Most client side nukers use it
|
||||
- "setblock" # could setblock a command block with anything
|
||||
- "data" # Could modify a command block to whatever they wanted
|
||||
log-dangerous: true # Default true | Weather or not to log to discord when a dangerous command is executed
|
||||
log-cmdblocks: true # Defaulted true | Log attempts of command-block place-ery in discord
|
||||
log-nbt: true # Defaulted true | Should items and their NBT's be logged to discord
|
||||
logged: # Commands that will always be logged to discord when executed.
|
||||
- "gamemode"
|
||||
- "give"
|
||||
deop: true # Defaulted true | This will remove an untrusted player's operator permissions whenever they attempt dangerous actions
|
||||
ban: false
|
||||
ban: false # Default false | Weather or not to ban a player if they attempt something dangerous.
|
||||
nbt-punish: false # Defaulted false | This will ban a player when they attempt to use an NBT item
|
||||
cmdblock-punish: false # Defaulted false | This will ban a player when they attempt to use a command block
|
||||
command-punish: true # Defaulted true | This will ban a player when they attempt to use a dangerous command
|
||||
|
||||
Reference in New Issue
Block a user