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 separate events for local and global chat #4683

Merged
merged 4 commits into from
Feb 13, 2023

Conversation

brawaru
Copy link
Contributor

@brawaru brawaru commented Dec 12, 2021

Information

This PR helps DiscordSRV/DiscordSRV#1223.

Details

Proposed feature:

This PR adds two new events: GlobalChatEvent and LocalChatEvent, which allow other plugin developers to know whether the message sent is a global or local one and act accordingly. If either of those events is cancelled, then the source event is cancelled too.

Since all chat-related events share the same structure, a new abstract class ChatEvent is created with the change made for LocalChatSpyEvent to use it without breaking its API.

Environments tested:

OS: Windows 10 20H2.

Java version:

openjdk version "17" 2021-09-14 LTS
OpenJDK Runtime Environment Zulu17.28+13-CA (build 17+35-LTS)
OpenJDK 64-Bit Server VM Zulu17.28+13-CA (build 17+35-LTS, mixed mode, sharing)
  • Most recent Paper version (1.18.1, git-Paper-71)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8

Demonstration:

Following this pull request, a draft pull request with the use of that API in Essentials Discord module was created — #4684.

@triagonal triagonal added module: chat Issues or PRs for the EssentialsChat module type: api Issue/Pull Request regards user-facing API labels Dec 15, 2021
@brawaru
Copy link
Contributor Author

brawaru commented Apr 2, 2022

Hello and thanks for the review! Sorry it took some time, but all noted issues should be fixed now.

@brawaru brawaru force-pushed the feat/add-chat-type-events branch from 21b8556 to 0cd4898 Compare July 6, 2022 19:47
@brawaru
Copy link
Contributor Author

brawaru commented Jul 6, 2022

Rebased and moved new event classes to net.essentialsx.api.v2.events.chat 👍🏻

JRoy
JRoy previously approved these changes Jul 6, 2022
@JRoy JRoy added this to the 2.20.0 milestone Jul 6, 2022
@mdcfe
Copy link
Member

mdcfe commented Aug 16, 2022

Hey, apologies for the slow response on this. We recently refactored EssentialsX Chat, so this PR will need need to be updated this PR accordingly (ie moving the callChatEvent method and call into AbstractChatHandler) before it can be merged. Aside from this, the PR looks good! If you'd like to update the PR, we would greatly appreciate it, but otherwise we'll update it when we're ready to merge it.

@brawaru
Copy link
Contributor Author

brawaru commented Aug 17, 2022

Heyo! I have rebased this on 2.x, partly re-implementing the changes instead of resolving confusing merge conflicts, so please review the code again, perhaps I missed something.

@brawaru brawaru force-pushed the feat/add-chat-type-events branch 2 times, most recently from 8977e3f to 3c60995 Compare August 19, 2022 11:35
Copy link
Member

@JRoy JRoy left a comment

Choose a reason for hiding this comment

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

final few things, otherwise approved for 2.20!

This commit adds two new events: GlobalChatEvent and LocalChatEvent,
which allow other plugin developers to know whether the message sent is
a global or local one and act accordingly. If either of those events is
cancelled, then the source event is cancelled too.

Since all chat-related events share the same structure, a new abstract
class ChatEvent is created with change made for LocalChatSpyEvent to use
it without breaking its API.
@mdcfe mdcfe enabled auto-merge (squash) February 13, 2023 23:12
@mdcfe mdcfe disabled auto-merge February 13, 2023 23:12
@mdcfe mdcfe enabled auto-merge (squash) February 13, 2023 23:12
@mdcfe mdcfe merged commit 17051ea into EssentialsX:2.x Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: chat Issues or PRs for the EssentialsChat module type: api Issue/Pull Request regards user-facing API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants