mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-01-03 22:08:28 +00:00
Separate option to cancel afk on chat from interact (#3863)
This commit is contained in:
parent
b84aaa1dab
commit
a8daa2160f
6 changed files with 21 additions and 1 deletions
|
@ -162,7 +162,7 @@ public class EssentialsPlayerListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
user.updateActivityOnInteract(true);
|
||||
user.updateActivityOnChat(true);
|
||||
user.setDisplayNick();
|
||||
}
|
||||
|
||||
|
|
|
@ -199,6 +199,8 @@ public interface ISettings extends IConf {
|
|||
|
||||
boolean cancelAfkOnInteract();
|
||||
|
||||
boolean cancelAfkOnChat();
|
||||
|
||||
boolean sleepIgnoresAfkPlayers();
|
||||
|
||||
boolean isAfkListName();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -42,6 +42,7 @@ public class AfkStatusChangeEvent extends StatusChangeEvent {
|
|||
INTERACT,
|
||||
COMMAND,
|
||||
JOIN,
|
||||
CHAT,
|
||||
QUIT,
|
||||
UNKNOWN
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue