Started CBW
This commit is contained in:
@@ -4,12 +4,10 @@ import io.github.itzispyder.pdk.PDK;
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
import io.github.thetrouper.sentinel.auth.Auth;
|
||||
import io.github.thetrouper.sentinel.cmds.*;
|
||||
import io.github.thetrouper.sentinel.data.cmdblocks.WhitelistStorage;
|
||||
import io.github.thetrouper.sentinel.data.config.*;
|
||||
import io.github.thetrouper.sentinel.events.*;
|
||||
import io.github.thetrouper.sentinel.server.functions.AntiSpam;
|
||||
import io.github.thetrouper.sentinel.server.functions.Authenticator;
|
||||
import io.github.thetrouper.sentinel.server.functions.ProfanityFilter;
|
||||
import io.github.thetrouper.sentinel.server.functions.Telemetry;
|
||||
import io.github.thetrouper.sentinel.server.functions.*;
|
||||
import io.github.thetrouper.sentinel.server.util.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -29,6 +27,8 @@ public final class Sentinel extends JavaPlugin {
|
||||
private static final File swrcfg = new File("plugins/Sentinel/swears.json");
|
||||
private static final File fpcfg = new File("plugins/Sentinel/false-positives.json");
|
||||
private static final File advcfg = new File("plugins/Sentinel/advanced-config.json");
|
||||
private static final File cmdWhitelist = new File("plugins/Sentinel/storage/whitelist.json");
|
||||
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());
|
||||
@@ -170,6 +170,7 @@ public final class Sentinel extends JavaPlugin {
|
||||
swearConfig = JsonSerializable.load(swrcfg,SwearsConfig.class,new SwearsConfig());
|
||||
nbtConfig = JsonSerializable.load(nbtcfg,NBTConfig.class,new NBTConfig());
|
||||
|
||||
|
||||
// Save
|
||||
mainConfig.save();
|
||||
advConfig.save();
|
||||
|
||||
@@ -28,6 +28,9 @@ public class SentinelCommand implements CustomCommand {
|
||||
Player p = (Player) commandSender;
|
||||
Sentinel instance = Sentinel.getInstance();
|
||||
switch (args.get(0).toString()) {
|
||||
case "commandblock", "cb" -> {
|
||||
|
||||
}
|
||||
case "reload" -> {
|
||||
if (!Sentinel.isTrusted(p)) return;
|
||||
p.sendMessage(Text.prefix("Reloading Sentinel!"));
|
||||
@@ -39,29 +42,29 @@ public class SentinelCommand implements CustomCommand {
|
||||
SystemCheck.fullCheck(p);
|
||||
}
|
||||
case "debug" -> {
|
||||
switch (args.get(1).toString()) {
|
||||
case "antiswear" -> {
|
||||
HashSet<Player> players = new HashSet<>();
|
||||
players.add(p);
|
||||
String msg = args.getAll(1).toString().trim();
|
||||
AsyncPlayerChatEvent e = new AsyncPlayerChatEvent(true, p, msg, players);
|
||||
ProfanityFilter.handleProfanityFilter(e);
|
||||
}
|
||||
case "antispam" -> {
|
||||
HashSet<Player> players = new HashSet<>();
|
||||
players.add(p);
|
||||
String msg = args.getAll(1).toString().trim();
|
||||
AsyncPlayerChatEvent e = new AsyncPlayerChatEvent(true, p, msg, players);
|
||||
io.github.thetrouper.sentinel.server.functions.AntiSpam.handleAntiSpam(e);
|
||||
}
|
||||
case "lang" -> {
|
||||
p.sendMessage(Sentinel.language.get("exmaple-message"));
|
||||
}
|
||||
case "toggle" -> {
|
||||
debugMode = !debugMode;
|
||||
p.sendMessage(Text.prefix((debugMode ? "Enabled" : "Disabled") + " debug mode."));
|
||||
}
|
||||
case "encrypt" -> {
|
||||
handleDebugCommand(p,args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleCommandBlock(Player p, Args args) {
|
||||
switch (args.get(1).toString()) {
|
||||
case "whitelist" -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDebugCommand(Player p, Args args) {
|
||||
switch (args.get(1).toString()) {
|
||||
case "lang" -> {
|
||||
p.sendMessage(Sentinel.language.get("exmaple-message"));
|
||||
}
|
||||
case "toggle" -> {
|
||||
debugMode = !debugMode;
|
||||
p.sendMessage(Text.prefix((debugMode ? "Enabled" : "Disabled") + " debug mode."));
|
||||
}
|
||||
/*case "encrypt" -> {
|
||||
final String enc = CipherUtils.encrypt(args.getAll(2).toString());
|
||||
final String check = CipherUtils.decrypt(enc);
|
||||
final String main = Text.prefix("Successfully encrypted \"&e" + check + "&7\" using AES.\n &7> &b" + enc);
|
||||
@@ -71,24 +74,15 @@ public class SentinelCommand implements CustomCommand {
|
||||
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new net.md_5.bungee.api.chat.hover.content.Text("&bClick to copy!")));
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, enc));
|
||||
p.spigot().sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
case "getHeat" -> {
|
||||
Player target = Bukkit.getPlayer(args.get(1).toString());
|
||||
if (target == null) {
|
||||
p.sendMessage(Text.prefix("Invalid Player!"));
|
||||
return;
|
||||
}
|
||||
p.sendMessage(Text.prefix("Heat of " + target.getName() + ": &8(&c" + io.github.thetrouper.sentinel.server.functions.AntiSpam.heatMap.get(target) + "&7/&4" + Sentinel.mainConfig.chat.antiSpam.punishHeat + "&8)"));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCompletions(CompletionBuilder b) {
|
||||
b.then(b.arg("reload","getheat","full-system-check"));
|
||||
b.then(b.arg("reload","full-system-check"));
|
||||
b.then(b.arg("debug").then(
|
||||
b.arg("antiswear","antispam","lang","toggle")));
|
||||
b.arg("lang","toggle")));
|
||||
b.then(b.arg("commandblock"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package io.github.thetrouper.sentinel.data.cmdblocks;
|
||||
|
||||
public enum CMDBlockType {
|
||||
CHAIN,
|
||||
REPEAT,
|
||||
IMPULSE,
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package io.github.thetrouper.sentinel.data.cmdblocks;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class WhitelistStorage implements JsonSerializable<WhitelistStorage> {
|
||||
@Override
|
||||
public File getFile() {
|
||||
File file = new File("plugins/Sentinel/storage/whitelist.json");
|
||||
file.getParentFile().mkdirs();
|
||||
return file;
|
||||
}
|
||||
|
||||
public Set<WhitelistedBlock> whitelistedCMDBlocks = new HashSet<>();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.github.thetrouper.sentinel.data.cmdblocks;
|
||||
|
||||
import io.papermc.paper.command.CommandBlockHolder;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record WhitelistedBlock(Location loc, UUID owner, CMDBlockType type, boolean conditional, boolean active ,String command) {
|
||||
|
||||
}
|
||||
@@ -1,7 +1,15 @@
|
||||
package io.github.thetrouper.sentinel.events;
|
||||
|
||||
import io.github.itzispyder.pdk.events.CustomListener;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.server.ServerCommandEvent;
|
||||
|
||||
public class CMDBlockExecute implements CustomListener {
|
||||
|
||||
@EventHandler
|
||||
private void onCommandBlock(ServerCommandEvent e) {
|
||||
if (!(e.getSender() instanceof BlockCommandSender s)) return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package io.github.thetrouper.sentinel.server.functions;
|
||||
|
||||
import io.github.itzispyder.pdk.utils.misc.JsonSerializable;
|
||||
import io.github.thetrouper.sentinel.Sentinel;
|
||||
import io.github.thetrouper.sentinel.data.cmdblocks.CMDBlockType;
|
||||
import io.github.thetrouper.sentinel.data.cmdblocks.WhitelistStorage;
|
||||
import io.github.thetrouper.sentinel.data.cmdblocks.WhitelistedBlock;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class CMDBlockWhitelist {
|
||||
public static void addWhitelist(CommandBlock cb, UUID owner) {
|
||||
//WhitelistedBlock commandblock = new WhitelistedBlock(cb.getLocation(),owner,getType(cb),)
|
||||
//Sentinel.whitelist.whitelistedCMDBlocks.add(new WhitelistedBlock(cb.getLocation(),))
|
||||
}
|
||||
|
||||
public static CMDBlockType getType(CommandBlock cb) {
|
||||
switch (cb.getType()) {
|
||||
case COMMAND_BLOCK -> {
|
||||
return CMDBlockType.IMPULSE;
|
||||
}
|
||||
case REPEATING_COMMAND_BLOCK -> {
|
||||
return CMDBlockType.REPEAT;
|
||||
}
|
||||
case CHAIN_COMMAND_BLOCK -> {
|
||||
return CMDBlockType.CHAIN;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user