CraftBook 3

CraftBook 3

139k Downloads

Comitems player_chat event doesn't work properly with cancel-action

CatgirlChilis opened this issue ยท 1 comments

commented

Versions
CraftBook version: 3.10.2-SNAPSHOT;4616-21180b0
Bukkit version: git-Spigot-a99063f-fad2494

Describe the bug
When using a command item with the PLAYER_CHAT event and cancel-action turned on, the message sent my the player is still visible in chat, though it is blocked from other plugins.
When using an comitem to send a /say @m command through the console, both the console message and player message are visible despite cancel-action being set to true.
The player message does not show up on my Discord server's linked Minecraft chat however, as intended

To Reproduce

  1. Create a command item with the PLAYER_CHAT event and cancel-action set to true
  2. Type something in chat, and notice how the players message is still sent

Expected behavior
Creating a console /say microphone for fun, and expect the chat message sent by the player to be blocked from sending by the cancel-action flag

Screenshots
use
use_discord

commented

This is currently broken due to Spigot changes. Beforehand we'd use the non-async version of the event, as there are things that /require/ being run sync.

As Spigot broke that functionality (as outlined in #1208), this can no longer be run as a sync event. This means the code for this commanditem must be run in the next game tick in order to not cause Spigot to error.

One negative of doing this, however, is the event can no longer be cancelled. I looked at potentially moving /just/ the cancel logic into the async handler, but that won't work as it must run after some code that can only be run in sync code.

Basically, there is no way to fix this with the way Spigot currently works.