Skip to content

New config.yml option: afk-timeout-command: #6169

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

Open
wants to merge 8 commits into
base: 2.x
Choose a base branch
from

Conversation

ZepsiZola
Copy link

Implements this #2864

Specifically, this functionality:

afk-timeout-command: "server afk {USERNAME}"
Sends the player to the AFK server on the server-network.

afk-timeout-command: "litebans:kick {USERNAME} You were kicked after {KICK_TIME} minutes of inactivity."
Kicks the player using litebans so that it shows up in their litebans history.

afk-timeout-command: "none"
Default behaviour of essentials kicking the player on afk-timeout.

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.

have a few issues with this, would also like @mdcfe's input on this

#
# Available placeholders:
# {USERNAME} - The player's username.
# {KICKTIME} - The time, in minutes, the player has been AFK for.
Copy link
Member

Choose a reason for hiding this comment

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

is there a reason we need this variable, wouldn't the time the player has been afk always be the same (the auto-afk-kick above).

@@ -484,6 +484,14 @@ auto-afk: 300
# Set to -1 for no timeout.
auto-afk-kick: -1
Copy link
Member

Choose a reason for hiding this comment

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

maybe we rename this option to auto-afk-timeout and explain that it will run the command below if set, otherwise kick the player?

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.

have a few issues with this, would also like @mdcfe's input on this

@JRoy JRoy requested a review from mdcfe June 13, 2025 03:11
@ZepsiZola
Copy link
Author

no reason to add this

I added it because this is what I got after doing ./gradlew and then ./gradlew shadowJar. This was directly after cloning the repo for the first time.
unknown
You can reject this change if you want, but I added it because there were unneeded files created on my repo that I did not want to push.

why would we replaceFormat here? you cannot send section signs thru commands

Fair enough. I wasn't familiar with the EssentialsX codebase and thought that that was needed if I wanted to parse placeholders in the config option. I can change that line to not use FormatUtil.

is there a reason we need this variable, wouldn't the time the player has been afk always be the same (the auto-afk-kick above).

The variable is there so that if a server owner changes the AFK timeout, they don't also have to change the afk-timeout-command. And no, the auto-afk-kick doesn't always stay the same. As a server owner myself I've changed it around a fair few times. It would be an inconvenience to anyone messing with their afk configuration to have to change a number in two places because they changed the auto-afk-kick config. A minor inconvenience, but a completely unneeded one as well.

maybe we rename this option to auto-afk-timeout and explain that it will run the command below if set, otherwise kick the player?

@JRoy auto-afk-timeout is bad naming. From the name, it would seem like it should define the timeout for a player's AFK. I don't think it should be named that just because the other config options have "auto-afk" in them. We shouldn't give something a bad name on purpose just so that it looks similar to the other config options. It should be called afk-timeout-command because it is the command that is run upon the players AFK-time running out. Isn't the fact that the config option is right below auto-afk-kick enough for it to be understood that it closely relates to that config option?

@SrBedrock
Copy link
Contributor

SrBedrock commented Jun 13, 2025

I believe this could be a list of commands and instead of none, check if the list is empty, just like other settings already do

@JasonHorkles
Copy link
Contributor

I added it because there were unneeded files created on my repo that I did not want to push.

You can deselect items that you don't want to commit 😉

It should be called afk-timeout-command because it is the command that is run upon the players AFK-time running out.

Josh was referring to the older config option auto-afk-kick (not the one you're adding)


I believe this could be a list of commands and instead of none, check if the list is empty, just like other settings already do

This is something that the team seems to agree with as well, although it's still being debated

@ZepsiZola
Copy link
Author

I added it because there were unneeded files created on my repo that I did not want to push.

You can deselect items that you don't want to commit 😉

I know that. But isn't the point of .gitignore to ignore files that will never be comitted? Unless this repo does require files in bin/ directories being pushed.

It should be called afk-timeout-command because it is the command that is run upon the players AFK-time running out.

Josh was referring to the older config option auto-afk-kick (not the one you're adding)

Ahh he was suggesting changing the existing config option name. Fair enough. I'm impartial to that.

I believe this could be a list of commands and instead of none, check if the list is empty, just like other settings already do

This is something that the team seems to agree with as well, although it's still being debated

I can implement this if you want. I don't necessarily care about that functionality, but it won't interfere with my own functionality, plus I just want this feature implemented so I can use it in my server as soon as I can.

Renamed config option to afk-timeout-commands and made it accept a list of strings.

Removed unnecessary FormatUtil.

Reverted .gitignore
@ZepsiZola
Copy link
Author

@SrBedrock @JasonHorkles @JRoy
Btw I made these changes:

  • Reverted the .gitignore change. So it remains unchanged from before the PR.
  • Removed use of FormatUtil where not needed.
  • Made it so you can specify a list of commands that run in succession as opposed to just one command. Config option is now called afk-timeout-commands:

Now the config.yml looks like this...

# Define a set of commands the server runs when a player's AFK time elapses.
# Set to [] to use Essentials' default AFK timeout kick behavior.
#
# Available placeholders:
# {USERNAME} - The player's username.
# {KICKTIME} - The time, in minutes, the player has been AFK for.
afk-timeout-commands: []

and you can set commands like this

afk-timeout-commands:
- "msg {USERNAME} You have been AFK for {KICKTIME}. Jailing you and moving you to AFK server..."
- "jail {USERNAME} jail-1"
- "server afk {USERNAME}"

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.

4 participants