File tree Expand file tree Collapse file tree 6 files changed +21
-1
lines changed Expand file tree Collapse file tree 6 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ public void onPlayerChat(final AsyncPlayerChatEvent event) {
162
162
}
163
163
}
164
164
165
- user .updateActivityOnInteract (true );
165
+ user .updateActivityOnChat (true );
166
166
user .setDisplayNick ();
167
167
}
168
168
Original file line number Diff line number Diff line change @@ -199,6 +199,8 @@ public interface ISettings extends IConf {
199
199
200
200
boolean cancelAfkOnInteract ();
201
201
202
+ boolean cancelAfkOnChat ();
203
+
202
204
boolean sleepIgnoresAfkPlayers ();
203
205
204
206
boolean isAfkListName ();
Original file line number Diff line number Diff line change @@ -984,6 +984,11 @@ private boolean _cancelAfkOnInteract() {
984
984
return config .getBoolean ("cancel-afk-on-interact" , true );
985
985
}
986
986
987
+ @ Override
988
+ public boolean cancelAfkOnChat () {
989
+ return config .getBoolean ("cancel-afk-on-chat" , true );
990
+ }
991
+
987
992
@ Override
988
993
public boolean sleepIgnoresAfkPlayers () {
989
994
return sleepIgnoresAfkPlayers ;
Original file line number Diff line number Diff line change @@ -668,6 +668,15 @@ public void updateActivityOnInteract(final boolean broadcast) {
668
668
}
669
669
}
670
670
671
+ public void updateActivityOnChat (final boolean broadcast ) {
672
+ if (ess .getSettings ().cancelAfkOnChat ()) {
673
+ //Chat happens async, make sure we have a sync context
674
+ ess .scheduleSyncDelayedTask (() -> {
675
+ updateActivity (broadcast , AfkStatusChangeEvent .Cause .CHAT );
676
+ });
677
+ }
678
+ }
679
+
671
680
public void checkActivity () {
672
681
// Graceful time before the first afk check call.
673
682
if (System .currentTimeMillis () - lastActivity <= 10000 ) {
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ public enum Cause {
42
42
INTERACT ,
43
43
COMMAND ,
44
44
JOIN ,
45
+ CHAT ,
45
46
QUIT ,
46
47
UNKNOWN
47
48
}
Original file line number Diff line number Diff line change @@ -450,6 +450,9 @@ cancel-afk-on-interact: true
450
450
# Disable this to reduce server lag.
451
451
cancel-afk-on-move : true
452
452
453
+ # Should we automatically remove afk status when a player sends a chat message?
454
+ cancel-afk-on-chat : true
455
+
453
456
# Should AFK players be ignored when other players are trying to sleep?
454
457
# When this setting is false, players won't be able to skip the night if some players are AFK.
455
458
# Users with the permission node essentials.sleepingignored will always be ignored.
You can’t perform that action at this time.
0 commit comments