EngineHub / CraftBook

🔧 Machines, ICs, PLCs, and more!
https://enginehub.org/craftbook/
GNU General Public License v3.0
304 stars 163 forks source link

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

Open CatgirlChilis opened 4 years ago

CatgirlChilis commented 4 years ago

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

me4502 commented 4 years ago

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 https://github.com/EngineHub/CraftBook/issues/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.