teakivy / teaks-tweaks

Vanilla Tweaks But its a Plugin
https://modrinth.com/plugin/teaks-tweaks
MIT License
20 stars 10 forks source link

[Aid Request] Looking for the AFK event used in MC to build an alert for DiscordSRV #102

Closed Espressocodes closed 3 weeks ago

Espressocodes commented 1 month ago

Hello!

I use DiscordSRV on my server and I would like to build alerts for the TweaksTweaks packages, but I need some information. For Essentials and CMI they have a event call that I can hook into in order to send a notice whenever the AFK status is added or removed. An example below with what I was attempting to use:

Send an AFK alert when someone is AFK / is no longer AFK

  • Trigger: displayAFKMessage Channel: Redacted Conditions:
    • '#player.hasPermission("teakstweaks.afk.command.afk")' Embed: Author: ImageUrl: "{embedavatarurl}" Name: '${#event.getAffected().getName() + " is " + (#event.value ? "now" : "no longer") + " AFK"}' Timestamp: true

Send an AFK alert when someone is AFK / is no longer AFK

  • Trigger: PlayerAFKEvent Channel: Redacted Conditions:
    • '#player.hasPermission("teakstweaks.afk.command.afk")' Embed: Author: ImageUrl: "{embedavatarurl}" Name: '{username} is ${#event.isGoingAfk() ? "now" : "no longer"} AFK' Timestamp: true

The following is from the Discord SRV documentation of a pre-built event of this type:

Send an AFK alert when someone is AFK / is no longer AFK

So, I'm not quite sure what event I'm looking for here. I'd also like to know if there's an event list of some sort that the pack uses so that I can build a few generic notifications, but I'm quite stuck! Any help is appreciated here to get the correct call.

teakivy commented 1 month ago

Do you know of any plugins that implement a similar system? and/or link documentation from the plugins for how this should be done?

Espressocodes commented 1 month ago

Do you know of any plugins that implement a similar system? and/or link documentation from the plugins for how this should be done?

Yes, of course. Essentials and CMI do it.

So so sorry for the delay! Here's the Discord SRV documentation on hooking into a permission/Event Here's the Bukkit Jdoc for event hooks

Specifically here's the CMI AFK Alert hook: CMIAfkEnterEvent.java

# Send an AFK alert when someone is AFK
  - Trigger: CMIAfkEnterEvent
    Channel: afk
    Embed:
      Color: "#869600"
      Author:
        ImageUrl: "https://crafthead.net/helm/${player.getUniqueId()}"
        Name: '${player.displayName + " is now AFK"}'

And essentials: AfkStatusChangeEvent.java

# Send an AFK alert when someone is AFK / is no longer AFK
  - Trigger: AfkStatusChangeEvent
    Channel: afk
    Embed:
      Color: "#869600"
      Author:
        ImageUrl: "https://crafthead.net/helm/${#event.getAffected().getUUID()}"
        Name: '${#event.getAffected().getName() + " is " + (#event.value ? "now" : "no longer") + " AFK"}'

I did try and use a permission for TT to get this to work, but it didn't seem to hook in properly.

Espressocodes commented 3 weeks ago

Saw your commit. I felt a disturbance in the force. Thank you for this. I can't wait to see what you do with the plugin moving forward.

teakivy commented 3 weeks ago

Will be added in the next update, see the wiki (https://github.com/teakivy/teaks-tweaks/wiki/Pack:-AFK-Display#events) for more information.