totemo / watson

A Minecraft mod that displays LogBlock, Prism and CoreProtect query results in 3-D.
MIT License
71 stars 11 forks source link

Watson breaks Macros onChat-Event #33

Closed ReneZeidler closed 10 years ago

ReneZeidler commented 10 years ago

Since Watson discards any chat packet, it breaks any other mod that uses LiteLoader's ChatFilter and gets loaded after Watson and breaks any normal LiteLoader ChatListener.

The onChat method isn't used correctly here. It is expected to return for every chat message that actually shows up in chat, and false only for chat messages that are completely removed (not changed) and therefore shouldn't reach any ChatListeners.

This is mostly a problem with Macros, since the onChat-Event is somehow an essential functionality, but it also causes trouble with other mods.

To fix this, onChat should always return true (I think Watson doesn't remove messages from chat. When it does, it should return false) and the chat packet of the event should be modified to contain any changes that should be applied.

Since the chat filter needs to run synchronized you should only run chat handlers directly from onChat that can modify or remove the chat message - any other handlers that only read chat and need excessive calculations can still run outside of onChat, since you don't need any return value for them.

I know this doesn't fit well with what you currently have in terms of chat handling, but this is the only way this mod works nicely with Macros and any other LiteMod that uses ChatListeners.

This is a great mod and as much as I would love to use this mod, I currently can't because pretty much every macro I use needs onChat. :)

Mumfrey commented 10 years ago

I noticed this as well. Because watson always returns false for the onChat callback it's basically filtering everything from downstream mods. This won't just affect macros but any mod which relies on incoming chat.

A ChatFilter implementor is supposed to return true for any messages to pass and false for any messages it wants to "eat" (or filter).

totemo commented 10 years ago

Thanks for reporting this. Watson does filter out some chat to do with received LogBlock query results. I'll look into how I can push the correct onChat() return value up from Watson's handlers.

totemo commented 10 years ago

Fixed in 0.6.1. https://github.com/totemo/watson/releases/tag/0.6.1-1.7.2_02