Separate option to cancel afk on chat from interact (#3863)

This commit is contained in:
OmegaWeaponDev 2021-01-01 10:50:08 +10:30 committed by GitHub
parent b84aaa1dab
commit a8daa2160f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 1 deletions

View File

@ -162,7 +162,7 @@ public class EssentialsPlayerListener implements Listener {
}
}
user.updateActivityOnInteract(true);
user.updateActivityOnChat(true);
user.setDisplayNick();
}

View File

@ -199,6 +199,8 @@ public interface ISettings extends IConf {
boolean cancelAfkOnInteract();
boolean cancelAfkOnChat();
boolean sleepIgnoresAfkPlayers();
boolean isAfkListName();

View File

@ -984,6 +984,11 @@ public class Settings implements net.ess3.api.ISettings {
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;

View File

@ -668,6 +668,15 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
}
}
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) {

View File

@ -42,6 +42,7 @@ public class AfkStatusChangeEvent extends StatusChangeEvent {
INTERACT,
COMMAND,
JOIN,
CHAT,
QUIT,
UNKNOWN
}

View File

@ -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.