sakurawald / fuji

A mod that ports EssentialsX / CMI from bukkit to fabric.
GNU General Public License v3.0
41 stars 5 forks source link

AFK notifier only happens every 5th minute, not after 5 minutes of no input from player, causing weird interactions with players who stopped moving for a second before minute 5 to be immediately flagged as AFK #170

Closed payphone101 closed 1 month ago

payphone101 commented 1 month ago

How to Reproduce the bug?

  1. Enable afk module
  2. Do not touch config for afk as it is already set to every 5 minutes
  3. Log in and afk on ??:04:30 (hh:mm:ss)

What is the expected behavior?

AFK should kick in every 5 minutes AFTER the player has stopped having input (clicking/sending messages/moving, etc.)

What is the actual behavior?

AFK kicks in only every multiple of 5 minutes (i.e. minute 5, 10, 15, 20, etc) and doesn't activate and flag in 5 minutes (300seconds, 6000 ticks) after the players' last input

Photo proof Fuji didn't flag me as afk at 23:20:47 from the last message test for afk

Please upload the server logs using https://mclo.gs/

Yes, my logs link is: https://mclo.gs/q1Qs64C

payphone101 commented 1 month ago

it even skipped minute 20 because I already was moving in between minute 15 and 20 and proceeded to only flag me as afk in minute 25

sakurawald commented 1 month ago

Hello, thanks for your feedback. The afk module is another thing i want to improve and document.

The afk module use a simple model: in vanilla minecraft, there is an existing time counter to record the last action time for each player. afk module unility this time counter, and simply compare 2 consecutive value of the time counter, if it's the same, then it's considered the player is in afk.

This 2-pass approach is high-performance, avoids the extra works to track the player action frequently. However, the drawback is that, the afk state checker will be less precise, which means that, for a job defined by cron expression that runs every 5 minutes, requires at least 2 pass to decide wheter a player is in afk.

In other words, if the cron in afk config is configured to run every 5 minutes, then a player marked as in afk is actually no action input for 5~10 minutes.

sakurawald commented 1 month ago

You can modify the cron value into 0 0/3 * ? * * *, which means that runs the afk time counter checker every 3 minutes, so that when a player is marked as in afk, it's actually no input for 3~6 minutes.

Also, you can use cron expression generator to define when the afk time counter will run: https://www.freeformatter.com/cron-expression-generator-quartz.html

image

sakurawald commented 1 month ago

The weird interactions with players who stopped moving for a second before minute 5 to be immediately flagged as AFK may be a bug, i will loot into it.

payphone101 commented 1 month ago

Yeah one time I was just sprint jumping (gliding) around my base and it flagged me as afk when the minute mark hit a multiple of 5. Also my friend was trading with a villager and it also flagged them as AFK

sakurawald commented 1 month ago

fixed in v2.4.1 version.