Skip to content

fix: fire the command event for finished prompt commands - #106

Merged
CyR1en merged 2 commits into
CyR1en:developmentfrom
bobhenl:fix/prompt-command-event
Nov 8, 2026
Merged

CyR1en merged 2 commits into
CyR1en:developmentfrom
bobhenl:fix/prompt-command-event

Conversation

@bobhenl

@bobhenl bobhenl commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

When a command has a prompt, the original PlayerCommandPreprocessEvent is cancelled and the finished command later runs through Bukkit.dispatchCommand, which fires no command event. Plugins that react to typed commands (e.g. DiscordSRV alerts, command loggers) never see these commands.

  • Fire a PlayerCommandPreprocessEvent for the finished command before player dispatch (primary and immediate actions). A listener can rewrite the message or cancel it, like for a typed command.
  • The prompt listener skips this re-fired event, so answers containing <...> never open a new prompt.
  • Tests for firing, rewrite, cancel and the listener skip.

bobhenl and others added 2 commits November 8, 2026 21:13
Plugins that watch typed commands (alerts, logs) now see commands that went through a prompt.
- Treat a listener cancel as cancelled: run ON_CANCEL actions and skip
  the error message, instead of reporting the command as completed.
- Fire the event before granting attachment permissions, and run a
  rewritten command as the plain player.
- Fire the event for the primary command only, not preset actions the
  player never typed.
- Show the command that actually ran in the completed message.
- Track the bridge's own event instead of a per-thread flag.
@CyR1en

CyR1en commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Thanks for this! I pushed a follow-up commit (05edabe) to your branch after reviewing it:

  • A command cancelled by a listener no longer counts as completed. It now runs ON_CANCEL actions, with no error message to the player.
  • In attachment mode, the event fires before the temporary permissions are granted, and a rewritten command runs as the plain player.
  • The event now fires for the primary command only, so preset on-deny and post-actions no longer look like typed commands. If you need those visible to loggers, let me know and we can look at it separately.
  • The completed message shows the command that actually ran after a rewrite.
  • The prompt listener now skips only the bridge's own event, instead of relying on a per-thread flag.

Added tests for attachment mode, the immediate dispatcher and the coordinator. prompt-paper tests pass locally (1791 run, 2 skipped).

@CyR1en
CyR1en merged commit 4fad41b into CyR1en:development Nov 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants