I would like to propose the addition of a TeamPreMessageEvent and TeamMessageEvent to allow third-party developers to more accurately detect, amend and cancel team messages.
This pull request contains the following amendments:
Created a new class TeamPreMessageEvent which contains all the components of a team message and allows modifiable components to be modified before a team message is dispatched.
Created a new class TeamMessageEvent which serves as a read-only notification that a message has been sent for monitoring purposes (such as third-party spy or audit plugins).
Implemented TeamPreMessageEvent in the existing Team class under method Team#sendMessage(TeamPlayer, String) by creating the event, providing it with the message components, dispatching the event, parsing all the returned values, and dispatching the team message with those (potentially) modified values.
Implemented TeamMessageEvent as the final line in the Team#sendMessage(...) method which dispatches the notification event with the final message and components.
Changed to version 4.8.1 as a minor change.
The reason for this change comes from a recent plugin I created relating to a chat filter which was forced to use AsyncPlayerChatEvent and PlayerCommandPreprocessEvent to filter and cancel messages, which was not a perfect solution as you may imagine. These events will make the API a lot more future-proof by providing supported events for chat messages rather than having to find workarounds which could be rendered useless if a major plugin update happened.
I would like to propose the addition of a TeamPreMessageEvent and TeamMessageEvent to allow third-party developers to more accurately detect, amend and cancel team messages.
This pull request contains the following amendments:
Team#sendMessage(TeamPlayer, String)
by creating the event, providing it with the message components, dispatching the event, parsing all the returned values, and dispatching the team message with those (potentially) modified values.Team#sendMessage(...)
method which dispatches the notification event with the final message and components.The reason for this change comes from a recent plugin I created relating to a chat filter which was forced to use AsyncPlayerChatEvent and PlayerCommandPreprocessEvent to filter and cancel messages, which was not a perfect solution as you may imagine. These events will make the API a lot more future-proof by providing supported events for chat messages rather than having to find workarounds which could be rendered useless if a major plugin update happened.
Happy to hear your thoughts on the new code!