Class CommandExecutionManager.CapturedFeedback

java.lang.Object
com.ultikits.ultitools.manager.CommandExecutionManager.CapturedFeedback
All Implemented Interfaces:
Consumer<net.kyori.adventure.text.Component>
Enclosing class:
CommandExecutionManager

static final class CommandExecutionManager.CapturedFeedback extends Object implements Consumer<net.kyori.adventure.text.Component>
The feedback of one v2 panel command, handed to Paper's capturing sender.

Until take() every printed line is kept for the command.result. From then on a line is written to the console through console instead, so output a command prints after its dispatch returned (an asynchronous body, a scheduled reply) is not lost: it lands in the result or on the console, exactly once, whichever thread prints it. The lock makes the hand-over atomic; the console is written outside it.

Bounded lifetime. Taking the result releases the captured lines, so a sender that a command or another plugin keeps holds only this small object. Late lines are forwarded for windowNanos after the result was taken; after that they are dropped, and one WARNING names the command (never its arguments, which can carry a secret) so the operator knows why.

  • Field Details

    • commandName

      private final String commandName
    • windowNanos

      private final long windowNanos
    • clock

      private final LongSupplier clock
    • console

      private final Consumer<String> console
    • lock

      private final Object lock
    • captured

      private List<String> captured
      The lines kept for the result, or null once taken. Guarded by lock.
    • takenAt

      private long takenAt
      The clock reading when the result was taken. Guarded by lock.
    • expiryReported

      private boolean expiryReported
      Whether the dropped-output warning was logged. Guarded by lock.
  • Constructor Details

  • Method Details

    • accept

      public void accept(net.kyori.adventure.text.Component component)
      Specified by:
      accept in interface Consumer<net.kyori.adventure.text.Component>
    • take

      List<String> take()
      Takes the lines printed so far for the result and switches later lines to the console.
      Returns:
      the captured lines; empty when they were already taken