Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

Add separate events for local and global chat

Open brawaru opened this issue 4 years ago • 4 comments

Information

This PR helps https://github.com/DiscordSRV/DiscordSRV/issues/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)
  • [x] 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.

brawaru avatar Dec 12 '21 21:12 brawaru

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

brawaru avatar Apr 02 '22 18:04 brawaru

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

brawaru avatar Jul 06 '22 19:07 brawaru

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.

mdcfe avatar Aug 16 '22 08:08 mdcfe

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 avatar Aug 17 '22 08:08 brawaru