Class CommandExecutionManager

java.lang.Object
com.ultikits.ultitools.manager.CommandExecutionManager

@Internal public class CommandExecutionManager extends Object
Command execution manager. Handles command execution requests received over the WebSocket connection.
  • Field Details

  • Constructor Details

    • CommandExecutionManager

      public CommandExecutionManager()
  • Method Details

    • loadConfiguration

      public final void loadConfiguration()
      Loads ultipanel.commands.blocklist from config.yml, copying ErrorReportCollector.loadConfiguration()'s exact shape: a null-guard on UltiTools.getInstance(), one try/catch whose failure branch keeps the current blocklist and logs a warning naming the key.

      Distinguishes an absent key from an explicit empty list via isSet(path) — Bukkit's getStringList returns an empty list for both, and collapsing that distinction would make D-03's honest "block nothing" escape value silently impossible (T-06-12). The shipped ten-command default applies only when the key is absent; an explicit empty list is honored as the operator deliberately granting every command.

    • setBlockedCommands

      public void setBlockedCommands(Set<String> commands)
      Set the blocklist of commands that should not be executed remotely. This is now loadConfiguration()'s config-load target, not just a test-only seam — it has zero production call sites of its own, but every operator-configured blocklist reaches this class through it.
      Parameters:
      commands - Set of command names to block (case-insensitive)
    • isCommandAllowed

      public AccessDecision isCommandAllowed(String command)
      Whether a command is allowed for remote execution.

      Extracts the base command (the first word) and strips any namespace prefix (e.g. bukkit:op -> op, minecraft:stop -> stop) BEFORE checking it against the operator-configured blocklist at ultipanel.commands.blocklist in plugins/UltiTools/config.yml — so both the bare command and its namespaced form are blocked; the stripping order is what makes that true. The blocklist is editable in both directions — an operator may remove any of the ten shipped defaults, add to them, or clear the list entirely — and there is deliberately no unoverridable floor beneath it (D-04): a floor would constrain the operator without constraining an attacker who already holds the operator's identity, since the same outcomes remain reachable through other commands or a third-party plugin's own admin commands.

      Parameters:
      command - The command to check (with or without leading slash)
      Returns:
      an AccessDecision naming why a refused command was refused
    • setWebSocketClient

      public void setWebSocketClient(UltiPanelWebSocketClient client)
      Sets the WebSocket client.
      Parameters:
      client - the WebSocket client
    • executeCommand

      public void executeCommand(com.google.gson.JsonObject commandData)
      Executes a command received from the panel.
    • executeCommandInternal

      private void executeCommandInternal(String command, String executor, String commandId, long startTime)
      Internal command execution logic.
    • resolveActor

      private static String resolveActor(String executor)
      The action-log actor field — the inbound executor field verbatim, or the literal "panel" when absent. Mirrors PluginInitiationUtils.resolveActor(JsonObject) exactly: the framework cannot attribute a remote command to an individual panel operator today (see RemoteActionLog.Entry's javadoc), so this never invents a per-operator identity.
    • sendCommandResult

      private void sendCommandResult(String commandId, boolean success, String output, long executionTime)
      Sends the command execution result.