Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void onPlayerChat(final AsyncPlayerChatEvent event) {
}
}

user.updateActivityOnInteract(true);
user.updateActivityOnChat(true);
user.setDisplayNick();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ public interface ISettings extends IConf {

boolean cancelAfkOnInteract();

boolean cancelAfkOnChat();

boolean sleepIgnoresAfkPlayers();

boolean isAfkListName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,11 @@ private boolean _cancelAfkOnInteract() {
return config.getBoolean("cancel-afk-on-interact", true);
}

@Override
public boolean cancelAfkOnChat() {
return config.getBoolean("cancel-afk-on-chat", true);
}

@Override
public boolean sleepIgnoresAfkPlayers() {
return sleepIgnoresAfkPlayers;
Expand Down
9 changes: 9 additions & 0 deletions Essentials/src/main/java/com/earth2me/essentials/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,15 @@ public void updateActivityOnInteract(final boolean broadcast) {
}
}

public void updateActivityOnChat(final boolean broadcast) {
if (ess.getSettings().cancelAfkOnChat()) {
//Chat happens async, make sure we have a sync context
ess.scheduleSyncDelayedTask(() -> {
updateActivity(broadcast, AfkStatusChangeEvent.Cause.CHAT);
});
}
}

public void checkActivity() {
// Graceful time before the first afk check call.
if (System.currentTimeMillis() - lastActivity <= 10000) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public enum Cause {
INTERACT,
COMMAND,
JOIN,
CHAT,
QUIT,
UNKNOWN
}
Expand Down
3 changes: 3 additions & 0 deletions Essentials/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ cancel-afk-on-interact: true
# Disable this to reduce server lag.
cancel-afk-on-move: true

# Should we automatically remove afk status when a player sends a chat message?
cancel-afk-on-chat: true

# Should AFK players be ignored when other players are trying to sleep?
# When this setting is false, players won't be able to skip the night if some players are AFK.
# Users with the permission node essentials.sleepingignored will always be ignored.
Expand Down