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

Add a TeamPreMessageEvent and TeamMessageEvent to the API #492

Merged
merged 6 commits into from
Aug 31, 2023

Conversation

Harieo
Copy link
Contributor

@Harieo Harieo commented Aug 5, 2023

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.

Happy to hear your thoughts on the new code!

Copy link
Owner

@booksaw booksaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution, apologies for the delay in merging

@booksaw booksaw merged commit c8f6bd3 into booksaw:master Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants