Merge pull request #2329 from triagonal/issue-2311

Implement config option for sleep ignoring AFK players
This commit is contained in:
md678685 2019-03-08 22:15:53 +00:00 committed by GitHub
commit 25ddaef423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 1 deletions

View File

@ -185,6 +185,8 @@ public interface ISettings extends IConf {
boolean cancelAfkOnInteract(); boolean cancelAfkOnInteract();
boolean sleepIgnoresAfkPlayers();
boolean isAfkListName(); boolean isAfkListName();
String getAfkListName(); String getAfkListName();

View File

@ -494,6 +494,7 @@ public class Settings implements net.ess3.api.ISettings {
cancelAfkOnInteract = _cancelAfkOnInteract(); cancelAfkOnInteract = _cancelAfkOnInteract();
cancelAfkOnMove = _cancelAfkOnMove(); cancelAfkOnMove = _cancelAfkOnMove();
getFreezeAfkPlayers = _getFreezeAfkPlayers(); getFreezeAfkPlayers = _getFreezeAfkPlayers();
sleepIgnoresAfkPlayers = _sleepIgnoresAfkPlayers();
afkListName = _getAfkListName(); afkListName = _getAfkListName();
isAfkListName = !afkListName.equalsIgnoreCase("none"); isAfkListName = !afkListName.equalsIgnoreCase("none");
itemSpawnBl = _getItemSpawnBlacklist(); itemSpawnBl = _getItemSpawnBlacklist();
@ -893,6 +894,17 @@ public class Settings implements net.ess3.api.ISettings {
return config.getBoolean("cancel-afk-on-interact", true); return config.getBoolean("cancel-afk-on-interact", true);
} }
private boolean sleepIgnoresAfkPlayers;
@Override
public boolean sleepIgnoresAfkPlayers() {
return sleepIgnoresAfkPlayers;
}
private boolean _sleepIgnoresAfkPlayers() {
return config.getBoolean("sleep-ignores-afk-players", true);
}
private String afkListName; private String afkListName;
private boolean isAfkListName; private boolean isAfkListName;

View File

@ -465,7 +465,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
return; return;
} }
this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set); this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") || set && ess.getSettings().sleepIgnoresAfkPlayers());
if (set && !isAfk()) { if (set && !isAfk()) {
afkPosition = this.getLocation(); afkPosition = this.getLocation();
this.afkSince = System.currentTimeMillis(); this.afkSince = System.currentTimeMillis();

View File

@ -405,6 +405,11 @@ cancel-afk-on-interact: true
# Disable this to reduce server lag. # Disable this to reduce server lag.
cancel-afk-on-move: true cancel-afk-on-move: 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.
sleep-ignores-afk-players: true
# Set the player's list name when they are AFK. This is none by default which specifies that Essentials # Set the player's list name when they are AFK. This is none by default which specifies that Essentials
# should not interfere with the AFK player's list name. # should not interfere with the AFK player's list name.
# You may use color codes, use {USERNAME} the player's name or {PLAYER} for the player's displayname. # You may use color codes, use {USERNAME} the player's name or {PLAYER} for the player's displayname.