Package com.ultikits.ultitools.manager
Class CommandExecutionManager
java.lang.Object
com.ultikits.ultitools.manager.CommandExecutionManager
命令执行管理器
负责处理来自WebSocket的命令执行请求
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class命令输出捕获器 Implements ConsoleCommandSender (not just CommandSender) because Paper 1.21+ requires the sender to be a recognized type when dispatching commands through Brigadier.static class命令结果数据类 -
Field Summary
FieldsModifier and TypeFieldDescription远程命令执行黑名单 Blocklist of dangerous commands that should not be executed remotelyprivate final com.google.gson.Gsonprivate UltiPanelWebSocketClient -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecuteCommand(com.google.gson.JsonObject commandData) 执行命令private voidexecuteCommandInternal(String command, String executor, String commandId, long startTime) 内部命令执行逻辑booleanisCommandAllowed(String command) 检查命令是否允许远程执行 Check if a command is allowed for remote execution.private voidsendCommandResult(String commandId, boolean success, String output, long executionTime) 发送命令执行结果voidsetBlockedCommands(Set<String> commands) 设置命令黑名单 Set the blocklist of commands that should not be executed remotelyvoid设置WebSocket客户端
-
Field Details
-
webSocketClient
-
pendingCommands
private final ConcurrentHashMap<String,CompletableFuture<CommandExecutionManager.CommandResult>> pendingCommands -
gson
private final com.google.gson.Gson gson -
blockedCommands
远程命令执行黑名单 Blocklist of dangerous commands that should not be executed remotely
-
-
Constructor Details
-
CommandExecutionManager
public CommandExecutionManager()
-
-
Method Details
-
setBlockedCommands
设置命令黑名单 Set the blocklist of commands that should not be executed remotely- Parameters:
commands- Set of command names to block (case-insensitive)
-
isCommandAllowed
检查命令是否允许远程执行 Check if a command is allowed for remote execution. Extracts the base command (first word) and checks against blocklist.- Parameters:
command- The command to check (with or without leading slash)- Returns:
- true if command is allowed, false if blocked or invalid
-
setWebSocketClient
设置WebSocket客户端- Parameters:
client- WebSocket客户端
-
executeCommand
public void executeCommand(com.google.gson.JsonObject commandData) 执行命令 -
executeCommandInternal
private void executeCommandInternal(String command, String executor, String commandId, long startTime) 内部命令执行逻辑 -
sendCommandResult
private void sendCommandResult(String commandId, boolean success, String output, long executionTime) 发送命令执行结果
-