Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement listener for PaperMC's AsyncPlayerSendCommandsEvent #1

Open
1 of 10 tasks
lokka30 opened this issue Aug 12, 2024 · 0 comments
Open
1 of 10 tasks

Implement listener for PaperMC's AsyncPlayerSendCommandsEvent #1

lokka30 opened this issue Aug 12, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@lokka30
Copy link
Member

lokka30 commented Aug 12, 2024

Context

BlackWidow's command blocking module requires a listener to review and manage command suggestions that the server/proxy implementation wants to send to players.

The Bukkit API has PlayerCommandSendEvent, which works great, with one major caveat: the server calls it synchronously.

On PaperMC server implementations, we can instead listen to AsyncPlayerSendCommandsEvent.html, which is (usually - but not guaranteed to.. anyways,) be called asynchronously by the server.

Challenges

This event seems to not be well-known and thus isn't utilized often in plugins. With rather limited documentation on the event and (very) poor knowledge with Brigadier, I'm ill-equipped as of posting this issue to tackle this.

To expand on the Brigadier challenge: the Paper event presents a Brigadier command node - a more contemporary API choice, which is great, but requires a new style of parser. Furthermore, instead of rather simple lists of arguments suggestions, we get a root command tree which needs to be managed entirely differently than just simply removing offending strings from a mutable list (Bukkit API / legacy approach).

That being said, I think it may be worth going through the server software source code and checking how PlayerCommandSendEvent adapts Brigadier commands into standard Bukkit command strings. Or, there is a better way to do it, research to be done...

Goals

  • Detect when PaperMC (or derivative) server software implementation is running.
  • To be completed together:
    • Disable listener PlayerCommandSendListener when PaperMC is used.
    • Implement AsyncPlayerSendCommandsListener.
    • Enable AsyncPlayerSendCommandsListener when PaperMC is used.
  • Test it works.
    • Detecting suggestions (can see them coming in)
    • Managing suggestions (removing those which are blocked for the player)
    • Listener handles the event asynchronously only
    • Not being accessed on SpigotMC servers (i.e., no Paper API present; NOT PaperMC or derivatives).

Other

I plan to work on this. If you have worked with this event before, please feel free to let me know below, I would love some assistance :)

@lokka30 lokka30 self-assigned this Aug 12, 2024
@lokka30 lokka30 added the enhancement New feature or request label Aug 12, 2024
@lokka30 lokka30 moved this to Backlog in BlackWidow Project Aug 18, 2024
@lokka30 lokka30 added this to the v1.2.x milestone Aug 18, 2024
@lokka30 lokka30 moved this from Waiting Other to Ready in BlackWidow Project Aug 18, 2024
@lokka30 lokka30 added the help wanted Extra attention is needed label Aug 18, 2024
@lokka30 lokka30 added the good first issue Good for newcomers label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: Ready
Development

No branches or pull requests

1 participant