Fixed up system check, update time!

This commit is contained in:
obvWolf
2024-02-08 20:55:06 -06:00
parent d33f2e08ee
commit f6b6e56078
2 changed files with 22 additions and 15 deletions

View File

@@ -20,7 +20,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.HashSet; import java.util.HashSet;
@CommandRegistry(value = "sentinel",permission = @Permission("sentinel.debug")) @CommandRegistry(value = "sentinel",permission = @Permission("sentinel.debug"),printStackTrace = true)
public class SentinelCommand implements CustomCommand { public class SentinelCommand implements CustomCommand {
public static boolean debugMode; public static boolean debugMode;
@Override @Override
@@ -35,6 +35,7 @@ public class SentinelCommand implements CustomCommand {
instance.loadConfig(); instance.loadConfig();
} }
case "full-system-check" -> { case "full-system-check" -> {
p.sendMessage(Text.prefix("Initiating a full system check!"));
SystemCheck.fullCheck(p); SystemCheck.fullCheck(p);
} }
case "debug" -> { case "debug" -> {
@@ -71,9 +72,6 @@ public class SentinelCommand implements CustomCommand {
message.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, enc)); message.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, enc));
p.spigot().sendMessage(message); p.spigot().sendMessage(message);
} }
case "tele" -> {
p.sendMessage(Telemetry.fetchTelemetryHook());
}
} }
} }
case "getHeat" -> { case "getHeat" -> {

View File

@@ -31,19 +31,21 @@ import java.util.Set;
public class SystemCheck { public class SystemCheck {
public static void fullCheck(Player p) { public static void fullCheck(Player p) {
boolean wasTrusted = false; if (!Sentinel.isTrusted(p)) return;
if (Sentinel.isTrusted(p)) { Sentinel.mainConfig.plugin.trustedPlayers.remove(p.getUniqueId().toString());
wasTrusted = true;
Sentinel.mainConfig.plugin.trustedPlayers.remove(p.getUniqueId().toString());
}
chatCheck(p); chatCheck(p);
p.setOp(true);
cmdPlaceCheck(p); cmdPlaceCheck(p);
p.setOp(true);
cmdBlockUseCheck(p); cmdBlockUseCheck(p);
p.setOp(true);
commandCheck(p); commandCheck(p);
p.setOp(true);
nbtCheck(p); nbtCheck(p);
p.setOp(true);
if (wasTrusted) Sentinel.mainConfig.plugin.trustedPlayers.add(p.getUniqueId().toString()); Sentinel.mainConfig.plugin.trustedPlayers.add(p.getUniqueId().toString());
} }
public static void cmdPlaceCheck(Player p) { public static void cmdPlaceCheck(Player p) {
@@ -65,12 +67,12 @@ public class SystemCheck {
.setNotifyTrusted(true) .setNotifyTrusted(true)
.setNotifyConsole(true) .setNotifyConsole(true)
.execute(); .execute();
p.setOp(true);
} }
public static void cmdBlockUseCheck(Player p) { public static void cmdBlockUseCheck(Player p) {
Block placed = p.getLocation().clone().add(0,-2,0).getBlock(); Block placed = p.getLocation().clone().add(0,-2,0).getBlock();
placed.setType(Material.COMMAND_BLOCK); placed.setType(Material.COMMAND_BLOCK);
CommandBlock cmd = (CommandBlock) placed;
PlayerInteractEvent cmdUse = new PlayerInteractEvent(p, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK,ItemBuilder.create().material(Material.AIR).build(),placed, BlockFace.UP); PlayerInteractEvent cmdUse = new PlayerInteractEvent(p, org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK,ItemBuilder.create().material(Material.AIR).build(),placed, BlockFace.UP);
Action a = new Action.Builder() Action a = new Action.Builder()
.setAction(ActionType.USE_COMMAND_BLOCK) .setAction(ActionType.USE_COMMAND_BLOCK)
@@ -84,12 +86,19 @@ public class SystemCheck {
.setNotifyTrusted(true) .setNotifyTrusted(true)
.setNotifyConsole(true) .setNotifyConsole(true)
.execute(); .execute();
p.setOp(true);
} }
public static void commandCheck(Player p) { public static void commandCheck(Player p) {
PlayerCommandPreprocessEvent command = new PlayerCommandPreprocessEvent(p,"/deop"); PlayerCommandPreprocessEvent command = new PlayerCommandPreprocessEvent(p,"fill ~ ~ ~ ~ ~ ~ air");
PlayerCommandPreprocessEvent command2 = new PlayerCommandPreprocessEvent(p,"deop"); PlayerCommandPreprocessEvent command2 = new PlayerCommandPreprocessEvent(p,"give @s illegal_item 1");
PlayerCommandPreprocessEvent command3 = new PlayerCommandPreprocessEvent(p,"bukkit:plugins");
new CommandEvent().onCommand(command); new CommandEvent().onCommand(command);
p.setOp(true);
new CommandEvent().onCommand(command2);
p.setOp(true);
new CommandEvent().onCommand(command3);
p.setOp(true);
} }
public static void nbtCheck(Player p) { public static void nbtCheck(Player p) {
@@ -115,6 +124,7 @@ public class SystemCheck {
.setNotifyTrusted(true) .setNotifyTrusted(true)
.setnotifyDiscord(Sentinel.mainConfig.plugin.logNBT) .setnotifyDiscord(Sentinel.mainConfig.plugin.logNBT)
.execute(); .execute();
p.setOp(true);
} }
@@ -128,7 +138,7 @@ public class SystemCheck {
ProfanityFilter.handleProfanityFilter(swear); ProfanityFilter.handleProfanityFilter(swear);
AdvancedBlockers.handleAntiUnicode(unicode); AdvancedBlockers.handleAntiUnicode(unicode);
AdvancedBlockers.handleAntiURL(url); AdvancedBlockers.handleAntiURL(url);
SchedulerUtils.loop(10,3, (loop)->{ SchedulerUtils.loop(5,4, (loop)->{
AntiSpam.lastMessageMap.put(p,"Sentinel AntiSpam Check"); AntiSpam.lastMessageMap.put(p,"Sentinel AntiSpam Check");
AntiSpam.handleAntiSpam(spam); AntiSpam.handleAntiSpam(spam);
}); });
@@ -140,6 +150,5 @@ public class SystemCheck {
}); });
Message.messagePlayer(p,p,"Sentinel Automatic System check > Private Message"); Message.messagePlayer(p,p,"Sentinel Automatic System check > Private Message");
} }
} }