Going to have to rewrite CBW
This commit is contained in:
58
src/main/java/me/trouper/sentinel/Director.java
Normal file
58
src/main/java/me/trouper/sentinel/Director.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package me.trouper.sentinel;
|
||||
|
||||
import me.trouper.sentinel.data.IO;
|
||||
import me.trouper.sentinel.server.functions.helpers.CBWhitelistManager;
|
||||
import me.trouper.sentinel.server.functions.helpers.MessageHandler;
|
||||
import me.trouper.sentinel.server.functions.helpers.ReportHandler;
|
||||
import me.trouper.sentinel.startup.*;
|
||||
import me.trouper.sentinel.startup.drm.Auth;
|
||||
import me.trouper.sentinel.startup.drm.Loader;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
|
||||
public final class Director {
|
||||
|
||||
public Loader loader;
|
||||
public BackdoorDetection backdoorDetection;
|
||||
public Auth auth;
|
||||
public Telemetry telemetry;
|
||||
public Injection injection;
|
||||
public CBWhitelistManager whitelistManager;
|
||||
public MessageHandler messageHandler;
|
||||
public ReportHandler reportHandler;
|
||||
public IO io;
|
||||
|
||||
public Director() {
|
||||
Sentinel.getInstance().getLogger().info("Instantiating Systems");
|
||||
telemetry = new Telemetry();
|
||||
auth = new Auth();
|
||||
loader = new Loader();
|
||||
backdoorDetection = new BackdoorDetection();
|
||||
injection = new Injection();
|
||||
whitelistManager = new CBWhitelistManager();
|
||||
messageHandler = new MessageHandler();
|
||||
reportHandler = new ReportHandler();
|
||||
io = new IO();
|
||||
}
|
||||
|
||||
public void launch() {
|
||||
Sentinel.getInstance().getLogger().info("Launching Sentinel");
|
||||
Sentinel.getInstance().ip = ServerUtils.getPublicIPAddress();
|
||||
Sentinel.getInstance().port = ServerUtils.getPort();
|
||||
Sentinel.getInstance().nonce = auth.getNonce();
|
||||
|
||||
Sentinel.getInstance().getLogger().info("Getting plugin file");
|
||||
|
||||
Sentinel.getInstance().getLogger().info("Reading Persistent files...");
|
||||
|
||||
io.loadConfig();
|
||||
|
||||
Sentinel.getInstance().getLogger().info("Language Status: (%s)".formatted(io.lang.brokenLang));
|
||||
|
||||
Sentinel.getInstance().getLogger().info("Initializing Auth Identifier");
|
||||
|
||||
Sentinel.getInstance().license = auth.getLicenseKey();
|
||||
Sentinel.getInstance().identifier = auth.getServerID();
|
||||
|
||||
loader.load(Sentinel.getInstance().license,Sentinel.getInstance().identifier, true);
|
||||
}
|
||||
}
|
||||
@@ -1,128 +1,116 @@
|
||||
package me.trouper.sentinel;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import de.tr7zw.changeme.nbtapi.NBT;
|
||||
import io.github.itzispyder.pdk.PDK;
|
||||
import io.github.itzispyder.pdk.utils.misc.config.JsonSerializable;
|
||||
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
|
||||
import me.trouper.sentinel.data.WhitelistStorage;
|
||||
import me.trouper.sentinel.data.config.*;
|
||||
import me.trouper.sentinel.data.config.lang.LanguageFile;
|
||||
import me.trouper.sentinel.server.events.PluginCloakingPacket;
|
||||
import me.trouper.sentinel.startup.Auth;
|
||||
import me.trouper.sentinel.startup.IndirectLaunch;
|
||||
import me.trouper.sentinel.server.events.extras.ShadowRealmEvents;
|
||||
import me.trouper.sentinel.server.events.violations.players.PluginCloakingPacket;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class Sentinel extends JavaPlugin {
|
||||
|
||||
public static final Logger log = Bukkit.getLogger();
|
||||
|
||||
private static Sentinel instance;
|
||||
public static LanguageFile lang;
|
||||
public static File us;
|
||||
|
||||
private static final File dataFolder = new File("plugins/SentinelAntiNuke");
|
||||
private static final File violationcfg = new File(Sentinel .dataFolder(),"/violation-config.json");
|
||||
private static final File cfgfile = new File(Sentinel.dataFolder(),"/main-config.json");
|
||||
private static final File nbtcfg = new File(Sentinel.dataFolder(), "/nbt-config.json");
|
||||
private static final File strctcfg = new File(Sentinel.dataFolder(), "/strict.json");
|
||||
private static final File swrcfg = new File(Sentinel.dataFolder(), "/swears.json");
|
||||
private static final File fpcfg = new File(Sentinel.dataFolder(), "/false-positives.json");
|
||||
private static final File advcfg = new File(Sentinel.dataFolder(), "/advanced-config.json");
|
||||
private static final File cmdWhitelist = new File(Sentinel.dataFolder(), "/storage/whitelist.json");
|
||||
|
||||
public static ViolationConfig violationConfig = JsonSerializable.load(violationcfg, ViolationConfig.class, new ViolationConfig());
|
||||
public static WhitelistStorage whitelist = JsonSerializable.load(cmdWhitelist, WhitelistStorage.class, new WhitelistStorage());
|
||||
public static MainConfig mainConfig = JsonSerializable.load(cfgfile, MainConfig.class, new MainConfig());
|
||||
public static FPConfig fpConfig = JsonSerializable.load(fpcfg, FPConfig.class, new FPConfig());
|
||||
public static SwearsConfig swearConfig = JsonSerializable.load(swrcfg, SwearsConfig.class, new SwearsConfig());
|
||||
public static StrictConfig strictConfig = JsonSerializable.load(strctcfg, StrictConfig.class, new StrictConfig());
|
||||
public static NBTConfig nbtConfig = JsonSerializable.load(nbtcfg, NBTConfig.class, new NBTConfig());
|
||||
public static AdvancedConfig advConfig = JsonSerializable.load(advcfg, AdvancedConfig.class, new AdvancedConfig());
|
||||
|
||||
private Director director;
|
||||
|
||||
public String identifier;
|
||||
public String license;
|
||||
public String nonce;
|
||||
public String ip;
|
||||
public int port;
|
||||
|
||||
/* ]=- Sentinel Startup Flow -=[
|
||||
Make sure everything is done in sequence to avoid NullPointerException!
|
||||
1. onLoad
|
||||
- PacketEvents Loading & Registration
|
||||
2. onEnable
|
||||
- Init PacketEvents
|
||||
- Init NBT-API
|
||||
- Init PDK
|
||||
- Instantiate Sentinel
|
||||
- Instantiate Director
|
||||
3. Launch
|
||||
- Init DRM
|
||||
- Read Config
|
||||
4. Load
|
||||
- Run DRM Checks
|
||||
- Register Commands
|
||||
- Register Events
|
||||
- Register Timers
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Sentinel.log.info("\n]======------ Pre-load started ------======[");
|
||||
getLogger().info("\n]======------ Pre-load started ------======[");
|
||||
|
||||
Sentinel.log.info("Setting PacketEvents API");
|
||||
getLogger().info("Setting PacketEvents API");
|
||||
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
|
||||
|
||||
Sentinel.log.info("Loading PacketEvents");
|
||||
getLogger().info("Loading PacketEvents");
|
||||
PacketEvents.getAPI().load();
|
||||
|
||||
Sentinel.log.info("Registering PacketEvents");
|
||||
getLogger().info("Registering PacketEvents");
|
||||
PacketEvents.getAPI().getEventManager().registerListener(new PluginCloakingPacket());
|
||||
PacketEvents.getAPI().getEventManager().registerListener(new ShadowRealmEvents());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
log.info("\n]======------ Loading Sentinel ------======[");
|
||||
public void onEnable() {
|
||||
getLogger().info("\n]======------ Loading Sentinel ------======[");
|
||||
|
||||
log.info("Initializing PacketEvents");
|
||||
getLogger().info("Initializing PacketEvents");
|
||||
|
||||
PacketEvents.getAPI().init();
|
||||
|
||||
log.info("Initializing PDK");
|
||||
getLogger().info("Pre-loading NBT-API");
|
||||
if (!NBT.preloadApi()) {
|
||||
getLogger().warning("NBT-API wasn't initialized properly. Sentinel may error out.");
|
||||
}
|
||||
|
||||
getLogger().info("Initializing PDK");
|
||||
PDK.init(this);
|
||||
|
||||
log.info("Instantiating plugin");
|
||||
getLogger().info("Instantiating Sentinel");
|
||||
instance = this;
|
||||
us = getFile();
|
||||
|
||||
IndirectLaunch.launch();
|
||||
}
|
||||
Sentinel.getInstance().getLogger().info("Instantiating Director");
|
||||
director = new Director();
|
||||
|
||||
public void loadConfig() {
|
||||
// Init
|
||||
mainConfig = JsonSerializable.load(cfgfile,MainConfig.class,new MainConfig());
|
||||
advConfig = JsonSerializable.load(advcfg,AdvancedConfig.class,new AdvancedConfig());
|
||||
fpConfig = JsonSerializable.load(fpcfg,FPConfig.class,new FPConfig());
|
||||
strictConfig = JsonSerializable.load(strctcfg,StrictConfig.class,new StrictConfig());
|
||||
swearConfig = JsonSerializable.load(swrcfg,SwearsConfig.class,new SwearsConfig());
|
||||
nbtConfig = JsonSerializable.load(nbtcfg,NBTConfig.class,new NBTConfig());
|
||||
violationConfig = JsonSerializable.load(violationcfg,ViolationConfig.class,new ViolationConfig());
|
||||
getLogger().info("Deleting Residual Block Displays");
|
||||
List<World> worlds = Bukkit.getWorlds();
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
for (World world : worlds) {
|
||||
entities.addAll(world.getEntities().stream().filter(entity -> entity.getScoreboardTags().contains("./Sentinel/ Block Display")).toList());
|
||||
entities.forEach(Entity::remove);
|
||||
}
|
||||
|
||||
// Save
|
||||
mainConfig.save();
|
||||
advConfig.save();
|
||||
fpConfig.save();
|
||||
strictConfig.save();
|
||||
swearConfig.save();
|
||||
nbtConfig.save();
|
||||
violationConfig.save();
|
||||
|
||||
whitelist = JsonSerializable.load(cmdWhitelist, WhitelistStorage.class, new WhitelistStorage());
|
||||
whitelist.save();
|
||||
|
||||
log.info("Loading Dictionary (%s)...".formatted(Sentinel.mainConfig.plugin.lang));
|
||||
|
||||
lang = JsonSerializable.load(LanguageFile.PATH,LanguageFile.class,new LanguageFile());
|
||||
lang.save();
|
||||
|
||||
log.info("Setting License Key");
|
||||
license = Auth.getLicenseKey();
|
||||
director.launch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
PacketEvents.getAPI().terminate();
|
||||
log.info("Sentinel has disabled! (%s) Your server is now no longer protected!".formatted(getDescription().getVersion()));
|
||||
getLogger().info("Sentinel has disabled! (%s) Your server is now no longer protected!".formatted(getDescription().getVersion()));
|
||||
}
|
||||
|
||||
public static Sentinel getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Director getDirector() {
|
||||
return director;
|
||||
}
|
||||
|
||||
public static File dataFolder() {
|
||||
return dataFolder;
|
||||
public NamespacedKey getNamespace(String key) {
|
||||
return new NamespacedKey(Sentinel.getInstance(), key);
|
||||
}
|
||||
}
|
||||
|
||||
68
src/main/java/me/trouper/sentinel/data/IO.java
Normal file
68
src/main/java/me/trouper/sentinel/data/IO.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package me.trouper.sentinel.data;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.config.JsonSerializable;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.config.*;
|
||||
import me.trouper.sentinel.data.config.lang.LanguageFile;
|
||||
import me.trouper.sentinel.data.storage.ExtraStorage;
|
||||
import me.trouper.sentinel.data.storage.CommandBlockStorage;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class IO {
|
||||
private final File dataFolder = new File("plugins/SentinelAntiNuke");
|
||||
private final File violationcfg = new File(dataFolder,"/violation-config.json");
|
||||
private final File cfgfile = new File(dataFolder,"/main-config.json");
|
||||
private final File nbtcfg = new File(dataFolder, "/nbt-config.json");
|
||||
private final File strctcfg = new File(dataFolder, "/strict.json");
|
||||
private final File swrcfg = new File(dataFolder, "/swears.json");
|
||||
private final File fpcfg = new File(dataFolder, "/false-positives.json");
|
||||
private final File advcfg = new File(dataFolder, "/advanced-config.json");
|
||||
private final File cmdWhitelist = new File(dataFolder, "/storage/whitelist.json");
|
||||
private final File extraFile = new File(dataFolder, "/storage/extra.json");
|
||||
|
||||
public LanguageFile lang;
|
||||
public ViolationConfig violationConfig = JsonSerializable.load(violationcfg, ViolationConfig.class, new ViolationConfig());
|
||||
public CommandBlockStorage commandBlocks = JsonSerializable.load(cmdWhitelist, CommandBlockStorage.class, new CommandBlockStorage());
|
||||
public ExtraStorage extraStorage = JsonSerializable.load(cmdWhitelist, ExtraStorage.class, new ExtraStorage());
|
||||
public MainConfig mainConfig = JsonSerializable.load(cfgfile, MainConfig.class, new MainConfig());
|
||||
public FPConfig fpConfig = JsonSerializable.load(fpcfg, FPConfig.class, new FPConfig());
|
||||
public SwearsConfig swearConfig = JsonSerializable.load(swrcfg, SwearsConfig.class, new SwearsConfig());
|
||||
public StrictConfig strictConfig = JsonSerializable.load(strctcfg, StrictConfig.class, new StrictConfig());
|
||||
public NBTConfig nbtConfig = JsonSerializable.load(nbtcfg, NBTConfig.class, new NBTConfig());
|
||||
public AdvancedConfig advConfig = JsonSerializable.load(advcfg, AdvancedConfig.class, new AdvancedConfig());
|
||||
|
||||
public void loadConfig() {
|
||||
// Init
|
||||
mainConfig = JsonSerializable.load(cfgfile,MainConfig.class,new MainConfig());
|
||||
advConfig = JsonSerializable.load(advcfg,AdvancedConfig.class,new AdvancedConfig());
|
||||
fpConfig = JsonSerializable.load(fpcfg,FPConfig.class,new FPConfig());
|
||||
strictConfig = JsonSerializable.load(strctcfg,StrictConfig.class,new StrictConfig());
|
||||
swearConfig = JsonSerializable.load(swrcfg,SwearsConfig.class,new SwearsConfig());
|
||||
nbtConfig = JsonSerializable.load(nbtcfg,NBTConfig.class,new NBTConfig());
|
||||
violationConfig = JsonSerializable.load(violationcfg,ViolationConfig.class,new ViolationConfig());
|
||||
|
||||
// Save
|
||||
mainConfig.save();
|
||||
advConfig.save();
|
||||
fpConfig.save();
|
||||
strictConfig.save();
|
||||
swearConfig.save();
|
||||
nbtConfig.save();
|
||||
violationConfig.save();
|
||||
|
||||
commandBlocks = JsonSerializable.load(cmdWhitelist, CommandBlockStorage.class, new CommandBlockStorage());
|
||||
extraStorage = JsonSerializable.load(extraFile, ExtraStorage.class, new ExtraStorage());
|
||||
commandBlocks.save();
|
||||
extraStorage.save();
|
||||
|
||||
Sentinel.getInstance().getLogger().info("Loading Dictionary (%s)...".formatted(mainConfig.plugin.lang));
|
||||
|
||||
lang = JsonSerializable.load(LanguageFile.PATH,LanguageFile.class,new LanguageFile());
|
||||
lang.save();
|
||||
}
|
||||
|
||||
public File getDataFolder() {
|
||||
return dataFolder;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package me.trouper.sentinel.data;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.config.JsonSerializable;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.WhitelistedBlock;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class WhitelistStorage implements JsonSerializable<WhitelistStorage> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.dataFolder(), "/storage/whitelist.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
public ConcurrentLinkedQueue<WhitelistedBlock> whitelistedCMDBlocks = new ConcurrentLinkedQueue<>();
|
||||
|
||||
}
|
||||
@@ -10,11 +10,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AdvancedConfig implements JsonSerializable<AdvancedConfig> {
|
||||
public static String nonce = "%%__NONCE__%%";
|
||||
public transient String nonce = "%%__NONCE__%%";
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.dataFolder(), "/advanced-config.json");
|
||||
File file = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/advanced-config.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class FPConfig implements JsonSerializable<FPConfig> {
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.dataFolder(), "/false-positives.json");
|
||||
File file = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/false-positives.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ import java.util.List;
|
||||
|
||||
public class MainConfig implements JsonSerializable<MainConfig> {
|
||||
|
||||
public static String user = "%%__USER__%%";
|
||||
public static String username = "%%__USERNAME__%%";
|
||||
public transient String user = "%%__USER__%%";
|
||||
public transient String username = "%%__USERNAME__%%";
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.dataFolder(), "/main-config.json");
|
||||
File file = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/main-config.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
@@ -23,8 +23,8 @@ public class MainConfig implements JsonSerializable<MainConfig> {
|
||||
public boolean telemetry = true;
|
||||
|
||||
public Plugin plugin = new Plugin();
|
||||
public Chat chat = new Chat();
|
||||
public BackdoorDetection backdoorDetection = new BackdoorDetection();
|
||||
public Chat chat = new Chat();
|
||||
|
||||
public class Plugin {
|
||||
public String license = "null";
|
||||
@@ -34,7 +34,7 @@ public class MainConfig implements JsonSerializable<MainConfig> {
|
||||
public List<String> trustedPlayers = Arrays.asList(
|
||||
"049460f7-21cb-42f5-8059-d42752bf406f"
|
||||
);
|
||||
|
||||
public boolean antiBan = true;
|
||||
public boolean reopCommand = false;
|
||||
public boolean pluginHider = true;
|
||||
public String identifier = "My Server (Edit in main-config.json)";
|
||||
@@ -96,7 +96,7 @@ public class MainConfig implements JsonSerializable<MainConfig> {
|
||||
public boolean enabled = true;
|
||||
public boolean silent = false;
|
||||
public boolean punished = false;
|
||||
public String regex = "[^A-Za-z0-9\\[,./?><|\\]§()*&^%$#@!~`{}:;'\"-_]";
|
||||
public String regex = "[^A-Za-z0-9\\[,./?><|\\]§()*&^%$#@!~`{}:;'\"-_ ]";
|
||||
public List<String> punishCommands = Arrays.asList(
|
||||
"clearchat",
|
||||
"mute %player% 1m Please refrain from spamming!"
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.io.File;
|
||||
public class NBTConfig implements JsonSerializable<NBTConfig> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.dataFolder(), "/nbt-config.json");
|
||||
File file = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/nbt-config.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
@@ -17,6 +17,10 @@ public class NBTConfig implements JsonSerializable<NBTConfig> {
|
||||
public boolean allowLore = true;
|
||||
public boolean allowAttributes = false;
|
||||
public boolean allowPotions = false;
|
||||
public boolean allowCustomConsumables = false;
|
||||
public boolean allowCustomTools = false;
|
||||
public boolean allowBooks = false;
|
||||
public boolean allowRecursion = true;
|
||||
public int globalMaxEnchant = 5;
|
||||
public int maxMending = 1;
|
||||
public int maxUnbreaking = 3;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.List;
|
||||
public class StrictConfig implements JsonSerializable<StrictConfig> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.dataFolder(), "/strict.json");
|
||||
File file = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/strict.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
public class SwearsConfig implements JsonSerializable<SwearsConfig> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.dataFolder(), "/swears.json");
|
||||
File file = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/swears.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
@@ -10,20 +10,107 @@ import java.util.List;
|
||||
public class ViolationConfig implements JsonSerializable<SwearsConfig> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.dataFolder(), "/violation-config.json");
|
||||
File file = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/violation-config.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
public CommandBlockEdit commandBlockEdit = new CommandBlockEdit();
|
||||
public CommandBlockExecute commandBlockExecute = new CommandBlockExecute();
|
||||
public CommandBlockWhitelist commandBlockWhitelist = new CommandBlockWhitelist();
|
||||
public CommandBlockMinecartPlace commandBlockMinecartPlace = new CommandBlockMinecartPlace();
|
||||
public CommandBlockMinecartUse commandBlockMinecartUse = new CommandBlockMinecartUse();
|
||||
public CommandBlockMinecartBreak commandBlockMinecartBreak = new CommandBlockMinecartBreak();
|
||||
public CommandBlockPlace commandBlockPlace = new CommandBlockPlace();
|
||||
public CommandBlockUse commandBlockUse = new CommandBlockUse();
|
||||
public CommandBlockBreak commandBlockBreak = new CommandBlockBreak();
|
||||
public CommandExecute commandExecute = new CommandExecute();
|
||||
public CreativeHotbarAction creativeHotbarAction = new CreativeHotbarAction();
|
||||
public StructureBlockPlace structureBlockPlace = new StructureBlockPlace();
|
||||
public StructureBlockBreak structureBlockBreak = new StructureBlockBreak();
|
||||
public StructureBlockUse structureBlockUse = new StructureBlockUse();
|
||||
public JigsawBlockPlace jigsawBlockPlace = new JigsawBlockPlace();
|
||||
public JigsawBlockBreak jigsawBlockBreak = new JigsawBlockBreak();
|
||||
public JigsawBlockUse jigsawBlockUse = new JigsawBlockUse();
|
||||
|
||||
public class JigsawBlockPlace {
|
||||
public boolean enabled = true;
|
||||
public boolean deop = true;
|
||||
public boolean logToDiscord = true;
|
||||
public boolean punish = false;
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
);
|
||||
}
|
||||
|
||||
public class JigsawBlockBreak {
|
||||
public boolean enabled = true;
|
||||
public boolean deop = true;
|
||||
public boolean logToDiscord = true;
|
||||
public boolean punish = false;
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
);
|
||||
}
|
||||
|
||||
public class JigsawBlockUse {
|
||||
public boolean enabled = true;
|
||||
public boolean deop = true;
|
||||
public boolean logToDiscord = true;
|
||||
public boolean punish = false;
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
);
|
||||
}
|
||||
|
||||
public class StructureBlockPlace {
|
||||
public boolean enabled = true;
|
||||
public boolean deop = true;
|
||||
public boolean logToDiscord = true;
|
||||
public boolean punish = false;
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
);
|
||||
}
|
||||
|
||||
public class StructureBlockBreak {
|
||||
public boolean enabled = true;
|
||||
public boolean deop = true;
|
||||
public boolean logToDiscord = true;
|
||||
public boolean punish = false;
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
);
|
||||
}
|
||||
|
||||
public class StructureBlockUse {
|
||||
public boolean enabled = true;
|
||||
public boolean deop = true;
|
||||
public boolean logToDiscord = true;
|
||||
public boolean punish = false;
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
);
|
||||
}
|
||||
|
||||
public class CommandBlockMinecartBreak {
|
||||
public boolean enabled = true;
|
||||
public boolean deop = true;
|
||||
public boolean logToDiscord = true;
|
||||
public boolean punish = false;
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
);
|
||||
}
|
||||
|
||||
public class CommandBlockBreak {
|
||||
public boolean enabled = true;
|
||||
public boolean deop = true;
|
||||
public boolean logToDiscord = true;
|
||||
public boolean punish = false;
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
);
|
||||
}
|
||||
|
||||
public class CommandBlockEdit {
|
||||
public boolean enabled = true;
|
||||
@@ -81,7 +168,7 @@ public class ViolationConfig implements JsonSerializable<SwearsConfig> {
|
||||
public boolean logToDiscord = true;
|
||||
public boolean punish = false;
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
"gamemode survival %player%"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,7 +200,9 @@ public class ViolationConfig implements JsonSerializable<SwearsConfig> {
|
||||
"pluginmanager",
|
||||
"rl",
|
||||
"reload",
|
||||
"plugman"
|
||||
"plugman",
|
||||
"spigot",
|
||||
"paper"
|
||||
);
|
||||
public boolean deop = true;
|
||||
public boolean logToDiscord = true;
|
||||
@@ -137,14 +226,24 @@ public class ViolationConfig implements JsonSerializable<SwearsConfig> {
|
||||
public List<String> punishmentCommands = Arrays.asList(
|
||||
"ban %player% ]=- Sentinel -=[ \nYou have been banned for attempting a dangerous action. \nIf you believe this to be a mistake, please contact the server owner."
|
||||
);
|
||||
public List<String> whitelist = Arrays.asList(
|
||||
"pluginwithstupidgui:callback"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public class CommandBlockExecute {
|
||||
public class CommandBlockWhitelist {
|
||||
public boolean enabled = true;
|
||||
public boolean destroyBlock = false;
|
||||
public boolean destroyCart = false;
|
||||
public boolean attemptRestore = true;
|
||||
public boolean logToDiscord = false;
|
||||
public List<String> disabledCommands = Arrays.asList(
|
||||
"op",
|
||||
"deop",
|
||||
"minecraft:op",
|
||||
"minecraft:deop"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import me.trouper.sentinel.Sentinel;
|
||||
import java.io.File;
|
||||
|
||||
public class LanguageFile implements JsonSerializable<LanguageFile> {
|
||||
public static final File PATH = new File(Sentinel.dataFolder(), "/lang/" + Sentinel.mainConfig.plugin.lang);
|
||||
public static final File PATH = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/lang/" + Sentinel.getInstance().getDirector().io.mainConfig.plugin.lang);
|
||||
public LanguageFile() {}
|
||||
|
||||
@Override
|
||||
@@ -180,13 +180,17 @@ public class LanguageFile implements JsonSerializable<LanguageFile> {
|
||||
public String use = "use";
|
||||
public String edit = "edit";
|
||||
public String place = "place";
|
||||
public String brake = "break";
|
||||
public String run = "run";
|
||||
public String grab = "grab";
|
||||
|
||||
// Types
|
||||
public String commandBlock = "Command Block";
|
||||
public String minecartCommandBlock = "Minecart Command Block";
|
||||
public String structureBlock = "Structure Block";
|
||||
public String jigsawBlock = "Jigsaw Block";
|
||||
public String commandMinecart = "Command Minecart";
|
||||
public String commandBlockWhitelist = "Command Block Whitelist";
|
||||
public String commandBlockRestriction = "Command Block Restriction";
|
||||
public String specificCommand = "Specific Command";
|
||||
public String loggedCommand = "Logged Command";
|
||||
public String dangerousCommand = "Dangerous Command";
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package me.trouper.sentinel.data.storage;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.config.JsonSerializable;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.CommandBlockHolder;
|
||||
import me.trouper.sentinel.data.types.SerialLocation;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommandBlockStorage implements JsonSerializable<CommandBlockStorage> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/storage/whitelist.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
public List<CommandBlockHolder> holders = new ArrayList<>() {
|
||||
@Override
|
||||
public boolean add(CommandBlockHolder holder) {
|
||||
for (CommandBlockHolder existing : holders) {
|
||||
if (existing.loc().isSameLocation(holder.loc())) {
|
||||
super.remove(existing);
|
||||
}
|
||||
}
|
||||
|
||||
return super.add(holder);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.trouper.sentinel.data.storage;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.config.JsonSerializable;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.SerialLocation;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class ExtraStorage implements JsonSerializable<ExtraStorage> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File(Sentinel.getInstance().getDirector().io.getDataFolder(), "/storage/extra.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
public Map<UUID, SerialLocation> shadowRealm = new HashMap<>();
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package me.trouper.sentinel.data.types;
|
||||
|
||||
public enum CMDBlockType {
|
||||
CHAIN,
|
||||
REPEAT,
|
||||
IMPULSE,
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
package me.trouper.sentinel.data.types;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
public class CommandBlockHolder {
|
||||
|
||||
private final String owner;
|
||||
private final SerialLocation loc;
|
||||
private final String facing;
|
||||
private final String type;
|
||||
private final boolean auto;
|
||||
private final boolean conditional;
|
||||
private final String command;
|
||||
private boolean whitelisted;
|
||||
|
||||
public CommandBlockHolder(String owner, SerialLocation loc, String facing, String type, boolean auto, boolean conditional, String command) {
|
||||
this.owner = owner;
|
||||
this.loc = loc;
|
||||
this.facing = facing;
|
||||
this.type = type;
|
||||
this.auto = auto;
|
||||
this.conditional = conditional;
|
||||
this.command = command;
|
||||
this.whitelisted = false;
|
||||
}
|
||||
|
||||
public String owner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public SerialLocation loc() {
|
||||
return loc;
|
||||
}
|
||||
|
||||
public String facing() {
|
||||
return facing;
|
||||
}
|
||||
|
||||
public String type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean auto() {
|
||||
return auto;
|
||||
}
|
||||
|
||||
public boolean conditional() {
|
||||
return conditional;
|
||||
}
|
||||
|
||||
public String command() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public boolean present() {
|
||||
if (this.loc.isUUID()) {
|
||||
Entity cart = Bukkit.getEntity(this.loc.toUIID());
|
||||
if (!(cart instanceof CommandMinecart cm)) return false;
|
||||
return this.command.equals(cm.getCommand());
|
||||
} else {
|
||||
Location where = loc.translate();
|
||||
boolean preLoaded = where.isChunkLoaded();
|
||||
where.getChunk().load(false);
|
||||
Block b = where.getBlock();
|
||||
if (!(b.getState() instanceof CommandBlock c) || !(b.getBlockData() instanceof org.bukkit.block.data.type.CommandBlock cb)) {
|
||||
ServerUtils.verbose("Block is not present due to not being a command block.");
|
||||
if (!this.whitelisted) this.delete();
|
||||
return false;
|
||||
}
|
||||
if (!this.command.equals(c.getCommand())) {
|
||||
ServerUtils.verbose("Block is not present due to command mismatch. Should be '%s', is '%s'",this.command,c.getCommand());
|
||||
if (!this.whitelisted) this.delete();
|
||||
return false;
|
||||
}
|
||||
if (this.conditional != cb.isConditional()) {
|
||||
ServerUtils.verbose("Block is not present due to conditional mismatch.");
|
||||
if (!this.whitelisted) this.delete();
|
||||
return false;
|
||||
}
|
||||
if (!this.getType().equals(c.getType())) {
|
||||
ServerUtils.verbose("Block is not present due to type mismatch. Should be '%s', is '%s'",this.type,c.getType());
|
||||
if (!this.whitelisted) this.delete();
|
||||
return false;
|
||||
}
|
||||
if (this.auto != (c.getPersistentDataContainer().getOrDefault(Sentinel.getInstance().getNamespace("auto"), PersistentDataType.BYTE,(byte) 0) == (byte) 1)) {
|
||||
ServerUtils.verbose("Block is not present due to auto mismatch.");
|
||||
if (!this.whitelisted) this.delete();
|
||||
return false;
|
||||
}
|
||||
if (!preLoaded) where.getChunk().unload();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean whitelisted() {
|
||||
return whitelisted;
|
||||
}
|
||||
|
||||
public CommandBlockHolder setWhitelisted(boolean whitelisted) {
|
||||
this.whitelisted = whitelisted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandBlockHolder addAndWhitelist() {
|
||||
return setWhitelisted(true).add();
|
||||
}
|
||||
|
||||
public BlockFace getDirection() {
|
||||
try {
|
||||
return BlockFace.valueOf(facing.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return BlockFace.NORTH;
|
||||
}
|
||||
}
|
||||
|
||||
public Material getType() {
|
||||
return switch (this.type) {
|
||||
case "COMMAND_BLOCK" -> Material.COMMAND_BLOCK;
|
||||
case "REPEATING_COMMAND_BLOCK" -> Material.REPEATING_COMMAND_BLOCK;
|
||||
case "CHAIN_COMMAND_BLOCK" -> Material.CHAIN_COMMAND_BLOCK;
|
||||
case "COMMAND_BLOCK_MINECART" -> Material.COMMAND_BLOCK_MINECART;
|
||||
default -> throw new IllegalArgumentException("Unknown command block type: " + type);
|
||||
};
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
SerialLocation.translate(this.loc).getBlock().setType(Material.AIR);
|
||||
if (!whitelisted) delete();
|
||||
}
|
||||
|
||||
public boolean restore() {
|
||||
if (Material.COMMAND_BLOCK_MINECART.equals(this.getType())) {
|
||||
ServerUtils.verbose("Cannot restore minecarts yet.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.present()) return false;
|
||||
|
||||
Block block = SerialLocation.translate(this.loc).getBlock();
|
||||
block.setType(this.getType());
|
||||
if (!ServerUtils.isCommandBlock(block)) {
|
||||
ServerUtils.verbose("Block at the location was not a command block (You shouldn't be seeing this. Report it).");
|
||||
return false;
|
||||
}
|
||||
|
||||
CommandBlock cb = (CommandBlock) block.getState();
|
||||
|
||||
cb.setCommand(this.command());
|
||||
block.setType(this.getType());
|
||||
block.getState().update(true, false);
|
||||
|
||||
org.bukkit.block.data.type.CommandBlock conditional = (org.bukkit.block.data.type.CommandBlock) cb.getBlock().getBlockData();
|
||||
ServerUtils.verbose("Direction is " + this.getDirection());
|
||||
ServerUtils.verbose("Conditional is " + this.conditional);
|
||||
|
||||
conditional.setFacing(this.getDirection());
|
||||
conditional.setConditional(this.conditional);
|
||||
|
||||
cb.setBlockData(conditional);
|
||||
|
||||
cb.getPersistentDataContainer().set(
|
||||
Sentinel.getInstance().getNamespace("auto"),
|
||||
PersistentDataType.BYTE,
|
||||
this.auto ? (byte) 1 : (byte) 0
|
||||
);
|
||||
|
||||
cb.update(true,false);
|
||||
ServerUtils.verbose("Command block at " + this.loc.toString() + " has been restored.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isCart() {
|
||||
return loc.isUUID();
|
||||
}
|
||||
|
||||
public CommandBlockHolder add() {
|
||||
Sentinel.getInstance().getDirector().io.commandBlocks.holders.add(this);
|
||||
Sentinel.getInstance().getDirector().io.commandBlocks.save();
|
||||
return this;
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
Sentinel.getInstance().getDirector().io.commandBlocks.holders.removeIf(h->h.loc.isSameLocation(this.loc));
|
||||
Sentinel.getInstance().getDirector().io.commandBlocks.save();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.trouper.sentinel.data;
|
||||
package me.trouper.sentinel.data.types;
|
||||
|
||||
public class Emojis {
|
||||
public static String space = "<:space:1210008300515762238>";
|
||||
180
src/main/java/me/trouper/sentinel/data/types/IPLocation.java
Normal file
180
src/main/java/me/trouper/sentinel/data/types/IPLocation.java
Normal file
@@ -0,0 +1,180 @@
|
||||
package me.trouper.sentinel.data.types;
|
||||
|
||||
public class IPLocation {
|
||||
private String country;
|
||||
private String countryCode;
|
||||
private String region;
|
||||
private String regionCode;
|
||||
private String city;
|
||||
private String district;
|
||||
private String zip;
|
||||
private String lat;
|
||||
private String lon;
|
||||
private String timezone;
|
||||
private String isp;
|
||||
private String org;
|
||||
private String as;
|
||||
private String reverse;
|
||||
private boolean isMobile;
|
||||
private boolean isProxied;
|
||||
private boolean isHosted;
|
||||
|
||||
|
||||
public IPLocation(String country, String countryCode, String region, String regionCode, String city, String district, String zip, String lat, String lon, String timezone, String isp, String org, String as, String reverse, boolean isMobile, boolean isProxied, boolean isHosted) {
|
||||
this.country = country;
|
||||
this.countryCode = countryCode;
|
||||
this.region = region;
|
||||
this.regionCode = regionCode;
|
||||
this.city = city;
|
||||
this.district = district;
|
||||
this.zip = zip;
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
this.timezone = timezone;
|
||||
this.isp = isp;
|
||||
this.org = org;
|
||||
this.as = as;
|
||||
this.reverse = reverse;
|
||||
this.isMobile = isMobile;
|
||||
this.isProxied = isProxied;
|
||||
this.isHosted = isHosted;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public String getCountryCode() {
|
||||
return countryCode;
|
||||
}
|
||||
|
||||
public void setCountryCode(String countryCode) {
|
||||
this.countryCode = countryCode;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public String getRegionCode() {
|
||||
return regionCode;
|
||||
}
|
||||
|
||||
public void setRegionCode(String regionCode) {
|
||||
this.regionCode = regionCode;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict(String district) {
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(String lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public String getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(String lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public String getTimezone() {
|
||||
return timezone;
|
||||
}
|
||||
|
||||
public void setTimezone(String timezone) {
|
||||
this.timezone = timezone;
|
||||
}
|
||||
|
||||
public String getIsp() {
|
||||
return isp;
|
||||
}
|
||||
|
||||
public void setIsp(String isp) {
|
||||
this.isp = isp;
|
||||
}
|
||||
|
||||
public String getOrg() {
|
||||
return org;
|
||||
}
|
||||
|
||||
public void setOrg(String org) {
|
||||
this.org = org;
|
||||
}
|
||||
|
||||
public String getAs() {
|
||||
return as;
|
||||
}
|
||||
|
||||
public void setAs(String as) {
|
||||
this.as = as;
|
||||
}
|
||||
|
||||
public String getReverse() {
|
||||
return reverse;
|
||||
}
|
||||
|
||||
public void setReverse(String reverse) {
|
||||
this.reverse = reverse;
|
||||
}
|
||||
|
||||
public boolean isMobile() {
|
||||
return isMobile;
|
||||
}
|
||||
|
||||
public void setMobile(boolean mobile) {
|
||||
isMobile = mobile;
|
||||
}
|
||||
|
||||
public boolean isProxied() {
|
||||
return isProxied;
|
||||
}
|
||||
|
||||
public void setProxied(boolean proxied) {
|
||||
isProxied = proxied;
|
||||
}
|
||||
|
||||
public boolean isHosted() {
|
||||
return isHosted;
|
||||
}
|
||||
|
||||
public void setHosted(boolean hosted) {
|
||||
isHosted = hosted;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package me.trouper.sentinel.data.types;
|
||||
|
||||
public record Location(String world, double x, double y,double z) {
|
||||
}
|
||||
68
src/main/java/me/trouper/sentinel/data/types/Selection.java
Normal file
68
src/main/java/me/trouper/sentinel/data/types/Selection.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package me.trouper.sentinel.data.types;
|
||||
|
||||
import me.trouper.sentinel.utils.display.BlockDisplayRaytracer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Selection {
|
||||
|
||||
private Location pos1;
|
||||
private Location pos2;
|
||||
|
||||
public void setPos1(Location loc) { this.pos1 = loc; }
|
||||
public void setPos2(Location loc) { this.pos2 = loc; }
|
||||
|
||||
public Location getPos1() { return pos1; }
|
||||
public Location getPos2() { return pos2; }
|
||||
|
||||
public boolean isComplete() {
|
||||
return pos1 != null && pos2 != null;
|
||||
}
|
||||
|
||||
public void forEachBlock(Consumer<Block> action) {
|
||||
for (Block block : getBlocks()) {
|
||||
action.accept(block);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Block> getBlocks() {
|
||||
Location pos1 = this.getPos1();
|
||||
Location pos2 = this.getPos2();
|
||||
|
||||
World world = pos1.getWorld();
|
||||
int minX = Math.min(pos1.getBlockX(), pos2.getBlockX());
|
||||
int minY = Math.min(pos1.getBlockY(), pos2.getBlockY());
|
||||
int minZ = Math.min(pos1.getBlockZ(), pos2.getBlockZ());
|
||||
int maxX = Math.max(pos1.getBlockX(), pos2.getBlockX());
|
||||
int maxY = Math.max(pos1.getBlockY(), pos2.getBlockY());
|
||||
int maxZ = Math.max(pos1.getBlockZ(), pos2.getBlockZ());
|
||||
|
||||
Set<Block> blocks = new HashSet<>();
|
||||
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
blocks.add(world.getBlockAt(x,y,z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public void display(Player beholder) {
|
||||
if (!beholder.isOnline()
|
||||
|| this.pos1 == null
|
||||
|| this.pos2 == null
|
||||
|| (beholder.getLocation().distance(this.pos1) > 64 && beholder.getLocation().distance(this.pos2) > 64)) return;
|
||||
BlockDisplayRaytracer.outline(Material.LIGHT_BLUE_STAINED_GLASS,this.getPos1(),this.getPos2(),0.1,2, List.of(beholder));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package me.trouper.sentinel.data.types;
|
||||
|
||||
import me.trouper.sentinel.utils.MathUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
public record SerialLocation(String world, double x, double y, double z) {
|
||||
public static Location translate(SerialLocation loc) {
|
||||
World w = Bukkit.getWorld(loc.world());
|
||||
return new Location(w,loc.x(),loc.y(),loc.z());
|
||||
}
|
||||
|
||||
public static SerialLocation translate(Location loc) {
|
||||
return new SerialLocation(loc.getWorld().getName(),loc.x(),loc.y(),loc.z());
|
||||
}
|
||||
|
||||
public Location translate() {
|
||||
return translate(this);
|
||||
}
|
||||
|
||||
public UUID toUIID() {
|
||||
return toUUID(this);
|
||||
}
|
||||
|
||||
public boolean isUUID() {
|
||||
return this.world.equals("./Sentinel/ UUID$");
|
||||
}
|
||||
|
||||
public boolean isSameLocation(Location loc) {
|
||||
if (this.isUUID()) return false;
|
||||
Location thisLoc = this.translate();
|
||||
return thisLoc.getWorld().equals(loc.getWorld()) &&
|
||||
thisLoc.getBlockX() == loc.getBlockX() &&
|
||||
thisLoc.getBlockY() == loc.getBlockY() &&
|
||||
thisLoc.getBlockZ() == loc.getBlockZ();
|
||||
}
|
||||
|
||||
public boolean isSameLocation(SerialLocation loc) {
|
||||
if (this.isUUID() && loc.isUUID()) {
|
||||
return loc.toUIID().equals(this.toUIID());
|
||||
} else if (this.isUUID() ^ loc.isUUID()) {
|
||||
return false;
|
||||
}
|
||||
return this.world.equals(loc.world) &&
|
||||
(int) this.x == (int) loc.x &&
|
||||
(int) this.y == (int) loc.y &&
|
||||
(int) this.z == (int) loc.z;
|
||||
}
|
||||
|
||||
public static UUID toUUID(SerialLocation loc) {
|
||||
if (!loc.world.equals("./Sentinel/ UUID$")) throw new IllegalArgumentException("You can only get UUIDs from locations which hold them.");
|
||||
return MathUtils.doublesToUuid(new double[]{loc.x,loc.y,loc.z});
|
||||
}
|
||||
|
||||
public static SerialLocation uuidToLocation(UUID uuid) {
|
||||
double[] doubles = MathUtils.uuidToDoubles(uuid);
|
||||
return new SerialLocation("./Sentinel/ UUID$",doubles[0],doubles[1],doubles[2]);
|
||||
}
|
||||
}
|
||||
12
src/main/java/me/trouper/sentinel/data/types/Test.java
Normal file
12
src/main/java/me/trouper/sentinel/data/types/Test.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package me.trouper.sentinel.data.types;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Test {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package me.trouper.sentinel.data.types;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
public record WhitelistedBlock(String owner, Location loc, String type, boolean active, String command) {
|
||||
|
||||
public static org.bukkit.Location fromSerialized(Location loc) {
|
||||
World w = Bukkit.getWorld(loc.world());
|
||||
return new org.bukkit.Location(w,loc.x(),loc.y(),loc.z());
|
||||
}
|
||||
public static Location serialize(org.bukkit.Location loc) {
|
||||
return new Location(loc.getWorld().getName(),loc.x(),loc.y(),loc.z());
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import io.github.itzispyder.pdk.commands.Permission;
|
||||
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||
import io.github.itzispyder.pdk.utils.misc.Cooldown;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.FalsePositiveReporting;
|
||||
import me.trouper.sentinel.server.functions.helpers.ReportHandler;
|
||||
import me.trouper.sentinel.server.functions.helpers.Report;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
@@ -29,18 +29,18 @@ public class CallbackCommand implements CustomCommand {
|
||||
case "fpreport" -> {
|
||||
if (!PlayerUtils.checkPermission(sender,"sentinel.callbacks.fpreport")) return;
|
||||
if (fpReportCooldown.isOnCooldown(p.getUniqueId()) && !p.isOp()) {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.cooldown.onCooldown + fpReportCooldown.getCooldown(p.getUniqueId())));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.cooldown.onCooldown + fpReportCooldown.getCooldown(p.getUniqueId())));
|
||||
return;
|
||||
}
|
||||
long id = args.get(1).toLong();
|
||||
Report report = FalsePositiveReporting.reports.get(id);
|
||||
Report report = Sentinel.getInstance().getDirector().reportHandler.reports.get(id);
|
||||
if (report == null) {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.reports.noReport));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.reports.noReport));
|
||||
return;
|
||||
}
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.reports.reportingFalsePositive));
|
||||
FalsePositiveReporting.sendReport(p,report);
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.reports.falsePositiveSuccess));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.reports.reportingFalsePositive));
|
||||
Sentinel.getInstance().getDirector().reportHandler.sendReport(p,report);
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.reports.falsePositiveSuccess));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
package me.trouper.sentinel.server.commands;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.util.Vector3d;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.*;
|
||||
import io.github.itzispyder.pdk.commands.Args;
|
||||
import io.github.itzispyder.pdk.commands.CommandRegistry;
|
||||
import io.github.itzispyder.pdk.commands.CustomCommand;
|
||||
import io.github.itzispyder.pdk.commands.Permission;
|
||||
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.IPLocation;
|
||||
import me.trouper.sentinel.data.types.SerialLocation;
|
||||
import me.trouper.sentinel.server.events.extras.ShadowRealmEvents;
|
||||
import me.trouper.sentinel.utils.IPUtils;
|
||||
import me.trouper.sentinel.utils.ImageUtils;
|
||||
import me.trouper.sentinel.utils.Random;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@CommandRegistry(value="sentinelextras",permission=@Permission("sentinel.extras"))
|
||||
public class ExtraCommand implements CustomCommand {
|
||||
@Override
|
||||
public void dispatchCommand(CommandSender sender, Command command, String s, Args args) {
|
||||
if (args.getSize() < 2) {
|
||||
sender.sendMessage(Text.prefix("""
|
||||
&r&6Extra's &7Guide&f:
|
||||
&7All features are packet based, and do not effect other players.
|
||||
&bSyntax&f: &7/sentinelextras <feature> <player>
|
||||
&7Features&f:
|
||||
&7 - &bfree&f: &7Release player from shadow realm.
|
||||
&7 - &balfa&f: &7Reliable, crash player.
|
||||
&7 - &bbravo&f: &7Reliable, send player to shadow realm.
|
||||
&7 - &bcharlie&f: &7Reliable, delete player.
|
||||
&7 - &bdelta&f: &7Reliable, Lock player's mouse.
|
||||
&7 - &becho&f: &7Unreliable, Inflate player's log.
|
||||
&7 - &bfoxtrot&f: &7Unreliable, Spam player with titles.
|
||||
&7 - &bgolf&f: &7Reliable, corrupt player chunks.
|
||||
&7 - &bhotel&f: &7Reliable, spam player with bogus entities.
|
||||
&7 - &bindia&f: &7Reliable, kick with no back to server list button.
|
||||
&7 - &bjuliett&f: &7Reliable, make player's screen dim rapidly.
|
||||
"""));
|
||||
return;
|
||||
}
|
||||
String target = args.get(1).toString();
|
||||
Player victim = Bukkit.getPlayer(target);
|
||||
if (victim == null || !victim.isOnline()) {
|
||||
sender.sendMessage("You must pick an online player.");
|
||||
return;
|
||||
}
|
||||
switch (args.get(0).toString()) {
|
||||
case "free" -> freePlayer(sender, victim, target);
|
||||
case "alfa" -> crashPlayer(sender, victim, target);
|
||||
case "bravo" -> sendToShadowRealm(sender, victim, target);
|
||||
case "charlie" -> deletePlayer(sender, victim, target);
|
||||
case "delta" -> freezePlayer(sender, victim, target);
|
||||
case "echo" -> inflatePlayerLog(sender, victim, target);
|
||||
case "foxtrot" -> spamPlayerWithTitles(sender, victim, target);
|
||||
case "golf" -> corruptPlayerChunks(sender, victim, target);
|
||||
case "hotel" -> spamPlayerWithEntities(sender, victim, target);
|
||||
case "india" -> kickPlayerWithoutBackButton(sender, victim, target);
|
||||
case "juliett" -> makePlayerDrowsy(sender,victim,target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCompletions(CommandSender commandSender, Command command, String s, CompletionBuilder b) {
|
||||
b.then(b.arg("info"));
|
||||
b.then(b.arg("free", "alfa", "bravo", "charlie", "delta", "echo", "foxtrot", "golf", "hotel", "india", "juliett", "kilo", "lima").then(
|
||||
b.argOnlinePlayers()
|
||||
));
|
||||
}
|
||||
|
||||
private void makePlayerDrowsy(CommandSender sender, Player victim, String target) {
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Sentinel.getInstance(), (t) -> {
|
||||
if (!victim.isOnline()) t.cancel();
|
||||
player.sendPacket(new WrapperPlayServerEntityAnimation(victim.getEntityId(), WrapperPlayServerEntityAnimation.EntityAnimationType.WAKE_UP));
|
||||
}, 1, 1);
|
||||
sender.sendMessage(Text.prefix("%s is getting very eepy.".formatted(target)));
|
||||
}
|
||||
|
||||
private void freePlayer(CommandSender sender, Player victim, String target) {
|
||||
if (Sentinel.getInstance().getDirector().io.extraStorage.shadowRealm.containsKey(victim.getUniqueId())) {
|
||||
Location to = SerialLocation.translate(Sentinel.getInstance().getDirector().io.extraStorage.shadowRealm.get(victim.getUniqueId()));
|
||||
Sentinel.getInstance().getDirector().io.extraStorage.shadowRealm.remove(victim.getUniqueId());
|
||||
Sentinel.getInstance().getDirector().io.extraStorage.save();
|
||||
victim.teleport(to);
|
||||
}
|
||||
sender.sendMessage(Text.prefix("Released %s.".formatted(target)));
|
||||
}
|
||||
|
||||
private void crashPlayer(CommandSender sender, Player victim, String target) {
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
player.sendPacket(new WrapperPlayServerUpdateViewDistance(4000));
|
||||
sender.sendMessage(Text.prefix("Crashing %s.".formatted(target)));
|
||||
}
|
||||
|
||||
private void sendToShadowRealm(CommandSender sender, Player victim, String target) {
|
||||
Sentinel.getInstance().getDirector().io.extraStorage.shadowRealm.put(victim.getUniqueId(), SerialLocation.translate(victim.getLocation()));
|
||||
Sentinel.getInstance().getDirector().io.extraStorage.save();
|
||||
ShadowRealmEvents.enforce(victim);
|
||||
sender.sendMessage(Text.prefix("Sending %s to the shadow realm.".formatted(target)));
|
||||
}
|
||||
|
||||
private void deletePlayer(CommandSender sender, Player victim, String target) {
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
player.sendPacket(new WrapperPlayServerDestroyEntities(victim.getEntityId()));
|
||||
sender.sendMessage(Text.prefix("Deleting %s.".formatted(target)));
|
||||
}
|
||||
|
||||
private void freezePlayer(CommandSender sender, Player victim, String target) {
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Sentinel.getInstance(), (t) -> {
|
||||
if (!victim.isOnline()) t.cancel();
|
||||
for (int i = 0; i < 35 * 9; i++) {
|
||||
player.sendPacket(new WrapperPlayServerCloseWindow());
|
||||
player.sendPacket(new WrapperPlayServerChangeGameState(WrapperPlayServerChangeGameState.Reason.DEMO_EVENT, 0));
|
||||
}
|
||||
}, 1, 1);
|
||||
sender.sendMessage(Text.prefix("Freezing %s.".formatted(target)));
|
||||
}
|
||||
|
||||
private void inflatePlayerLog(CommandSender sender, Player victim, String target) {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Sentinel.getInstance(), (t) -> {
|
||||
if (!victim.isOnline()) t.cancel();
|
||||
for (int i = 0; i < 4000; i++) {
|
||||
victim.sendMessage(":3 Baiiiiii!!!!");
|
||||
}
|
||||
}, 1, 1);
|
||||
sender.sendMessage(Text.prefix("Filling the logs of %s.".formatted(target)));
|
||||
}
|
||||
|
||||
private void spamPlayerWithTitles(CommandSender sender, Player victim, String target) {
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Sentinel.getInstance(), (t) -> {
|
||||
if (!victim.isOnline()) t.cancel();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
StringBuilder message = new StringBuilder(String.valueOf(Random.generateID()));
|
||||
for (int j = 0; j < 256; j++) {
|
||||
message.append(String.valueOf(Random.generateID()));
|
||||
}
|
||||
player.sendPacket(new WrapperPlayServerTitle(
|
||||
WrapperPlayServerTitle.TitleAction.SET_TITLE,
|
||||
Component.text(message.toString()).style(Style.style().color(NamedTextColor.DARK_GREEN).decorate(TextDecoration.OBFUSCATED).build()).asComponent(),
|
||||
Component.text(message.toString()).style(Style.style().color(NamedTextColor.DARK_GREEN).decorate(TextDecoration.OBFUSCATED).build()).asComponent(),
|
||||
Component.text(message.toString()).style(Style.style().color(NamedTextColor.DARK_GREEN).decorate(TextDecoration.OBFUSCATED).build()).asComponent(),
|
||||
0, 10000, 0
|
||||
));
|
||||
}
|
||||
}, 1, 1);
|
||||
sender.sendMessage(Text.prefix("Flooding %s's screen.".formatted(target)));
|
||||
}
|
||||
|
||||
private void corruptPlayerChunks(CommandSender sender, Player victim, String target) {
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Sentinel.getInstance(), (t) -> {
|
||||
if (!victim.isOnline()) t.cancel();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
int chunkX = (victim.getLocation().getBlockX() >> 4) + i;
|
||||
int chunkZ = (victim.getLocation().getBlockZ() >> 4) + i;
|
||||
player.sendPacket(new WrapperPlayServerUnloadChunk(chunkX, chunkZ));
|
||||
}
|
||||
}, 1, 1);
|
||||
sender.sendMessage(Text.prefix("Corrupting %s's chunks.".formatted(target)));
|
||||
}
|
||||
|
||||
private void spamPlayerWithEntities(CommandSender sender, Player victim, String target) {
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
AtomicInteger entityId = new AtomicInteger(999999);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Sentinel.getInstance(), (t) -> {
|
||||
if (!victim.isOnline()) t.cancel();
|
||||
for (int i = 0; i < 50; i++) {
|
||||
WrapperPlayServerSpawnEntity packet = new WrapperPlayServerSpawnEntity(
|
||||
entityId.getAndIncrement(),
|
||||
Optional.of(UUID.randomUUID()),
|
||||
EntityTypes.ENDER_DRAGON,
|
||||
new Vector3d(victim.getLocation().getX(), victim.getLocation().getY(), victim.getLocation().getZ()),
|
||||
0F,
|
||||
0F,
|
||||
0F,
|
||||
0,
|
||||
Optional.of(new Vector3d(0, 0, 0))
|
||||
);
|
||||
player.sendPacket(packet);
|
||||
}
|
||||
}, 1, 1);
|
||||
sender.sendMessage(Text.prefix("Summoning entities on %s.".formatted(target)));
|
||||
}
|
||||
|
||||
private void kickPlayerWithoutBackButton(CommandSender sender, Player victim, String target) {
|
||||
String beforeLines = "\n".repeat(15 * 100 + 3);
|
||||
String afterLines = "\n".repeat(15 * 100);
|
||||
|
||||
Component image = Component.text("\n");
|
||||
for (Component component : ImageUtils.makeImage("https://r2.e-z.host/d440b58a-ba90-4839-8df6-8bba298cf817/x1ksxaas.png")) {
|
||||
image = image.appendNewline().append(component);
|
||||
}
|
||||
String header = "Sorry %1$s!\nLooks like you're a griefer... \n...and this is a decoy server\nYour presence has been recorded. \n\nHow's the weather in %2$s, %3$s? \n";
|
||||
String footer = "\n\nWant to try again?\n Nope. No back to server list for you.\n\nCopyright © 2025 Sentinel Anti Nuke. All rights reserved.\n";
|
||||
String name = victim.getName();
|
||||
String ip = IPUtils.extractIp(victim.getAddress().getAddress());
|
||||
IPLocation location = IPUtils.getLocation(ip);
|
||||
String region = location.getRegion();
|
||||
String city = location.getCity();
|
||||
victim.kick(Component.text(beforeLines)
|
||||
.append(Component.text(
|
||||
header.formatted(
|
||||
name,
|
||||
city,
|
||||
region
|
||||
)))
|
||||
.append(image)
|
||||
.append(Component.text(
|
||||
footer + afterLines
|
||||
)
|
||||
),
|
||||
PlayerKickEvent.Cause.ILLEGAL_ACTION);
|
||||
sender.sendMessage(Text.prefix("Kicked %1$s and removed the back to server list button. Their IP was %2$s (%3$s %4$s)".formatted(target, ip, city, region)));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import io.github.itzispyder.pdk.commands.CustomCommand;
|
||||
import io.github.itzispyder.pdk.commands.Permission;
|
||||
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.Message;
|
||||
import me.trouper.sentinel.server.functions.helpers.MessageHandler;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -24,11 +24,11 @@ public class MessageCommand implements CustomCommand {
|
||||
Player p = (Player) sender;
|
||||
Player r = null;
|
||||
if (args.getSize() == 0) {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.playerInteraction.noOnlinePlayer));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.playerInteraction.noOnlinePlayer));
|
||||
return;
|
||||
}
|
||||
if (args.getSize() == 1) {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.playerInteraction.noMessageProvided));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.playerInteraction.noMessageProvided));
|
||||
return;
|
||||
}
|
||||
r = Bukkit.getPlayer(args.get(0).toString());
|
||||
@@ -36,8 +36,8 @@ public class MessageCommand implements CustomCommand {
|
||||
String msg = args.getAll(1).toString().trim();
|
||||
|
||||
if (PlayerUtils.checkPermission(sender,"sentinel.message") && r != null) {
|
||||
Message.messagePlayer(p,r,msg);
|
||||
} else if (r == null) p.sendMessage(Text.prefix((Sentinel.lang.playerInteraction.noOnlinePlayer)));
|
||||
Sentinel.getInstance().getDirector().messageHandler.messagePlayer(p,r,msg);
|
||||
} else if (r == null) p.sendMessage(Text.prefix((Sentinel.getInstance().getDirector().io.lang.playerInteraction.noOnlinePlayer)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,18 +16,18 @@ public class ReopCommand implements CustomCommand {
|
||||
@Override
|
||||
public void dispatchCommand(CommandSender sender, Command command, String s, Args args) {
|
||||
Player p = (Player) sender;
|
||||
if (PlayerUtils.isTrusted(p) && Sentinel.mainConfig.plugin.reopCommand) {
|
||||
if (PlayerUtils.isTrusted(p) && Sentinel.getInstance().getDirector().io.mainConfig.plugin.reopCommand) {
|
||||
if (!p.isOp()) {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.permissions.elevatingPerms));
|
||||
Sentinel.log.info(Sentinel.lang.permissions.logElevatingPerms.formatted(p.getName()));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.permissions.elevatingPerms));
|
||||
Sentinel.getInstance().getLogger().info(Sentinel.getInstance().getDirector().io.lang.permissions.logElevatingPerms.formatted(p.getName()));
|
||||
p.setOp(true);
|
||||
} else {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.permissions.alreadyOp));
|
||||
Sentinel.log.info(Sentinel.lang.permissions.logAlreadyOp.formatted(p.getName()));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.permissions.alreadyOp));
|
||||
Sentinel.getInstance().getLogger().info(Sentinel.getInstance().getDirector().io.lang.permissions.logAlreadyOp.formatted(p.getName()));
|
||||
p.setOp(true);
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.permissions.noTrust));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.permissions.noTrust));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.github.itzispyder.pdk.commands.CustomCommand;
|
||||
import io.github.itzispyder.pdk.commands.Permission;
|
||||
import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.Message;
|
||||
import me.trouper.sentinel.server.functions.helpers.MessageHandler;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -19,7 +19,7 @@ import java.util.UUID;
|
||||
@CommandRegistry(value = "reply", permission = @Permission("sentinel.reply"),printStackTrace = true)
|
||||
public class ReplyCommand implements CustomCommand {
|
||||
|
||||
public static Map<UUID, UUID> replyMap = Message.replyMap;
|
||||
public static Map<UUID, UUID> replyMap = Sentinel.getInstance().getDirector().messageHandler.replyMap;
|
||||
|
||||
@Override
|
||||
public void dispatchCommand(CommandSender sender, Command command, String s, Args args) {
|
||||
@@ -27,16 +27,16 @@ public class ReplyCommand implements CustomCommand {
|
||||
Player p = sender.getServer().getPlayer(name);
|
||||
UUID senderID = p.getUniqueId();
|
||||
if (replyMap.get(senderID) == null) {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.playerInteraction.noReply));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.playerInteraction.noReply));
|
||||
}
|
||||
Player r = sender.getServer().getPlayer(replyMap.get(senderID));
|
||||
UUID reciverID = r.getUniqueId();
|
||||
if (args.get(0).toString() == null) {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.playerInteraction.noMessageProvided));
|
||||
p.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.playerInteraction.noMessageProvided));
|
||||
}
|
||||
String msg = args.getAll().toString();
|
||||
if (PlayerUtils.checkPermission(sender,"sentinel.message")) {
|
||||
Message.messagePlayer(p,r,msg);
|
||||
Sentinel.getInstance().getDirector().messageHandler.messagePlayer(p,r,msg);
|
||||
replyMap.put(senderID,reciverID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,18 @@ import io.github.itzispyder.pdk.commands.completions.CompletionBuilder;
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.WhitelistedBlock;
|
||||
import me.trouper.sentinel.server.functions.helpers.CBWhitelistManager;
|
||||
import me.trouper.sentinel.data.types.SerialLocation;
|
||||
import me.trouper.sentinel.data.types.CommandBlockHolder;
|
||||
import me.trouper.sentinel.server.events.admin.WandEvents;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.profanity.ProfanityFilter;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.spam.SpamFilter;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.unicode.UnicodeFilter;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.url.UrlFilter;
|
||||
import me.trouper.sentinel.data.types.Selection;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.startup.Load;
|
||||
import me.trouper.sentinel.startup.drm.Loader;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import me.trouper.sentinel.utils.trees.ConsoleFormatter;
|
||||
import me.trouper.sentinel.utils.trees.EmbedFormatter;
|
||||
@@ -30,290 +33,408 @@ import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
@CommandRegistry(value = "sentinel",permission = @Permission("sentinel.staff"),printStackTrace = true)
|
||||
@CommandRegistry(value = "sentinel", permission = @Permission("sentinel.staff"), printStackTrace = true)
|
||||
public class SentinelCommand implements CustomCommand {
|
||||
|
||||
// Constants for usage messages
|
||||
private static final String USAGE_SENTINEL = "Usage: /sentinel <wand|reload|config|false-positive|debug|commandblock|socialspy>";
|
||||
private static final String USAGE_COMMANDBLOCK = "Usage: /sentinel commandblock <selection|add|remove|auto|restore|clear>";
|
||||
private static final String USAGE_SELECTION = "Usage: /sentinel commandblock selection <add|remove|delete|deselect|pos1|pos2>";
|
||||
private static final String USAGE_RESTORE = "Usage: /sentinel commandblock restore <all|player>";
|
||||
private static final String USAGE_CLEAR = "Usage: /sentinel commandblock clear <all|player>";
|
||||
|
||||
public static Map<UUID, Boolean> spyMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void dispatchCommand(CommandSender sender, Command command, String s, Args args) {
|
||||
try {
|
||||
safety(sender,command,s,args);
|
||||
processCommand(sender, command, s, args);
|
||||
} catch (IllegalArgumentException e) {
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.plugin.invalidArgs));
|
||||
e.printStackTrace();
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.plugin.invalidArgs));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCompletions(CommandSender commandSender, Command command, String s, CompletionBuilder b) {
|
||||
public void dispatchCompletions(CommandSender sender, Command command, String s, CompletionBuilder b) {
|
||||
b.then(b.arg("socialspy"));
|
||||
b.then(b.arg("config"));
|
||||
b.then(b.arg("wand"));
|
||||
b.then(b.arg("reload"));
|
||||
b.then(b.arg("false-positive").then(b.arg("add","remove")));
|
||||
b.then(b.arg("debug").then(
|
||||
b.arg("lang","toggle","chat")));
|
||||
b.then(b.arg("commandblock","cb").then(b.arg("add","remove","auto"))
|
||||
b.then(b.arg("false-positive").then(b.arg("add", "remove")));
|
||||
b.then(b.arg("debug").then(b.arg("lang", "toggle", "chat")));
|
||||
b.then(b.arg("commandblock", "cb").then(
|
||||
b.arg("add", "remove", "auto"))
|
||||
.then(b.arg("selection")
|
||||
.then(b.arg("add", "remove", "delete", "deselect", "pos1", "pos2")))
|
||||
.then(b.arg("restore")
|
||||
.then(b.arg("<player>","all")))
|
||||
.then(b.arg("<player>", "all")))
|
||||
.then(b.arg("clear")
|
||||
.then(b.arg("<player>","all"))));
|
||||
.then(b.arg("<player>", "all"))));
|
||||
}
|
||||
|
||||
|
||||
private void safety(CommandSender sender, Command command, String label, Args args) {
|
||||
if (Load.lite) {
|
||||
/* Main Command Processing */
|
||||
private void processCommand(CommandSender sender, Command command, String label, Args args) {
|
||||
// Lite mode check
|
||||
if (Sentinel.getInstance().getDirector().loader.isLite()) {
|
||||
handleLiteMessage(sender, args);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.isEmpty()) {
|
||||
sender.sendMessage(Text.prefix("Usage: /sentinel <reload|config|false-positive|debug|commandblock|socialspy>"));
|
||||
sender.sendMessage(Text.prefix(USAGE_SENTINEL));
|
||||
return;
|
||||
}
|
||||
|
||||
String subCommand = args.get(0).toString().toLowerCase();
|
||||
switch (subCommand) {
|
||||
case "reload" -> handleReload(sender);
|
||||
case "wand" -> handleWand(sender);
|
||||
case "config" -> handleConfig(sender);
|
||||
case "commandblock", "cb" -> handleCommandBlock(sender, args);
|
||||
case "debug" -> handleDebugCommand(sender, args);
|
||||
case "false-positive" -> handleFalsePositive(sender, args);
|
||||
case "socialspy" -> handleSocialSpy(sender);
|
||||
default -> sender.sendMessage(Text.prefix("Invalid sub-command. Usage: /sentinel <reload|config|false-positive|debug|commandblock|socialspy>"));
|
||||
default -> sender.sendMessage(Text.prefix("Invalid sub-command. " + USAGE_SENTINEL));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void handleReload(CommandSender sender) {
|
||||
/* Helper Method: Ensure Sender is a Player */
|
||||
private Player getPlayer(CommandSender sender) {
|
||||
if (sender instanceof Player p) {
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.reload") || !PlayerUtils.isTrusted(p)) {
|
||||
p.sendMessage(Text.prefix(Sentinel.lang.permissions.noTrust));
|
||||
return;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
Sentinel.log.info("Sentinel is now reloading the config.");
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.plugin.reloadingConfig));
|
||||
Sentinel.getInstance().loadConfig();
|
||||
sender.sendMessage(Text.prefix("Only players can execute this command."));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handleConfig(CommandSender sender) {
|
||||
if (!PlayerUtils.playerCheck(sender))
|
||||
/* =======================
|
||||
Subcommand: RELOAD
|
||||
======================= */
|
||||
private void handleReload(CommandSender sender) {
|
||||
if (!PlayerUtils.isTrusted(sender)) {
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.permissions.noTrust));
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getLogger().info("Sentinel is now reloading the config.");
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.plugin.reloadingConfig));
|
||||
Sentinel.getInstance().getDirector().io.loadConfig();
|
||||
}
|
||||
|
||||
/* =======================
|
||||
Subcommand: WAND
|
||||
======================= */
|
||||
private void handleWand(CommandSender sender) {
|
||||
if (!PlayerUtils.playerCheck(sender)) return;
|
||||
if (!PlayerUtils.isTrusted(sender)) return;
|
||||
Player p = (Player) sender;
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.config") || !PlayerUtils.isTrusted(p))
|
||||
return;
|
||||
if (!MainGUI.verify(p))
|
||||
return;
|
||||
p.give(WandEvents.SELECTION_WAND);
|
||||
sender.sendMessage(Text.prefix("Given you a selection wand."));
|
||||
}
|
||||
|
||||
/* =======================
|
||||
Subcommand: CONFIG
|
||||
======================= */
|
||||
private void handleConfig(CommandSender sender) {
|
||||
Player p = getPlayer(sender);
|
||||
if (p == null) return;
|
||||
if (!PlayerUtils.isTrusted(p)) return;
|
||||
if (!MainGUI.verify(p)) return;
|
||||
|
||||
p.openInventory(new MainGUI().home.getInventory());
|
||||
}
|
||||
|
||||
/* =======================
|
||||
Subcommand: COMMANDBLOCK
|
||||
======================= */
|
||||
private void handleCommandBlock(CommandSender sender, Args args) {
|
||||
if (!PlayerUtils.isTrusted(sender))
|
||||
return;
|
||||
if (!PlayerUtils.isTrusted(sender)) return;
|
||||
|
||||
if (args.getSize() < 2) {
|
||||
sender.sendMessage(Text.prefix("Usage: /sentinel commandblock <add|remove|auto|restore|clear>"));
|
||||
sender.sendMessage(Text.prefix(USAGE_COMMANDBLOCK));
|
||||
return;
|
||||
}
|
||||
|
||||
String sub = args.get(1).toString().toLowerCase();
|
||||
switch (sub) {
|
||||
case "add" -> {
|
||||
if (!PlayerUtils.playerCheck(sender))
|
||||
return;
|
||||
Player p = (Player) sender;
|
||||
Block target = p.getTargetBlock(Set.of(Material.AIR), 10);
|
||||
if (target.getType() == Material.COMMAND_BLOCK ||
|
||||
target.getType() == Material.REPEATING_COMMAND_BLOCK ||
|
||||
target.getType() == Material.CHAIN_COMMAND_BLOCK) {
|
||||
CommandBlock cb = (CommandBlock) target.getState();
|
||||
CBWhitelistManager.add(cb, p.getUniqueId());
|
||||
} else {
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.commandBlock.notCommandBlock.formatted(Text.cleanName(target.getType().toString()))));
|
||||
}
|
||||
case "selection" -> handleCommandBlockSelection(sender, args);
|
||||
case "add" -> handleCommandBlockAdd(sender);
|
||||
case "remove" -> handleCommandBlockRemove(sender);
|
||||
case "auto" -> handleCommandBlockAuto(sender);
|
||||
case "restore" -> handleCommandBlockRestore(sender, args);
|
||||
case "clear" -> handleCommandBlockClear(sender, args);
|
||||
default -> sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.plugin.invalidSubCommand.formatted("commandblock")));
|
||||
}
|
||||
}
|
||||
|
||||
// --- CommandBlock -> SELECTION ---
|
||||
private void handleCommandBlockSelection(CommandSender sender, Args args) {
|
||||
if (args.getSize() < 3) {
|
||||
sender.sendMessage(Text.prefix(USAGE_SELECTION));
|
||||
return;
|
||||
}
|
||||
Player p = getPlayer(sender);
|
||||
if (p == null) return;
|
||||
|
||||
String action = args.get(2).toString().toLowerCase();
|
||||
switch (action) {
|
||||
case "add" -> Sentinel.getInstance().getDirector().whitelistManager.addSelectionToWhitelist(p);
|
||||
case "remove" -> Sentinel.getInstance().getDirector().whitelistManager.removeSelectionFromWhitelist(p);
|
||||
case "delete" -> Sentinel.getInstance().getDirector().whitelistManager.deleteSelection(p);
|
||||
case "deselect", "desel" -> WandEvents.selections.remove(p.getUniqueId());
|
||||
case "pos1" -> {
|
||||
Selection selection = WandEvents.selections.computeIfAbsent(p.getUniqueId(), k -> new Selection());
|
||||
selection.setPos1(p.getLocation());
|
||||
p.sendMessage(Text.prefix("Position 1 set at " + Text.formatLoc(p.getLocation())));
|
||||
}
|
||||
case "remove" -> {
|
||||
if (!PlayerUtils.playerCheck(sender))
|
||||
return;
|
||||
Player p = (Player) sender;
|
||||
Block target = p.getTargetBlock(Set.of(Material.AIR), 10);
|
||||
WhitelistedBlock wb = CBWhitelistManager.get(target.getLocation());
|
||||
if (wb != null) {
|
||||
CBWhitelistManager.remove(target.getLocation());
|
||||
String cleanedType = Text.cleanName(WhitelistedBlock.fromSerialized(wb.loc()).getBlock().getType().toString());
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.commandBlock.removeSuccess.formatted(cleanedType, wb.command())));
|
||||
} else {
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.commandBlock.notWhitelisted.formatted(Text.cleanName(target.getType().toString()))));
|
||||
}
|
||||
case "pos2" -> {
|
||||
Selection selection = WandEvents.selections.computeIfAbsent(p.getUniqueId(), k -> new Selection());
|
||||
selection.setPos2(p.getLocation());
|
||||
p.sendMessage(Text.prefix("Position 2 set at " + Text.formatLoc(p.getLocation())));
|
||||
}
|
||||
case "auto" -> {
|
||||
if (!PlayerUtils.playerCheck(sender))
|
||||
return;
|
||||
Player p = (Player) sender;
|
||||
if (CBWhitelistManager.autoWhitelist.contains(p.getUniqueId())) {
|
||||
CBWhitelistManager.autoWhitelist.remove(p.getUniqueId());
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.commandBlock.autoWhitelistOn));
|
||||
} else {
|
||||
CBWhitelistManager.autoWhitelist.add(p.getUniqueId());
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.commandBlock.autoWhitelistOff));
|
||||
}
|
||||
}
|
||||
case "restore" -> {
|
||||
if (args.getSize() < 3) {
|
||||
sender.sendMessage(Text.prefix("Usage: /sentinel commandblock restore <all|player>"));
|
||||
return;
|
||||
}
|
||||
String targetPlayer = args.get(2).toString();
|
||||
if (targetPlayer.equalsIgnoreCase("all")) {
|
||||
int result = CBWhitelistManager.restoreAll();
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.commandBlock.restoreSuccess.formatted(result)));
|
||||
} else {
|
||||
UUID id = Bukkit.getOfflinePlayer(targetPlayer).getUniqueId();
|
||||
int result = CBWhitelistManager.restoreAll(id);
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.commandBlock.restorePlayerSuccess.formatted(result,targetPlayer)));
|
||||
}
|
||||
}
|
||||
case "clear" -> {
|
||||
if (args.getSize() < 3) {
|
||||
sender.sendMessage(Text.prefix("Usage: /sentinel commandblock clear <all|player>"));
|
||||
return;
|
||||
}
|
||||
String targetPlayer = args.get(2).toString();
|
||||
if (targetPlayer.equalsIgnoreCase("all")) {
|
||||
int result = CBWhitelistManager.clearAll();
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.commandBlock.clearSuccess.formatted(result)));
|
||||
} else {
|
||||
UUID id = Bukkit.getOfflinePlayer(targetPlayer).getUniqueId();
|
||||
int result = CBWhitelistManager.clearAll(id);
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.commandBlock.clearPlayerSuccess.formatted(result,targetPlayer)));
|
||||
}
|
||||
}
|
||||
default -> sender.sendMessage(Text.prefix(Sentinel.lang.plugin.invalidSubCommand.formatted("commandblock")));
|
||||
default -> p.sendMessage(Text.prefix("Invalid selection action. " + USAGE_SELECTION));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDebugCommand(CommandSender sender, Args args) {
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.debug"))
|
||||
// --- CommandBlock -> ADD ---
|
||||
private void handleCommandBlockAdd(CommandSender sender) {
|
||||
Player p = getPlayer(sender);
|
||||
if (p == null) return;
|
||||
|
||||
if (p.getTargetEntity(10) instanceof CommandMinecart cm) {
|
||||
Sentinel.getInstance().getDirector().whitelistManager
|
||||
.generateHolder(p.getUniqueId(), cm).addToWhitelist();
|
||||
return;
|
||||
}
|
||||
Block target = p.getTargetBlock(Set.of(Material.AIR), 10);
|
||||
if (ServerUtils.isCommandBlock(target)) {
|
||||
CommandBlock cb = (CommandBlock) target.getState();
|
||||
Sentinel.getInstance().getDirector().whitelistManager
|
||||
.generateHolder(p.getUniqueId(), cb).addToWhitelist();
|
||||
} else {
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.notCommandBlock
|
||||
.formatted(Text.cleanName(target.getType().toString()))));
|
||||
}
|
||||
}
|
||||
|
||||
// --- CommandBlock -> REMOVE ---
|
||||
private void handleCommandBlockRemove(CommandSender sender) {
|
||||
Player p = getPlayer(sender);
|
||||
if (p == null) return;
|
||||
|
||||
if (p.getTargetEntity(10) instanceof CommandMinecart cm) {
|
||||
CommandBlockHolder wb = Sentinel.getInstance().getDirector().whitelistManager
|
||||
.generateHolder(p.getUniqueId(), cm);
|
||||
if (wb.removeFromWhitelist()) {
|
||||
String cleanedType = Text.cleanName(SerialLocation.translate(wb.loc()).getBlock().getType().toString());
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.removeSuccess
|
||||
.formatted(cleanedType, wb.command())));
|
||||
} else {
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.notWhitelisted
|
||||
.formatted(Text.cleanName(cm.getType().toString()))));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Block target = p.getTargetBlock(Set.of(Material.AIR), 10);
|
||||
CommandBlockHolder wb = Sentinel.getInstance().getDirector().whitelistManager
|
||||
.getFromWhitelist(target.getLocation());
|
||||
if (wb != null && wb.removeFromWhitelist()) {
|
||||
String cleanedType = Text.cleanName(SerialLocation.translate(wb.loc()).getBlock().getType().toString());
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.removeSuccess
|
||||
.formatted(cleanedType, wb.command())));
|
||||
} else {
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.notWhitelisted
|
||||
.formatted(Text.cleanName(target.getType().toString()))));
|
||||
}
|
||||
}
|
||||
|
||||
// --- CommandBlock -> AUTO ---
|
||||
private void handleCommandBlockAuto(CommandSender sender) {
|
||||
Player p = getPlayer(sender);
|
||||
if (p == null) return;
|
||||
|
||||
var whitelistManager = Sentinel.getInstance().getDirector().whitelistManager;
|
||||
if (whitelistManager.autoWhitelist.contains(p.getUniqueId())) {
|
||||
whitelistManager.autoWhitelist.remove(p.getUniqueId());
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.autoWhitelistOn));
|
||||
} else {
|
||||
whitelistManager.autoWhitelist.add(p.getUniqueId());
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.autoWhitelistOff));
|
||||
}
|
||||
}
|
||||
|
||||
// --- CommandBlock -> RESTORE ---
|
||||
private void handleCommandBlockRestore(CommandSender sender, Args args) {
|
||||
if (args.getSize() < 3) {
|
||||
sender.sendMessage(Text.prefix(USAGE_RESTORE));
|
||||
return;
|
||||
}
|
||||
String targetPlayer = args.get(2).toString();
|
||||
if (targetPlayer.equalsIgnoreCase("all")) {
|
||||
int result = Sentinel.getInstance().getDirector().whitelistManager.restoreAll();
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.restoreSuccess
|
||||
.formatted(result)));
|
||||
} else {
|
||||
UUID id = Bukkit.getOfflinePlayer(targetPlayer).getUniqueId();
|
||||
int result = Sentinel.getInstance().getDirector().whitelistManager.restoreAll(id);
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.restorePlayerSuccess
|
||||
.formatted(result, targetPlayer)));
|
||||
}
|
||||
}
|
||||
|
||||
// --- CommandBlock -> CLEAR ---
|
||||
private void handleCommandBlockClear(CommandSender sender, Args args) {
|
||||
if (args.getSize() < 3) {
|
||||
sender.sendMessage(Text.prefix(USAGE_CLEAR));
|
||||
return;
|
||||
}
|
||||
String targetPlayer = args.get(2).toString();
|
||||
if (targetPlayer.equalsIgnoreCase("all")) {
|
||||
int result = Sentinel.getInstance().getDirector().whitelistManager.clearAll();
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.clearSuccess
|
||||
.formatted(result)));
|
||||
} else {
|
||||
UUID id = Bukkit.getOfflinePlayer(targetPlayer).getUniqueId();
|
||||
int result = Sentinel.getInstance().getDirector().whitelistManager.clearAll(id);
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.commandBlock.clearPlayerSuccess
|
||||
.formatted(result, targetPlayer)));
|
||||
}
|
||||
}
|
||||
|
||||
/* =======================
|
||||
Subcommand: DEBUG
|
||||
======================= */
|
||||
private void handleDebugCommand(CommandSender sender, Args args) {
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.debug")) return;
|
||||
if (args.getSize() < 2) {
|
||||
sender.sendMessage(Text.prefix("Usage: /sentinel debug <lang|toggle|chat>"));
|
||||
return;
|
||||
}
|
||||
String sub = args.get(1).toString().toLowerCase();
|
||||
switch (sub) {
|
||||
case "lang" -> sender.sendMessage(Sentinel.lang.brokenLang);
|
||||
case "lang" -> sender.sendMessage(Sentinel.getInstance().getDirector().io.lang.brokenLang);
|
||||
case "toggle" -> {
|
||||
Sentinel.mainConfig.debugMode = !Sentinel.mainConfig.debugMode;
|
||||
String message = Sentinel.mainConfig.debugMode
|
||||
? Sentinel.lang.debug.debugEnabled
|
||||
: Sentinel.lang.debug.debugDisabled;
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.debugMode = !Sentinel.getInstance().getDirector().io.mainConfig.debugMode;
|
||||
String message = Sentinel.getInstance().getDirector().io.mainConfig.debugMode
|
||||
? Sentinel.getInstance().getDirector().io.lang.debug.debugEnabled
|
||||
: Sentinel.getInstance().getDirector().io.lang.debug.debugDisabled;
|
||||
sender.sendMessage(Text.prefix(message));
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
}
|
||||
case "chat" -> {
|
||||
if (!PlayerUtils.playerCheck(sender))
|
||||
return;
|
||||
if (args.getSize() < 3) {
|
||||
sender.sendMessage(Text.prefix("Usage: /sentinel debug chat <message>"));
|
||||
return;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
String messageText = args.getAll(2).toString();
|
||||
AsyncChatEvent message = new AsyncChatEvent(true,
|
||||
p,
|
||||
Set.of(p),
|
||||
ChatRenderer.defaultRenderer(),
|
||||
Component.text(messageText),
|
||||
Component.text(messageText),
|
||||
SignedMessage.system(messageText, Component.text(messageText))
|
||||
);
|
||||
UnicodeFilter.handleUnicodeFilter(message);
|
||||
UrlFilter.handleUrlFilter(message);
|
||||
SpamFilter.handleSpamFilter(message);
|
||||
ProfanityFilter.handleProfanityFilter(message);
|
||||
if (!message.isCancelled()) {
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.debug.notFlagged));
|
||||
}
|
||||
}
|
||||
default -> sender.sendMessage(Text.prefix(Sentinel.lang.plugin.invalidSubCommand.formatted("debug")));
|
||||
case "chat" -> handleDebugChat(sender, args);
|
||||
default -> sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.plugin.invalidSubCommand.formatted("debug")));
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDebugChat(CommandSender sender, Args args) {
|
||||
if (!PlayerUtils.playerCheck(sender)) return;
|
||||
if (args.getSize() < 3) {
|
||||
sender.sendMessage(Text.prefix("Usage: /sentinel debug chat <message>"));
|
||||
return;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
String messageText = args.getAll(2).toString();
|
||||
AsyncChatEvent chatEvent = new AsyncChatEvent(true,
|
||||
p,
|
||||
Set.of(p),
|
||||
ChatRenderer.defaultRenderer(),
|
||||
Component.text(messageText),
|
||||
Component.text(messageText),
|
||||
SignedMessage.system(messageText, Component.text(messageText))
|
||||
);
|
||||
UnicodeFilter.handleUnicodeFilter(chatEvent);
|
||||
UrlFilter.handleUrlFilter(chatEvent);
|
||||
SpamFilter.handleSpamFilter(chatEvent);
|
||||
ProfanityFilter.handleProfanityFilter(chatEvent);
|
||||
if (!chatEvent.isCancelled()) {
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.debug.notFlagged));
|
||||
}
|
||||
}
|
||||
|
||||
/* =======================
|
||||
Subcommand: FALSE-POSITIVE
|
||||
======================= */
|
||||
private void handleFalsePositive(CommandSender sender, Args args) {
|
||||
if (args.getSize() < 2) {
|
||||
sender.sendMessage(Text.prefix("Usage: /sentinel false-positive <add|remove> <value>"));
|
||||
return;
|
||||
}
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.false-positive"))
|
||||
return;
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.false-positive")) return;
|
||||
String sub = args.get(1).toString().toLowerCase();
|
||||
String falsePositive = args.getAll(2).toString();
|
||||
|
||||
Node root = new Node("Sentinel");
|
||||
root.addTextLine("False Positive Management Log");
|
||||
Node info = new Node("Info");
|
||||
info.addKeyValue("User", sender.getName());
|
||||
|
||||
switch (sub) {
|
||||
case "add" -> {
|
||||
if (!PlayerUtils.checkPermission(sender,"sentinel.false-positive.add")) return;
|
||||
Sentinel.fpConfig.swearWhitelist.add(falsePositive);
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.falsePositive.addSuccess.formatted(falsePositive)));
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.false-positive.add")) return;
|
||||
Sentinel.getInstance().getDirector().io.fpConfig.swearWhitelist.add(falsePositive);
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.falsePositive.addSuccess.formatted(falsePositive)));
|
||||
info.addKeyValue("Action", "Add");
|
||||
}
|
||||
case "remove" -> {
|
||||
if (!PlayerUtils.checkPermission(sender,"sentinel.false-positive.remove")) return;
|
||||
Sentinel.fpConfig.swearWhitelist.remove(falsePositive);
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.falsePositive.removeSuccess.formatted(falsePositive)));
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.false-positive.remove")) return;
|
||||
Sentinel.getInstance().getDirector().io.fpConfig.swearWhitelist.remove(falsePositive);
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.falsePositive.removeSuccess.formatted(falsePositive)));
|
||||
info.addKeyValue("Action", "Remove");
|
||||
}
|
||||
default -> {
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.plugin.invalidSubCommand.formatted("false-positive")));
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.plugin.invalidSubCommand.formatted("false-positive")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
info.addKeyValue("False Positive Edited", falsePositive);
|
||||
root.addChild(info);
|
||||
Sentinel.fpConfig.save();
|
||||
Sentinel.log.info(ConsoleFormatter.format(root));
|
||||
Sentinel.getInstance().getDirector().io.fpConfig.save();
|
||||
Sentinel.getInstance().getLogger().info(ConsoleFormatter.format(root));
|
||||
EmbedFormatter.sendEmbed(EmbedFormatter.format(root));
|
||||
}
|
||||
|
||||
/* =======================
|
||||
Subcommand: SOCIALSPY
|
||||
======================= */
|
||||
private void handleSocialSpy(CommandSender sender) {
|
||||
if (!PlayerUtils.playerCheck(sender))
|
||||
return;
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.socialspy"))
|
||||
return;
|
||||
if (!PlayerUtils.playerCheck(sender)) return;
|
||||
if (!PlayerUtils.checkPermission(sender, "sentinel.socialspy")) return;
|
||||
Player p = (Player) sender;
|
||||
UUID senderID = p.getUniqueId();
|
||||
boolean enabled = spyMap.getOrDefault(senderID, false);
|
||||
if (!enabled) {
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.socialSpy.enabled));
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.socialSpy.enabled));
|
||||
spyMap.put(senderID, true);
|
||||
} else {
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.socialSpy.disabled));
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.socialSpy.disabled));
|
||||
spyMap.put(senderID, false);
|
||||
}
|
||||
}
|
||||
|
||||
/* =======================
|
||||
Lite Mode Handler
|
||||
======================= */
|
||||
private void handleLiteMessage(CommandSender sender, Args args) {
|
||||
if (!args.isEmpty() && args.get(0).toString().equalsIgnoreCase("reload")) {
|
||||
if (sender instanceof Player p && !PlayerUtils.isTrusted(p)) {
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.permissions.noTrust));
|
||||
if (!PlayerUtils.isTrusted(sender)) {
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.permissions.noTrust));
|
||||
return;
|
||||
}
|
||||
Sentinel.log.info("Sentinel is now reloading the config in lite mode.");
|
||||
sender.sendMessage(Text.prefix(Sentinel.lang.plugin.reloadingConfigLite));
|
||||
Sentinel.getInstance().loadConfig();
|
||||
Sentinel.getInstance().getLogger().info("Sentinel is now reloading the config in lite mode.");
|
||||
sender.sendMessage(Text.prefix(Sentinel.getInstance().getDirector().io.lang.plugin.reloadingConfigLite));
|
||||
Sentinel.getInstance().getDirector().io.loadConfig();
|
||||
|
||||
if (Load.load(Sentinel.getInstance().license, Sentinel.getInstance().identifier, false)) {
|
||||
if (Sentinel.getInstance().getDirector().loader.load(Sentinel.getInstance().license, Sentinel.getInstance().identifier, false)) {
|
||||
return;
|
||||
}
|
||||
Sentinel.log.info("Re-authentication Failed.");
|
||||
Sentinel.getInstance().getLogger().info("Re-authentication Failed.");
|
||||
} else {
|
||||
sender.sendMessage(Load.liteMode);
|
||||
sender.sendMessage(Loader.LITE_MODE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ public class TrapCommand implements CustomCommand {
|
||||
|
||||
@Override
|
||||
public void dispatchCompletions(CommandSender commandSender, Command command, String s, CompletionBuilder b) {
|
||||
ServerUtils.verbose("Listing the fake plugins: %s".formatted(Sentinel.advConfig.fakePlugins));
|
||||
b.then(b.arg(Sentinel.advConfig.fakePlugins));
|
||||
b.then(b.arg(Sentinel.getInstance().getDirector().io.advConfig.fakePlugins));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.functions.helpers.CBWhitelistManager;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.trees.Node;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
|
||||
public class CommandBlockEdit extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onCMDBlockChange(EntityChangeBlockEvent e) {
|
||||
//ServerUtils.verbose("CommandBlockChange: Detected the event");
|
||||
if (!Sentinel.violationConfig.commandBlockEdit.enabled) return;
|
||||
//ServerUtils.verbose("CommandBlockChange: Enabled");
|
||||
if (!(e.getEntity() instanceof Player p)) return;
|
||||
//ServerUtils.verbose("CommandBlockChange: Changer is a player");
|
||||
Block b = e.getBlock();
|
||||
if (!(b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK))
|
||||
return;
|
||||
ServerUtils.verbose("CommandBlockChange: Block is a command block");
|
||||
CommandBlock cb = (CommandBlock) b.getState();
|
||||
if (PlayerUtils.isTrusted(p)) {
|
||||
if (!CBWhitelistManager.autoWhitelist.contains(p.getUniqueId())) return;
|
||||
CBWhitelistManager.add(cb, p.getUniqueId());
|
||||
return;
|
||||
}
|
||||
ServerUtils.verbose("CommandBlockChange: Not trusted, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.violationConfig.commandBlockEdit.deop)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.violationConfig.commandBlockEdit.punish)
|
||||
.setPunishmentCommands(Sentinel.violationConfig.commandBlockEdit.punishmentCommands)
|
||||
.logToDiscord(Sentinel.violationConfig.commandBlockEdit.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.edit, Sentinel.lang.violations.protections.rootName.commandBlock),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.edit, Sentinel.lang.violations.protections.rootName.commandBlock),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.functions.helpers.CBWhitelistManager;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
public class CommandBlockExecute extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void commandBlockExecute(ServerCommandEvent e) {
|
||||
//ServerUtils.verbose("Handling command block event: " + e.getCommand());
|
||||
if (!Sentinel.violationConfig.commandBlockExecute.enabled) return;
|
||||
//ServerUtils.verbose("Whitelist not disabled ");
|
||||
if (!(e.getSender() instanceof BlockCommandSender s)) return;
|
||||
//ServerUtils.verbose("Sender is command block");
|
||||
Block cmdBlock = s.getBlock();
|
||||
if (CBWhitelistManager.canRun(cmdBlock)) return;
|
||||
ServerUtils.verbose("Command block can't run.");
|
||||
|
||||
CommandBlock cb = (CommandBlock) cmdBlock.getState();
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setBlock(cmdBlock)
|
||||
.cancel(true)
|
||||
.destroyBlock(Sentinel.violationConfig.commandBlockExecute.destroyBlock)
|
||||
.restoreBlock(Sentinel.violationConfig.commandBlockExecute.attemptRestore)
|
||||
.logToDiscord(Sentinel.violationConfig.commandBlockExecute.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormat.formatted(Sentinel.lang.violations.protections.rootName.commandBlockWhitelist),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormat.formatted( Sentinel.lang.violations.protections.rootName.commandBlockWhitelist),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class CommandBlockMinecartPlace extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onCMDMinecartPlace(PlayerInteractEvent e) {
|
||||
//ServerUtils.verbose("MinecartCommandPlace: Detected interaction");
|
||||
if (!Sentinel.violationConfig.commandBlockMinecartPlace.enabled) return;
|
||||
//ServerUtils.verbose("MinecartCommandPlace: Check is enabled");
|
||||
Player p = e.getPlayer();
|
||||
if (!p.isOp()) return;
|
||||
//ServerUtils.verbose("MinecartCommandPlace: Player is op");
|
||||
if (e.getItem() == null) return;
|
||||
ServerUtils.verbose("MinecartCommandPlace: Item isn't null");
|
||||
if (e.getClickedBlock() == null) return;
|
||||
ServerUtils.verbose("MinecartCommandPlace: Clicked block isn't null");
|
||||
if (!e.getItem().getType().equals(Material.COMMAND_BLOCK_MINECART)) return;
|
||||
ServerUtils.verbose("MinecartCommandPlace: Item is a minecart command");
|
||||
if (!(e.getClickedBlock().getType() == Material.RAIL || e.getClickedBlock().getType() == Material.POWERED_RAIL || e.getClickedBlock().getType() == Material.ACTIVATOR_RAIL || e.getClickedBlock().getType() == Material.DETECTOR_RAIL)) return;
|
||||
ServerUtils.verbose("MinecartCommandPlace: Clicked block is a rail");
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("MinecartCommandPlace: Not trusted, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.violationConfig.commandBlockMinecartPlace.punish)
|
||||
.deop(Sentinel.violationConfig.commandBlockMinecartPlace.deop)
|
||||
.setPunishmentCommands(Sentinel.violationConfig.commandBlockMinecartPlace.punishmentCommands)
|
||||
.logToDiscord(Sentinel.violationConfig.commandBlockMinecartPlace.logToDiscord);
|
||||
|
||||
// Remove the command block minecart from the player's inventory
|
||||
p.getInventory().remove(Material.COMMAND_BLOCK_MINECART);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.place, Sentinel.lang.violations.protections.rootName.minecartCommandBlock),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.place, Sentinel.lang.violations.protections.rootName.minecartCommandBlock),
|
||||
generateBlockInfo(e.getClickedBlock()),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
public class CommandBlockMinecartUse extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onCMDBlockMinecartUse(PlayerInteractEntityEvent e) {
|
||||
//ServerUtils.verbose("MinecartCommandUse: Detected Interaction with entity");
|
||||
if (!Sentinel.violationConfig.commandBlockMinecartUse.enabled) return;
|
||||
//ServerUtils.verbose("MinecartCommandUse: Enabled");
|
||||
Player p = e.getPlayer();
|
||||
if (!p.isOp()) return;
|
||||
ServerUtils.verbose("MinecartCommandUse: Player op");
|
||||
if (e.getRightClicked().getType() != EntityType.COMMAND_BLOCK_MINECART) return;
|
||||
ServerUtils.verbose("MinecartCommandUse: Entity is minecart command");
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("MinecartCommandUse: Not trusted, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.violationConfig.commandBlockMinecartUse.punish)
|
||||
.deop(Sentinel.violationConfig.commandBlockMinecartUse.deop)
|
||||
.setPunishmentCommands(Sentinel.violationConfig.commandBlockMinecartUse.punishmentCommands)
|
||||
.logToDiscord(Sentinel.violationConfig.commandBlockMinecartUse.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.use, Sentinel.lang.violations.protections.rootName.minecartCommandBlock),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.use, Sentinel.lang.violations.protections.rootName.minecartCommandBlock),
|
||||
generateMinecartInfo(e.getRightClicked()),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class CommandBlockPlace extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
public void listen(BlockPlaceEvent e) {
|
||||
//ServerUtils.verbose("CommandBlockPlace: Detected block place");
|
||||
if (!Sentinel.violationConfig.commandBlockPlace.enabled) return;
|
||||
//ServerUtils.verbose("CommandBlockPlace: Enabled");
|
||||
Player p = e.getPlayer();
|
||||
if (!p.isOp()) return;
|
||||
//ServerUtils.verbose("CommandBlockPlace: Player is operator");
|
||||
Block b = e.getBlockPlaced();
|
||||
if (!(b.getType().equals(Material.COMMAND_BLOCK) ||
|
||||
b.getType().equals(Material.REPEATING_COMMAND_BLOCK) ||
|
||||
b.getType().equals(Material.CHAIN_COMMAND_BLOCK))) return;
|
||||
ServerUtils.verbose("CommandBlockPlace: Block is a command block");
|
||||
CommandBlock cb = (CommandBlock) b.getState();
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("CommandBlockPlace: Not trusted, performing action");
|
||||
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.violationConfig.commandBlockPlace.deop)
|
||||
.cancel(true)
|
||||
.setEvent(e)
|
||||
.punish(true)
|
||||
.setPunishmentCommands(Sentinel.violationConfig.commandBlockPlace.punishmentCommands)
|
||||
.logToDiscord(Sentinel.violationConfig.commandBlockPlace.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.place, Sentinel.lang.violations.protections.rootName.commandBlock),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.place, Sentinel.lang.violations.protections.rootName.commandBlock),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.functions.helpers.CBWhitelistManager;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class CommandBlockUse extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onCMDBlockUse(PlayerInteractEvent e) {
|
||||
//ServerUtils.verbose("CommandBlockUse: Detected Interaction");
|
||||
if (!Sentinel.violationConfig.commandBlockUse.enabled) return;
|
||||
//ServerUtils.verbose("CommandBlockUse: Enabled");
|
||||
Player p = e.getPlayer();
|
||||
if (!p.isOp()) return;
|
||||
//ServerUtils.verbose("CommandBlockUse: Player is op");
|
||||
if (e.getClickedBlock() == null) return;
|
||||
//ServerUtils.verbose("CommandBlockUse: Block isn't null");
|
||||
Block b = e.getClickedBlock();
|
||||
if (!(b.getType() == Material.COMMAND_BLOCK || b.getType() == Material.REPEATING_COMMAND_BLOCK || b.getType() == Material.CHAIN_COMMAND_BLOCK)) return;
|
||||
CommandBlock cb = (CommandBlock) b.getState();
|
||||
ServerUtils.verbose("CommandBlockUse: Block is a command block");
|
||||
if (PlayerUtils.isTrusted(p)) {
|
||||
if (!CBWhitelistManager.autoWhitelist.contains(p.getUniqueId())) return;
|
||||
if (CBWhitelistManager.canRun(cb.getBlock())) return;
|
||||
e.setCancelled(true);
|
||||
CBWhitelistManager.add(cb, p.getUniqueId());
|
||||
return;
|
||||
}
|
||||
ServerUtils.verbose("CommandBlockUse: Not trusted, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.violationConfig.commandBlockUse.deop)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.violationConfig.commandBlockUse.punish)
|
||||
.setPunishmentCommands(Sentinel.violationConfig.commandBlockUse.punishmentCommands)
|
||||
.logToDiscord(Sentinel.violationConfig.commandBlockUse.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.use, Sentinel.lang.violations.protections.rootName.commandBlock),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.use, Sentinel.lang.violations.protections.rootName.commandBlock),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class CommandExecute extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onCommand(PlayerCommandPreprocessEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
String label = e.getMessage().substring(1).split(" ")[0];
|
||||
String args = e.getMessage();
|
||||
|
||||
Set<String> status = getCommandStatus(label);
|
||||
|
||||
if (status.contains("SPECIFIC") && Sentinel.violationConfig.commandExecute.specific.enabled) {
|
||||
e.setCancelled(true);
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.violationConfig.commandExecute.specific.punish)
|
||||
.setPunishmentCommands(Sentinel.violationConfig.commandExecute.specific.punishmentCommands)
|
||||
.logToDiscord(Sentinel.violationConfig.commandExecute.specific.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.run, Sentinel.lang.violations.protections.rootName.specificCommand),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.run, Sentinel.lang.violations.protections.rootName.specificCommand),
|
||||
generateCommandInfo(args, p),
|
||||
config
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (status.contains("DANGEROUS") && Sentinel.violationConfig.commandExecute.dangerous.enabled) {
|
||||
e.setCancelled(true);
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.violationConfig.commandExecute.dangerous.deop)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.violationConfig.commandExecute.dangerous.punish)
|
||||
.setPunishmentCommands(Sentinel.violationConfig.commandExecute.dangerous.punishmentCommands)
|
||||
.logToDiscord(Sentinel.violationConfig.commandExecute.dangerous.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.run, Sentinel.lang.violations.protections.rootName.dangerousCommand),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.run, Sentinel.lang.violations.protections.rootName.dangerousCommand),
|
||||
generateCommandInfo(args, p),
|
||||
config
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (status.contains("LOGGED") && Sentinel.violationConfig.commandExecute.logged.enabled) {
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setPlayer(p)
|
||||
.logToDiscord(Sentinel.violationConfig.commandExecute.logged.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.run, Sentinel.lang.violations.protections.rootName.loggedCommand),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.run, Sentinel.lang.violations.protections.rootName.loggedCommand),
|
||||
generateCommandInfo(args, p),
|
||||
config
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<String> getCommandStatus(String label) {
|
||||
Set<String> commandTypes = new HashSet<>();
|
||||
|
||||
if (label.startsWith("/")) {
|
||||
label = label.substring(1);
|
||||
}
|
||||
|
||||
if (label.contains(":")) {
|
||||
commandTypes.add("SPECIFIC");
|
||||
}
|
||||
|
||||
for (String loggedCommand : Sentinel.violationConfig.commandExecute.logged.commands) {
|
||||
if (loggedCommand.equals(label)) commandTypes.add("LOGGED");
|
||||
}
|
||||
|
||||
for (String dangerousCommand : Sentinel.violationConfig.commandExecute.dangerous.commands) {
|
||||
if (dangerousCommand.equals(label)) commandTypes.add("DANGEROUS");
|
||||
}
|
||||
|
||||
return commandTypes;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.utils.ItemUtils;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CreativeHotbar extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onNBTPull(InventoryCreativeEvent e) {
|
||||
//ServerUtils.verbose("NBT: Detected creative mode action");
|
||||
if (!Sentinel.violationConfig.creativeHotbarAction.enabled) return;
|
||||
ServerUtils.verbose("NBT: Enabled");
|
||||
if (!(e.getWhoClicked() instanceof Player p)) return;
|
||||
ServerUtils.verbose("NBT: Clicker is a player");
|
||||
if (e.getCursor() == null) return; // Well it threw an exception during testing, so it isn't always false!
|
||||
ServerUtils.verbose("NBT: Cursor isn't null");
|
||||
ItemStack i = e.getCursor();
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("NBT: Not trusted");
|
||||
if (e.getCursor().getItemMeta() == null) return;
|
||||
ServerUtils.verbose("NBT: Cursor has meta");
|
||||
if (!(i.hasItemMeta() && i.getItemMeta() != null)) return;
|
||||
ServerUtils.verbose("NBT: Item has meta");
|
||||
if (ItemUtils.itemPasses(i)) return;
|
||||
ServerUtils.verbose("NBT: Item doesn't pass, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.violationConfig.creativeHotbarAction.punish)
|
||||
.deop(Sentinel.violationConfig.creativeHotbarAction.deop)
|
||||
.setPunishmentCommands(Sentinel.violationConfig.creativeHotbarAction.punishmentCommands)
|
||||
.logToDiscord(Sentinel.violationConfig.creativeHotbarAction.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.grab, Sentinel.lang.violations.protections.rootName.nbtItem),
|
||||
Sentinel.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.lang.violations.protections.rootName.grab, Sentinel.lang.violations.protections.rootName.nbtItem),
|
||||
generateItemInfo(i),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package me.trouper.sentinel.server.events.admin;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
public class AntiBanEvents implements CustomListener {
|
||||
|
||||
// Well. I hope that no banning plugins use the highest priority as well, that would be embarrassing.
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onKick(PlayerKickEvent e) {
|
||||
if (PlayerUtils.isTrusted(e.getPlayer()) && Sentinel.getInstance().getDirector().io.mainConfig.plugin.antiBan) e.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onLogin(PlayerLoginEvent e) {
|
||||
if (PlayerUtils.isTrusted(e.getPlayer()) && Sentinel.getInstance().getDirector().io.mainConfig.plugin.antiBan) e.allow();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void beforeLogin(AsyncPlayerPreLoginEvent e) {
|
||||
if (PlayerUtils.isTrusted(e.getUniqueId()) && Sentinel.getInstance().getDirector().io.mainConfig.plugin.antiBan) e.allow();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package me.trouper.sentinel.server.events.admin;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class BlockDisplayHideEvent implements CustomListener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Entity entity : player.getWorld().getEntities()) {
|
||||
if (entity instanceof BlockDisplay && entity.getScoreboardTags().contains("./Sentinel/ Block Display")) {
|
||||
player.hideEntity(Sentinel.getInstance(), entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
package me.trouper.sentinel.server.events.admin;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.itzispyder.pdk.plugin.builders.ItemBuilder;
|
||||
import io.github.itzispyder.pdk.utils.misc.SoundPlayer;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.CommandBlockHolder;
|
||||
import me.trouper.sentinel.data.types.Selection;
|
||||
import me.trouper.sentinel.utils.DisplayUtils;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import me.trouper.sentinel.utils.display.BlockDisplayRaytracer;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class WandEvents implements CustomListener {
|
||||
public static final ItemStack SELECTION_WAND = ItemBuilder.create()
|
||||
.material(Material.BLAZE_ROD)
|
||||
.name(Text.color("&dCommand Block Wand"))
|
||||
.lore(Text.color("&7Use this wand to manage command blocks."))
|
||||
.lore(Text.color("&7It can scan up to 10 blocks away."))
|
||||
.lore(Text.color("&7Selections are visible up to 64 blocks away."))
|
||||
.lore(Text.color("&8&l➥&r &7Left Click&8:&f Set Position 1"))
|
||||
.lore(Text.color("&8&l➥&r &7Right Click&8:&f Set Position 2"))
|
||||
.lore(Text.color("&8&l➥&r &7Break CMD Block&8:&f Remove from whitelist"))
|
||||
.lore(Text.color("&8&l➥&r &7Click CMD Block&8:&f Add to whitelist"))
|
||||
.lore(Text.color("&8&l➥&r &7Sneak&8:&f Force Position Setting"))
|
||||
.lore(Text.color("&7Blocks close to you will get highlighted when holding."))
|
||||
.lore(Text.color(" &fHighlight Color Key&8:"))
|
||||
.lore(Text.color(" &8- &cRed &7: &fNot whitelisted."))
|
||||
.lore(Text.color(" &8- &aGreen &7: &fWhitelisted."))
|
||||
.lore(Text.color(" &8- &9Blue &7: &fYour selection."))
|
||||
.lore(Text.color(" &8- &dPurple &7: &fMissing Command Block"))
|
||||
.lore(Text.color(" &8- &fBlack &7: &fUnknown Command Block (Auto-Correcting)"))
|
||||
.customModelData(1984)
|
||||
.build();
|
||||
|
||||
public static final Map<UUID, Selection> selections = new HashMap<>();
|
||||
private static final ConcurrentLinkedQueue<BlockHighlight> blockHighlights = new ConcurrentLinkedQueue<>();
|
||||
private static final Map<UUID, Set<BlockHighlight>> playerBlockHighlights = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentLinkedQueue<EntityHighlight> entityHighlights = new ConcurrentLinkedQueue<>();
|
||||
private static final Map<UUID, Set<EntityHighlight>> playerEntityHighlights = new ConcurrentHashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onClickEntity(PlayerInteractEntityEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack i = p.getInventory().getItemInMainHand();
|
||||
|
||||
if (!i.isSimilar(SELECTION_WAND)) return;
|
||||
if (!PlayerUtils.isTrusted(p)) return;
|
||||
|
||||
SoundPlayer add = new SoundPlayer(p.getLocation(),Sound.ENTITY_EXPERIENCE_ORB_PICKUP,100,1);
|
||||
if (!(e.getRightClicked() instanceof CommandMinecart cm)) return;
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),cm).addToWhitelist();
|
||||
add.play(p);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(VehicleDamageEvent e) {
|
||||
if (!(e.getAttacker() instanceof Player p)) return;
|
||||
ItemStack i = p.getInventory().getItemInMainHand();
|
||||
|
||||
if (!i.isSimilar(SELECTION_WAND)) return;
|
||||
if (!PlayerUtils.isTrusted(p)) return;
|
||||
|
||||
SoundPlayer remove = new SoundPlayer(p.getLocation(),Sound.BLOCK_GLASS_BREAK,100,1);
|
||||
|
||||
if (!(e.getVehicle() instanceof CommandMinecart cm)) return;
|
||||
e.setCancelled(true);
|
||||
|
||||
Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),cm).removeFromWhitelist();
|
||||
remove.play(p);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack i = p.getInventory().getItemInMainHand();
|
||||
|
||||
if (!i.isSimilar(SELECTION_WAND)) return;
|
||||
if (!PlayerUtils.isTrusted(p)) return;
|
||||
|
||||
SoundPlayer add = new SoundPlayer(p.getLocation(),Sound.ENTITY_EXPERIENCE_ORB_PICKUP,100,1);
|
||||
SoundPlayer remove = new SoundPlayer(p.getLocation(),Sound.BLOCK_GLASS_BREAK,100,1);
|
||||
SoundPlayer set1 = new SoundPlayer(p.getLocation(),Sound.UI_BUTTON_CLICK,100,1);
|
||||
SoundPlayer set2 = new SoundPlayer(p.getLocation(),Sound.UI_BUTTON_CLICK,100,0.8F);
|
||||
|
||||
Selection selection = selections.computeIfAbsent(p.getUniqueId(), k -> new Selection());
|
||||
if (p.getTargetBlockExact(10) == null) return;
|
||||
Location loc = p.getTargetBlockExact(10).getLocation();
|
||||
|
||||
if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
e.setCancelled(true);
|
||||
if (p.isSneaking() && ServerUtils.isCommandBlock(loc.getBlock())) {
|
||||
set1.play(p);
|
||||
setPos1(p,selection,loc);
|
||||
} else if (ServerUtils.isCommandBlock(loc.getBlock())) {
|
||||
remove.play(p);
|
||||
Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),(CommandBlock) loc.getBlock().getState()).removeFromWhitelist();
|
||||
} else {
|
||||
set1.play(p);
|
||||
setPos1(p,selection,loc);
|
||||
}
|
||||
} else if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
e.setCancelled(true);
|
||||
if (p.isSneaking() && ServerUtils.isCommandBlock(loc.getBlock())) {
|
||||
set2.play(p);
|
||||
setPos2(p,selection,loc);
|
||||
} else if (ServerUtils.isCommandBlock(loc.getBlock())) {
|
||||
add.play(p);
|
||||
Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),(CommandBlock) loc.getBlock().getState()).addToWhitelist();
|
||||
} else {
|
||||
set2.play(p);
|
||||
setPos2(p,selection,loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record EntityHighlight(Player beholder, Entity ent, Color color) {
|
||||
public void display() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
DisplayUtils.ring(ent.getLocation().clone().add(0, (double) i /5,0),0.6, (location) -> {
|
||||
DisplayUtils.PLAYER_DUST_PARTICLE_FACTORY.apply(color,1F).accept(beholder,location);
|
||||
},((location, integer) -> {
|
||||
return integer % 36 == 0;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record BlockHighlight(Player beholder, Location loc, Material color) {
|
||||
public void display() {
|
||||
BlockDisplayRaytracer.outline(color, loc, 0.05, 2, List.of(beholder));
|
||||
}
|
||||
}
|
||||
|
||||
private static void sortNear(Player p) {
|
||||
ItemStack i = p.getInventory().getItemInMainHand();
|
||||
|
||||
if (!i.isSimilar(SELECTION_WAND) || !PlayerUtils.isTrusted(p)) {
|
||||
Set<BlockHighlight> existingBlocks = playerBlockHighlights.remove(p.getUniqueId());
|
||||
Set<EntityHighlight> existingEntities = playerEntityHighlights.remove(p.getUniqueId());
|
||||
if (existingBlocks != null) {
|
||||
blockHighlights.removeAll(existingBlocks);
|
||||
entityHighlights.removeAll(existingEntities);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Set<BlockHighlight> currentBlocks = new HashSet<>();
|
||||
Set<EntityHighlight> currentEntities = new HashSet<>();
|
||||
Selection around = new Selection();
|
||||
around.setPos1(p.getLocation().add(-10, -10, -10));
|
||||
around.setPos2(p.getLocation().add(10, 10, 10));
|
||||
around.getBlocks().stream()
|
||||
.filter(block -> ServerUtils.isCommandBlock(block) && block.getLocation().distance(p.getLocation()) <= 10)
|
||||
.forEach(block -> {
|
||||
CommandBlock cb = (CommandBlock) block.getState();
|
||||
CommandBlockHolder holder = Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),cb);
|
||||
Material color = holder.isWhitelisted()
|
||||
? Material.LIME_CONCRETE_POWDER
|
||||
: Material.RED_CONCRETE_POWDER;
|
||||
if (holder.isUnknown()) {
|
||||
color = Material.BLACK_CONCRETE_POWDER;
|
||||
holder.addToExisting();
|
||||
}
|
||||
currentBlocks.add(new BlockHighlight(p, block.getLocation(), color));
|
||||
});
|
||||
|
||||
List<Entity> carts = p.getNearbyEntities(10,10,10).stream().filter(entity -> entity instanceof CommandMinecart).toList();
|
||||
|
||||
for (Entity cart : carts) {
|
||||
if (!(cart instanceof CommandMinecart cm)) continue;
|
||||
CommandBlockHolder holder = Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),cm);
|
||||
Color color = holder.isWhitelisted()
|
||||
? Color.fromRGB(0x00FF00)
|
||||
: Color.fromRGB(0xFF0000);
|
||||
if (holder.isUnknown()) {
|
||||
color = Color.fromRGB(0);
|
||||
holder.addToExisting();
|
||||
}
|
||||
currentEntities.add(new EntityHighlight(p, cart, color));
|
||||
}
|
||||
|
||||
for (CommandBlockHolder wl : Sentinel.getInstance().getDirector().io.commandBlocks.whitelistedCMDBlocks) {
|
||||
if (!wl.isPresent() && !wl.isCart()) {
|
||||
currentBlocks.add(new BlockHighlight(p, wl.loc().translate(), Material.PURPLE_CONCRETE_POWDER));
|
||||
}
|
||||
}
|
||||
|
||||
Set<BlockHighlight> previousBlocks = playerBlockHighlights.getOrDefault(p.getUniqueId(), new HashSet<>());
|
||||
Set<BlockHighlight> blocksToAdd = new HashSet<>(currentBlocks);
|
||||
blocksToAdd.removeAll(previousBlocks);
|
||||
Set<BlockHighlight> blocksToRemove = new HashSet<>(previousBlocks);
|
||||
blocksToRemove.removeAll(currentBlocks);
|
||||
|
||||
Set<EntityHighlight> previousEntities = playerEntityHighlights.getOrDefault(p.getUniqueId(), new HashSet<>());
|
||||
Set<EntityHighlight> entitiesToAdd = new HashSet<>(currentEntities);
|
||||
entitiesToAdd.removeAll(previousEntities);
|
||||
Set<EntityHighlight> entitiesToRemove = new HashSet<>(previousEntities);
|
||||
entitiesToRemove.removeAll(currentEntities);
|
||||
|
||||
blockHighlights.addAll(blocksToAdd);
|
||||
blockHighlights.removeAll(blocksToRemove);
|
||||
playerBlockHighlights.put(p.getUniqueId(), currentBlocks);
|
||||
|
||||
entityHighlights.addAll(entitiesToAdd);
|
||||
entityHighlights.removeAll(entitiesToRemove);
|
||||
playerEntityHighlights.put(p.getUniqueId(), currentEntities);
|
||||
}
|
||||
|
||||
public static void handleDisplay() {
|
||||
PlayerUtils.forEachTrusted(WandEvents::sortNear);
|
||||
|
||||
Iterator<BlockHighlight> blockIterator = blockHighlights.iterator();
|
||||
while (blockIterator.hasNext()) {
|
||||
BlockHighlight bh = blockIterator.next();
|
||||
if (bh.beholder == null || !bh.beholder.isOnline() || bh.loc.distance(bh.beholder.getLocation()) > 10) {
|
||||
blockIterator.remove();
|
||||
playerBlockHighlights.computeIfPresent(bh.beholder.getUniqueId(), (uuid, set) -> {
|
||||
set.remove(bh);
|
||||
return set.isEmpty() ? null : set;
|
||||
});
|
||||
} else {
|
||||
bh.display();
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<EntityHighlight> entityIterator = entityHighlights.iterator();
|
||||
while (entityIterator.hasNext()) {
|
||||
EntityHighlight eh = entityIterator.next();
|
||||
if (eh.beholder == null || !eh.beholder.isOnline() || eh.ent.getLocation().distance(eh.beholder.getLocation()) > 10) {
|
||||
entityIterator.remove();
|
||||
playerEntityHighlights.computeIfPresent(eh.beholder.getUniqueId(), (uuid,set) -> {
|
||||
set.remove(eh);
|
||||
return set.isEmpty() ? null : set;
|
||||
});
|
||||
} else {
|
||||
eh.display();
|
||||
}
|
||||
}
|
||||
|
||||
selections.forEach((uuid, selection) -> {
|
||||
Player p = Bukkit.getPlayer(uuid);
|
||||
if (p == null || !p.isOnline() || !p.getInventory().getItemInMainHand().isSimilar(SELECTION_WAND)) return;
|
||||
selection.display(p);
|
||||
});
|
||||
}
|
||||
|
||||
private void setPos2(Player p, Selection selection, Location loc) {
|
||||
if (selection.getPos2() != null && selection.getPos2().distance(loc) < 0.1) return;
|
||||
selection.setPos2(loc);
|
||||
p.sendMessage(Text.prefix("Position 2 set to " + Text.formatLoc(loc)));
|
||||
}
|
||||
|
||||
private void setPos1(Player p, Selection selection, Location loc) {
|
||||
if (selection.getPos1() != null && selection.getPos1().distance(loc) < 0.1) return;
|
||||
selection.setPos1(loc);
|
||||
p.sendMessage(Text.prefix("Position 1 set to " + Text.formatLoc(loc)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package me.trouper.sentinel.server.events.extras;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
|
||||
import com.github.retrooper.packetevents.event.PacketSendEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.protocol.player.GameMode;
|
||||
import com.github.retrooper.packetevents.protocol.teleport.RelativeFlag;
|
||||
import com.github.retrooper.packetevents.protocol.world.Difficulty;
|
||||
import com.github.retrooper.packetevents.protocol.world.dimension.DimensionTypes;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerCloseWindow;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerPositionAndLook;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerRespawn;
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.itzispyder.pdk.utils.SchedulerUtils;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class ShadowRealmEvents extends PacketListenerAbstract implements CustomListener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (!Sentinel.getInstance().getDirector().io.extraStorage.shadowRealm.containsKey(p.getUniqueId())) return;
|
||||
SchedulerUtils.later(20,()->{
|
||||
enforce(p);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent e) {
|
||||
if (e.getPacketType() == PacketType.Play.Client.KEEP_ALIVE) return;
|
||||
if (e.getPacketType() == PacketType.Play.Client.TELEPORT_CONFIRM) return;
|
||||
if (e.getPacketType() == PacketType.Play.Client.CLIENT_SETTINGS) return;
|
||||
if (e.getPacketType() == PacketType.Play.Client.PLAYER_FLYING) return;
|
||||
Player player = e.getPlayer();
|
||||
if (player == null) return;
|
||||
if (!Sentinel.getInstance().getDirector().io.extraStorage.shadowRealm.containsKey(player.getUniqueId())) return;
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSend(PacketSendEvent e) {
|
||||
if (e.getPacketType() == PacketType.Play.Server.KEEP_ALIVE) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.PLAYER_POSITION_AND_LOOK) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.RESPAWN) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.DISCONNECT) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.CLOSE_WINDOW) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.CHUNK_DATA) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.CHUNK_BATCH_BEGIN) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.CHUNK_BATCH_END) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.CHUNK_BIOMES) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.UNLOAD_CHUNK) return;
|
||||
if (e.getPacketType() == PacketType.Play.Server.MAP_CHUNK_BULK) return;
|
||||
|
||||
Player player = e.getPlayer();
|
||||
if (player == null) return;
|
||||
if (!Sentinel.getInstance().getDirector().io.extraStorage.shadowRealm.containsKey(player.getUniqueId())) return;
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
public static void enforce(Player p) {
|
||||
if (p == null || !Sentinel.getInstance().getDirector().io.extraStorage.shadowRealm.containsKey(p.getUniqueId())) return;
|
||||
sendFakeRespawn(p);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(Sentinel.getInstance(),(t)->{
|
||||
if (p == null || !p.isOnline() || !Sentinel.getInstance().getDirector().io.extraStorage.shadowRealm.containsKey(p.getUniqueId())) t.cancel();
|
||||
sendFakePosition(p,0,666,0);
|
||||
sendCloseScreen(p);
|
||||
},1,1);
|
||||
}
|
||||
|
||||
public static void sendFakeRespawn(Player victim) {
|
||||
if (victim == null || !victim.isOnline()) return;
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
WrapperPlayServerRespawn packet = new WrapperPlayServerRespawn(DimensionTypes.THE_END,"minecraft:the_end", Difficulty.PEACEFUL,1L, GameMode.SPECTATOR,null,false,false,false,null,null,null);
|
||||
player.sendPacket(packet);
|
||||
}
|
||||
|
||||
public static void sendCloseScreen(Player victim) {
|
||||
if (victim == null || !victim.isOnline()) return;
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
if (player == null) return;
|
||||
WrapperPlayServerCloseWindow packet = new WrapperPlayServerCloseWindow();
|
||||
player.sendPacket(packet);
|
||||
}
|
||||
|
||||
public static void sendFakePosition(Player victim, double x, double y, double z) {
|
||||
if (victim == null || !victim.isOnline()) return;
|
||||
var player = PacketEvents.getAPI().getPlayerManager().getUser(victim);
|
||||
if (player == null) return;
|
||||
WrapperPlayServerPlayerPositionAndLook packet = new WrapperPlayServerPlayerPositionAndLook(x,y,z,0,90, RelativeFlag.NONE.getMask(),0,false);
|
||||
player.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package me.trouper.sentinel.server.events.violations;
|
||||
|
||||
import io.github.itzispyder.pdk.commands.Args;
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import io.github.itzispyder.pdk.utils.misc.config.ConfigUpdater;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.config.ViolationConfig;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.utils.FileUtils;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import me.trouper.sentinel.utils.trees.ConsoleFormatter;
|
||||
import me.trouper.sentinel.utils.trees.EmbedFormatter;
|
||||
import me.trouper.sentinel.utils.trees.HoverFormatter;
|
||||
import me.trouper.sentinel.utils.trees.Node;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public abstract class AbstractViolation implements CustomListener {
|
||||
|
||||
public abstract CustomGui getConfigGui();
|
||||
public abstract void getMainPage(Inventory inv);
|
||||
public abstract void onClick(InventoryClickEvent e);
|
||||
|
||||
public static ConfigUpdater<AsyncChatEvent, ViolationConfig> updater = new ConfigUpdater<>(Sentinel.getInstance().getDirector().io.violationConfig);
|
||||
|
||||
protected void queuePlayer(Player player, BiConsumer<ViolationConfig, Args> action, String currentValue) {
|
||||
MainGUI.awaitingCallback.add(player.getUniqueId());
|
||||
player.closeInventory();
|
||||
updater.queuePlayer(player, 20*60, (e)->{
|
||||
e.setCancelled(true);
|
||||
return LegacyComponentSerializer.legacySection().serialize(e.message());
|
||||
}, (cfg, newValue) -> {
|
||||
action.accept(cfg,new Args(newValue.split("\\s+")));
|
||||
cfg.save();
|
||||
player.sendMessage(Text.prefix("Value updated successfully"));
|
||||
player.openInventory(getConfigGui().getInventory());
|
||||
});
|
||||
player.sendMessage(Component.text(Text.prefix("Enter the new value in chat. The value is currently set to &b%s&7. (Click to insert)".formatted(currentValue))).clickEvent(ClickEvent.suggestCommand(currentValue)));
|
||||
}
|
||||
|
||||
public void runActions(String rootName, String rootNamePlayer, Node violationInfo, ActionConfiguration.Builder configuration) {
|
||||
ActionConfiguration config = configuration.build();
|
||||
|
||||
Node root = new Node("Sentinel");
|
||||
root.addTextLine(rootName);
|
||||
|
||||
if (config.getPlayer() != null) root.addChild(generatePlayerInfo(config.getPlayer()));
|
||||
|
||||
root.addChild(violationInfo);
|
||||
|
||||
root.addChild(configuration.getActionNode());
|
||||
|
||||
notifyTrusted(root,(rootNamePlayer == null || rootNamePlayer.isBlank()) ? rootName : rootNamePlayer);
|
||||
if (configuration.isLoggedToDiscord()) EmbedFormatter.sendEmbed(EmbedFormatter.format(root));
|
||||
Sentinel.getInstance().getLogger().info(ConsoleFormatter.format(root));
|
||||
}
|
||||
|
||||
public void notifyTrusted(Node root, String rootNamePlayer) {
|
||||
PlayerUtils.forEachTrusted(trusted -> {
|
||||
trusted.sendMessage(Component.text(Text.prefix(rootNamePlayer)).hoverEvent(Component.text(HoverFormatter.format(root)).asHoverEvent()));
|
||||
});
|
||||
}
|
||||
|
||||
public Node generatePlayerInfo(Player p) {
|
||||
Node playerInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.playerInfo);
|
||||
playerInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.name, p.getName());
|
||||
playerInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.uuid, p.getUniqueId().toString());
|
||||
playerInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.operator, p.isOp() ? Sentinel.getInstance().getDirector().io.lang.generic.yes : Sentinel.getInstance().getDirector().io.lang.generic.no);
|
||||
playerInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.locationField, Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.locationFormat.formatted(Math.round(p.getX()), Math.round(p.getY()), Math.round(p.getZ())));
|
||||
|
||||
return playerInfo;
|
||||
}
|
||||
|
||||
public static Node generateBlockInfo(Block block) {
|
||||
Node blockInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.blockInfo);
|
||||
blockInfo.addTextLine(Text.cleanName(block.getType().toString()));
|
||||
blockInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.worldField,block.getWorld().getName());
|
||||
blockInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.blockLocationField,Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.locationFormat.formatted(block.getX(), block.getY(), block.getZ()));
|
||||
|
||||
return blockInfo;
|
||||
}
|
||||
|
||||
public Node generateCommandBlockInfo(CommandBlock commandBlock) {
|
||||
Node commandBlockInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.blockInfo);
|
||||
commandBlockInfo.addTextLine(Text.cleanName(commandBlock.getType().toString()));
|
||||
commandBlockInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.worldField,commandBlock.getWorld().getName());
|
||||
commandBlockInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.blockLocationField,Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.locationFormat.formatted(commandBlock.getX(), commandBlock.getY(), commandBlock.getZ()));
|
||||
|
||||
String command = commandBlock.getCommand();
|
||||
if (command == null || command.isBlank()) {
|
||||
return commandBlockInfo;
|
||||
} else if (command.length() <= 128) {
|
||||
commandBlockInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.commandField, command);
|
||||
} else {
|
||||
commandBlockInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.commandTooLargeField, FileUtils.createCommandLog(command));
|
||||
}
|
||||
|
||||
return commandBlockInfo;
|
||||
}
|
||||
|
||||
public Node generateMinecartInfo(CommandMinecart entity) {
|
||||
Node minecartInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.minecartInfo);
|
||||
minecartInfo.addTextLine(Text.cleanName(entity.getType().toString()));
|
||||
minecartInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.worldField,entity.getWorld().getName());
|
||||
minecartInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.cartLocationField,Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.locationFormat.formatted(Math.round(entity.getX()), Math.round(entity.getY()), Math.round(entity.getZ())));
|
||||
|
||||
String command = entity.getCommand();
|
||||
if (command == null || command.isBlank()) {
|
||||
return minecartInfo;
|
||||
} else if (command.length() <= 128) {
|
||||
minecartInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.commandField, command);
|
||||
} else {
|
||||
minecartInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.commandTooLargeField, FileUtils.createCommandLog(command));
|
||||
}
|
||||
|
||||
return minecartInfo;
|
||||
}
|
||||
|
||||
public Node generateItemInfo(ItemStack item) {
|
||||
Node itemInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.itemInfo);
|
||||
itemInfo.addTextLine(Text.cleanName(item.getType().toString()));
|
||||
itemInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.hasMeta,item.hasItemMeta() ? Sentinel.getInstance().getDirector().io.lang.generic.yes : Sentinel.getInstance().getDirector().io.lang.generic.no);
|
||||
if (item.hasItemMeta()) {
|
||||
itemInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.hasName,item.getItemMeta().hasCustomName() ? Sentinel.getInstance().getDirector().io.lang.generic.yes : Sentinel.getInstance().getDirector().io.lang.generic.no);
|
||||
itemInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.hasLore,item.getItemMeta().hasLore() ? Sentinel.getInstance().getDirector().io.lang.generic.yes : Sentinel.getInstance().getDirector().io.lang.generic.no);
|
||||
itemInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.hasAttributes,item.getItemMeta().hasAttributeModifiers() ? Sentinel.getInstance().getDirector().io.lang.generic.yes : Sentinel.getInstance().getDirector().io.lang.generic.no);
|
||||
itemInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.hasEnchants,item.getItemMeta().hasEnchants() ? Sentinel.getInstance().getDirector().io.lang.generic.yes : Sentinel.getInstance().getDirector().io.lang.generic.no);
|
||||
itemInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.nbtStored, FileUtils.createNBTLog(item));
|
||||
}
|
||||
|
||||
return itemInfo;
|
||||
}
|
||||
|
||||
public Node generateCommandInfo(String command, Player executor) {
|
||||
Node commandInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.commandInfo);
|
||||
String name = command.split(" ")[0].substring(1);
|
||||
ServerUtils.verbose("Command Name: " + name);
|
||||
Command executed = Bukkit.getServer().getCommandMap().getCommand(name);
|
||||
|
||||
commandInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.name,name);
|
||||
if (command.length() <= 128) {
|
||||
commandInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.commandField, command);
|
||||
} else {
|
||||
commandInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.commandTooLargeField, FileUtils.createCommandLog(command));
|
||||
}
|
||||
if (executed == null || executed.getPermission() == null) return commandInfo;
|
||||
commandInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.permissionRequired,executed.getPermission());
|
||||
commandInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.permissionSatisfied,executor.hasPermission(executed.getPermission()) ? Sentinel.getInstance().getDirector().io.lang.generic.yes : Sentinel.getInstance().getDirector().io.lang.generic.no);
|
||||
|
||||
return commandInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.command;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.SerialLocation;
|
||||
import me.trouper.sentinel.data.types.CommandBlockHolder;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBlockBreak extends AbstractViolation{
|
||||
|
||||
@EventHandler
|
||||
public void onBreak(BlockBreakEvent e) {
|
||||
//ServerUtils.verbose("CommandBlockBreak: Detected the event");
|
||||
//ServerUtils.verbose("CommandBlockBreak: Changer is a player");
|
||||
Block b = e.getBlock();
|
||||
if (!(ServerUtils.isCommandBlock(b))) return;
|
||||
ServerUtils.verbose("CommandBlockBreak: Block is a command block");
|
||||
Player p = e.getPlayer();
|
||||
CommandBlock cb = (CommandBlock) b.getState();
|
||||
CommandBlockHolder holder = Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),cb);
|
||||
if (PlayerUtils.isTrusted(e.getPlayer())) {
|
||||
if (!Sentinel.getInstance().getDirector().whitelistManager.autoWhitelist.contains(p.getUniqueId())) {
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.enabled) return;
|
||||
|
||||
ServerUtils.verbose("CommandBlockBreak: is enabled, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.deop)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.brake, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.brake, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlock),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Command Block Break"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.enabled,Items.configItem("Check Toggle",Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.deop = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punish = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.commandBlockBreak.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.command;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBlockEdit extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onCMDBlockChange(EntityChangeBlockEvent e) {
|
||||
//ServerUtils.verbose("CommandBlockChange: Detected the event");
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.enabled) return;
|
||||
//ServerUtils.verbose("CommandBlockChange: Enabled");
|
||||
if (!(e.getEntity() instanceof Player p)) return;
|
||||
//ServerUtils.verbose("CommandBlockChange: Changer is a player");
|
||||
Block b = e.getBlock();
|
||||
if (!(ServerUtils.isCommandBlock(b)))
|
||||
return;
|
||||
ServerUtils.verbose("CommandBlockChange: Block is a command block");
|
||||
CommandBlock cb = (CommandBlock) b.getState();
|
||||
if (PlayerUtils.isTrusted(p)) {
|
||||
if (!Sentinel.getInstance().getDirector().whitelistManager.autoWhitelist.contains(p.getUniqueId())) return;
|
||||
Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),cb).addToWhitelist();
|
||||
return;
|
||||
}
|
||||
ServerUtils.verbose("CommandBlockChange: Not trusted, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.deop)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.edit, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.edit, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlock),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Command Block Edit"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.deop = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.punish = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.commandBlockEdit.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockEdit.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.command;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.CommandBlockHolder;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBlockPlace extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
public void listen(BlockPlaceEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
Block b = e.getBlockPlaced();
|
||||
if (!ServerUtils.isCommandBlock(b)) return;
|
||||
CommandBlock cb = (CommandBlock) b.getState();
|
||||
CommandBlockHolder holder = Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),cb);
|
||||
if (PlayerUtils.isTrusted(p)) {
|
||||
holder.addToExisting();
|
||||
if (Sentinel.getInstance().getDirector().whitelistManager.autoWhitelist.contains(p.getUniqueId())) holder.addToWhitelist();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled) {
|
||||
holder.addToExisting();
|
||||
return;
|
||||
}
|
||||
|
||||
ServerUtils.verbose("CommandBlockPlace: Enabled, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.deop)
|
||||
.cancel(true)
|
||||
.setEvent(e)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.place, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.place, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlock),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Command Block Place"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.deop = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.punish = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.commandBlockPlace.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.command;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandBlockUse extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onCMDBlockUse(PlayerInteractEvent e) {
|
||||
//ServerUtils.verbose("CommandBlockUse: Detected Interaction");
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.enabled) return;
|
||||
//ServerUtils.verbose("CommandBlockUse: Enabled");
|
||||
Player p = e.getPlayer();
|
||||
if (e.getClickedBlock() == null) return;
|
||||
//ServerUtils.verbose("CommandBlockUse: Block isn't null");
|
||||
Block b = e.getClickedBlock();
|
||||
if (!(ServerUtils.isCommandBlock(b))) return;
|
||||
CommandBlock cb = (CommandBlock) b.getState();
|
||||
if (PlayerUtils.isTrusted(p)) {
|
||||
if (!Sentinel.getInstance().getDirector().whitelistManager.autoWhitelist.contains(p.getUniqueId())) return;
|
||||
if (Sentinel.getInstance().getDirector().whitelistManager.isWhitelisted(cb)) return;
|
||||
e.setCancelled(true);
|
||||
Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(), cb).addToWhitelist();
|
||||
return;
|
||||
}
|
||||
ServerUtils.verbose("CommandBlockUse: Not trusted, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.deop)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.use, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.use, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlock),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Command Block Use"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.deop = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.punish = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.commandBlockUse.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockUse.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.jigsaw;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JigsawBlockBreak extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
public void onPlace(BlockBreakEvent e) {
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled) return;
|
||||
Player p = e.getPlayer();
|
||||
Block b = e.getBlock();
|
||||
if (b == null) return;
|
||||
if (!Material.JIGSAW.equals(b.getType())) return;
|
||||
ServerUtils.verbose("StructureBlockBreak: Block is a Structure block");
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("StructureBlockBreak: Not trusted, performing action");
|
||||
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.deop)
|
||||
.cancel(true)
|
||||
.setEvent(e)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.brake, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.jigsawBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.brake, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.jigsawBlock),
|
||||
generateBlockInfo(b),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Jigsaw Block Break"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.enabled,Items.configItem("Check Toggle",Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.deop = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.punish = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.jigsawBlockBreak.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockBreak.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.jigsaw;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JigsawBlockPlace extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
public void onPlace(BlockPlaceEvent e) {
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled) return;
|
||||
Player p = e.getPlayer();
|
||||
Block b = e.getBlockPlaced();
|
||||
if (b == null) return;
|
||||
if (!b.getType().equals(Material.JIGSAW)) return;
|
||||
ServerUtils.verbose("StructureBlockPlace: Block is a Structure block");
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("StructureBlockPlace: Not trusted, performing action");
|
||||
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.deop)
|
||||
.cancel(true)
|
||||
.setEvent(e)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.place, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.jigsawBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.place, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.jigsawBlock),
|
||||
generateBlockInfo(b),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Jigsaw Block Place"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.enabled,Items.configItem("Check Toggle",Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.deop = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.punish = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.jigsawBlockPlace.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockPlace.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.jigsaw;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JigsawBlockUse extends AbstractViolation {
|
||||
@EventHandler
|
||||
public void onPlace(PlayerInteractEvent e) {
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled) return;
|
||||
Player p = e.getPlayer();
|
||||
Block b = e.getClickedBlock();
|
||||
if (b == null) return;
|
||||
if (!Material.JIGSAW.equals(b.getType())) return;
|
||||
ServerUtils.verbose("StructureBlockUse: Block is a Structure block");
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("StructureBlockUse: Not trusted, performing action");
|
||||
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.deop)
|
||||
.cancel(true)
|
||||
.setEvent(e)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.use, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.jigsawBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.use, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.jigsawBlock),
|
||||
generateBlockInfo(b),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Jigsaw Block Use"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.enabled,Items.configItem("Check Toggle",Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.deop = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.punish = !Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.jigsawBlockUse.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.jigsawBlockUse.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.structure;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StructureBlockBreak extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
public void onPlace(BlockBreakEvent e) {
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled) return;
|
||||
Player p = e.getPlayer();
|
||||
Block b = e.getBlock();
|
||||
if (b == null) return;
|
||||
if (!Material.STRUCTURE_BLOCK.equals(b.getType())) return;
|
||||
ServerUtils.verbose("StructureBlockBreak: Block is a Structure block");
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("StructureBlockBreak: Not trusted, performing action");
|
||||
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.deop)
|
||||
.cancel(true)
|
||||
.setEvent(e)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.brake, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.structureBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.brake, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.structureBlock),
|
||||
generateBlockInfo(b),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Structure Block Break"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.enabled,Items.configItem("Check Toggle",Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.deop = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.punish = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.structureBlockBreak.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockBreak.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.structure;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StructureBlockPlace extends AbstractViolation {
|
||||
@EventHandler
|
||||
public void onPlace(BlockPlaceEvent e) {
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled) return;
|
||||
Player p = e.getPlayer();
|
||||
Block b = e.getBlockPlaced();
|
||||
if (b == null) return;
|
||||
if (!b.getType().equals(Material.STRUCTURE_BLOCK)) return;
|
||||
ServerUtils.verbose("StructureBlockPlace: Block is a Structure block");
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("StructureBlockPlace: Not trusted, performing action");
|
||||
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.deop)
|
||||
.cancel(true)
|
||||
.setEvent(e)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.place, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.structureBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.place, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.structureBlock),
|
||||
generateBlockInfo(b),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Structure Block Place"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.enabled,Items.configItem("Check Toggle",Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.deop = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.punish = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.structureBlockPlace.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockPlace.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package me.trouper.sentinel.server.events.violations.blocks.structure;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StructureBlockUse extends AbstractViolation {
|
||||
@EventHandler
|
||||
public void onPlace(PlayerInteractEvent e) {
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockPlace.enabled) return;
|
||||
Player p = e.getPlayer();
|
||||
Block b = e.getClickedBlock();
|
||||
if (b == null) return;
|
||||
if (!Material.STRUCTURE_BLOCK.equals(b.getType())) return;
|
||||
ServerUtils.verbose("StructureBlockUse: Block is a Structure block");
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
|
||||
ServerUtils.verbose("StructureBlockUse: Not trusted, performing action");
|
||||
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.deop)
|
||||
.cancel(true)
|
||||
.setEvent(e)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.use, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.structureBlock),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.use, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.structureBlock),
|
||||
generateBlockInfo(b),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Structure Block Use"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.enabled,Items.configItem("Check Toggle",Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.deop = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.punish = !Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.structureBlockUse.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.structureBlockUse.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package me.trouper.sentinel.server.events.violations.command;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DangerousCommand extends AbstractViolation {
|
||||
@EventHandler
|
||||
private void onCommand(PlayerCommandPreprocessEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
String label = e.getMessage().substring(1).split(" ")[0];
|
||||
String args = e.getMessage();
|
||||
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.commands.contains(label) && Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.enabled) {
|
||||
e.setCancelled(true);
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.deop)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.run, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.dangerousCommand),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.run, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.dangerousCommand),
|
||||
generateCommandInfo(args, p),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Dangerous Command Check"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i, Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
inv.setItem(22,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.commands,Material.CRIMSON_HANGING_SIGN,"Commands","Commands that will flag this check."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.deop = !Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.punish = !Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> {
|
||||
cfg.commandExecute.dangerous.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 22 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> {
|
||||
cfg.commandExecute.dangerous.commands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.commands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.dangerous.commands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package me.trouper.sentinel.server.events.violations.command;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LoggedCommand extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
String label = e.getMessage().substring(1).split(" ")[0];
|
||||
String args = e.getMessage();
|
||||
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.commands.contains(label) && Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.enabled) {
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setPlayer(p)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.run, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.loggedCommand),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.run, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.loggedCommand),
|
||||
generateCommandInfo(args, p),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Logged Command Check"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(11,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.logToDiscord,Items.configItem("Log to Discord",Material.OAK_LOG,"If this check will log to discord")));
|
||||
inv.setItem(15,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.commands,Material.CRIMSON_HANGING_SIGN,"Commands","Commands that will flag this check"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 11 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 15 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> {
|
||||
cfg.commandExecute.logged.commands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.commands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.logged.commands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package me.trouper.sentinel.server.events.violations.command;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class SpecificCommand extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onCommand(PlayerCommandPreprocessEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
String label = e.getMessage().substring(1).split(" ")[0];
|
||||
String args = e.getMessage();
|
||||
|
||||
if (label.contains(":") && Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.enabled) {
|
||||
e.setCancelled(true);
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.run, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.specificCommand),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.run, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.specificCommand),
|
||||
generateCommandInfo(args, p),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Specific Command Check"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack top = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.enabled) {
|
||||
top = Items.GREEN;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
inv.setItem(i,top);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(4,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(11,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"If this check will run the punishment commands")));
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(15,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.punishmentCommands,Material.DIAMOND_AXE,"Commands","Commands that will flag this check"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 4 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 11 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.punish = !Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 15 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.commandExecute.specific.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandExecute.specific.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package me.trouper.sentinel.server.events.violations.entities;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandMinecartBreak extends AbstractViolation {
|
||||
@EventHandler
|
||||
public void onBreak(EntityDamageEvent e) {
|
||||
//ServerUtils.verbose("CommandBlockBreak: Detected the event");
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.enabled) return;
|
||||
//ServerUtils.verbose("CommandBlockBreak: Changer is a player");
|
||||
if (!(e.getEntity() instanceof CommandMinecart s)) return;
|
||||
if (e.getDamageSource() == null) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (e.getDamageSource().getCausingEntity() == null) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!(e.getDamageSource().getCausingEntity() instanceof Player p)) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (PlayerUtils.isTrusted(p)) {
|
||||
if (Sentinel.getInstance().getDirector().whitelistManager.getFromExisting(s.getLocation()).isWhitelisted()) return;
|
||||
Sentinel.getInstance().getDirector().whitelistManager.getFromExisting(s.getLocation()).removeFromExisting();
|
||||
return;
|
||||
}
|
||||
ServerUtils.verbose("Not trusted, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setEntity(s)
|
||||
.setPlayer(p)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.deop)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punish)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockBreak.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.brake, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandMinecart),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.brake, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandMinecart),
|
||||
generateMinecartInfo(s),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Command Cart Break"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.deop = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.punish = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.commandBlockMinecartBreak.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartBreak.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package me.trouper.sentinel.server.events.violations.entities;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.vehicle.VehicleCreateEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class CommandMinecartPlace extends AbstractViolation {
|
||||
|
||||
private final ConcurrentHashMap<Location,UUID> queuedInteractions = new ConcurrentHashMap<>();
|
||||
|
||||
private UUID getPlayer(Location loc) {
|
||||
ServerUtils.verbose("Getting responsible player for a location");
|
||||
AtomicReference<UUID> player = new AtomicReference<>();
|
||||
|
||||
queuedInteractions.forEach((location,uuid)->{
|
||||
if (player.get() == null) {
|
||||
ServerUtils.verbose("Loop is running");
|
||||
if (loc.distance(location) < 1) {
|
||||
ServerUtils.verbose("Found a matching minecart");
|
||||
player.set(uuid);
|
||||
queuedInteractions.remove(location);
|
||||
}
|
||||
}
|
||||
});
|
||||
return player.get();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onVehicleCreate(VehicleCreateEvent e) {
|
||||
//ServerUtils.verbose("Vehicle Creation Event");
|
||||
if (!(e.getVehicle() instanceof CommandMinecart commandMinecart)) return;
|
||||
if (queuedInteractions.isEmpty()) {
|
||||
ServerUtils.verbose("Queue is empty, preventing");
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
UUID uuid = getPlayer(e.getVehicle().getLocation());
|
||||
if (uuid == null) {
|
||||
ServerUtils.verbose("UUID is null, preventing");
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Player p = Bukkit.getPlayer(uuid);
|
||||
if (p == null) {
|
||||
ServerUtils.verbose("Player is null, preventing");
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PlayerUtils.isTrusted(p)) {
|
||||
ServerUtils.verbose("Player is trusted, allowing.");
|
||||
Sentinel.getInstance().getDirector().whitelistManager.generateHolder(p.getUniqueId(),commandMinecart)
|
||||
.addToExisting();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.punish)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.deop)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.logToDiscord);
|
||||
|
||||
// Remove the command block minecart from the player's inventory
|
||||
p.getInventory().remove(Material.COMMAND_BLOCK_MINECART);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.place, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandMinecart),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.place, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandMinecart),
|
||||
generateMinecartInfo(commandMinecart),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onIneteract(PlayerInteractEvent e) {
|
||||
//ServerUtils.verbose("Player Interaction Event");
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.enabled) return;
|
||||
//ServerUtils.verbose("MinecartCommandPlace: Check is enabled");
|
||||
Player p = e.getPlayer();
|
||||
if (e.getItem() == null) return;
|
||||
//ServerUtils.verbose("MinecartCommandPlace: Item isn't null");
|
||||
if (e.getClickedBlock() == null) return;
|
||||
//ServerUtils.verbose("MinecartCommandPlace: Clicked block isn't null");
|
||||
if (!e.getItem().getType().equals(Material.COMMAND_BLOCK_MINECART)) return;
|
||||
ServerUtils.verbose("Item is a minecart command");
|
||||
if (!(e.getClickedBlock().getType() == Material.RAIL || e.getClickedBlock().getType() == Material.POWERED_RAIL || e.getClickedBlock().getType() == Material.ACTIVATOR_RAIL || e.getClickedBlock().getType() == Material.DETECTOR_RAIL)) return;
|
||||
ServerUtils.verbose("Clicked block is a rail, adding to list");
|
||||
|
||||
queuedInteractions.put(e.getClickedBlock().getLocation(),p.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Command Cart Place"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.deop = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.punish = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.commandBlockMinecartPlace.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartPlace.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package me.trouper.sentinel.server.events.violations.entities;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandMinecartUse extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onCMDBlockMinecartUse(PlayerInteractEntityEvent e) {
|
||||
//ServerUtils.verbose("MinecartCommandUse: Detected Interaction with entity");
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.enabled) return;
|
||||
//ServerUtils.verbose("MinecartCommandUse: Enabled");
|
||||
Player p = e.getPlayer();
|
||||
if (!(e.getRightClicked() instanceof CommandMinecart s)) return;
|
||||
ServerUtils.verbose("MinecartCommandUse: Entity is minecart command");
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("MinecartCommandUse: Not trusted, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.setEntity(s)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.punish)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.deop)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.use, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandMinecart),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.use, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandMinecart),
|
||||
generateMinecartInfo(s),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Command Cart Use"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.deop = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.punish = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.commandBlockMinecartUse.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockMinecartUse.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,27 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
package me.trouper.sentinel.server.events.violations.players;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import io.github.itzispyder.pdk.utils.SchedulerUtils;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.command.CommandBlockBreak;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.command.CommandBlockEdit;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.command.CommandBlockPlace;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.command.CommandBlockUse;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.jigsaw.JigsawBlockBreak;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.jigsaw.JigsawBlockPlace;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.jigsaw.JigsawBlockUse;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.structure.StructureBlockBreak;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.structure.StructureBlockPlace;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.structure.StructureBlockUse;
|
||||
import me.trouper.sentinel.server.events.violations.command.DangerousCommand;
|
||||
import me.trouper.sentinel.server.events.violations.command.LoggedCommand;
|
||||
import me.trouper.sentinel.server.events.violations.command.SpecificCommand;
|
||||
import me.trouper.sentinel.server.events.violations.entities.CommandMinecartBreak;
|
||||
import me.trouper.sentinel.server.events.violations.entities.CommandMinecartPlace;
|
||||
import me.trouper.sentinel.server.events.violations.entities.CommandMinecartUse;
|
||||
import me.trouper.sentinel.server.events.violations.whitelist.CommandBlockExecute;
|
||||
import me.trouper.sentinel.server.events.violations.whitelist.CommandMinecartExecute;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.profanity.ProfanityFilter;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.spam.SpamFilter;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.unicode.UnicodeFilter;
|
||||
@@ -13,10 +31,6 @@ import me.trouper.sentinel.server.gui.config.chat.ProfanityFilterGUI;
|
||||
import me.trouper.sentinel.server.gui.config.chat.SpamFilterGUI;
|
||||
import me.trouper.sentinel.server.gui.config.chat.UnicodeFilterGUI;
|
||||
import me.trouper.sentinel.server.gui.config.chat.UrlFilterGUI;
|
||||
import me.trouper.sentinel.server.gui.config.nuke.checks.*;
|
||||
import me.trouper.sentinel.server.gui.config.nuke.checks.command.DangerousCMDGUI;
|
||||
import me.trouper.sentinel.server.gui.config.nuke.checks.command.LoggedCMDGUI;
|
||||
import me.trouper.sentinel.server.gui.config.nuke.checks.command.SpecificCMDGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -45,15 +59,25 @@ public class ChatEvent implements CustomListener {
|
||||
UrlFilterGUI.updater.invokeCallbacks(e);
|
||||
ProfanityFilterGUI.updater.invokeCallbacks(e);
|
||||
SpamFilterGUI.updater.invokeCallbacks(e);
|
||||
DangerousCMDGUI.updater.invokeCallbacks(e);
|
||||
LoggedCMDGUI.updater.invokeCallbacks(e);
|
||||
SpecificCMDGUI.updater.invokeCallbacks(e);
|
||||
CBEditGUI.updater.invokeCallbacks(e);
|
||||
CBMCPlaceGUI.updater.invokeCallbacks(e);
|
||||
CBMCUseGUI.updater.invokeCallbacks(e);
|
||||
CBPlaceGUI.updater.invokeCallbacks(e);
|
||||
CBUseGUI.updater.invokeCallbacks(e);
|
||||
HotbarActionGUI.updater.invokeCallbacks(e);
|
||||
DangerousCommand.updater.invokeCallbacks(e);
|
||||
LoggedCommand.updater.invokeCallbacks(e);
|
||||
SpecificCommand.updater.invokeCallbacks(e);
|
||||
CommandBlockBreak.updater.invokeCallbacks(e);
|
||||
CommandBlockEdit.updater.invokeCallbacks(e);
|
||||
CommandBlockPlace.updater.invokeCallbacks(e);
|
||||
CommandBlockUse.updater.invokeCallbacks(e);
|
||||
JigsawBlockBreak.updater.invokeCallbacks(e);
|
||||
JigsawBlockPlace.updater.invokeCallbacks(e);
|
||||
JigsawBlockUse.updater.invokeCallbacks(e);
|
||||
StructureBlockBreak.updater.invokeCallbacks(e);
|
||||
StructureBlockPlace.updater.invokeCallbacks(e);
|
||||
StructureBlockUse.updater.invokeCallbacks(e);
|
||||
CommandMinecartBreak.updater.invokeCallbacks(e);
|
||||
CommandMinecartPlace.updater.invokeCallbacks(e);
|
||||
CommandMinecartUse.updater.invokeCallbacks(e);
|
||||
CommandBlockExecute.updater.invokeCallbacks(e);
|
||||
CommandMinecartExecute.updater.invokeCallbacks(e);
|
||||
CreativeHotbar.updater.invokeCallbacks(e);
|
||||
});
|
||||
}
|
||||
return;
|
||||
@@ -65,7 +89,7 @@ public class ChatEvent implements CustomListener {
|
||||
|
||||
handle(p,
|
||||
"sentinel.chatfilter.unicode.bypass",
|
||||
Sentinel.mainConfig.chat.unicodeFilter.enabled, "unicode",
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.enabled, "unicode",
|
||||
e,
|
||||
UnicodeFilter::handleUnicodeFilter);
|
||||
|
||||
@@ -73,7 +97,7 @@ public class ChatEvent implements CustomListener {
|
||||
|
||||
handle(p,
|
||||
"sentinel.chatfilter.url.bypass",
|
||||
Sentinel.mainConfig.chat.urlFilter.enabled, "url",
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.urlFilter.enabled, "url",
|
||||
e,
|
||||
UrlFilter::handleUrlFilter);
|
||||
|
||||
@@ -81,7 +105,7 @@ public class ChatEvent implements CustomListener {
|
||||
|
||||
handle(p,
|
||||
"sentinel.chatfilter.spam.bypass",
|
||||
Sentinel.mainConfig.chat.spamFilter.enabled,
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.enabled,
|
||||
"spam",
|
||||
e,
|
||||
SpamFilter::handleSpamFilter);
|
||||
@@ -90,7 +114,7 @@ public class ChatEvent implements CustomListener {
|
||||
|
||||
handle(p,
|
||||
"sentinel.chatfilter.swear.bypass",
|
||||
Sentinel.mainConfig.chat.profanityFilter.enabled,
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.enabled,
|
||||
"swear",
|
||||
e,
|
||||
ProfanityFilter::handleProfanityFilter);
|
||||
@@ -0,0 +1,141 @@
|
||||
package me.trouper.sentinel.server.events.violations.players;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.functions.itemchecks.ItemCheck;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCreativeEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CreativeHotbar extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void onNBTPull(InventoryCreativeEvent e) {
|
||||
//ServerUtils.verbose("NBT: Detected creative mode action");
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.enabled) return;
|
||||
ServerUtils.verbose("NBT: Enabled");
|
||||
if (!(e.getWhoClicked() instanceof Player p)) return;
|
||||
ServerUtils.verbose("NBT: Clicker is a player");
|
||||
if (e.getCursor() == null) return; // Well it threw an exception during testing, so it isn't always false!
|
||||
ServerUtils.verbose("NBT: Cursor isn't null");
|
||||
ItemStack i = e.getCursor();
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
ServerUtils.verbose("NBT: Not trusted");
|
||||
if (e.getCursor().getItemMeta() == null) return;
|
||||
ServerUtils.verbose("NBT: Cursor has meta");
|
||||
if (!(i.hasItemMeta() && i.getItemMeta() != null)) return;
|
||||
ServerUtils.verbose("NBT: Item has meta");
|
||||
if (new ItemCheck().passes(i)) return;
|
||||
ServerUtils.verbose("NBT: Item doesn't pass, performing action");
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setPlayer(p)
|
||||
.cancel(true)
|
||||
.punish(Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.punish)
|
||||
.deop(Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.deop)
|
||||
.setPunishmentCommands(Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.punishmentCommands)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.logToDiscord);
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.grab, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.nbtItem),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormatPlayer.formatted(p.getName(), Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.grab, Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.nbtItem),
|
||||
generateItemInfo(i),
|
||||
config
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Creative Hotbar Check"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i, Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack ring = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.enabled) {
|
||||
ring = Items.GREEN;
|
||||
}
|
||||
|
||||
List<Integer> ringList = List.of(3,4,5,12,14,21,22,23);
|
||||
|
||||
for (Integer i : ringList) {
|
||||
inv.setItem(i,ring);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(2,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.deop,Items.configItem("De-Op",Material.END_CRYSTAL,"Remove the user's operator privileges")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(6,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.punish,Items.configItem("Punish",Material.REDSTONE_TORCH,"Run the punishment commands")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.punishmentCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands that will be ran \nif this check is flagged."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
|
||||
switch (e.getSlot()) {
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 2 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.deop = !Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.deop;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 20 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 6 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.punish = !Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.punish;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg, args) -> {
|
||||
cfg.creativeHotbarAction.punishmentCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.punishmentCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.creativeHotbarAction.punishmentCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
package me.trouper.sentinel.server.events.violations.players;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -13,7 +12,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PluginCloakingEvent implements CustomListener {
|
||||
public class PluginCloakingEvents implements CustomListener {
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
@@ -23,7 +22,7 @@ public class PluginCloakingEvent implements CustomListener {
|
||||
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent e) {
|
||||
if (!Sentinel.mainConfig.plugin.pluginHider) return;
|
||||
if (!Sentinel.getInstance().getDirector().io.mainConfig.plugin.pluginHider) return;
|
||||
Player p = e.getPlayer();
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
|
||||
@@ -33,16 +32,16 @@ public class PluginCloakingEvent implements CustomListener {
|
||||
message = message.substring(1);
|
||||
}
|
||||
|
||||
for (String alias : Sentinel.advConfig.commandsWithPluginAccess) {
|
||||
for (String alias : Sentinel.getInstance().getDirector().io.advConfig.commandsWithPluginAccess) {
|
||||
if (!message.startsWith(alias)) continue;
|
||||
e.setCancelled(true);
|
||||
p.sendMessage(Text.color(Sentinel.lang.permissions.noPlugins));
|
||||
p.sendMessage(Text.color(Sentinel.getInstance().getDirector().io.lang.permissions.noPlugins));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(PlayerCommandSendEvent e) {
|
||||
if (!Sentinel.mainConfig.plugin.pluginHider) return;
|
||||
if (!Sentinel.getInstance().getDirector().io.mainConfig.plugin.pluginHider) return;
|
||||
Player p = e.getPlayer();
|
||||
if (PlayerUtils.isTrusted(p)) return;
|
||||
|
||||
@@ -52,15 +51,15 @@ public class PluginCloakingEvent implements CustomListener {
|
||||
e.getCommands().remove(command);
|
||||
continue;
|
||||
}
|
||||
if (Sentinel.advConfig.commandsWithPluginAccess.contains(command)) {
|
||||
if (Sentinel.getInstance().getDirector().io.advConfig.commandsWithPluginAccess.contains(command)) {
|
||||
e.getCommands().remove(command);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ServerUtils.verbose("Removed all the plugin specific commands form the listing. It now contains %s".formatted(e.getCommands().stream().toList().toString()));
|
||||
for (String fakePlugin : Sentinel.advConfig.fakePlugins) {
|
||||
//ServerUtils.verbose("Removed all the plugin specific commands form the listing. It now contains %s".formatted(e.getCommands().stream().toList().toString()));
|
||||
for (String fakePlugin : Sentinel.getInstance().getDirector().io.advConfig.fakePlugins) {
|
||||
e.getCommands().add(fakePlugin + ":" + fakePlugin);
|
||||
}
|
||||
ServerUtils.verbose("Added the fake plugins, now it contains this: %s".formatted(e.getCommands().stream().toList().toString()));
|
||||
//ServerUtils.verbose("Added the fake plugins, now it contains this: %s".formatted(e.getCommands().stream().toList().toString()));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package me.trouper.sentinel.server.events;
|
||||
package me.trouper.sentinel.server.events.violations.players;
|
||||
|
||||
import com.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
import com.github.retrooper.packetevents.event.PacketListenerPriority;
|
||||
@@ -29,7 +29,7 @@ public class PluginCloakingPacket extends PacketListenerAbstract {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (!Sentinel.mainConfig.plugin.pluginHider) return;
|
||||
if (!Sentinel.getInstance().getDirector().io.mainConfig.plugin.pluginHider) return;
|
||||
if (event.getPacketType() != PacketType.Play.Client.TAB_COMPLETE) return;
|
||||
|
||||
WrapperPlayClientTabComplete wrapper = new WrapperPlayClientTabComplete(event);
|
||||
@@ -38,7 +38,7 @@ public class PluginCloakingPacket extends PacketListenerAbstract {
|
||||
if (PlayerUtils.isTrusted(player)) return;
|
||||
|
||||
String text = wrapper.getText();
|
||||
for (String versionAlias : Sentinel.advConfig.pluginTabCompletions) {
|
||||
for (String versionAlias : Sentinel.getInstance().getDirector().io.advConfig.pluginTabCompletions) {
|
||||
if (!text.contains(versionAlias)) continue;
|
||||
ServerUtils.verbose("Caught a version command tab completion. (%s -> %s)".formatted(text,versionAlias));
|
||||
tabReplaceQueue.add(player.getUniqueId());
|
||||
@@ -50,7 +50,7 @@ public class PluginCloakingPacket extends PacketListenerAbstract {
|
||||
|
||||
@Override
|
||||
public void onPacketSend(PacketSendEvent event) {
|
||||
if (!Sentinel.mainConfig.plugin.pluginHider) return;
|
||||
if (!Sentinel.getInstance().getDirector().io.mainConfig.plugin.pluginHider) return;
|
||||
|
||||
Player player = (Player) event.getPlayer();
|
||||
if (player == null) return;
|
||||
@@ -63,7 +63,7 @@ public class PluginCloakingPacket extends PacketListenerAbstract {
|
||||
ServerUtils.verbose("Player was queued for replacement, setting tab completions.");
|
||||
WrapperPlayServerTabComplete wrapper = new WrapperPlayServerTabComplete(event);
|
||||
List<WrapperPlayServerTabComplete.CommandMatch> matches = new ArrayList<>();
|
||||
for (String fakePlugin : Sentinel.advConfig.fakePlugins) {
|
||||
for (String fakePlugin : Sentinel.getInstance().getDirector().io.advConfig.fakePlugins) {
|
||||
matches.add(new WrapperPlayServerTabComplete.CommandMatch(fakePlugin));
|
||||
}
|
||||
wrapper.setCommandMatches(matches);
|
||||
@@ -0,0 +1,155 @@
|
||||
package me.trouper.sentinel.server.events.violations.whitelist;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CommandBlockExecute extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
private void commandBlockExecute(ServerCommandEvent e) {
|
||||
//ServerUtils.verbose("Handling command block event: " + e.getCommand());
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.enabled) return;
|
||||
//ServerUtils.verbose("Whitelist not disabled");
|
||||
if (!(e.getSender() instanceof BlockCommandSender s)) return;
|
||||
//ServerUtils.verbose("Sender is command block");
|
||||
|
||||
Block block = s.getBlock();
|
||||
CommandBlock cb = (CommandBlock) block.getState();
|
||||
|
||||
String label = cb.getCommand();
|
||||
ServerUtils.verbose("Command block is set to %s.".formatted(label));
|
||||
label = label.split(" ")[0];
|
||||
if (label.startsWith("/")) label = label.substring(1);
|
||||
ServerUtils.verbose("It's label is %s.".formatted(label));
|
||||
|
||||
boolean isRestricted = Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.disabledCommands.contains(label);
|
||||
boolean canRun = Sentinel.getInstance().getDirector().whitelistManager.isWhitelisted(cb);
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setBlock(block)
|
||||
.cancel(true)
|
||||
.destroyBlock(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.destroyBlock)
|
||||
.restoreBlock(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.attemptRestore)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.logToDiscord);
|
||||
|
||||
if (isRestricted) {
|
||||
ServerUtils.verbose("Command block is using a restricted command.");
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormat.formatted(Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlockRestriction),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormat.formatted( Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlockRestriction),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
} else if (!canRun) {
|
||||
ServerUtils.verbose("Command block can't run.");
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormat.formatted(Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlockWhitelist),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormat.formatted(Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlockWhitelist),
|
||||
generateCommandBlockInfo(cb),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Command Block Whitelist"))
|
||||
.size(27)
|
||||
.onDefine(this::getMainPage)
|
||||
.defineMain(this::onClick)
|
||||
.define(26, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
|
||||
ItemStack top = Items.RED;
|
||||
if (Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.enabled) {
|
||||
top = Items.GREEN;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
inv.setItem(i,top);
|
||||
}
|
||||
|
||||
inv.setItem(26,Items.BACK);
|
||||
inv.setItem(4,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.enabled,Items.configItem("Check Toggle", Material.CLOCK,"Enable/Disable this check entirely")));
|
||||
inv.setItem(11,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.destroyBlock,Items.configItem("Destroy",Material.NETHERITE_PICKAXE,"Destroy the offending command-block")));
|
||||
inv.setItem(12,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.destroyCart,Items.configItem("Destroy",Material.TNT_MINECART,"Destroy the offending command-cart")));
|
||||
inv.setItem(13,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.attemptRestore,Items.configItem("Restore",Material.COMMAND_BLOCK,"Attempt to restore the block if a \nwhitelisted one exists at the location")));
|
||||
inv.setItem(14,Items.booleanItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.logToDiscord,Items.configItem("Log",Material.OAK_LOG,"If this check will produce a log to discord")));
|
||||
inv.setItem(15,Items.stringListItem(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.disabledCommands,Material.CRIMSON_HANGING_SIGN,"Commands","Commands no command blocks can run. \nWorks even if whitelist is disabled. \nYou must add plugin specific versions yourself."));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
e.setCancelled(true);
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 4 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.enabled = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.enabled;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 11 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.destroyBlock = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.destroyBlock;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 12 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.destroyCart = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.destroyCart;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 13 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.attemptRestore = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.attemptRestore;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 14 -> {
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.logToDiscord = !Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.logToDiscord;
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
case 15 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> {
|
||||
cfg.commandBlockWhitelist.disabledCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.disabledCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.disabledCommands.clear();
|
||||
getMainPage(e.getInventory());
|
||||
Sentinel.getInstance().getDirector().io.violationConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package me.trouper.sentinel.server.events.violations.whitelist;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.events.violations.AbstractViolation;
|
||||
import me.trouper.sentinel.server.functions.helpers.ActionConfiguration;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class CommandMinecartExecute extends AbstractViolation {
|
||||
|
||||
@EventHandler
|
||||
public void onExecute(ServerCommandEvent e) {
|
||||
//ServerUtils.verbose("Handling command block event: " + e.getCommand());
|
||||
if (!Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.enabled) return;
|
||||
//ServerUtils.verbose("Whitelist not disabled");
|
||||
if (!(e.getSender() instanceof CommandMinecart s)) return;
|
||||
//ServerUtils.verbose("Sender is command block");
|
||||
|
||||
|
||||
String label = s.getCommand();
|
||||
ServerUtils.verbose("Command block is set to %s.".formatted(label));
|
||||
label = label.split(" ")[0];
|
||||
if (label.startsWith("/")) label = label.substring(1);
|
||||
ServerUtils.verbose("It's label is %s.".formatted(label));
|
||||
|
||||
boolean isRestricted = Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.disabledCommands.contains(label);
|
||||
boolean canRun = Sentinel.getInstance().getDirector().whitelistManager.isWhitelisted(s);
|
||||
|
||||
ActionConfiguration.Builder config = new ActionConfiguration.Builder()
|
||||
.setEvent(e)
|
||||
.setEntity(s)
|
||||
.cancel(true)
|
||||
.removeEntity(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.destroyCart)
|
||||
.logToDiscord(Sentinel.getInstance().getDirector().io.violationConfig.commandBlockWhitelist.logToDiscord);
|
||||
|
||||
if (isRestricted) {
|
||||
ServerUtils.verbose("Command cart is using a restricted command.");
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormat.formatted(Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlockRestriction),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormat.formatted( Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlockRestriction),
|
||||
generateMinecartInfo(s),
|
||||
config
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canRun) {
|
||||
ServerUtils.verbose("Command cart can't run.");
|
||||
|
||||
runActions(
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormat.formatted(Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlockWhitelist),
|
||||
Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.rootNameFormat.formatted(Sentinel.getInstance().getDirector().io.lang.violations.protections.rootName.commandBlockWhitelist),
|
||||
generateMinecartInfo(s),
|
||||
config
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomGui getConfigGui() {
|
||||
return new CommandBlockExecute().getConfigGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMainPage(Inventory inv) {
|
||||
new CommandBlockExecute().getMainPage(inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
new CommandBlockExecute().onClick(e);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package me.trouper.sentinel.server.functions.chatfilter;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.discord.DiscordEmbed;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.FalsePositiveReporting;
|
||||
import me.trouper.sentinel.server.functions.helpers.FilterHelpers;
|
||||
import me.trouper.sentinel.utils.trees.ConsoleFormatter;
|
||||
import me.trouper.sentinel.utils.trees.EmbedFormatter;
|
||||
import me.trouper.sentinel.utils.trees.Node;
|
||||
@@ -11,11 +10,11 @@ import me.trouper.sentinel.utils.trees.Node;
|
||||
public abstract class AbstractActionHandler<T extends FilterResponse> {
|
||||
|
||||
public void run(T response) {
|
||||
FalsePositiveReporting.reports.put(response.getReport().getId(), response.getReport());
|
||||
Sentinel.getInstance().getDirector().reportHandler.reports.put(response.getReport().getId(), response.getReport());
|
||||
Node tree = buildTree(response);
|
||||
|
||||
if (response.isBlocked()) {
|
||||
FilterHelpers.restrictMessage(response.getEvent(),!shouldWarnPlayer(response));
|
||||
restrictMessage(response.getEvent(),!shouldWarnPlayer(response));
|
||||
}
|
||||
if (response.isPunished()) {
|
||||
punish(response);
|
||||
@@ -36,11 +35,20 @@ public abstract class AbstractActionHandler<T extends FilterResponse> {
|
||||
protected abstract boolean shouldWarnPlayer(T response);
|
||||
|
||||
protected void consoleLog(Node tree) {
|
||||
Sentinel.log.info(ConsoleFormatter.format(tree));
|
||||
Sentinel.getInstance().getLogger().info(ConsoleFormatter.format(tree));
|
||||
}
|
||||
|
||||
protected void discordNotification(Node tree) {
|
||||
DiscordEmbed embed = EmbedFormatter.format(tree);
|
||||
EmbedFormatter.sendEmbed(embed);
|
||||
}
|
||||
|
||||
protected void restrictMessage(AsyncChatEvent event, boolean silent) {
|
||||
if (silent) {
|
||||
event.viewers().clear();
|
||||
event.viewers().add(event.getPlayer());
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.trouper.sentinel.server.functions.chatfilter.profanity;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.AbstractActionHandler;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import me.trouper.sentinel.utils.trees.HoverFormatter;
|
||||
@@ -14,11 +15,11 @@ public class ProfanityAction extends AbstractActionHandler<ProfanityResponse> {
|
||||
@Override
|
||||
public void punish(ProfanityResponse response) {
|
||||
if (response.getSeverity().equals(Severity.SLUR)) {
|
||||
for (String slurCommand : Sentinel.mainConfig.chat.profanityFilter.strictPunishCommands) {
|
||||
for (String slurCommand : Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.strictPunishCommands) {
|
||||
ServerUtils.sendCommand(slurCommand.replaceAll("%player%", response.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
for (String swearCommand : Sentinel.mainConfig.chat.profanityFilter.profanityPunishCommands) {
|
||||
for (String swearCommand : Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.profanityPunishCommands) {
|
||||
ServerUtils.sendCommand(swearCommand.replaceAll("%player%", response.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
@@ -27,21 +28,21 @@ public class ProfanityAction extends AbstractActionHandler<ProfanityResponse> {
|
||||
public void staffWarning(ProfanityResponse response, Node tree) {
|
||||
String messageText = Text.prefix("&b&n%s&r &7%s &8(&4%s&7/&c%s&8)".formatted(
|
||||
response.getPlayer().getName(),
|
||||
response.isPunished() ? Sentinel.lang.violations.chat.profanity.autoPunishNotification : Sentinel.lang.violations.chat.profanity.preventNotification,
|
||||
response.isPunished() ? Sentinel.getInstance().getDirector().io.lang.violations.chat.profanity.autoPunishNotification : Sentinel.getInstance().getDirector().io.lang.violations.chat.profanity.preventNotification,
|
||||
ProfanityFilter.scoreMap.getOrDefault(response.getPlayer().getUniqueId(), 0),
|
||||
Sentinel.mainConfig.chat.profanityFilter.punishScore
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.punishScore
|
||||
));
|
||||
String hoverText = HoverFormatter.format(tree);
|
||||
|
||||
ServerUtils.forEachPlayer(player -> {
|
||||
PlayerUtils.forEachPlayer(player -> {
|
||||
if (player.hasPermission("sentinel.chatfilter.profanity.view")) player.sendMessage(Component.text(messageText).hoverEvent(Component.text(hoverText).asHoverEvent()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerWarning(ProfanityResponse response) {
|
||||
String message = Text.prefix(response.isPunished() ? Sentinel.lang.violations.chat.profanity.autoPunishWarning : Sentinel.lang.violations.chat.profanity.preventWarning);
|
||||
String hoverText = Sentinel.lang.automatedActions.reportable;
|
||||
String message = Text.prefix(response.isPunished() ? Sentinel.getInstance().getDirector().io.lang.violations.chat.profanity.autoPunishWarning : Sentinel.getInstance().getDirector().io.lang.violations.chat.profanity.preventWarning);
|
||||
String hoverText = Sentinel.getInstance().getDirector().io.lang.automatedActions.reportable;
|
||||
String command = "/sentinelcallback fpreport %s".formatted(response.getReport().getId());
|
||||
response.getPlayer().sendMessage(Component.text(message)
|
||||
.hoverEvent(Component.text(hoverText).asHoverEvent())
|
||||
@@ -51,22 +52,22 @@ public class ProfanityAction extends AbstractActionHandler<ProfanityResponse> {
|
||||
@Override
|
||||
public Node buildTree(ProfanityResponse response) {
|
||||
Node root = new Node("Sentinel");
|
||||
root.addTextLine(Sentinel.lang.violations.chat.profanity.treeTitle);
|
||||
root.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.chat.profanity.treeTitle);
|
||||
|
||||
Node playerInfo = new Node(Sentinel.lang.violations.protections.infoNode.playerInfo.formatted(response.getPlayer().getName()));
|
||||
playerInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.uuid, response.getPlayer().getUniqueId().toString());
|
||||
playerInfo.addKeyValue(Sentinel.lang.violations.chat.profanity.score, "%s/%s".formatted(ProfanityFilter.scoreMap.getOrDefault(response.getPlayer().getUniqueId(),0),Sentinel.mainConfig.chat.profanityFilter.punishScore));
|
||||
Node playerInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.playerInfo.formatted(response.getPlayer().getName()));
|
||||
playerInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.uuid, response.getPlayer().getUniqueId().toString());
|
||||
playerInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.chat.profanity.score, "%s/%s".formatted(ProfanityFilter.scoreMap.getOrDefault(response.getPlayer().getUniqueId(),0),Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.punishScore));
|
||||
root.addChild(playerInfo);
|
||||
|
||||
Node reportInfo = new Node(Sentinel.lang.violations.chat.profanity.reportInfoTitle);
|
||||
reportInfo.addField(Sentinel.lang.violations.chat.originalMessage, response.getOriginalMessage());
|
||||
reportInfo.addField(Sentinel.lang.violations.chat.profanity.processedMessage, response.getProcessedMessage());
|
||||
reportInfo.addKeyValue(Sentinel.lang.violations.chat.profanity.severity, response.getSeverity().toString());
|
||||
Node reportInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.chat.profanity.reportInfoTitle);
|
||||
reportInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.chat.originalMessage, response.getOriginalMessage());
|
||||
reportInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.chat.profanity.processedMessage, response.getProcessedMessage());
|
||||
reportInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.chat.profanity.severity, response.getSeverity().toString());
|
||||
root.addChild(reportInfo);
|
||||
|
||||
Node actions = new Node(Sentinel.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
actions.addTextLine(Sentinel.lang.violations.chat.denyMessage);
|
||||
if (response.isPunished()) actions.addTextLine(Sentinel.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
Node actions = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
actions.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.chat.denyMessage);
|
||||
if (response.isPunished()) actions.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
root.addChild(actions);
|
||||
|
||||
return root;
|
||||
@@ -74,6 +75,6 @@ public class ProfanityAction extends AbstractActionHandler<ProfanityResponse> {
|
||||
|
||||
@Override
|
||||
protected boolean shouldWarnPlayer(ProfanityResponse response) {
|
||||
return !Sentinel.mainConfig.chat.profanityFilter.silent;
|
||||
return !Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.silent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ProfanityFilter {
|
||||
ServerUtils.verbose("Anti Profanity Opening: Event is canceled.");
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
ProfanityResponse response = ProfanityResponse.generate(event);
|
||||
ProfanityResponse response = new ProfanityResponse(null,null,null,null,null,false,false).generate(event);
|
||||
Severity severity = response.getSeverity();
|
||||
ServerUtils.verbose("Response came back.");
|
||||
if (severity == null) return;
|
||||
@@ -33,7 +33,7 @@ public class ProfanityFilter {
|
||||
int newScore = previousScore + severity.getScore();
|
||||
scoreMap.put(player.getUniqueId(), newScore);
|
||||
|
||||
if (newScore > Sentinel.mainConfig.chat.profanityFilter.punishScore || Severity.SLUR.equals(severity)) {
|
||||
if (newScore > Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.punishScore || Severity.SLUR.equals(severity)) {
|
||||
response.setPunished(true);
|
||||
new ProfanityAction().run(response);
|
||||
return;
|
||||
@@ -46,7 +46,7 @@ public class ProfanityFilter {
|
||||
for (UUID uuid : scoreMap.keySet()) {
|
||||
int score = scoreMap.get(uuid);
|
||||
if (score > 0) {
|
||||
score = score - Sentinel.mainConfig.chat.profanityFilter.scoreDecay;
|
||||
score = score - Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.scoreDecay;
|
||||
scoreMap.put(uuid, Math.max(0, score));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package me.trouper.sentinel.server.functions.chatfilter.profanity;
|
||||
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.data.Emojis;
|
||||
import me.trouper.sentinel.server.functions.helpers.FalsePositiveReporting;
|
||||
import me.trouper.sentinel.server.functions.helpers.FilterHelpers;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.Emojis;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.FilterResponse;
|
||||
import me.trouper.sentinel.server.functions.helpers.Report;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
@@ -11,6 +10,9 @@ import me.trouper.sentinel.utils.Text;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ProfanityResponse implements FilterResponse {
|
||||
|
||||
private AsyncChatEvent event;
|
||||
@@ -98,7 +100,7 @@ public class ProfanityResponse implements FilterResponse {
|
||||
}
|
||||
|
||||
String message = LegacyComponentSerializer.legacySection().serialize(e.message());
|
||||
Report report = FalsePositiveReporting.initializeReport(message);
|
||||
Report report = Sentinel.getInstance().getDirector().reportHandler.initializeReport(message);
|
||||
Severity severity = Severity.SAFE;
|
||||
|
||||
ProfanityResponse response = new ProfanityResponse(e,message,null,report,severity,false,false);
|
||||
@@ -109,77 +111,78 @@ public class ProfanityResponse implements FilterResponse {
|
||||
// 1:
|
||||
String lowercasedText = text.toLowerCase();
|
||||
response.getReport().getStepsTaken().put("Lowercased", lowercasedText);
|
||||
response.setProcessedMessage(FilterHelpers.highlightProfanity(lowercasedText,"<hs>", "<he>"));
|
||||
response.setProcessedMessage(highlightProfanity(lowercasedText,"<hs>", "<he>"));
|
||||
ServerUtils.verbose("ProfanityFilter: Lowercased: " + lowercasedText);
|
||||
|
||||
|
||||
// 2:
|
||||
String cleanedText = FilterHelpers.removeFalsePositives(lowercasedText);
|
||||
String cleanedText = removeFalsePositives(lowercasedText);
|
||||
response.getReport().getStepsTaken().put("Remove False Positives", cleanedText);
|
||||
response.setProcessedMessage(FilterHelpers.highlightProfanity(cleanedText,"<hs>", "<he>"));
|
||||
response.setProcessedMessage(highlightProfanity(cleanedText,"<hs>", "<he>"));
|
||||
ServerUtils.verbose(("ProfanityFilter: Removed False positives: " + cleanedText));
|
||||
|
||||
response.setSeverity(FilterHelpers.checkSlur(cleanedText, Severity.LOW));
|
||||
response.setSeverity(checkProfanity(cleanedText, Severity.LOW));
|
||||
if (response.getSeverity() != Severity.SAFE) {
|
||||
response.getReport().getStepsTaken().replace("Remove False Positives", "%s %s".formatted(
|
||||
FilterHelpers.highlightProfanity(cleanedText,"||","||"),
|
||||
highlightProfanity(cleanedText,"||","||"),
|
||||
Emojis.alarm));
|
||||
return response;
|
||||
}
|
||||
|
||||
// 4:
|
||||
String convertedText = FilterHelpers.convertLeetSpeakCharacters(cleanedText);
|
||||
String convertedText = convertLeetSpeakCharacters(cleanedText);
|
||||
response.getReport().getStepsTaken().put("Convert LeetSpeak", convertedText);
|
||||
response.setProcessedMessage(FilterHelpers.highlightProfanity(convertedText,"<hs>", "<he>"));
|
||||
response.setProcessedMessage(highlightProfanity(convertedText,"<hs>", "<he>"));
|
||||
ServerUtils.verbose(("ProfanityFilter: Leet Converted: " + convertedText));
|
||||
|
||||
response.setSeverity(FilterHelpers.checkSlur(convertedText, Severity.MEDIUM_LOW));
|
||||
response.setSeverity(checkProfanity(convertedText, Severity.MEDIUM_LOW));
|
||||
if (response.getSeverity() != Severity.SAFE) {
|
||||
response.getReport().getStepsTaken().replace("Convert LeetSpeak", "%s %s".formatted(
|
||||
FilterHelpers.highlightProfanity(cleanedText,"||","||"),
|
||||
highlightProfanity(cleanedText,"||","||"),
|
||||
Emojis.alarm));
|
||||
return response;
|
||||
}
|
||||
|
||||
// 6:
|
||||
String strippedText = FilterHelpers.stripSpecialCharacters(convertedText);
|
||||
String strippedText = stripSpecialCharacters(convertedText);
|
||||
response.getReport().getStepsTaken().put("Remove Special Characters", strippedText);
|
||||
response.setProcessedMessage(FilterHelpers.highlightProfanity(strippedText,"<hs>", "<he>"));
|
||||
response.setProcessedMessage(highlightProfanity(strippedText,"<hs>", "<he>"));
|
||||
ServerUtils.verbose(("ProfanityFilter: Specials Removed: " + strippedText));
|
||||
|
||||
response.setSeverity(FilterHelpers.checkSlur(strippedText, Severity.MEDIUM));
|
||||
response.setSeverity(checkProfanity(strippedText, Severity.MEDIUM));
|
||||
if (response.getSeverity() != Severity.SAFE) {
|
||||
response.getReport().getStepsTaken().replace("Remove Special Characters", "%s %s".formatted(
|
||||
FilterHelpers.highlightProfanity(cleanedText,"||","||"),
|
||||
highlightProfanity(cleanedText,"||","||"),
|
||||
Emojis.alarm));
|
||||
return response;
|
||||
}
|
||||
|
||||
// 8:
|
||||
String simplifiedText = FilterHelpers.simplifyRepeatingLetters(strippedText);
|
||||
String simplifiedText = simplifyRepeatingLetters(strippedText);
|
||||
response.getReport().getStepsTaken().put("Remove Repeats", simplifiedText);
|
||||
response.setProcessedMessage(FilterHelpers.highlightProfanity(simplifiedText,"<hs>", "<he>"));
|
||||
response.setProcessedMessage(highlightProfanity(simplifiedText,"<hs>", "<he>"));
|
||||
ServerUtils.verbose(("ProfanityFilter: Removed Repeating: " + simplifiedText));
|
||||
|
||||
response.setSeverity(FilterHelpers.checkSlur(simplifiedText, Severity.MEDIUM_HIGH));
|
||||
response.setSeverity(checkProfanity(simplifiedText, Severity.MEDIUM_HIGH));
|
||||
if (response.getSeverity() != Severity.SAFE) {
|
||||
response.getReport().getStepsTaken().replace("Remove Repeats", "%s %s".formatted(
|
||||
FilterHelpers.highlightProfanity(cleanedText,"||","||"),
|
||||
highlightProfanity(cleanedText,"||","||"),
|
||||
Emojis.alarm));
|
||||
return response;
|
||||
}
|
||||
|
||||
// 10:
|
||||
String finalText = FilterHelpers.removePeriodsAndSpaces(simplifiedText);
|
||||
String finalText = removePeriodsAndSpaces(simplifiedText);
|
||||
response.getReport().getStepsTaken().put("Remove Punctuation", finalText);
|
||||
response.setProcessedMessage(FilterHelpers.highlightProfanity(finalText,"<hs>", "<he>"));
|
||||
response.setProcessedMessage(highlightProfanity(finalText,"<hs>", "<he>"));
|
||||
ServerUtils.verbose(("ProfanityFilter: Remove Punctuation: " + finalText));
|
||||
|
||||
response.setSeverity(FilterHelpers.checkSlur(finalText, Severity.HIGH));
|
||||
response.setSeverity(checkProfanity(finalText, Severity.HIGH));
|
||||
if (response.getSeverity() != Severity.SAFE) {
|
||||
response.getReport().getStepsTaken().replace("Remove Punctuation", "%s %s".formatted(
|
||||
FilterHelpers.highlightProfanity(cleanedText,"||","||"),
|
||||
highlightProfanity(cleanedText,"||","||"),
|
||||
Emojis.alarm));
|
||||
return response;
|
||||
}
|
||||
|
||||
ServerUtils.verbose(("ProfanityFilter: Finished " + finalText));
|
||||
@@ -188,4 +191,91 @@ public class ProfanityResponse implements FilterResponse {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private static Severity checkProfanity(String text, Severity backup) {
|
||||
if (containsSlurs(text)) return Severity.SLUR;
|
||||
if (containsSwears(text)) return backup;
|
||||
return Severity.SAFE;
|
||||
}
|
||||
|
||||
private static boolean containsSwears(String text) {
|
||||
ServerUtils.verbose("ProfanityFilter: Checking for swears");
|
||||
for (String swear : Sentinel.getInstance().getDirector().io.swearConfig.swears) {
|
||||
if (text.contains(swear)) return true;
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile(Sentinel.getInstance().getDirector().io.swearConfig.regexSwears, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
|
||||
return matcher.find() && Sentinel.getInstance().getDirector().io.swearConfig.useRegex;
|
||||
}
|
||||
|
||||
private static boolean containsSlurs(String text) {
|
||||
ServerUtils.verbose("ProfanityFilter: Checking for slurs");
|
||||
for (String slur : Sentinel.getInstance().getDirector().io.strictConfig.strict) {
|
||||
if (text.contains(slur)) return true;
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile(Sentinel.getInstance().getDirector().io.strictConfig.regexStrict, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
|
||||
return matcher.find() && Sentinel.getInstance().getDirector().io.strictConfig.useRegex;
|
||||
}
|
||||
|
||||
private static String removeFalsePositives(String text) {
|
||||
for (String falsePositive : Sentinel.getInstance().getDirector().io.fpConfig.swearWhitelist) {
|
||||
text = text.replace(falsePositive, "");
|
||||
}
|
||||
if (Sentinel.getInstance().getDirector().io.fpConfig.useRegex) text = text.replaceAll(Sentinel.getInstance().getDirector().io.fpConfig.regexWhitelist,"");
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String convertLeetSpeakCharacters(String text) {
|
||||
text = Text.fromLeetString(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String stripSpecialCharacters(String text) {
|
||||
text = text.replaceAll("[^A-Za-z0-9.,!?;:'\"()\\[\\]{}]", "").trim();
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String simplifyRepeatingLetters(String text) {
|
||||
text = Text.replaceRepeatingLetters(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String removePeriodsAndSpaces(String text) {
|
||||
return text.replaceAll("[^A-Za-z0-9]", "").replace(" ", "");
|
||||
}
|
||||
|
||||
private static String highlightProfanity(String text, String start, String end) {
|
||||
String highlightedSwears = highlightSwears(fullSimplify(text), start, end);
|
||||
return Text.color(highlightSlurs(highlightedSwears, start, end));
|
||||
}
|
||||
|
||||
private static String highlightSwears(String text, String start, String end) {
|
||||
for (String swear : Sentinel.getInstance().getDirector().io.swearConfig.swears) {
|
||||
text = text.replace(swear, start + swear + end);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String highlightSlurs(String text, String start, String end) {
|
||||
for (String slur : Sentinel.getInstance().getDirector().io.strictConfig.strict) {
|
||||
text = text.replace(slur, start + slur + end);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String fullSimplify(String text) {
|
||||
String lowercasedText = text.toLowerCase();
|
||||
String cleanedText = removeFalsePositives(lowercasedText);
|
||||
String convertedText =convertLeetSpeakCharacters(cleanedText);
|
||||
String strippedText = stripSpecialCharacters(convertedText);
|
||||
String simplifiedText = simplifyRepeatingLetters(strippedText);
|
||||
return removePeriodsAndSpaces(simplifiedText);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ package me.trouper.sentinel.server.functions.chatfilter.profanity;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
|
||||
public enum Severity {
|
||||
LOW(Sentinel.mainConfig.chat.profanityFilter.lowScore),
|
||||
MEDIUM_LOW(Sentinel.mainConfig.chat.profanityFilter.mediumLowScore),
|
||||
MEDIUM(Sentinel.mainConfig.chat.profanityFilter.mediumScore),
|
||||
MEDIUM_HIGH(Sentinel.mainConfig.chat.profanityFilter.mediumHighScore),
|
||||
HIGH(Sentinel.mainConfig.chat.profanityFilter.highScore),
|
||||
REGEX(Sentinel.mainConfig.chat.profanityFilter.regexScore),
|
||||
SLUR(Sentinel.mainConfig.chat.profanityFilter.highScore),
|
||||
LOW(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.lowScore),
|
||||
MEDIUM_LOW(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.mediumLowScore),
|
||||
MEDIUM(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.mediumScore),
|
||||
MEDIUM_HIGH(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.mediumHighScore),
|
||||
HIGH(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.highScore),
|
||||
REGEX(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.regexScore),
|
||||
SLUR(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.highScore),
|
||||
SAFE(0);
|
||||
|
||||
private final int score;
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.trouper.sentinel.server.functions.chatfilter.spam;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.AbstractActionHandler;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import me.trouper.sentinel.utils.trees.HoverFormatter;
|
||||
@@ -13,7 +14,7 @@ public class SpamAction extends AbstractActionHandler<SpamResponse> {
|
||||
|
||||
@Override
|
||||
public void punish(SpamResponse response) {
|
||||
for (String spamPunishCommand : Sentinel.mainConfig.chat.spamFilter.punishCommands) {
|
||||
for (String spamPunishCommand : Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.punishCommands) {
|
||||
ServerUtils.sendCommand(spamPunishCommand.replaceAll("%player%", response.getEvent().getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
@@ -22,21 +23,21 @@ public class SpamAction extends AbstractActionHandler<SpamResponse> {
|
||||
public void staffWarning(SpamResponse report, Node tree) {
|
||||
String messageText = Text.prefix("&b&n%s&r &7%s &8(&4%s&7/&c%s&8)".formatted(
|
||||
report.getEvent().getPlayer().getName(),
|
||||
report.isPunished() ? Sentinel.lang.violations.chat.spam.autoPunishNotification : Sentinel.lang.violations.chat.spam.preventNotification,
|
||||
report.isPunished() ? Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.autoPunishNotification : Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.preventNotification,
|
||||
SpamFilter.heatMap.get(report.getEvent().getPlayer().getUniqueId()),
|
||||
Sentinel.mainConfig.chat.spamFilter.punishHeat
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.punishHeat
|
||||
));
|
||||
String hoverText = HoverFormatter.format(tree);
|
||||
|
||||
ServerUtils.forEachPlayer(player -> {
|
||||
PlayerUtils.forEachPlayer(player -> {
|
||||
if (player.hasPermission("sentinel.chatfilter.spam.view")) player.sendMessage(Component.text(messageText).hoverEvent(Component.text(hoverText).asHoverEvent()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerWarning(SpamResponse response) {
|
||||
String message = Text.prefix(response.isPunished() ? Sentinel.lang.violations.chat.spam.autoPunishWarning : Sentinel.lang.violations.chat.spam.preventWarning) ;
|
||||
String hoverText = Sentinel.lang.automatedActions.reportable;
|
||||
String message = Text.prefix(response.isPunished() ? Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.autoPunishWarning : Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.preventWarning) ;
|
||||
String hoverText = Sentinel.getInstance().getDirector().io.lang.automatedActions.reportable;
|
||||
String command = "/sentinelcallback fpreport %s".formatted(response.getReport().getId());
|
||||
response.getEvent().getPlayer().sendMessage(Component.text(message)
|
||||
.hoverEvent(Component.text(hoverText).asHoverEvent())
|
||||
@@ -46,22 +47,22 @@ public class SpamAction extends AbstractActionHandler<SpamResponse> {
|
||||
@Override
|
||||
public Node buildTree(SpamResponse response) {
|
||||
Node root = new Node("Sentinel");
|
||||
root.addTextLine(Sentinel.lang.violations.chat.spam.treeTitle);
|
||||
root.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.treeTitle);
|
||||
|
||||
Node playerInfo = new Node(Sentinel.lang.violations.protections.infoNode.playerInfo.formatted(response.getEvent().getPlayer().getName()));
|
||||
playerInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.uuid, response.getEvent().getPlayer().getUniqueId().toString());
|
||||
playerInfo.addKeyValue(Sentinel.lang.violations.chat.spam.heat, "%s/%s".formatted(SpamFilter.heatMap.get(response.getEvent().getPlayer().getUniqueId()),Sentinel.mainConfig.chat.spamFilter.punishHeat));
|
||||
Node playerInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.playerInfo.formatted(response.getEvent().getPlayer().getName()));
|
||||
playerInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.uuid, response.getEvent().getPlayer().getUniqueId().toString());
|
||||
playerInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.heat, "%s/%s".formatted(SpamFilter.heatMap.get(response.getEvent().getPlayer().getUniqueId()),Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.punishHeat));
|
||||
root.addChild(playerInfo);
|
||||
|
||||
Node reportInfo = new Node(Sentinel.lang.violations.chat.spam.reportInfoTitle);
|
||||
reportInfo.addField(Sentinel.lang.violations.chat.spam.previousMessage, response.getPreviousMessage());
|
||||
reportInfo.addField(Sentinel.lang.violations.chat.spam.currentMessage, response.getCurrentMessage());
|
||||
reportInfo.addKeyValue(Sentinel.lang.violations.chat.spam.similarity, "%s/%s".formatted((int) Math.round(response.getSimilarity()),Sentinel.mainConfig.chat.spamFilter.blockSimilarity));
|
||||
Node reportInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.reportInfoTitle);
|
||||
reportInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.previousMessage, response.getPreviousMessage());
|
||||
reportInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.currentMessage, response.getCurrentMessage());
|
||||
reportInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.chat.spam.similarity, "%s/%s".formatted((int) Math.round(response.getSimilarity()),Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.blockSimilarity));
|
||||
root.addChild(reportInfo);
|
||||
|
||||
Node actions = new Node(Sentinel.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
actions.addTextLine(Sentinel.lang.violations.chat.denyMessage);
|
||||
if (response.isPunished()) actions.addTextLine(Sentinel.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
Node actions = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
actions.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.chat.denyMessage);
|
||||
if (response.isPunished()) actions.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
root.addChild(actions);
|
||||
|
||||
return root;
|
||||
@@ -69,6 +70,6 @@ public class SpamAction extends AbstractActionHandler<SpamResponse> {
|
||||
|
||||
@Override
|
||||
protected boolean shouldWarnPlayer(SpamResponse response) {
|
||||
return !Sentinel.mainConfig.chat.spamFilter.silent;
|
||||
return !Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.silent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SpamFilter {
|
||||
}
|
||||
Player p = e.getPlayer();
|
||||
String message = Text.removeFirstColor(LegacyComponentSerializer.legacySection().serialize(e.message()));
|
||||
for (String whitelistedMessage : Sentinel.mainConfig.chat.spamFilter.whitelist) {
|
||||
for (String whitelistedMessage : Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.whitelist) {
|
||||
if (whitelistedMessage.equalsIgnoreCase(message)) return;
|
||||
}
|
||||
int currentHeat = heatMap.getOrDefault(p.getUniqueId(),0);
|
||||
@@ -34,7 +34,7 @@ public class SpamFilter {
|
||||
ServerUtils.verbose("AntiSpam responded");
|
||||
response.getReport().getStepsTaken().put("Response came back", "Heat to add: %s".formatted(addHeat));
|
||||
|
||||
if (currentHeat > Sentinel.mainConfig.chat.spamFilter.punishHeat) {
|
||||
if (currentHeat > Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.punishHeat) {
|
||||
response.setBlocked(true);
|
||||
response.getReport().getStepsTaken().put("Punished user", "Their final heat was %s".formatted(currentHeat));
|
||||
response.setPunished(true);
|
||||
@@ -43,7 +43,7 @@ public class SpamFilter {
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentHeat > Sentinel.mainConfig.chat.spamFilter.blockHeat) {
|
||||
if (currentHeat > Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.blockHeat) {
|
||||
response.setBlocked(true);
|
||||
response.getReport().getStepsTaken().put("Blocked message", "Their heat is %s".formatted(currentHeat));
|
||||
new SpamAction().run(response);
|
||||
@@ -51,7 +51,7 @@ public class SpamFilter {
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.getSimilarity() > Sentinel.mainConfig.chat.spamFilter.blockSimilarity) {
|
||||
if (response.getSimilarity() > Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.blockSimilarity) {
|
||||
response.setBlocked(true);
|
||||
response.getReport().getStepsTaken().put("Blocked message", "The similarity was too high! %s".formatted(response.getSimilarity()));
|
||||
new SpamAction().run(response);
|
||||
@@ -69,7 +69,7 @@ public class SpamFilter {
|
||||
for (UUID p : heatMap.keySet()) {
|
||||
int heat = heatMap.getOrDefault(p,0);
|
||||
if (heat > 0) {
|
||||
heat = heat - Sentinel.mainConfig.chat.spamFilter.heatDecay;
|
||||
heat = heat - Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.heatDecay;
|
||||
heatMap.put(p, Math.max(0, heat));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package me.trouper.sentinel.server.functions.chatfilter.spam;
|
||||
import io.github.retrooper.packetevents.adventure.serializer.legacy.LegacyComponentSerializer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.helpers.FalsePositiveReporting;
|
||||
import me.trouper.sentinel.server.functions.helpers.ReportHandler;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.FilterResponse;
|
||||
import me.trouper.sentinel.server.functions.helpers.Report;
|
||||
import me.trouper.sentinel.utils.MathUtils;
|
||||
@@ -40,7 +40,7 @@ public class SpamResponse implements FilterResponse {
|
||||
}
|
||||
|
||||
String message = LegacyComponentSerializer.legacySection().serialize(e.message());
|
||||
Report report = FalsePositiveReporting.initializeReport(message);
|
||||
Report report = Sentinel.getInstance().getDirector().reportHandler.initializeReport(message);
|
||||
|
||||
message = Text.removeFirstColor(message);
|
||||
String previousMessage = lastMessageMap.getOrDefault(e.getPlayer().getUniqueId(),"/* Placeholder Message from Sentinel */");
|
||||
@@ -52,25 +52,25 @@ public class SpamResponse implements FilterResponse {
|
||||
response.setSimilarity(similarity);
|
||||
report.getStepsTaken().put("Calculated Similarity: ","%s".formatted(similarity));
|
||||
|
||||
int addHeat = Sentinel.mainConfig.chat.spamFilter.defaultGain;
|
||||
if (similarity > Sentinel.mainConfig.chat.spamFilter.blockSimilarity) {
|
||||
addHeat = Sentinel.mainConfig.chat.spamFilter.highGain;
|
||||
response.getReport().getStepsTaken().put("Similarity is greater than %s%%".formatted(Sentinel.mainConfig.chat.spamFilter.blockSimilarity), "That is %s heat. (Auto-Block due to configured value)".formatted(addHeat));
|
||||
int addHeat = Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.defaultGain;
|
||||
if (similarity > Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.blockSimilarity) {
|
||||
addHeat = Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.highGain;
|
||||
response.getReport().getStepsTaken().put("Similarity is greater than %s%%".formatted(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.blockSimilarity), "That is %s heat. (Auto-Block due to configured value)".formatted(addHeat));
|
||||
response.setHeatAdded(addHeat);
|
||||
return response;
|
||||
} else if (similarity > 90) {
|
||||
addHeat = Sentinel.mainConfig.chat.spamFilter.highGain;
|
||||
addHeat = Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.highGain;
|
||||
response.getReport().getStepsTaken().put("Similarity is greater than 90%", "That is %s heat.".formatted(addHeat));
|
||||
response.setHeatAdded(addHeat);
|
||||
return response;
|
||||
} else if (similarity > 50) {
|
||||
addHeat = Sentinel.mainConfig.chat.spamFilter.mediumGain;
|
||||
addHeat = Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.mediumGain;
|
||||
response.getReport().getStepsTaken().put("Similarity is greater than 50%", "That is %s heat.".formatted(addHeat));
|
||||
response.setHeatAdded(addHeat);
|
||||
return response;
|
||||
} else if (similarity > 25) {
|
||||
response.getReport().getStepsTaken().put("Similarity is greater than 25%", "That is %s heat.".formatted(addHeat));
|
||||
addHeat = Sentinel.mainConfig.chat.spamFilter.lowGain;
|
||||
addHeat = Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.lowGain;
|
||||
response.setHeatAdded(addHeat);
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.trouper.sentinel.server.functions.chatfilter.unicode;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.AbstractActionHandler;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import me.trouper.sentinel.utils.trees.HoverFormatter;
|
||||
@@ -12,7 +13,7 @@ import net.kyori.adventure.text.event.ClickEvent;
|
||||
public class UnicodeAction extends AbstractActionHandler<UnicodeResponse> {
|
||||
@Override
|
||||
protected void punish(UnicodeResponse response) {
|
||||
for (String punishCommand : Sentinel.mainConfig.chat.unicodeFilter.punishCommands) {
|
||||
for (String punishCommand : Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.punishCommands) {
|
||||
ServerUtils.sendCommand(punishCommand.replaceAll("%player%",response.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
@@ -21,19 +22,19 @@ public class UnicodeAction extends AbstractActionHandler<UnicodeResponse> {
|
||||
protected void staffWarning(UnicodeResponse response, Node tree) {
|
||||
String messageText = Text.prefix("&b&n%s&r &7%s".formatted(
|
||||
response.getPlayer().getName(),
|
||||
response.isPunished() ? Sentinel.lang.violations.chat.unicode.autoPunishNotification : Sentinel.lang.violations.chat.unicode.preventNotification
|
||||
response.isPunished() ? Sentinel.getInstance().getDirector().io.lang.violations.chat.unicode.autoPunishNotification : Sentinel.getInstance().getDirector().io.lang.violations.chat.unicode.preventNotification
|
||||
));
|
||||
String hoverText = HoverFormatter.format(tree);
|
||||
|
||||
ServerUtils.forEachPlayer(player -> {
|
||||
PlayerUtils.forEachPlayer(player -> {
|
||||
if (player.hasPermission("sentinel.chatfilter.unicode.view")) player.sendMessage(Component.text(messageText).hoverEvent(Component.text(hoverText).asHoverEvent()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void playerWarning(UnicodeResponse response) {
|
||||
String message = Text.prefix(response.isPunished() ? Sentinel.lang.violations.chat.unicode.autoPunishWarning : Sentinel.lang.violations.chat.unicode.preventWarning);
|
||||
String hoverText = Sentinel.lang.automatedActions.reportable;
|
||||
String message = Text.prefix(response.isPunished() ? Sentinel.getInstance().getDirector().io.lang.violations.chat.unicode.autoPunishWarning : Sentinel.getInstance().getDirector().io.lang.violations.chat.unicode.preventWarning);
|
||||
String hoverText = Sentinel.getInstance().getDirector().io.lang.automatedActions.reportable;
|
||||
String command = "/sentinelcallback fpreport %s".formatted(response.getReport().getId());
|
||||
response.getPlayer().sendMessage(Component.text(message)
|
||||
.hoverEvent(Component.text(hoverText).asHoverEvent())
|
||||
@@ -43,20 +44,20 @@ public class UnicodeAction extends AbstractActionHandler<UnicodeResponse> {
|
||||
@Override
|
||||
protected Node buildTree(UnicodeResponse response) {
|
||||
Node root = new Node("Sentinel");
|
||||
root.addTextLine(Sentinel.lang.violations.chat.unicode.treeTitle);
|
||||
root.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.chat.unicode.treeTitle);
|
||||
|
||||
Node playerInfo = new Node(Sentinel.lang.violations.protections.infoNode.playerInfo.formatted(response.getPlayer().getName()));
|
||||
playerInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.uuid, response.getPlayer().getUniqueId().toString());
|
||||
Node playerInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.playerInfo.formatted(response.getPlayer().getName()));
|
||||
playerInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.uuid, response.getPlayer().getUniqueId().toString());
|
||||
root.addChild(playerInfo);
|
||||
|
||||
Node reportInfo = new Node(Sentinel.lang.violations.chat.unicode.reportInfoTitle);
|
||||
reportInfo.addField(Sentinel.lang.violations.chat.originalMessage, response.getOriginalMessage());
|
||||
reportInfo.addField(Sentinel.lang.violations.chat.highlightedMessage, response.getHighlightedMessage());
|
||||
Node reportInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.chat.unicode.reportInfoTitle);
|
||||
reportInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.chat.originalMessage, response.getOriginalMessage());
|
||||
reportInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.chat.highlightedMessage, response.getHighlightedMessage());
|
||||
root.addChild(reportInfo);
|
||||
|
||||
Node actions = new Node(Sentinel.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
actions.addTextLine(Sentinel.lang.violations.chat.denyMessage);
|
||||
if (response.isPunished()) actions.addTextLine(Sentinel.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
Node actions = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
actions.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.chat.denyMessage);
|
||||
if (response.isPunished()) actions.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
root.addChild(actions);
|
||||
|
||||
return root;
|
||||
@@ -64,6 +65,6 @@ public class UnicodeAction extends AbstractActionHandler<UnicodeResponse> {
|
||||
|
||||
@Override
|
||||
protected boolean shouldWarnPlayer(UnicodeResponse response) {
|
||||
return !Sentinel.mainConfig.chat.unicodeFilter.silent;
|
||||
return !Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.silent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ package me.trouper.sentinel.server.functions.chatfilter.unicode;
|
||||
import io.github.retrooper.packetevents.adventure.serializer.legacy.LegacyComponentSerializer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.Emojis;
|
||||
import me.trouper.sentinel.server.functions.helpers.FalsePositiveReporting;
|
||||
import me.trouper.sentinel.data.types.Emojis;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.FilterResponse;
|
||||
import me.trouper.sentinel.server.functions.helpers.Report;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
@@ -39,11 +38,11 @@ public class UnicodeResponse implements FilterResponse {
|
||||
|
||||
String message = LegacyComponentSerializer.legacySection().serialize(e.message());
|
||||
message = Text.removeFirstColor(message);
|
||||
Report report = FalsePositiveReporting.initializeReport(message);
|
||||
Report report = Sentinel.getInstance().getDirector().reportHandler.initializeReport(message);
|
||||
|
||||
UnicodeResponse response = new UnicodeResponse(e,message,message,report,false,false);
|
||||
|
||||
String disallowedRegex = Sentinel.mainConfig.chat.unicodeFilter.regex;
|
||||
String disallowedRegex = Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.regex;
|
||||
ServerUtils.verbose("Regex: %s\nMessage: %s".formatted(disallowedRegex,message));
|
||||
|
||||
Pattern pattern = Pattern.compile(disallowedRegex, Pattern.CASE_INSENSITIVE);
|
||||
@@ -59,8 +58,8 @@ public class UnicodeResponse implements FilterResponse {
|
||||
response.getReport().getStepsTaken().replace("Anti-Unicode", "`%s` %s".formatted(message, Emojis.alarm));
|
||||
|
||||
response.setBlocked(true);
|
||||
response.setPunished(Sentinel.mainConfig.chat.unicodeFilter.punished);
|
||||
response.setHighlightedMessage(Text.regexHighlighter(message,Sentinel.mainConfig.chat.unicodeFilter.regex," > ", " < "));
|
||||
response.setPunished(Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.punished);
|
||||
response.setHighlightedMessage(Text.regexHighlighter(message,Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.regex," > ", " < "));
|
||||
}
|
||||
|
||||
return response;
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.trouper.sentinel.server.functions.chatfilter.url;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.AbstractActionHandler;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import me.trouper.sentinel.utils.trees.HoverFormatter;
|
||||
@@ -12,7 +13,7 @@ import net.kyori.adventure.text.event.ClickEvent;
|
||||
public class UrlAction extends AbstractActionHandler<UrlResponse> {
|
||||
@Override
|
||||
protected void punish(UrlResponse response) {
|
||||
for (String punishCommand : Sentinel.mainConfig.chat.urlFilter.punishCommands) {
|
||||
for (String punishCommand : Sentinel.getInstance().getDirector().io.mainConfig.chat.urlFilter.punishCommands) {
|
||||
ServerUtils.sendCommand(punishCommand.replaceAll("%player%",response.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
@@ -21,19 +22,19 @@ public class UrlAction extends AbstractActionHandler<UrlResponse> {
|
||||
protected void staffWarning(UrlResponse response, Node tree) {
|
||||
String messageText = Text.prefix("&b&n%s&r &7%s".formatted(
|
||||
response.getPlayer().getName(),
|
||||
response.isPunished() ? Sentinel.lang.violations.chat.url.autoPunishNotification : Sentinel.lang.violations.chat.url.preventNotification
|
||||
response.isPunished() ? Sentinel.getInstance().getDirector().io.lang.violations.chat.url.autoPunishNotification : Sentinel.getInstance().getDirector().io.lang.violations.chat.url.preventNotification
|
||||
));
|
||||
String hoverText = HoverFormatter.format(tree);
|
||||
|
||||
ServerUtils.forEachPlayer(player -> {
|
||||
PlayerUtils.forEachPlayer(player -> {
|
||||
if (player.hasPermission("sentinel.chatfilter.url.view")) player.sendMessage(Component.text(messageText).hoverEvent(Component.text(hoverText).asHoverEvent()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void playerWarning(UrlResponse response) {
|
||||
String message = Text.prefix(response.isPunished() ? Sentinel.lang.violations.chat.url.autoPunishWarning : Sentinel.lang.violations.chat.url.preventWarning);
|
||||
String hoverText = Sentinel.lang.automatedActions.reportable;
|
||||
String message = Text.prefix(response.isPunished() ? Sentinel.getInstance().getDirector().io.lang.violations.chat.url.autoPunishWarning : Sentinel.getInstance().getDirector().io.lang.violations.chat.url.preventWarning);
|
||||
String hoverText = Sentinel.getInstance().getDirector().io.lang.automatedActions.reportable;
|
||||
String command = "/sentinelcallback fpreport %s".formatted(response.getReport().getId());
|
||||
response.getPlayer().sendMessage(Component.text(message)
|
||||
.hoverEvent(Component.text(hoverText).asHoverEvent())
|
||||
@@ -43,20 +44,20 @@ public class UrlAction extends AbstractActionHandler<UrlResponse> {
|
||||
@Override
|
||||
protected Node buildTree(UrlResponse response) {
|
||||
Node root = new Node("Sentinel");
|
||||
root.addTextLine(Sentinel.lang.violations.chat.url.treeTitle);
|
||||
root.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.chat.url.treeTitle);
|
||||
|
||||
Node playerInfo = new Node(Sentinel.lang.violations.protections.infoNode.playerInfo.formatted(response.getPlayer().getName()));
|
||||
playerInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.uuid, response.getPlayer().getUniqueId().toString());
|
||||
Node playerInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.playerInfo.formatted(response.getPlayer().getName()));
|
||||
playerInfo.addKeyValue(Sentinel.getInstance().getDirector().io.lang.violations.protections.infoNode.uuid, response.getPlayer().getUniqueId().toString());
|
||||
root.addChild(playerInfo);
|
||||
|
||||
Node reportInfo = new Node(Sentinel.lang.violations.chat.url.reportInfoTitle);
|
||||
reportInfo.addField(Sentinel.lang.violations.chat.originalMessage, response.getOriginalMessage());
|
||||
reportInfo.addField(Sentinel.lang.violations.chat.highlightedMessage, response.getHighlightedMessage());
|
||||
Node reportInfo = new Node(Sentinel.getInstance().getDirector().io.lang.violations.chat.url.reportInfoTitle);
|
||||
reportInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.chat.originalMessage, response.getOriginalMessage());
|
||||
reportInfo.addField(Sentinel.getInstance().getDirector().io.lang.violations.chat.highlightedMessage, response.getHighlightedMessage());
|
||||
root.addChild(reportInfo);
|
||||
|
||||
Node actions = new Node(Sentinel.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
actions.addTextLine(Sentinel.lang.violations.chat.denyMessage);
|
||||
if (response.isPunished()) actions.addTextLine(Sentinel.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
Node actions = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
actions.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.chat.denyMessage);
|
||||
if (response.isPunished()) actions.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
root.addChild(actions);
|
||||
|
||||
return root;
|
||||
@@ -64,6 +65,6 @@ public class UrlAction extends AbstractActionHandler<UrlResponse> {
|
||||
|
||||
@Override
|
||||
protected boolean shouldWarnPlayer(UrlResponse response) {
|
||||
return !Sentinel.mainConfig.chat.urlFilter.silent;
|
||||
return !Sentinel.getInstance().getDirector().io.mainConfig.chat.urlFilter.silent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,7 @@ package me.trouper.sentinel.server.functions.chatfilter.url;
|
||||
import io.github.retrooper.packetevents.adventure.serializer.legacy.LegacyComponentSerializer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.Emojis;
|
||||
import me.trouper.sentinel.server.functions.helpers.FalsePositiveReporting;
|
||||
import me.trouper.sentinel.data.types.Emojis;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.FilterResponse;
|
||||
import me.trouper.sentinel.server.functions.helpers.Report;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
@@ -36,9 +35,9 @@ public class UrlResponse implements FilterResponse {
|
||||
}
|
||||
|
||||
String message = LegacyComponentSerializer.legacySection().serialize(e.message());
|
||||
Report report = FalsePositiveReporting.initializeReport(message);
|
||||
Report report = Sentinel.getInstance().getDirector().reportHandler.initializeReport(message);
|
||||
UrlResponse response = new UrlResponse(e,message,message,report,false,false);
|
||||
for (String allowed : Sentinel.mainConfig.chat.urlFilter.whitelist) {
|
||||
for (String allowed : Sentinel.getInstance().getDirector().io.mainConfig.chat.urlFilter.whitelist) {
|
||||
message = message.replaceAll(allowed,"");
|
||||
}
|
||||
|
||||
@@ -46,7 +45,7 @@ public class UrlResponse implements FilterResponse {
|
||||
message
|
||||
));
|
||||
|
||||
String urlRegex = Sentinel.mainConfig.chat.urlFilter.regex;
|
||||
String urlRegex = Sentinel.getInstance().getDirector().io.mainConfig.chat.urlFilter.regex;
|
||||
|
||||
Pattern pattern = Pattern.compile(urlRegex, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(message);
|
||||
@@ -56,12 +55,12 @@ public class UrlResponse implements FilterResponse {
|
||||
));
|
||||
|
||||
if (matcher.find()) {
|
||||
String highlighted = Text.regexHighlighter(message,Sentinel.mainConfig.chat.urlFilter.regex," > "," < ");
|
||||
String highlighted = Text.regexHighlighter(message,Sentinel.getInstance().getDirector().io.mainConfig.chat.urlFilter.regex," > "," < ");
|
||||
ServerUtils.verbose("Caught URL: " + highlighted);
|
||||
response.getReport().getStepsTaken().replace("Anti-URL", "`%s` %s".formatted(highlighted, Emojis.alarm));
|
||||
|
||||
response.setBlocked(true);
|
||||
response.setPunished(Sentinel.mainConfig.chat.urlFilter.punished);
|
||||
response.setPunished(Sentinel.getInstance().getDirector().io.mainConfig.chat.urlFilter.punished);
|
||||
response.setHighlightedMessage(highlighted);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
package me.trouper.sentinel.server.functions.helpers;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.utils.FileUtils;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import me.trouper.sentinel.utils.trees.ConsoleFormatter;
|
||||
import me.trouper.sentinel.utils.trees.EmbedFormatter;
|
||||
import me.trouper.sentinel.utils.trees.HoverFormatter;
|
||||
import me.trouper.sentinel.utils.trees.Node;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public abstract class AbstractViolation implements CustomListener {
|
||||
|
||||
public void runActions(String rootName, String rootNamePlayer, Node violationInfo, ActionConfiguration.Builder configuration) {
|
||||
ActionConfiguration config = configuration.build();
|
||||
|
||||
Node root = new Node("Sentinel");
|
||||
root.addTextLine(rootName);
|
||||
|
||||
if (config.getPlayer() != null) root.addChild(generatePlayerInfo(config.getPlayer()));
|
||||
|
||||
root.addChild(violationInfo);
|
||||
|
||||
root.addChild(configuration.getActionNode());
|
||||
|
||||
notifyTrusted(root,(rootNamePlayer == null || rootNamePlayer.isBlank()) ? rootName : rootNamePlayer);
|
||||
if (configuration.isLoggedToDiscord()) EmbedFormatter.sendEmbed(EmbedFormatter.format(root));
|
||||
Sentinel.log.info(ConsoleFormatter.format(root));
|
||||
}
|
||||
|
||||
public void notifyTrusted(Node root, String rootNamePlayer) {
|
||||
ServerUtils.forEachPlayer(trusted -> {
|
||||
if (PlayerUtils.isTrusted(trusted)) {
|
||||
trusted.sendMessage(Component.text(Text.prefix(rootNamePlayer)).hoverEvent(Component.text(HoverFormatter.format(root)).asHoverEvent()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Node generatePlayerInfo(Player p) {
|
||||
Node playerInfo = new Node(Sentinel.lang.violations.protections.infoNode.playerInfo);
|
||||
playerInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.name, p.getName());
|
||||
playerInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.uuid, p.getUniqueId().toString());
|
||||
playerInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.operator, p.isOp() ? Sentinel.lang.generic.yes : Sentinel.lang.generic.no);
|
||||
playerInfo.addField(Sentinel.lang.violations.protections.infoNode.locationField, Sentinel.lang.violations.protections.infoNode.locationFormat.formatted(Math.round(p.getX()), Math.round(p.getY()), Math.round(p.getZ())));
|
||||
|
||||
return playerInfo;
|
||||
}
|
||||
|
||||
public static Node generateBlockInfo(Block block) {
|
||||
Node blockInfo = new Node(Sentinel.lang.violations.protections.infoNode.blockInfo);
|
||||
blockInfo.addTextLine(Text.cleanName(block.getType().toString()));
|
||||
blockInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.worldField,block.getWorld().getName());
|
||||
blockInfo.addField(Sentinel.lang.violations.protections.infoNode.blockLocationField,Sentinel.lang.violations.protections.infoNode.locationFormat.formatted(block.getX(), block.getY(), block.getZ()));
|
||||
|
||||
return blockInfo;
|
||||
}
|
||||
|
||||
public Node generateCommandBlockInfo(CommandBlock commandBlock) {
|
||||
Node commandBlockInfo = new Node(Sentinel.lang.violations.protections.infoNode.blockInfo);
|
||||
commandBlockInfo.addTextLine(Text.cleanName(commandBlock.getType().toString()));
|
||||
commandBlockInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.worldField,commandBlock.getWorld().getName());
|
||||
commandBlockInfo.addField(Sentinel.lang.violations.protections.infoNode.blockLocationField,Sentinel.lang.violations.protections.infoNode.locationFormat.formatted(commandBlock.getX(), commandBlock.getY(), commandBlock.getZ()));
|
||||
|
||||
String command = commandBlock.getCommand();
|
||||
if (command == null || command.isBlank()) {
|
||||
return commandBlockInfo;
|
||||
} else if (command.length() <= 128) {
|
||||
commandBlockInfo.addField(Sentinel.lang.violations.protections.infoNode.commandField, command);
|
||||
} else {
|
||||
commandBlockInfo.addField(Sentinel.lang.violations.protections.infoNode.commandTooLargeField, FileUtils.createCommandLog(command));
|
||||
}
|
||||
|
||||
return commandBlockInfo;
|
||||
}
|
||||
|
||||
public Node generateMinecartInfo(Entity entity) {
|
||||
Node minecartInfo = new Node(Sentinel.lang.violations.protections.infoNode.minecartInfo);
|
||||
minecartInfo.addTextLine(Text.cleanName(entity.getType().toString()));
|
||||
minecartInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.worldField,entity.getWorld().getName());
|
||||
minecartInfo.addField(Sentinel.lang.violations.protections.infoNode.cartLocationField,Sentinel.lang.violations.protections.infoNode.locationFormat.formatted(Math.round(entity.getX()), Math.round(entity.getY()), Math.round(entity.getZ())));
|
||||
|
||||
return minecartInfo;
|
||||
}
|
||||
|
||||
public Node generateItemInfo(ItemStack item) {
|
||||
Node itemInfo = new Node(Sentinel.lang.violations.protections.infoNode.itemInfo);
|
||||
itemInfo.addTextLine(Text.cleanName(item.getType().toString()));
|
||||
itemInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.hasMeta,item.hasItemMeta() ? Sentinel.lang.generic.yes : Sentinel.lang.generic.no);
|
||||
if (item.hasItemMeta()) {
|
||||
itemInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.hasName,item.getItemMeta().hasCustomName() ? Sentinel.lang.generic.yes : Sentinel.lang.generic.no);
|
||||
itemInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.hasLore,item.getItemMeta().hasLore() ? Sentinel.lang.generic.yes : Sentinel.lang.generic.no);
|
||||
itemInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.hasAttributes,item.getItemMeta().hasAttributeModifiers() ? Sentinel.lang.generic.yes : Sentinel.lang.generic.no);
|
||||
itemInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.hasEnchants,item.getItemMeta().hasEnchants() ? Sentinel.lang.generic.yes : Sentinel.lang.generic.no);
|
||||
itemInfo.addField(Sentinel.lang.violations.protections.infoNode.nbtStored, FileUtils.createNBTLog(item));
|
||||
}
|
||||
|
||||
return itemInfo;
|
||||
}
|
||||
|
||||
public Node generateCommandInfo(String command, Player executor) {
|
||||
Node commandInfo = new Node(Sentinel.lang.violations.protections.infoNode.commandInfo);
|
||||
String name = command.split(" ")[0].substring(1);
|
||||
ServerUtils.verbose("Command Name: " + name);
|
||||
Command executed = Bukkit.getServer().getCommandMap().getCommand(name);
|
||||
|
||||
commandInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.name,name);
|
||||
if (command.length() <= 128) {
|
||||
commandInfo.addField(Sentinel.lang.violations.protections.infoNode.commandField, command);
|
||||
} else {
|
||||
commandInfo.addField(Sentinel.lang.violations.protections.infoNode.commandTooLargeField, FileUtils.createCommandLog(command));
|
||||
}
|
||||
if (executed == null || executed.getPermission() == null) return commandInfo;
|
||||
commandInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.permissionRequired,executed.getPermission());
|
||||
commandInfo.addKeyValue(Sentinel.lang.violations.protections.infoNode.permissionSatisfied,executor.hasPermission(executed.getPermission()) ? Sentinel.lang.generic.yes : Sentinel.lang.generic.no);
|
||||
|
||||
return commandInfo;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package me.trouper.sentinel.server.functions.helpers;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.SerialLocation;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.trees.Node;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
||||
@@ -18,7 +20,9 @@ public class ActionConfiguration {
|
||||
private Cancellable event;
|
||||
private boolean cancel;
|
||||
private Block block;
|
||||
private Entity entity;
|
||||
private boolean destroyBlock;
|
||||
private boolean removeEntity;
|
||||
private boolean restoreBlock;
|
||||
private boolean punish;
|
||||
private List<String> punishmentCommands;
|
||||
@@ -31,7 +35,9 @@ public class ActionConfiguration {
|
||||
this.event = builder.event;
|
||||
this.cancel = builder.cancel;
|
||||
this.block = builder.block;
|
||||
this.entity = builder.entity;
|
||||
this.destroyBlock = builder.destroyBlock;
|
||||
this.removeEntity = builder.removeEntity;
|
||||
this.restoreBlock = builder.restoreBlock;
|
||||
this.punish = builder.punish;
|
||||
this.punishmentCommands = builder.punishmentCommands;
|
||||
@@ -80,6 +86,14 @@ public class ActionConfiguration {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void setEntity(Entity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public boolean isDestroyBlock() {
|
||||
return destroyBlock;
|
||||
}
|
||||
@@ -88,6 +102,14 @@ public class ActionConfiguration {
|
||||
this.destroyBlock = destroyBlock;
|
||||
}
|
||||
|
||||
public void setRemoveEntity(boolean removeEntity) {
|
||||
this.removeEntity = removeEntity;
|
||||
}
|
||||
|
||||
public boolean getRemoveEntity() {
|
||||
return removeEntity;
|
||||
}
|
||||
|
||||
public boolean isRestoreBlock() {
|
||||
return restoreBlock;
|
||||
}
|
||||
@@ -134,12 +156,14 @@ public class ActionConfiguration {
|
||||
private Cancellable event;
|
||||
private boolean cancel;
|
||||
private Block block;
|
||||
private Entity entity;
|
||||
private boolean destroyBlock;
|
||||
private boolean removeEntity;
|
||||
private boolean restoreBlock;
|
||||
private boolean punish;
|
||||
private List<String> punishmentCommands = new ArrayList<>();
|
||||
private boolean logToDiscord;
|
||||
private Node actionNode = new Node(Sentinel.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
private Node actionNode = new Node(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.actionNodeTitle);
|
||||
|
||||
private List<Consumer<ActionConfiguration>> actions = new ArrayList<>();
|
||||
|
||||
@@ -156,7 +180,7 @@ public class ActionConfiguration {
|
||||
if (config.player != null) {
|
||||
config.player.setOp(false);
|
||||
}
|
||||
config.actionNode.addTextLine(Sentinel.lang.violations.protections.actionNode.userDeoped);
|
||||
config.actionNode.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.userDeoped);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
@@ -174,7 +198,7 @@ public class ActionConfiguration {
|
||||
if (config.event != null) {
|
||||
config.event.setCancelled(true);
|
||||
}
|
||||
config.actionNode.addTextLine(Sentinel.lang.violations.protections.actionNode.eventCancelled);
|
||||
config.actionNode.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.eventCancelled);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
@@ -191,7 +215,7 @@ public class ActionConfiguration {
|
||||
config.destroyBlock = destroyBlock;
|
||||
if (config.block != null) {
|
||||
config.block.setType(Material.AIR);
|
||||
config.actionNode.addTextLine(Sentinel.lang.violations.protections.actionNode.destroyedBlock);
|
||||
config.actionNode.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.destroyedBlock);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
@@ -202,16 +226,33 @@ public class ActionConfiguration {
|
||||
actions.add(config -> {
|
||||
config.restoreBlock = restoreBlock;
|
||||
if (config.block != null) {
|
||||
if (CBWhitelistManager.restore(config.block.getLocation())) {
|
||||
config.actionNode.addTextLine(Sentinel.lang.violations.protections.actionNode.restore);
|
||||
if (Sentinel.getInstance().getDirector().whitelistManager.getFromWhitelist(config.block.getLocation()) != null && Sentinel.getInstance().getDirector().whitelistManager.getFromWhitelist(config.block.getLocation()).restore()) {
|
||||
config.actionNode.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.restore);
|
||||
} else {
|
||||
config.actionNode.addTextLine(Sentinel.lang.violations.protections.actionNode.restoreFailed);
|
||||
config.actionNode.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.restoreFailed);
|
||||
}
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setEntity(Entity entity) {
|
||||
this.entity = entity;
|
||||
actions.add(config -> config.entity = entity);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder removeEntity(boolean removeEntity) {
|
||||
this.removeEntity = removeEntity;
|
||||
actions.add(config -> {
|
||||
config.removeEntity = removeEntity;
|
||||
if (config.entity != null) {
|
||||
entity.remove();
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder punish(boolean punish) {
|
||||
this.punish = punish;
|
||||
actions.add(config -> config.punish = punish);
|
||||
@@ -226,7 +267,7 @@ public class ActionConfiguration {
|
||||
for (String cmd : punishmentCommands) {
|
||||
ServerUtils.sendCommand(cmd.replaceAll("%player%", config.player.getName()));
|
||||
}
|
||||
config.actionNode.addTextLine(Sentinel.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
config.actionNode.addTextLine(Sentinel.getInstance().getDirector().io.lang.violations.protections.actionNode.punishmentCommandsExecuted);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
|
||||
@@ -1,185 +1,166 @@
|
||||
package me.trouper.sentinel.server.functions.helpers;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.types.WhitelistedBlock;
|
||||
import me.trouper.sentinel.data.types.SerialLocation;
|
||||
import me.trouper.sentinel.data.types.CommandBlockHolder;
|
||||
import me.trouper.sentinel.server.events.admin.WandEvents;
|
||||
import me.trouper.sentinel.data.types.Selection;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class CBWhitelistManager {
|
||||
|
||||
public static Set<UUID> autoWhitelist = new HashSet<>();
|
||||
public Set<UUID> autoWhitelist = new HashSet<>();
|
||||
|
||||
public static void add(CommandBlock cb, UUID owner) {
|
||||
ServerUtils.verbose("Adding a command block to the whitelist.");
|
||||
boolean alwaysActive = getNBTBoolean(cb, "auto");
|
||||
WhitelistedBlock wb = new WhitelistedBlock(owner.toString(),WhitelistedBlock.serialize(cb.getLocation()),getType(cb),alwaysActive,cb.getCommand());
|
||||
|
||||
Location wbloc = WhitelistedBlock.fromSerialized(wb.loc());
|
||||
|
||||
remove(wbloc);
|
||||
|
||||
Sentinel.whitelist.whitelistedCMDBlocks.add(wb);
|
||||
Sentinel.whitelist.save();
|
||||
if (Bukkit.getPlayer(owner) != null && !Bukkit.getPlayer(owner).isOnline()) return;
|
||||
Bukkit.getPlayer(owner).sendMessage(Text.prefix("Successfully whitelisted a &b" + Text.cleanName(cb.getType().toString()) + "&7 with the command &a" + cb.getCommand() + "&7."));
|
||||
}
|
||||
|
||||
public static void remove(Location where) {
|
||||
for (WhitelistedBlock cb : Sentinel.whitelist.whitelistedCMDBlocks) {
|
||||
Location cbl = WhitelistedBlock.fromSerialized(cb.loc());
|
||||
if (cbl.distance(where) < 0.5) {
|
||||
Sentinel.whitelist.whitelistedCMDBlocks.remove(cb);
|
||||
}
|
||||
}
|
||||
|
||||
Sentinel.whitelist.save();
|
||||
}
|
||||
|
||||
public static boolean canRun(Block b) {
|
||||
CommandBlock test = (CommandBlock) b.getState();
|
||||
String command = test.getCommand();
|
||||
boolean alwaysActive = getNBTBoolean(test, "auto");
|
||||
for (WhitelistedBlock cb : Sentinel.whitelist.whitelistedCMDBlocks) {
|
||||
if (!(b.getLocation().distance(WhitelistedBlock.fromSerialized(cb.loc())) < 0.5)) continue;
|
||||
if (cb.active() != alwaysActive) return false;
|
||||
if (!cb.command().equals(command)) return false;
|
||||
if (!cb.type().equals(getType(test))) return false;
|
||||
return PlayerUtils.isTrusted(cb.owner());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static WhitelistedBlock get(Location where) {
|
||||
for (WhitelistedBlock cb : Sentinel.whitelist.whitelistedCMDBlocks) {
|
||||
Location cbl = WhitelistedBlock.fromSerialized(cb.loc());
|
||||
if (cbl.distance(where) < 0.5) {
|
||||
return cb;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int clearAll() {
|
||||
int total = 0;
|
||||
for (WhitelistedBlock cb : Sentinel.whitelist.whitelistedCMDBlocks) {
|
||||
Location remove = WhitelistedBlock.fromSerialized(cb.loc());
|
||||
remove(remove);
|
||||
remove.getBlock().setType(Material.AIR);
|
||||
total++;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public static int clearAll(UUID who) {
|
||||
int total = 0;
|
||||
for (WhitelistedBlock cb : Sentinel.whitelist.whitelistedCMDBlocks) {
|
||||
if (!cb.owner().equals(who.toString())) continue;
|
||||
Location remove = WhitelistedBlock.fromSerialized(cb.loc());
|
||||
remove(remove);
|
||||
remove.getBlock().setType(Material.AIR);
|
||||
total++;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public static int restoreAll() {
|
||||
int total = 0;
|
||||
for (WhitelistedBlock cb : Sentinel.whitelist.whitelistedCMDBlocks) {
|
||||
if (restore(WhitelistedBlock.fromSerialized(cb.loc()))) total++;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public static int restoreAll(UUID who) {
|
||||
int total = 0;
|
||||
for (WhitelistedBlock cb : Sentinel.whitelist.whitelistedCMDBlocks) {
|
||||
if (!cb.owner().equals(who.toString())) continue;
|
||||
if (restore(WhitelistedBlock.fromSerialized(cb.loc()))) total++;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
public static boolean restore(Location where) {
|
||||
WhitelistedBlock wb = get(where);
|
||||
if (wb == null) {
|
||||
ServerUtils.verbose("No whitelisted command block found at the specified location.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Block block = where.getBlock();
|
||||
block.setType(getBlockType(wb.type()));
|
||||
if (!(block.getState() instanceof CommandBlock)) {
|
||||
ServerUtils.verbose("Block at the location was not a command block (You shouldn't be seeing this. Report it).");
|
||||
return false;
|
||||
}
|
||||
|
||||
CommandBlock cb = (CommandBlock) block.getState();
|
||||
cb.setCommand(wb.command());
|
||||
cb.setType(getBlockType(wb.type()));
|
||||
setNBTBoolean(cb, "auto", wb.active());
|
||||
|
||||
cb.update();
|
||||
ServerUtils.verbose("Command block at " + where.toString() + " has been restored.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getType(CommandBlock cb) {
|
||||
switch (cb.getType()) {
|
||||
case COMMAND_BLOCK -> {
|
||||
return "impulse";
|
||||
}
|
||||
case REPEATING_COMMAND_BLOCK -> {
|
||||
return "repeat";
|
||||
}
|
||||
case CHAIN_COMMAND_BLOCK -> {
|
||||
return "chain";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Material getBlockType(String type) {
|
||||
return switch (type) {
|
||||
case "impulse" -> Material.COMMAND_BLOCK;
|
||||
case "repeat" -> Material.REPEATING_COMMAND_BLOCK;
|
||||
case "chain" -> Material.CHAIN_COMMAND_BLOCK;
|
||||
default -> throw new IllegalArgumentException("Unknown command block type: " + type);
|
||||
};
|
||||
}
|
||||
|
||||
private static void setNBTBoolean(CommandBlock cmdBlock, String key, boolean value) {
|
||||
cmdBlock.getPersistentDataContainer().set(
|
||||
getKey(key),
|
||||
PersistentDataType.BYTE,
|
||||
value ? (byte) 1 : (byte) 0
|
||||
public CommandBlockHolder generateHolder(UUID owner, CommandMinecart cm) {
|
||||
return new CommandBlockHolder(owner.toString(),
|
||||
SerialLocation.uuidToLocation(cm.getUniqueId()),
|
||||
"minecart",
|
||||
cm.getType().name(),
|
||||
false,
|
||||
false,
|
||||
cm.getCommand()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
private static boolean getNBTBoolean(CommandBlock cmdBlock, String key) {
|
||||
return cmdBlock.getPersistentDataContainer().has(
|
||||
getKey(key),
|
||||
PersistentDataType.BYTE
|
||||
) && cmdBlock.getPersistentDataContainer().get(
|
||||
getKey(key),
|
||||
PersistentDataType.BYTE
|
||||
) == 1;
|
||||
public CommandBlockHolder generateHolder(UUID owner, CommandBlock cb) {
|
||||
return new CommandBlockHolder(owner.toString(),
|
||||
SerialLocation.translate(cb.getLocation()),
|
||||
serializeFacing(cb.getBlock()),
|
||||
serializeType(cb),
|
||||
isAuto(cb),
|
||||
isConditional(cb),
|
||||
cb.getCommand()
|
||||
);
|
||||
}
|
||||
|
||||
private static NamespacedKey getKey(String key) {
|
||||
return new NamespacedKey(Sentinel.getInstance(), key);
|
||||
public void removeSelectionFromWhitelist(Player player) {
|
||||
Selection selection = WandEvents.selections.get(player.getUniqueId());
|
||||
if (selection == null || !selection.isComplete()) {
|
||||
player.sendMessage(Text.prefix("You must set 2 points first."));
|
||||
return;
|
||||
}
|
||||
AtomicInteger number = new AtomicInteger();
|
||||
selection.forEachBlock(block -> {
|
||||
if (block.getType().equals(Material.COMMAND_BLOCK) || block.getType().equals(Material.REPEATING_COMMAND_BLOCK) || block.getType().equals(Material.CHAIN_COMMAND_BLOCK)) {
|
||||
generateHolder(player.getUniqueId(),(CommandBlock) block.getState()).removeFromWhitelist();
|
||||
number.getAndIncrement();
|
||||
}
|
||||
});
|
||||
|
||||
player.sendMessage(Text.prefix("Removed all &b%s&7 command blocks from the whitelist in your selection.".formatted(number.get())));
|
||||
}
|
||||
|
||||
public void deleteSelection(Player player) {
|
||||
Selection selection = WandEvents.selections.get(player.getUniqueId());
|
||||
if (selection == null || !selection.isComplete()) {
|
||||
player.sendMessage(Text.prefix("You must set 2 points first."));
|
||||
return;
|
||||
}
|
||||
AtomicInteger number = new AtomicInteger();
|
||||
selection.forEachBlock(block -> {
|
||||
if (block.getType().equals(Material.COMMAND_BLOCK) || block.getType().equals(Material.REPEATING_COMMAND_BLOCK) || block.getType().equals(Material.CHAIN_COMMAND_BLOCK)) {
|
||||
generateHolder(player.getUniqueId(),(CommandBlock) block.getState()).destroy();
|
||||
number.getAndIncrement();
|
||||
}
|
||||
});
|
||||
|
||||
player.sendMessage(Text.prefix("Deleted all &b%s&7 command blocks from the whitelist in your selection.".formatted(number.get())));
|
||||
}
|
||||
|
||||
public void addSelectionToWhitelist(Player player) {
|
||||
Selection selection = WandEvents.selections.get(player.getUniqueId());
|
||||
if (selection == null || !selection.isComplete()) {
|
||||
player.sendMessage(Text.prefix("You must set 2 points first."));
|
||||
return;
|
||||
}
|
||||
|
||||
AtomicInteger number = new AtomicInteger();
|
||||
selection.forEachBlock(block -> {
|
||||
if (ServerUtils.isCommandBlock(block)) {
|
||||
CommandBlock cb = (CommandBlock) block.getState();
|
||||
generateHolder(player.getUniqueId(),cb).addToWhitelist();
|
||||
number.getAndIncrement();
|
||||
}
|
||||
});
|
||||
|
||||
player.sendMessage(Text.prefix("Whitelisted all &b%s&7 command blocks in your selection.".formatted(number.get())));
|
||||
}
|
||||
|
||||
public int clearAll() {
|
||||
int total = 0;
|
||||
for (CommandBlockHolder cb : Sentinel.getInstance().getDirector().io.commandBlocks.holders) {
|
||||
cb.removeFromWhitelist();
|
||||
total++;
|
||||
|
||||
if (cb.loc().isUUID()) continue;
|
||||
Location remove = SerialLocation.translate(cb.loc());
|
||||
remove.getBlock().setType(Material.AIR);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int clearAll(UUID who) {
|
||||
int total = 0;
|
||||
for (CommandBlockHolder cb : Sentinel.getInstance().getDirector().io.commandBlocks.holders) {
|
||||
if (!cb.owner().equals(who.toString())) continue;
|
||||
cb.removeFromWhitelist();
|
||||
total++;
|
||||
|
||||
if (cb.loc().isUUID()) continue;
|
||||
Location remove = SerialLocation.translate(cb.loc());
|
||||
remove.getBlock().setType(Material.AIR);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int restoreAll() {
|
||||
int total = 0;
|
||||
for (CommandBlockHolder cb : Sentinel.getInstance().getDirector().io.commandBlocks.holders) {
|
||||
if (cb.isWhitelisted() && cb.restore()) total++;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int restoreAll(UUID who) {
|
||||
int total = 0;
|
||||
for (CommandBlockHolder cb : Sentinel.getInstance().getDirector().io.commandBlocks.holders) {
|
||||
if (!cb.owner().equals(who.toString())) continue;
|
||||
if (cb.isWhitelisted() && cb.restore()) total++;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public String serializeFacing(Block block) {
|
||||
if (block.getBlockData() instanceof Directional directional) {
|
||||
return directional.getFacing().name();
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
public String serializeType(CommandBlock cb) {
|
||||
return cb.getType().name();
|
||||
}
|
||||
|
||||
public boolean isAuto(CommandBlock cb) {
|
||||
return cb.getPersistentDataContainer().getOrDefault(Sentinel.getInstance().getNamespace("auto"), PersistentDataType.BYTE,(byte) 0) == (byte) 1;
|
||||
}
|
||||
|
||||
public boolean isConditional(CommandBlock cb) {
|
||||
return cb.getBlock().getBlockData() instanceof org.bukkit.block.data.type.CommandBlock cbs && cbs.isConditional();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
package me.trouper.sentinel.server.functions.helpers;
|
||||
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.chatfilter.profanity.Severity;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class FilterHelpers {
|
||||
|
||||
public static Severity checkSlur(String text, Severity backup) {
|
||||
if (containsSlurs(text)) return Severity.SLUR;
|
||||
if (containsSwears(text)) return backup;
|
||||
return Severity.SAFE;
|
||||
}
|
||||
|
||||
public static boolean containsSwears(String text) {
|
||||
ServerUtils.verbose("ProfanityFilter: Checking for swears");
|
||||
for (String swear : Sentinel.swearConfig.swears) {
|
||||
if (text.contains(swear)) return true;
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile(Sentinel.swearConfig.regexSwears, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
|
||||
return matcher.find() && Sentinel.swearConfig.useRegex;
|
||||
}
|
||||
|
||||
public static boolean containsSlurs(String text) {
|
||||
ServerUtils.verbose("ProfanityFilter: Checking for slurs");
|
||||
for (String slur : Sentinel.strictConfig.strict) {
|
||||
if (text.contains(slur)) return true;
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile(Sentinel.strictConfig.regexStrict, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
|
||||
return matcher.find() && Sentinel.strictConfig.useRegex;
|
||||
}
|
||||
|
||||
public static String removeFalsePositives(String text) {
|
||||
for (String falsePositive : Sentinel.fpConfig.swearWhitelist) {
|
||||
text = text.replace(falsePositive, "");
|
||||
}
|
||||
text = text.replaceAll(Sentinel.fpConfig.regexWhitelist,"");
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String convertLeetSpeakCharacters(String text) {
|
||||
text = Text.fromLeetString(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String stripSpecialCharacters(String text) {
|
||||
text = text.replaceAll("[^A-Za-z0-9.,!?;:'\"()\\[\\]{}]", "").trim();
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String simplifyRepeatingLetters(String text) {
|
||||
text = Text.replaceRepeatingLetters(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String removePeriodsAndSpaces(String text) {
|
||||
return text.replaceAll("[^A-Za-z0-9]", "").replace(" ", "");
|
||||
}
|
||||
|
||||
public static String highlightProfanity(String text, String start, String end) {
|
||||
String highlightedSwears = highlightSwears(fullSimplify(text), start, end);
|
||||
return Text.color(highlightSlurs(highlightedSwears, start, end));
|
||||
}
|
||||
|
||||
private static String highlightSwears(String text, String start, String end) {
|
||||
for (String swear : Sentinel.swearConfig.swears) {
|
||||
text = text.replace(swear, start + swear + end);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static String highlightSlurs(String text, String start, String end) {
|
||||
for (String slur : Sentinel.strictConfig.strict) {
|
||||
text = text.replace(slur, start + slur + end);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String fullSimplify(String text) {
|
||||
String lowercasedText = text.toLowerCase();
|
||||
String cleanedText = FilterHelpers.removeFalsePositives(lowercasedText);
|
||||
String convertedText = FilterHelpers.convertLeetSpeakCharacters(cleanedText);
|
||||
String strippedText = FilterHelpers.stripSpecialCharacters(convertedText);
|
||||
String simplifiedText = FilterHelpers.simplifyRepeatingLetters(strippedText);
|
||||
return FilterHelpers.removePeriodsAndSpaces(simplifiedText);
|
||||
}
|
||||
|
||||
public static void restrictMessage(AsyncChatEvent event, boolean silent) {
|
||||
if (silent) {
|
||||
event.viewers().clear();
|
||||
event.viewers().add(event.getPlayer());
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import io.papermc.paper.chat.ChatRenderer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.commands.SentinelCommand;
|
||||
import me.trouper.sentinel.server.events.ChatEvent;
|
||||
import me.trouper.sentinel.server.events.violations.players.ChatEvent;
|
||||
import net.kyori.adventure.chat.SignedMessage;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
@@ -13,27 +13,27 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Message {
|
||||
public static final Map<UUID,UUID> replyMap = new HashMap<>();
|
||||
public static void messagePlayer(Player sender, Player receiver, String message) {
|
||||
public class MessageHandler {
|
||||
public final Map<UUID,UUID> replyMap = new HashMap<>();
|
||||
public void messagePlayer(Player sender, Player receiver, String message) {
|
||||
AsyncChatEvent checkEvent = new AsyncChatEvent(true,sender, new HashSet<>(Arrays.asList(receiver, sender)), ChatRenderer.defaultRenderer(),Component.text(message),Component.text(message), SignedMessage.system(message,Component.text(message)));
|
||||
if (checkEvent.isCancelled()) return;
|
||||
new ChatEvent().handleEvent(checkEvent);
|
||||
if (checkEvent.isCancelled()) return;
|
||||
|
||||
sender.sendMessage(Sentinel.lang.playerInteraction.messageSent.formatted(receiver.getName(),message));
|
||||
receiver.sendMessage(Sentinel.lang.playerInteraction.messageReceived.formatted(sender.getName(),message));
|
||||
sender.sendMessage(Sentinel.getInstance().getDirector().io.lang.playerInteraction.messageSent.formatted(receiver.getName(),message));
|
||||
receiver.sendMessage(Sentinel.getInstance().getDirector().io.lang.playerInteraction.messageReceived.formatted(sender.getName(),message));
|
||||
replyMap.put(receiver.getUniqueId(),sender.getUniqueId());
|
||||
sendSpy(sender,receiver,message);
|
||||
}
|
||||
|
||||
public static void sendSpy(Player sender, Player receiver, String message) {
|
||||
public void sendSpy(Player sender, Player receiver, String message) {
|
||||
ServerUtils.forEachPlayer(player -> {
|
||||
|
||||
if (SentinelCommand.spyMap.getOrDefault(player.getUniqueId(),false)) {
|
||||
TextComponent notification = Component
|
||||
.text(Sentinel.lang.socialSpy.spyMessage.formatted(sender.getName(),receiver.getName()))
|
||||
.hoverEvent(Component.text(Sentinel.lang.socialSpy.spyMessageHover.formatted(sender.getName(),receiver.getName(),message)));
|
||||
.text(Sentinel.getInstance().getDirector().io.lang.socialSpy.spyMessage.formatted(sender.getName(),receiver.getName()))
|
||||
.hoverEvent(Component.text(Sentinel.getInstance().getDirector().io.lang.socialSpy.spyMessageHover.formatted(sender.getName(),receiver.getName(),message)));
|
||||
player.sendMessage(notification);
|
||||
}
|
||||
});
|
||||
@@ -2,8 +2,8 @@ package me.trouper.sentinel.server.functions.helpers;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.SchedulerUtils;
|
||||
import io.github.itzispyder.pdk.utils.discord.DiscordEmbed;
|
||||
import me.trouper.sentinel.data.Emojis;
|
||||
import me.trouper.sentinel.utils.Randomizer;
|
||||
import me.trouper.sentinel.data.types.Emojis;
|
||||
import me.trouper.sentinel.utils.Random;
|
||||
import me.trouper.sentinel.utils.trees.EmbedFormatter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -11,11 +11,11 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FalsePositiveReporting {
|
||||
public static Map<Long, Report> reports = new HashMap<>();
|
||||
public class ReportHandler {
|
||||
public Map<Long, Report> reports = new HashMap<>();
|
||||
|
||||
public static Report initializeReport(String message) {
|
||||
final long reportID = Randomizer.generateID();
|
||||
public Report initializeReport(String message) {
|
||||
final long reportID = Random.generateID();
|
||||
LinkedHashMap<String,String> steps = new LinkedHashMap<>();
|
||||
steps.put("Original Message", "`%s`".formatted(message));
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FalsePositiveReporting {
|
||||
return new Report(reportID,message,steps);
|
||||
}
|
||||
|
||||
public static void sendReport(Player sender, Report report) {
|
||||
public void sendReport(Player sender, Report report) {
|
||||
DiscordEmbed.Builder embed = DiscordEmbed.create()
|
||||
.author(new DiscordEmbed.Author("Anti-Swear False Positive","",null))
|
||||
.title("A player has reported a false positive")
|
||||
@@ -0,0 +1,10 @@
|
||||
package me.trouper.sentinel.server.functions.itemchecks;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public abstract class AbstractCheck<T> {
|
||||
public abstract boolean passes(T input);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package me.trouper.sentinel.server.functions.itemchecks;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.bukkit.enchantments.Enchantment.MENDING;
|
||||
|
||||
public class EnchantmentCheck {
|
||||
|
||||
public boolean hasIllegalEnchants(ItemStack item) {
|
||||
ServerUtils.verbose("Checking item for illegal enchants: ", item.getType().name());
|
||||
if (item.hasItemMeta() && item.getItemMeta().hasEnchants()) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
Map<Enchantment, Integer> enchantments = meta.getEnchants();
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
||||
Enchantment enchantment = entry.getKey();
|
||||
int level = entry.getValue();
|
||||
if (level > Sentinel.getInstance().getDirector().io.nbtConfig.globalMaxEnchant || isOverLimit(enchantment, level)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isOverLimit(Enchantment enchantment, int level) {
|
||||
int maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.globalMaxEnchant;
|
||||
|
||||
if (enchantment.equals(MENDING)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxMending;
|
||||
} else if (enchantment.equals(Enchantment.UNBREAKING)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxUnbreaking;
|
||||
} else if (enchantment.equals(Enchantment.VANISHING_CURSE)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxCurseOfVanishing;
|
||||
} else if (enchantment.equals(Enchantment.BINDING_CURSE)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxCurseOfBinding;
|
||||
} else if (enchantment.equals(Enchantment.AQUA_AFFINITY)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxAquaAffinity;
|
||||
} else if (enchantment.equals(Enchantment.PROTECTION)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxProtection;
|
||||
} else if (enchantment.equals(Enchantment.BLAST_PROTECTION)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxBlastProtection;
|
||||
} else if (enchantment.equals(Enchantment.DEPTH_STRIDER)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxDepthStrider;
|
||||
} else if (enchantment.equals(Enchantment.FEATHER_FALLING)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxFeatherFalling;
|
||||
} else if (enchantment.equals(Enchantment.FIRE_PROTECTION)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxFireProtection;
|
||||
} else if (enchantment.equals(Enchantment.FROST_WALKER)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxFrostWalker;
|
||||
} else if (enchantment.equals(Enchantment.PROJECTILE_PROTECTION)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxProjectileProtection;
|
||||
} else if (enchantment.equals(Enchantment.RESPIRATION)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxRespiration;
|
||||
} else if (enchantment.equals(Enchantment.SOUL_SPEED)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxSoulSpeed;
|
||||
} else if (enchantment.equals(Enchantment.THORNS)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxThorns;
|
||||
} else if (enchantment.equals(Enchantment.SWEEPING_EDGE)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxSweepingEdge;
|
||||
} else if (enchantment.equals(Enchantment.SWIFT_SNEAK)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxSwiftSneak;
|
||||
} else if (enchantment.equals(Enchantment.BANE_OF_ARTHROPODS)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxBaneOfArthropods;
|
||||
} else if (enchantment.equals(Enchantment.FIRE_ASPECT)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxFireAspect;
|
||||
} else if (enchantment.equals(Enchantment.LOOTING)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxLooting;
|
||||
} else if (enchantment.equals(Enchantment.IMPALING)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxImpaling;
|
||||
} else if (enchantment.equals(Enchantment.KNOCKBACK)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxKnockback;
|
||||
} else if (enchantment.equals(Enchantment.SHARPNESS)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxSharpness;
|
||||
} else if (enchantment.equals(Enchantment.SMITE)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxSmite;
|
||||
} else if (enchantment.equals(Enchantment.CHANNELING)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxChanneling;
|
||||
} else if (enchantment.equals(Enchantment.FLAME)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxFlame;
|
||||
} else if (enchantment.equals(Enchantment.INFINITY)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxInfinity;
|
||||
} else if (enchantment.equals(Enchantment.LOYALTY)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxLoyalty;
|
||||
} else if (enchantment.equals(Enchantment.RIPTIDE)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxRiptide;
|
||||
} else if (enchantment.equals(Enchantment.MULTISHOT)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxMultishot;
|
||||
} else if (enchantment.equals(Enchantment.PIERCING)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxPiercing;
|
||||
} else if (enchantment.equals(Enchantment.POWER)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxPower;
|
||||
} else if (enchantment.equals(Enchantment.PUNCH)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxPunch;
|
||||
} else if (enchantment.equals(Enchantment.QUICK_CHARGE)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxQuickCharge;
|
||||
} else if (enchantment.equals(Enchantment.EFFICIENCY)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxEfficiency;
|
||||
} else if (enchantment.equals(Enchantment.FORTUNE)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxFortune;
|
||||
} else if (enchantment.equals(Enchantment.LUCK_OF_THE_SEA)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxLuckOfTheSea;
|
||||
} else if (enchantment.equals(Enchantment.LURE)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxLure;
|
||||
} else if (enchantment.equals(Enchantment.SILK_TOUCH)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxSilkTouch;
|
||||
} else if (enchantment.equals(Enchantment.BREACH)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxBreach;
|
||||
} else if (enchantment.equals(Enchantment.DENSITY)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxDensity;
|
||||
} else if (enchantment.equals(Enchantment.WIND_BURST)) {
|
||||
maxLevel = Sentinel.getInstance().getDirector().io.nbtConfig.maxWindBurst;
|
||||
}
|
||||
|
||||
return level > maxLevel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package me.trouper.sentinel.server.functions.itemchecks;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBT;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.utils.InventoryUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.MerchantRecipe;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class EntityCheck extends AbstractCheck<Entity> {
|
||||
|
||||
@Override
|
||||
public boolean passes(Entity entity) {
|
||||
if (entity instanceof Item itemEntity) {
|
||||
if (!new ItemCheck().passes(itemEntity.getItemStack())) {
|
||||
ServerUtils.verbose("Entity failed check: Item not allowed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Inventory inv = InventoryUtils.getInventory(entity);
|
||||
if (inv != null && !new InventoryCheck().passes(inv)) {
|
||||
ServerUtils.verbose("Entity inventory failed check.");
|
||||
return false;
|
||||
}
|
||||
if (entity instanceof Villager villager) {
|
||||
for (MerchantRecipe recipe : villager.getRecipes()) {
|
||||
if (!new ItemCheck().passes(recipe.getResult())) {
|
||||
ServerUtils.verbose("Villager recipe failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entity instanceof Mob mob) {
|
||||
if (!new EquipmentCheck().passes(mob)) {
|
||||
ServerUtils.verbose("Mob equipment failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!entity.getPassengers().isEmpty()) {
|
||||
if (!Sentinel.getInstance().getDirector().io.nbtConfig.allowRecursion) {
|
||||
ServerUtils.verbose("Entity recursion not allowed.");
|
||||
return false;
|
||||
}
|
||||
for (Entity passenger : entity.getPassengers()) {
|
||||
if (!passes(passenger)) {
|
||||
ServerUtils.verbose("Entity passenger failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
AtomicBoolean failsTiming = new AtomicBoolean(false);
|
||||
NBT.get(entity, nbt -> {
|
||||
if (nbt.hasTag("DeathTime") && nbt.getInteger("DeathTime") < 1) {
|
||||
ServerUtils.verbose("Entity death time check failed.");
|
||||
failsTiming.set(true);
|
||||
}
|
||||
if (nbt.hasTag("Hurttime") && nbt.getInteger("Hurttime") < 1) {
|
||||
ServerUtils.verbose("Entity hurt time check failed.");
|
||||
failsTiming.set(true);
|
||||
}
|
||||
});
|
||||
if (failsTiming.get()) {
|
||||
ServerUtils.verbose("Entity timing check failed.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.trouper.sentinel.server.functions.itemchecks;
|
||||
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntitySnapshot;
|
||||
|
||||
public class EntitySnapshotCheck extends AbstractCheck<EntitySnapshot> {
|
||||
|
||||
@Override
|
||||
public boolean passes(EntitySnapshot input) {
|
||||
Location loc = new Location(Bukkit.getWorlds().getFirst(), 0, 1000000, 0);
|
||||
Entity temp = input.createEntity(loc);
|
||||
boolean result = new EntityCheck().passes(temp);
|
||||
ServerUtils.verbose("Temp Entity %s Entity Check", result ? "failed" : "passed");
|
||||
temp.remove();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package me.trouper.sentinel.server.functions.itemchecks;
|
||||
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
||||
public class EquipmentCheck extends AbstractCheck<Mob> {
|
||||
|
||||
@Override
|
||||
public boolean passes(Mob mob) {
|
||||
ServerUtils.verbose("Running mob check.");
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemStack item = mob.getEquipment().getItem(slot);
|
||||
if (item != null && !new ItemCheck().passes(item)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.trouper.sentinel.server.functions.itemchecks;
|
||||
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.functions.itemchecks.AbstractCheck;
|
||||
import me.trouper.sentinel.server.functions.itemchecks.ItemCheck;
|
||||
import me.trouper.sentinel.utils.InventoryUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class InventoryCheck extends AbstractCheck<Inventory> {
|
||||
|
||||
@Override
|
||||
public boolean passes(Inventory inventory) {
|
||||
ServerUtils.verbose("Running Inventory Check");
|
||||
for (ItemStack item : inventory.getContents()) {
|
||||
if (item == null || item.getType().isAir()) continue;
|
||||
if (!new ItemCheck().passes(item)) {
|
||||
ServerUtils.verbose("Inventory item failed check.");
|
||||
return false;
|
||||
}
|
||||
Inventory subInventory = InventoryUtils.getInventory(item);
|
||||
if (subInventory != null && !Sentinel.getInstance().getDirector().io.nbtConfig.allowRecursion) return false;
|
||||
if (subInventory != null && !passes(subInventory)) {
|
||||
ServerUtils.verbose("Sub-inventory failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ServerUtils.verbose("Inventory passed all checks.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
package me.trouper.sentinel.server.functions.itemchecks;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBT;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.utils.InventoryUtils;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.inventory.meta.BundleMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class ItemCheck extends AbstractCheck<ItemStack> {
|
||||
@Override
|
||||
public boolean passes(ItemStack item) {
|
||||
ServerUtils.verbose("Checking item: " + item.getType().name());
|
||||
|
||||
// No metadata? Nothing to check.
|
||||
if (item.getItemMeta() == null) {
|
||||
ServerUtils.verbose("Item passes because it has no metadata.");
|
||||
return true;
|
||||
}
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
// Check for an inventory inside the item.
|
||||
Inventory inv = InventoryUtils.getInventory(item);
|
||||
if (inv != null) {
|
||||
ServerUtils.verbose("Item contains an inventory: " + inv);
|
||||
if (!new InventoryCheck().passes(inv)) {
|
||||
ServerUtils.verbose("Item failed inventory check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// NBT-based checks (e.g. custom consumables/tools).
|
||||
var nbt = NBT.itemStackToNBT(item);
|
||||
var components = nbt.getCompound("components");
|
||||
if (!Sentinel.getInstance().getDirector().io.nbtConfig.allowCustomConsumables && components.getCompound("minecraft:consumable") != null) {
|
||||
ServerUtils.verbose("Item is consumable and not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (!Sentinel.getInstance().getDirector().io.nbtConfig.allowCustomTools && components.getCompound("minecraft:tool") != null) {
|
||||
ServerUtils.verbose("Item is custom tool and not allowed.");
|
||||
return false;
|
||||
}
|
||||
var entityData = components.getCompound("minecraft:entity_data");
|
||||
if (entityData != null) {
|
||||
if (item.getType().name().contains("ITEM_FRAME")) {
|
||||
var itemData = entityData.getCompound("Item");
|
||||
ItemStack heldItem = NBT.itemStackFromNBT(itemData);
|
||||
if (heldItem != null && !new ItemCheck().passes(heldItem)) {
|
||||
ServerUtils.verbose("Item frame contents failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (isSpawnEgg(item)) {
|
||||
if (entityData.hasTag("DeathTime") && entityData.getInteger("DeathTime") < 1) {
|
||||
ServerUtils.verbose("Egg death time check failed.");
|
||||
return false;
|
||||
}
|
||||
if (entityData.hasTag("Hurttime") && entityData.getInteger("HurtTime") < 1) {
|
||||
ServerUtils.verbose("Egg hurt time check failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bundle check – recursively check the contained items.
|
||||
if (item.getType().name().contains("_BUNDLE") && meta instanceof BundleMeta bm) {
|
||||
for (ItemStack bundleItem : bm.getItems()) {
|
||||
if (!passes(bundleItem)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Campfire check.
|
||||
if (item.getType().name().contains("CAMPFIRE") && meta instanceof BlockStateMeta blockStateMeta) {
|
||||
BlockState bs = blockStateMeta.getBlockState();
|
||||
if (bs instanceof Campfire campfire) {
|
||||
for (int slot = 0; slot < 4; slot++) {
|
||||
ItemStack campfireItem = campfire.getItem(slot);
|
||||
if (campfireItem != null && !passes(campfireItem)) {
|
||||
ServerUtils.verbose("Campfire item failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Lectern and Chiseled Bookshelf check (by validating their inventories).
|
||||
if (item.getType().equals(Material.LECTERN) && meta instanceof BlockStateMeta blockStateMeta) {
|
||||
BlockState bs = blockStateMeta.getBlockState();
|
||||
if (bs instanceof Lectern lectern) {
|
||||
if (!new InventoryCheck().passes(lectern.getInventory())) {
|
||||
ServerUtils.verbose("Lectern inventory failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (item.getType().equals(Material.CHISELED_BOOKSHELF) && meta instanceof BlockStateMeta blockStateMeta) {
|
||||
BlockState bs = blockStateMeta.getBlockState();
|
||||
if (bs instanceof ChiseledBookshelf bookshelf) {
|
||||
if (!new InventoryCheck().passes(bookshelf.getInventory())) {
|
||||
ServerUtils.verbose("Chiseled bookshelf inventory failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spawner check.
|
||||
if (item.getType().equals(Material.SPAWNER) && meta instanceof BlockStateMeta blockStateMeta) {
|
||||
BlockState bs = blockStateMeta.getBlockState();
|
||||
if (bs instanceof CreatureSpawner spawner) {
|
||||
if (spawner.getSpawnedEntity() != null) {
|
||||
if (spawner.getSpawnedEntity().getEntityType().equals(EntityType.FALLING_BLOCK) ||
|
||||
spawner.getSpawnedEntity().getEntityType().equals(EntityType.COMMAND_BLOCK_MINECART)) {
|
||||
ServerUtils.verbose("Spawner contains disallowed entity type.");
|
||||
return false;
|
||||
}
|
||||
if (!new EntitySnapshotCheck().passes(spawner.getSpawnedEntity())) {
|
||||
ServerUtils.verbose("Spawner entity snapshot check failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trial Spawner check.
|
||||
if (item.getType() == Material.TRIAL_SPAWNER && meta instanceof BlockStateMeta blockStateMeta) {
|
||||
BlockState bs = blockStateMeta.getBlockState();
|
||||
if (bs instanceof TrialSpawner trialSpawner) {
|
||||
if (!new TrialSpawnerCheck().passes(trialSpawner)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Spawn egg checks.
|
||||
if (isSpawnEgg(item)) {
|
||||
if (!SpawnEggCheck.matches(item)) {
|
||||
ServerUtils.verbose("Spawn egg match check failed.");
|
||||
return false;
|
||||
}
|
||||
if (!new SpawnEggCheck().passes(item)) {
|
||||
ServerUtils.verbose("Spawn egg check failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Name, lore, potion, attribute and enchantment checks.
|
||||
if (!Sentinel.getInstance().getDirector().io.nbtConfig.allowName && meta.hasDisplayName()) {
|
||||
ServerUtils.verbose("Custom names not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (!Sentinel.getInstance().getDirector().io.nbtConfig.allowLore && meta.hasLore()) {
|
||||
ServerUtils.verbose("Custom lore not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (!Sentinel.getInstance().getDirector().io.nbtConfig.allowPotions &&
|
||||
(item.getType().equals(Material.POTION) ||
|
||||
item.getType().equals(Material.SPLASH_POTION) ||
|
||||
item.getType().equals(Material.LINGERING_POTION))) {
|
||||
ServerUtils.verbose("Potions not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (!Sentinel.getInstance().getDirector().io.nbtConfig.allowAttributes && meta.hasAttributeModifiers()) {
|
||||
ServerUtils.verbose("Attribute modifiers not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (Sentinel.getInstance().getDirector().io.nbtConfig.globalMaxEnchant != 0 && new EnchantmentCheck().hasIllegalEnchants(item)) {
|
||||
ServerUtils.verbose("Illegal enchantments found.");
|
||||
return false;
|
||||
}
|
||||
// Recursion check for use-remainder items.
|
||||
if (meta.hasUseRemainder()) {
|
||||
if (!Sentinel.getInstance().getDirector().io.nbtConfig.allowRecursion) {
|
||||
ServerUtils.verbose("Recursion not allowed.");
|
||||
return false;
|
||||
}
|
||||
if (meta.getUseRemainder() != null && !passes(meta.getUseRemainder())) {
|
||||
ServerUtils.verbose("Use remainder item failed check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ServerUtils.verbose("Item passed all checks.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isSpawnEgg(ItemStack item) {
|
||||
return item.getType().name().toLowerCase().contains("spawn_egg");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.trouper.sentinel.server.functions.itemchecks;
|
||||
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SpawnEggMeta;
|
||||
|
||||
public class SpawnEggCheck extends AbstractCheck<ItemStack> {
|
||||
|
||||
@Override
|
||||
public boolean passes(ItemStack item) {
|
||||
ServerUtils.verbose("Running spawn egg checks on item: ",item.getType().name());
|
||||
if (item.hasItemMeta() && item.getItemMeta() instanceof SpawnEggMeta sem) {
|
||||
if (sem.getSpawnedEntity() != null && !new EntitySnapshotCheck().passes(sem.getSpawnedEntity())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean matches(ItemStack item) {
|
||||
if (item.hasItemMeta() && item.getItemMeta() instanceof SpawnEggMeta sem) {
|
||||
String eggEntityName = item.getType().name().replace("_SPAWN_EGG", "");
|
||||
return sem.getSpawnedEntity() != null &&
|
||||
sem.getSpawnedEntity().getEntityType().name().equals(eggEntityName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.trouper.sentinel.server.functions.itemchecks;
|
||||
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.TrialSpawner;
|
||||
import org.bukkit.block.spawner.SpawnerEntry;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.spawner.TrialSpawnerConfiguration;
|
||||
|
||||
public class TrialSpawnerCheck extends AbstractCheck<TrialSpawner> {
|
||||
|
||||
@Override
|
||||
public boolean passes(TrialSpawner spawner) {
|
||||
ServerUtils.verbose("Running trial spawner check.");
|
||||
if (spawner.getNormalConfiguration() != null) {
|
||||
TrialSpawnerConfiguration config = spawner.getNormalConfiguration();
|
||||
if (config.getSpawnedEntity() != null && !new EntitySnapshotCheck().passes(config.getSpawnedEntity())) {
|
||||
ServerUtils.verbose("Trial Spawner failed check: Normal entity snapshot not allowed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (spawner.getOminousConfiguration() != null) {
|
||||
TrialSpawnerConfiguration config = spawner.getOminousConfiguration();
|
||||
if (config.getSpawnedEntity() != null && !new EntitySnapshotCheck().passes(config.getSpawnedEntity())) {
|
||||
ServerUtils.verbose("Trial Spawner failed check: Ominous entity snapshot not allowed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.trouper.sentinel.server.gui;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.builders.ItemBuilder;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.startup.Auth;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
@@ -62,7 +61,8 @@ public class Items {
|
||||
.name(Text.color("&bChat Config"))
|
||||
.lore(Text.color("&8&l➥&7 Spam Filter"))
|
||||
.lore(Text.color("&8&l➥&7 Profanity Filter"))
|
||||
.lore(Text.color("&8&l➥&7 Regex Filters"))
|
||||
.lore(Text.color("&8&l➥&7 Unicode Filter"))
|
||||
.lore(Text.color("&8&l➥&7 URL Filter"))
|
||||
.enchant(Enchantment.PROTECTION,64)
|
||||
.flag(ItemFlag.HIDE_ENCHANTS)
|
||||
.build();
|
||||
@@ -70,16 +70,18 @@ public class Items {
|
||||
public static final ItemStack ANTI_NUKE_CONFIG = ItemBuilder.create()
|
||||
.material(Material.TNT)
|
||||
.name(Text.color("&cAnti-Nuke Config"))
|
||||
.lore(Text.color("&8&l➥&7 Command Block Whitelist"))
|
||||
.lore(Text.color("&8&l➥&7 Command Block editing"))
|
||||
.lore(Text.color("&8&l➥&7 Command Block placing"))
|
||||
.lore(Text.color("&8&l➥&7 Command Block using"))
|
||||
.lore(Text.color("&8&l➥&7 Command Block Minecart placing"))
|
||||
.lore(Text.color("&8&l➥&7 Command Block Minecart using"))
|
||||
.lore(Text.color("&8&l➥&7 Creative Hotbar Items"))
|
||||
.lore(Text.color("&8&l➥&7 Manage all violations"))
|
||||
.enchant(Enchantment.PROTECTION,64)
|
||||
.flag(ItemFlag.HIDE_ENCHANTS)
|
||||
.build();
|
||||
|
||||
public static final ItemStack WHITELIST = ItemBuilder.create()
|
||||
.material(Material.TNT)
|
||||
.name(Text.color("&aCommand Block Whitelist"))
|
||||
.lore(Text.color("&8&l➥&7 Manage running command blocks"))
|
||||
.enchant(Enchantment.PROTECTION, 64)
|
||||
.flag(ItemFlag.HIDE_ENCHANTS)
|
||||
.build();
|
||||
|
||||
public static ItemStack configItem(String valueName, Material material, String description) {
|
||||
ServerUtils.verbose("Items#configItem: Creating a config item:\n Value Name -> %s\nMaterial in use -> %s".formatted(valueName,material.toString()));
|
||||
|
||||
@@ -2,6 +2,8 @@ package me.trouper.sentinel.server.gui;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.server.gui.config.ConfigGUI;
|
||||
import me.trouper.sentinel.server.gui.whitelist.WhitelistGUI;
|
||||
import me.trouper.sentinel.utils.PlayerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -21,10 +23,15 @@ public class MainGUI {
|
||||
.size(27)
|
||||
.onDefine(this::blankPage)
|
||||
.defineMain(this::mainClick)
|
||||
.define(12,Items.CREDITS)
|
||||
.define(14,Items.CONFIG,this::openConfig)
|
||||
.define(11,Items.CREDITS)
|
||||
.define(13,Items.WHITELIST,this::openWhitelist)
|
||||
.define(15,Items.CONFIG,this::openConfig)
|
||||
.build();
|
||||
|
||||
private void openWhitelist(InventoryClickEvent e) {
|
||||
e.getWhoClicked().openInventory(new WhitelistGUI().createGUI((Player) e.getWhoClicked()).getInventory());
|
||||
}
|
||||
|
||||
private void openConfig(InventoryClickEvent e) {
|
||||
e.getWhoClicked().openInventory(new ConfigGUI().home.getInventory());
|
||||
}
|
||||
@@ -42,7 +49,7 @@ public class MainGUI {
|
||||
|
||||
public static boolean verify(Player p) {
|
||||
if (PlayerUtils.isTrusted(p)) return true;
|
||||
Sentinel.log.info("WARNING: %s has just attempted to use the GUI without authorization. This has been prevented by Sentinel, as we are NOT Vulcan AntiCheat.");
|
||||
Sentinel.getInstance().getLogger().info("WARNING: %s has just attempted to use the GUI without authorization. This has been prevented by Sentinel, as we are NOT Vulcan AntiCheat.");
|
||||
p.closeInventory();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,27 @@ package me.trouper.sentinel.server.gui.config;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.builders.ItemBuilder;
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.server.gui.ConfigGUI;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.command.CommandBlockBreak;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.command.CommandBlockEdit;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.command.CommandBlockPlace;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.command.CommandBlockUse;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.jigsaw.JigsawBlockBreak;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.jigsaw.JigsawBlockPlace;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.jigsaw.JigsawBlockUse;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.structure.StructureBlockBreak;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.structure.StructureBlockPlace;
|
||||
import me.trouper.sentinel.server.events.violations.blocks.structure.StructureBlockUse;
|
||||
import me.trouper.sentinel.server.events.violations.command.DangerousCommand;
|
||||
import me.trouper.sentinel.server.events.violations.command.LoggedCommand;
|
||||
import me.trouper.sentinel.server.events.violations.command.SpecificCommand;
|
||||
import me.trouper.sentinel.server.events.violations.entities.CommandMinecartBreak;
|
||||
import me.trouper.sentinel.server.events.violations.entities.CommandMinecartPlace;
|
||||
import me.trouper.sentinel.server.events.violations.entities.CommandMinecartUse;
|
||||
import me.trouper.sentinel.server.events.violations.players.CreativeHotbar;
|
||||
import me.trouper.sentinel.server.events.violations.whitelist.CommandBlockExecute;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.nuke.CommandGUI;
|
||||
import me.trouper.sentinel.server.gui.config.nuke.checks.*;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,36 +33,48 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class AntiNukeGUI {
|
||||
public final CustomGui home = CustomGui.create()
|
||||
.title(Text.color("&6&lSentinel &8»&0 Choose a check"))
|
||||
.size(54)
|
||||
.size(9*5)
|
||||
.onDefine(this::blankPage)
|
||||
.defineMain(this::mainClick)
|
||||
.define(53, Items.BACK, e->{
|
||||
.define((9*5)-1, Items.BACK, e->{
|
||||
e.getWhoClicked().openInventory(new ConfigGUI().home.getInventory());
|
||||
})
|
||||
.define(10,COMMAND_BLOCK_WHITELIST, e->{
|
||||
e.getWhoClicked().openInventory(new CBExecuteGUI().home.getInventory());
|
||||
})
|
||||
.define(12,COMMAND_BLOCK_PLACE, e->{
|
||||
e.getWhoClicked().openInventory(new CBPlaceGUI().home.getInventory());
|
||||
})
|
||||
.define(14,COMMAND_BLOCK_USE, e->{
|
||||
e.getWhoClicked().openInventory(new CBUseGUI().home.getInventory());
|
||||
})
|
||||
.define(16,COMMAND_BLOCK_EDITING, e->{
|
||||
e.getWhoClicked().openInventory(new CBEditGUI().home.getInventory());
|
||||
})
|
||||
.define(37,COMMAND_BLOCK_MINECART_USE, e->{
|
||||
e.getWhoClicked().openInventory(new CBMCUseGUI().home.getInventory());
|
||||
})
|
||||
.define(39,COMMAND_BLOCK_MINECART_PLACE, e->{
|
||||
e.getWhoClicked().openInventory(new CBMCPlaceGUI().home.getInventory());
|
||||
})
|
||||
.define(41,COMMAND_EXECUTE, e->{
|
||||
e.getWhoClicked().openInventory(new CommandGUI().home.getInventory());
|
||||
})
|
||||
.define(43,HOTBAR_ACTION, e->{
|
||||
e.getWhoClicked().openInventory(new HotbarActionGUI().home.getInventory());
|
||||
})
|
||||
.define(10,getCheckItem(Material.COMMAND_BLOCK,"Command Block Break"),
|
||||
e->e.getWhoClicked().openInventory(new CommandBlockBreak().getConfigGui().getInventory()))
|
||||
.define(11,getCheckItem(Material.REPEATING_COMMAND_BLOCK,"Command Block Edit"),
|
||||
e->e.getWhoClicked().openInventory(new CommandBlockEdit().getConfigGui().getInventory()))
|
||||
.define(12,getCheckItem(Material.CHAIN_COMMAND_BLOCK,"Command Block Place"),
|
||||
e->e.getWhoClicked().openInventory(new CommandBlockPlace().getConfigGui().getInventory()))
|
||||
.define(13,getCheckItem(Material.CHAIN_COMMAND_BLOCK,"Command Block Use"),
|
||||
e->e.getWhoClicked().openInventory(new CommandBlockUse().getConfigGui().getInventory()))
|
||||
.define(14,getCheckItem(Material.JIGSAW,"Jigsaw Block Break"),
|
||||
e->e.getWhoClicked().openInventory(new JigsawBlockBreak().getConfigGui().getInventory()))
|
||||
.define(15,getCheckItem(Material.JIGSAW,"Jigsaw Block Place"),
|
||||
e->e.getWhoClicked().openInventory(new JigsawBlockPlace().getConfigGui().getInventory()))
|
||||
.define(16,getCheckItem(Material.JIGSAW,"Jigsaw Block Use"),
|
||||
e->e.getWhoClicked().openInventory(new JigsawBlockUse().getConfigGui().getInventory()))
|
||||
.define(19,getCheckItem(Material.STRUCTURE_BLOCK,"Structure Block Break"),
|
||||
e->e.getWhoClicked().openInventory(new StructureBlockBreak().getConfigGui().getInventory()))
|
||||
.define(20,getCheckItem(Material.STRUCTURE_BLOCK,"Structure Block Place"),
|
||||
e->e.getWhoClicked().openInventory(new StructureBlockPlace().getConfigGui().getInventory()))
|
||||
.define(21,getCheckItem(Material.STRUCTURE_BLOCK,"Structure Block Use"),
|
||||
e->e.getWhoClicked().openInventory(new StructureBlockUse().getConfigGui().getInventory()))
|
||||
.define(22,getCheckItem(Material.TNT,"Dangerous Commands"),
|
||||
e->e.getWhoClicked().openInventory(new DangerousCommand().getConfigGui().getInventory()))
|
||||
.define(23,getCheckItem(Material.ENDER_PEARL,"Specific Commands"),
|
||||
e->e.getWhoClicked().openInventory(new SpecificCommand().getConfigGui().getInventory()))
|
||||
.define(24,getCheckItem(Material.SPYGLASS,"Logged Commands"),
|
||||
e->e.getWhoClicked().openInventory(new LoggedCommand().getConfigGui().getInventory()))
|
||||
.define(25,getCheckItem(Material.TNT_MINECART,"Command Minecart Break"),
|
||||
e->e.getWhoClicked().openInventory(new CommandMinecartBreak().getConfigGui().getInventory()))
|
||||
.define(29,getCheckItem(Material.COMMAND_BLOCK_MINECART,"Command Minecart Place"),
|
||||
e->e.getWhoClicked().openInventory(new CommandMinecartPlace().getConfigGui().getInventory()))
|
||||
.define(30,getCheckItem(Material.COMMAND_BLOCK_MINECART,"Command Minecart Use"),
|
||||
e->e.getWhoClicked().openInventory(new CommandMinecartUse().getConfigGui().getInventory()))
|
||||
.define(32,getCheckItem(Material.DIAMOND_SWORD,"NBT Item Pull"),
|
||||
e->e.getWhoClicked().openInventory(new CreativeHotbar().getConfigGui().getInventory()))
|
||||
.define(33,getCheckItem(Material.EMERALD,"Command Block Whitelist"),
|
||||
e->e.getWhoClicked().openInventory(new CommandBlockExecute().getConfigGui().getInventory()))
|
||||
.build();
|
||||
|
||||
private void mainClick(InventoryClickEvent e) {
|
||||
@@ -55,59 +83,17 @@ public class AntiNukeGUI {
|
||||
}
|
||||
|
||||
private void blankPage(Inventory inv) {
|
||||
ServerUtils.verbose("Making anti-nuke page");
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
inv.setItem(i,Items.BLANK);
|
||||
}
|
||||
}
|
||||
|
||||
private static final ItemStack COMMAND_BLOCK_EDITING = ItemBuilder.create()
|
||||
.material(Material.DEBUG_STICK)
|
||||
.name(Text.color("&bCommand Block Editing"))
|
||||
.lore(Text.color("&8&l➥&7 Modify this check"))
|
||||
.build();
|
||||
|
||||
private static final ItemStack COMMAND_BLOCK_WHITELIST = ItemBuilder.create()
|
||||
.material(Material.EMERALD)
|
||||
.name(Text.color("&bCommand Block Whitelist"))
|
||||
.lore(Text.color("&8&l➥&7 Modify this check"))
|
||||
.build();
|
||||
|
||||
private static final ItemStack COMMAND_BLOCK_MINECART_PLACE = ItemBuilder.create()
|
||||
.material(Material.RAIL)
|
||||
.name(Text.color("&bCommand Block Minecart Placing"))
|
||||
.lore(Text.color("&8&l➥&7 Modify this check"))
|
||||
.build();
|
||||
|
||||
private static final ItemStack COMMAND_BLOCK_MINECART_USE = ItemBuilder.create()
|
||||
.material(Material.COMMAND_BLOCK_MINECART)
|
||||
.name(Text.color("&bCommand Block Minecart Using"))
|
||||
.lore(Text.color("&8&l➥&7 Modify this check"))
|
||||
.build();
|
||||
|
||||
private static final ItemStack COMMAND_BLOCK_PLACE = ItemBuilder.create()
|
||||
.material(Material.CHAIN_COMMAND_BLOCK)
|
||||
.name(Text.color("&bCommand Block Placing"))
|
||||
.lore(Text.color("&8&l➥&7 Modify this check"))
|
||||
.build();
|
||||
|
||||
private static final ItemStack COMMAND_BLOCK_USE = ItemBuilder.create()
|
||||
.material(Material.REPEATING_COMMAND_BLOCK)
|
||||
.name(Text.color("&bCommand Block Using"))
|
||||
.lore(Text.color("&8&l➥&7 Modify this check"))
|
||||
.build();
|
||||
|
||||
private static final ItemStack COMMAND_EXECUTE = ItemBuilder.create()
|
||||
.material(Material.SPYGLASS)
|
||||
.name(Text.color("&bCommand Execution"))
|
||||
.lore(Text.color("&8&l➥&7 Dangerous Commands"))
|
||||
.lore(Text.color("&8&l➥&7 Logged Commands"))
|
||||
.lore(Text.color("&8&l➥&7 Specific Commands"))
|
||||
.build();
|
||||
|
||||
private static final ItemStack HOTBAR_ACTION = ItemBuilder.create()
|
||||
.material(Material.DIAMOND_SWORD)
|
||||
.name(Text.color("&bNBT Items"))
|
||||
.lore(Text.color("&8&l➥&7 Modify this check"))
|
||||
.build();
|
||||
|
||||
private static ItemStack getCheckItem(Material item, String name) {
|
||||
return ItemBuilder.create()
|
||||
.material(item)
|
||||
.name(Text.color("&b" + name))
|
||||
.lore(Text.color("&8&l➥&7 Modify this check"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package me.trouper.sentinel.server.gui;
|
||||
package me.trouper.sentinel.server.gui.config;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.server.gui.config.AntiNukeGUI;
|
||||
import me.trouper.sentinel.server.gui.config.ChatGUI;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.chat.ChatGUI;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@@ -14,7 +15,7 @@ public class ConfigGUI {
|
||||
.size(27)
|
||||
.onDefine(this::blankPage)
|
||||
.defineMain(this::mainClick)
|
||||
.define(12, Items.ANTI_NUKE_CONFIG,e->{
|
||||
.define(12, Items.ANTI_NUKE_CONFIG, e->{
|
||||
e.getWhoClicked().openInventory(new AntiNukeGUI().home.getInventory());
|
||||
})
|
||||
.define(14,Items.CHAT_CONFIG,e->{
|
||||
@@ -1,14 +1,10 @@
|
||||
package me.trouper.sentinel.server.gui.config;
|
||||
package me.trouper.sentinel.server.gui.config.chat;
|
||||
|
||||
import io.github.itzispyder.pdk.plugin.builders.ItemBuilder;
|
||||
import io.github.itzispyder.pdk.plugin.gui.CustomGui;
|
||||
import me.trouper.sentinel.server.gui.ConfigGUI;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.chat.ProfanityFilterGUI;
|
||||
import me.trouper.sentinel.server.gui.config.chat.SpamFilterGUI;
|
||||
import me.trouper.sentinel.server.gui.config.chat.UnicodeFilterGUI;
|
||||
import me.trouper.sentinel.server.gui.config.chat.UrlFilterGUI;
|
||||
import me.trouper.sentinel.server.gui.config.ConfigGUI;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import org.bukkit.Material;
|
||||
@@ -8,7 +8,6 @@ import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.config.MainConfig;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.ChatGUI;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -17,7 +16,6 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -44,7 +42,7 @@ public class ProfanityFilterGUI {
|
||||
}
|
||||
ServerUtils.verbose("ProfanityFilterGUI#blankPage Page now blank");
|
||||
ItemStack top = Items.RED;
|
||||
if (Sentinel.mainConfig.chat.profanityFilter.enabled) {
|
||||
if (Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.enabled) {
|
||||
top = Items.GREEN;
|
||||
}
|
||||
|
||||
@@ -54,18 +52,18 @@ public class ProfanityFilterGUI {
|
||||
ServerUtils.verbose("ProfanityFilterGUI#blankPage Adding GUI Items");
|
||||
|
||||
inv.setItem(53,Items.BACK);
|
||||
inv.setItem(3,Items.booleanItem(Sentinel.mainConfig.chat.profanityFilter.enabled, Items.configItem("Profanity Filter Toggle",Material.CLOCK,"Enable or Disable the whole Profanity filter")));
|
||||
inv.setItem(5,Items.booleanItem(Sentinel.mainConfig.chat.profanityFilter.silent, Items.configItem("Silent Mode",Material.FEATHER,"Whether to notify players that their messages \nwere blocked. Enabling could help deter bypassing.")));
|
||||
inv.setItem(10,Items.intItem(Sentinel.mainConfig.chat.profanityFilter.lowScore, Items.configItem("Low Score Gain", Material.WHITE_WOOL, "How much score will be added if the player \ndid not attempt to bypass the filter.")));
|
||||
inv.setItem(19,Items.intItem(Sentinel.mainConfig.chat.profanityFilter.mediumLowScore, Items.configItem("Medium-Low Score Gain", Material.LIME_WOOL, "How much score will be added if the player \nused l33t speak to attempt a bypass")));
|
||||
inv.setItem(28,Items.intItem(Sentinel.mainConfig.chat.profanityFilter.mediumScore, Items.configItem("Medium Score Gain", Material.YELLOW_WOOL, "How much score will be added if the player \nused sp/ecia|l characters to attempt a bypass")));
|
||||
inv.setItem(37,Items.intItem(Sentinel.mainConfig.chat.profanityFilter.mediumHighScore, Items.configItem("Medium-High Score Gain", Material.ORANGE_WOOL, "How much score will be added if the player \nused reeeeeeepeating letters to attempt a bypass")));
|
||||
inv.setItem(46,Items.intItem(Sentinel.mainConfig.chat.profanityFilter.highScore, Items.configItem("High Score Gain", Material.RED_WOOL, "How much score will be added if the player \nused pun. ctua, tion or spaces to attempt a bypass")));
|
||||
inv.setItem(29,Items.intItem(Sentinel.mainConfig.chat.profanityFilter.regexScore, Items.configItem("Regex Score Gain", Material.DISPENSER, "How much score will be added if the player \nmatched the regex setting throughout \nthe processing of the message")));
|
||||
inv.setItem(22,Items.intItem(Sentinel.mainConfig.chat.profanityFilter.punishScore, Items.configItem("Punish Score", Material.IRON_BARS, "If the player's score is above this \nthe punishment commands will be ran.")));
|
||||
inv.setItem(33,Items.intItem(Sentinel.mainConfig.chat.profanityFilter.scoreDecay, Items.configItem("Score Decay", Material.DEAD_BUBBLE_CORAL_BLOCK, "How much score players will loose each minute.")));
|
||||
inv.setItem(31,Items.stringListItem(Sentinel.mainConfig.chat.profanityFilter.profanityPunishCommands,Material.WOODEN_AXE, "Default Punishment Commands", "%player% will be replaced with the offender's name"));
|
||||
inv.setItem(40,Items.stringListItem(Sentinel.mainConfig.chat.profanityFilter.strictPunishCommands,Material.DIAMOND_AXE, "Strict Punishment Commands", "If words from the strict words list are flagged, \nthis list will be ran instead \n%player% will be replaced with the offender's name"));
|
||||
inv.setItem(3,Items.booleanItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.enabled, Items.configItem("Profanity Filter Toggle",Material.CLOCK,"Enable or Disable the whole Profanity filter")));
|
||||
inv.setItem(5,Items.booleanItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.silent, Items.configItem("Silent Mode",Material.FEATHER,"Whether to notify players that their messages \nwere blocked. Enabling could help deter bypassing.")));
|
||||
inv.setItem(10,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.lowScore, Items.configItem("Low Score Gain", Material.WHITE_WOOL, "How much score will be added if the player \ndid not attempt to bypass the filter.")));
|
||||
inv.setItem(19,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.mediumLowScore, Items.configItem("Medium-Low Score Gain", Material.LIME_WOOL, "How much score will be added if the player \nused l33t speak to attempt a bypass")));
|
||||
inv.setItem(28,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.mediumScore, Items.configItem("Medium Score Gain", Material.YELLOW_WOOL, "How much score will be added if the player \nused sp/ecia|l characters to attempt a bypass")));
|
||||
inv.setItem(37,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.mediumHighScore, Items.configItem("Medium-High Score Gain", Material.ORANGE_WOOL, "How much score will be added if the player \nused reeeeeeepeating letters to attempt a bypass")));
|
||||
inv.setItem(46,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.highScore, Items.configItem("High Score Gain", Material.RED_WOOL, "How much score will be added if the player \nused pun. ctua, tion or spaces to attempt a bypass")));
|
||||
inv.setItem(29,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.regexScore, Items.configItem("Regex Score Gain", Material.DISPENSER, "How much score will be added if the player \nmatched the regex setting throughout \nthe processing of the message")));
|
||||
inv.setItem(22,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.punishScore, Items.configItem("Punish Score", Material.IRON_BARS, "If the player's score is above this \nthe punishment commands will be ran.")));
|
||||
inv.setItem(33,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.scoreDecay, Items.configItem("Score Decay", Material.DEAD_BUBBLE_CORAL_BLOCK, "How much score players will loose each minute.")));
|
||||
inv.setItem(31,Items.stringListItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.profanityPunishCommands,Material.WOODEN_AXE, "Default Punishment Commands", "%player% will be replaced with the offender's name"));
|
||||
inv.setItem(40,Items.stringListItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.strictPunishCommands,Material.DIAMOND_AXE, "Strict Punishment Commands", "If words from the strict words list are flagged, \nthis list will be ran instead \n%player% will be replaced with the offender's name"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -76,35 +74,35 @@ public class ProfanityFilterGUI {
|
||||
if (!MainGUI.verify((Player) e.getWhoClicked())) return;
|
||||
switch (e.getSlot()) {
|
||||
case 3 -> {
|
||||
Sentinel.mainConfig.chat.profanityFilter.enabled = !Sentinel.mainConfig.chat.profanityFilter.enabled;
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.enabled = !Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.enabled;
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
blankPage(e.getInventory());
|
||||
}
|
||||
|
||||
case 5 -> {
|
||||
Sentinel.mainConfig.chat.profanityFilter.silent = !Sentinel.mainConfig.chat.profanityFilter.silent;
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.silent = !Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.silent;
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
blankPage(e.getInventory());
|
||||
}
|
||||
|
||||
case 10 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.lowScore = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.profanityFilter.lowScore);
|
||||
case 19 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.mediumLowScore = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.profanityFilter.mediumLowScore);
|
||||
case 28 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.mediumScore = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.profanityFilter.mediumScore);
|
||||
case 37 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.mediumHighScore = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.profanityFilter.mediumHighScore);
|
||||
case 46 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.highScore = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.profanityFilter.highScore);
|
||||
case 29 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.regexScore = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.profanityFilter.regexScore);
|
||||
case 22 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.punishScore = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.profanityFilter.punishScore);
|
||||
case 33 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.scoreDecay = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.profanityFilter.scoreDecay);
|
||||
case 10 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.lowScore = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.lowScore);
|
||||
case 19 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.mediumLowScore = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.mediumLowScore);
|
||||
case 28 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.mediumScore = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.mediumScore);
|
||||
case 37 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.mediumHighScore = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.mediumHighScore);
|
||||
case 46 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.highScore = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.highScore);
|
||||
case 29 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.regexScore = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.regexScore);
|
||||
case 22 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.punishScore = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.punishScore);
|
||||
case 33 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.profanityFilter.scoreDecay = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.scoreDecay);
|
||||
|
||||
case 31 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> {
|
||||
cfg.chat.profanityFilter.profanityPunishCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.mainConfig.chat.profanityFilter.profanityPunishCommands);
|
||||
},"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.profanityPunishCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.mainConfig.chat.profanityFilter.profanityPunishCommands.clear();
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.profanityPunishCommands.clear();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
blankPage(e.getInventory());
|
||||
|
||||
}
|
||||
@@ -112,17 +110,17 @@ public class ProfanityFilterGUI {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> {
|
||||
cfg.chat.profanityFilter.strictPunishCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.mainConfig.chat.profanityFilter.strictPunishCommands);
|
||||
},"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.strictPunishCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.mainConfig.chat.profanityFilter.strictPunishCommands.clear();
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.profanityFilter.strictPunishCommands.clear();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
blankPage(e.getInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ConfigUpdater<AsyncChatEvent, MainConfig> updater = new ConfigUpdater<>(Sentinel.mainConfig);
|
||||
public static ConfigUpdater<AsyncChatEvent, MainConfig> updater = new ConfigUpdater<>(Sentinel.getInstance().getDirector().io.mainConfig);
|
||||
|
||||
private void queuePlayer(Player player, BiConsumer<MainConfig, Args> action, String currentValue) {
|
||||
MainGUI.awaitingCallback.add(player.getUniqueId());
|
||||
|
||||
@@ -8,8 +8,6 @@ import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.config.MainConfig;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.ChatGUI;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
@@ -17,7 +15,6 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -43,7 +40,7 @@ public class SpamFilterGUI {
|
||||
}
|
||||
|
||||
ItemStack top = Items.RED;
|
||||
if (Sentinel.mainConfig.chat.spamFilter.enabled) {
|
||||
if (Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.enabled) {
|
||||
top = Items.GREEN;
|
||||
}
|
||||
|
||||
@@ -52,18 +49,18 @@ public class SpamFilterGUI {
|
||||
}
|
||||
|
||||
inv.setItem(53,Items.BACK);
|
||||
inv.setItem(3,Items.booleanItem(Sentinel.mainConfig.chat.spamFilter.enabled, Items.configItem("Spam Filter Toggle", Material.CLOCK, "Enable or disable the whole Spam Filter")));
|
||||
inv.setItem(5,Items.booleanItem(Sentinel.mainConfig.chat.spamFilter.silent, Items.configItem("Silent Toggle", Material.FEATHER, "Whether to notify players that their messages \nwere blocked. Enabling could help deter bypassing.")));
|
||||
inv.setItem(10,Items.intItem(Sentinel.mainConfig.chat.spamFilter.defaultGain, Items.configItem("Default Heat Gain", Material.BUCKET, "How much heat will be added to each message.")));
|
||||
inv.setItem(19,Items.intItem(Sentinel.mainConfig.chat.spamFilter.lowGain, Items.configItem("Low Heat Gain", Material.WATER_BUCKET, "Extra heat to be added if the \nmessage is greater than 25% similar \nto their previous message.")));
|
||||
inv.setItem(28,Items.intItem(Sentinel.mainConfig.chat.spamFilter.mediumGain, Items.configItem("Medium Heat Gain", Material.COD_BUCKET, "Extra heat to be added if the \nmessage is greater than 50% similar \nto their previous message.")));
|
||||
inv.setItem(37,Items.intItem(Sentinel.mainConfig.chat.spamFilter.highGain, Items.configItem("High Heat Gain", Material.PUFFERFISH_BUCKET, "Extra heat to be added if the \nmessage is greater than 90% similar \nto their previous message.")));
|
||||
inv.setItem(46,Items.intItem(Sentinel.mainConfig.chat.spamFilter.blockHeat, Items.configItem("Block Heat", Material.BARRIER, "If the player's heat is above this \nthen their message will be blocked and \nflagged as spam.")));
|
||||
inv.setItem(21,Items.intItem(Sentinel.mainConfig.chat.spamFilter.blockSimilarity, Items.configItem("Block Similarity", Material.BARRIER, "If the message's similarity is above \nthis, it will get automatically blocked \nand flagged as spam.")));
|
||||
inv.setItem(23,Items.intItem(Sentinel.mainConfig.chat.spamFilter.punishHeat, Items.configItem("Punish Heat", Material.IRON_BARS, "If the player's heat is above this \nthe punishment commands will be ran.")));
|
||||
inv.setItem(25,Items.intItem(Sentinel.mainConfig.chat.spamFilter.heatDecay, Items.configItem("Heat Decay", Material.DEAD_BUBBLE_CORAL_BLOCK, "How much heat players will loose each second.")));
|
||||
inv.setItem(32,Items.stringListItem(Sentinel.mainConfig.chat.spamFilter.punishCommands,Material.DIAMOND_AXE, "Punishment Commands", "%player% will be replaced with the offender's name"));
|
||||
inv.setItem(34,Items.stringListItem(Sentinel.mainConfig.chat.spamFilter.whitelist,Material.PAPER, "Message Whitelist", "Messages which will be ignored by the spam filter"));
|
||||
inv.setItem(3,Items.booleanItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.enabled, Items.configItem("Spam Filter Toggle", Material.CLOCK, "Enable or disable the whole Spam Filter")));
|
||||
inv.setItem(5,Items.booleanItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.silent, Items.configItem("Silent Toggle", Material.FEATHER, "Whether to notify players that their messages \nwere blocked. Enabling could help deter bypassing.")));
|
||||
inv.setItem(10,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.defaultGain, Items.configItem("Default Heat Gain", Material.BUCKET, "How much heat will be added to each message.")));
|
||||
inv.setItem(19,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.lowGain, Items.configItem("Low Heat Gain", Material.WATER_BUCKET, "Extra heat to be added if the \nmessage is greater than 25% similar \nto their previous message.")));
|
||||
inv.setItem(28,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.mediumGain, Items.configItem("Medium Heat Gain", Material.COD_BUCKET, "Extra heat to be added if the \nmessage is greater than 50% similar \nto their previous message.")));
|
||||
inv.setItem(37,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.highGain, Items.configItem("High Heat Gain", Material.PUFFERFISH_BUCKET, "Extra heat to be added if the \nmessage is greater than 90% similar \nto their previous message.")));
|
||||
inv.setItem(46,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.blockHeat, Items.configItem("Block Heat", Material.BARRIER, "If the player's heat is above this \nthen their message will be blocked and \nflagged as spam.")));
|
||||
inv.setItem(21,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.blockSimilarity, Items.configItem("Block Similarity", Material.BARRIER, "If the message's similarity is above \nthis, it will get automatically blocked \nand flagged as spam.")));
|
||||
inv.setItem(23,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.punishHeat, Items.configItem("Punish Heat", Material.IRON_BARS, "If the player's heat is above this \nthe punishment commands will be ran.")));
|
||||
inv.setItem(25,Items.intItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.heatDecay, Items.configItem("Heat Decay", Material.DEAD_BUBBLE_CORAL_BLOCK, "How much heat players will loose each second.")));
|
||||
inv.setItem(32,Items.stringListItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.punishCommands,Material.DIAMOND_AXE, "Punishment Commands", "%player% will be replaced with the offender's name"));
|
||||
inv.setItem(34,Items.stringListItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.whitelist,Material.PAPER, "Message Whitelist", "Messages which will be ignored by the spam filter"));
|
||||
}
|
||||
|
||||
private void mainClick(InventoryClickEvent e) {
|
||||
@@ -73,40 +70,40 @@ public class SpamFilterGUI {
|
||||
|
||||
switch (e.getSlot()) {
|
||||
case 3 -> {
|
||||
Sentinel.mainConfig.chat.spamFilter.enabled = !Sentinel.mainConfig.chat.spamFilter.enabled;
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.enabled = !Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.enabled;
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
blankPage(e.getInventory());
|
||||
}
|
||||
case 5 -> {
|
||||
Sentinel.mainConfig.chat.spamFilter.silent = !Sentinel.mainConfig.chat.spamFilter.silent;
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.silent = !Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.silent;
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
blankPage(e.getInventory());
|
||||
}
|
||||
|
||||
case 10 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.defaultGain = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.spamFilter.defaultGain);
|
||||
case 19 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.lowGain = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.spamFilter.lowGain);
|
||||
case 28 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.mediumGain = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.spamFilter.mediumGain);
|
||||
case 37 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.highGain = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.spamFilter.highGain);
|
||||
case 46 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.blockHeat = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.spamFilter.blockHeat);
|
||||
case 21 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.blockSimilarity = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.spamFilter.blockSimilarity);
|
||||
case 23 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.punishHeat = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.spamFilter.punishHeat);
|
||||
case 25 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.heatDecay = args.getAll().toInt(),"" + Sentinel.mainConfig.chat.spamFilter.heatDecay);
|
||||
case 10 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.defaultGain = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.defaultGain);
|
||||
case 19 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.lowGain = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.lowGain);
|
||||
case 28 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.mediumGain = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.mediumGain);
|
||||
case 37 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.highGain = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.highGain);
|
||||
case 46 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.blockHeat = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.blockHeat);
|
||||
case 21 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.blockSimilarity = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.blockSimilarity);
|
||||
case 23 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.punishHeat = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.punishHeat);
|
||||
case 25 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.spamFilter.heatDecay = args.getAll().toInt(),"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.heatDecay);
|
||||
|
||||
case 32 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> {
|
||||
cfg.chat.spamFilter.punishCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.mainConfig.chat.spamFilter.punishCommands);
|
||||
},"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.punishCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.mainConfig.chat.spamFilter.punishCommands.clear();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.spamFilter.punishCommands.clear();
|
||||
blankPage(e.getInventory());
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ConfigUpdater<AsyncChatEvent, MainConfig> updater = new ConfigUpdater<>(Sentinel.mainConfig);
|
||||
public static ConfigUpdater<AsyncChatEvent, MainConfig> updater = new ConfigUpdater<>(Sentinel.getInstance().getDirector().io.mainConfig);
|
||||
|
||||
private void queuePlayer(Player player, BiConsumer<MainConfig, Args> action, String currentValue) {
|
||||
MainGUI.awaitingCallback.add(player.getUniqueId());
|
||||
|
||||
@@ -8,7 +8,6 @@ import me.trouper.sentinel.Sentinel;
|
||||
import me.trouper.sentinel.data.config.MainConfig;
|
||||
import me.trouper.sentinel.server.gui.Items;
|
||||
import me.trouper.sentinel.server.gui.MainGUI;
|
||||
import me.trouper.sentinel.server.gui.config.ChatGUI;
|
||||
import me.trouper.sentinel.utils.ServerUtils;
|
||||
import me.trouper.sentinel.utils.Text;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -41,7 +40,7 @@ public class UnicodeFilterGUI {
|
||||
}
|
||||
ServerUtils.verbose("Unicode Filter GUI blank!");
|
||||
ItemStack top = Items.RED;
|
||||
if (Sentinel.mainConfig.chat.unicodeFilter.enabled) {
|
||||
if (Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.enabled) {
|
||||
top = Items.GREEN;
|
||||
}
|
||||
|
||||
@@ -49,11 +48,11 @@ public class UnicodeFilterGUI {
|
||||
inv.setItem(i,top);
|
||||
}
|
||||
|
||||
inv.setItem(3,Items.booleanItem(Sentinel.mainConfig.chat.unicodeFilter.enabled, Items.configItem("Unicode Filter Toggle", Material.CLOCK,"Enable or Disable the whole Unicode filter")));
|
||||
inv.setItem(5,Items.booleanItem(Sentinel.mainConfig.chat.unicodeFilter.silent, Items.configItem("Silent Mode",Material.FEATHER,"Whether to notify players that their messages \nwere blocked. Enabling could help deter bypassing.")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.mainConfig.chat.unicodeFilter.punished,Items.configItem("Punished",Material.IRON_BARS,"Toggles execution of punishment commands.")));
|
||||
inv.setItem(22,Items.stringItem(Sentinel.mainConfig.chat.unicodeFilter.regex,Items.configItem("Allowed Char Regex",Material.DISPENSER,"Toggles execution of punishment commands.")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.mainConfig.chat.unicodeFilter.punishCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands which will be executed if punishment is enabled."));
|
||||
inv.setItem(3,Items.booleanItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.enabled, Items.configItem("Unicode Filter Toggle", Material.CLOCK,"Enable or Disable the whole Unicode filter")));
|
||||
inv.setItem(5,Items.booleanItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.silent, Items.configItem("Silent Mode",Material.FEATHER,"Whether to notify players that their messages \nwere blocked. Enabling could help deter bypassing.")));
|
||||
inv.setItem(20,Items.booleanItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.punished,Items.configItem("Punished",Material.IRON_BARS,"Toggles execution of punishment commands.")));
|
||||
inv.setItem(22,Items.stringItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.regex,Items.configItem("Allowed Char Regex",Material.DISPENSER,"Toggles execution of punishment commands.")));
|
||||
inv.setItem(24,Items.stringListItem(Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.punishCommands,Material.DIAMOND_AXE,"Punishment Commands","Commands which will be executed if punishment is enabled."));
|
||||
|
||||
}
|
||||
|
||||
@@ -63,41 +62,41 @@ public class UnicodeFilterGUI {
|
||||
|
||||
switch (e.getSlot()) {
|
||||
case 3 -> {
|
||||
Sentinel.mainConfig.chat.unicodeFilter.enabled = !Sentinel.mainConfig.chat.unicodeFilter.enabled;
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.enabled = !Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.enabled;
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
blankPage(e.getInventory());
|
||||
}
|
||||
|
||||
case 5 -> {
|
||||
Sentinel.mainConfig.chat.unicodeFilter.silent = !Sentinel.mainConfig.chat.unicodeFilter.silent;
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.silent = !Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.silent;
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
blankPage(e.getInventory());
|
||||
}
|
||||
|
||||
case 20 -> {
|
||||
Sentinel.mainConfig.chat.unicodeFilter.punished = !Sentinel.mainConfig.chat.unicodeFilter.punished;
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.punished = !Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.punished;
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
blankPage(e.getInventory());
|
||||
}
|
||||
|
||||
case 22 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.unicodeFilter.regex = args.getAll().toString(),Sentinel.mainConfig.chat.unicodeFilter.regex);
|
||||
case 22 -> queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> cfg.chat.unicodeFilter.regex = args.getAll().toString(),Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.regex);
|
||||
|
||||
case 24 -> {
|
||||
if (e.isLeftClick()) {
|
||||
queuePlayer((Player) e.getWhoClicked(), (cfg,args) -> {
|
||||
cfg.chat.unicodeFilter.punishCommands.add(args.getAll().toString());
|
||||
},"" + Sentinel.mainConfig.chat.unicodeFilter.punishCommands);
|
||||
},"" + Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.punishCommands);
|
||||
return;
|
||||
}
|
||||
Sentinel.mainConfig.chat.unicodeFilter.punishCommands.clear();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.chat.unicodeFilter.punishCommands.clear();
|
||||
blankPage(e.getInventory());
|
||||
Sentinel.mainConfig.save();
|
||||
Sentinel.getInstance().getDirector().io.mainConfig.save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ConfigUpdater<AsyncChatEvent, MainConfig> updater = new ConfigUpdater<>(Sentinel.mainConfig);
|
||||
public static ConfigUpdater<AsyncChatEvent, MainConfig> updater = new ConfigUpdater<>(Sentinel.getInstance().getDirector().io.mainConfig);
|
||||
|
||||
private void queuePlayer(Player player, BiConsumer<MainConfig, Args> action, String currentValue) {
|
||||
MainGUI.awaitingCallback.add(player.getUniqueId());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user