Skip to content

Commit 25ddaef

Browse files
authored
Merge pull request #2329 from triagonal/issue-2311
Implement config option for sleep ignoring AFK players
2 parents 585f2be + 3d004d2 commit 25ddaef

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

Essentials/src/com/earth2me/essentials/ISettings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ public interface ISettings extends IConf {
185185

186186
boolean cancelAfkOnInteract();
187187

188+
boolean sleepIgnoresAfkPlayers();
189+
188190
boolean isAfkListName();
189191

190192
String getAfkListName();

Essentials/src/com/earth2me/essentials/Settings.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ public void reloadConfig() {
494494
cancelAfkOnInteract = _cancelAfkOnInteract();
495495
cancelAfkOnMove = _cancelAfkOnMove();
496496
getFreezeAfkPlayers = _getFreezeAfkPlayers();
497+
sleepIgnoresAfkPlayers = _sleepIgnoresAfkPlayers();
497498
afkListName = _getAfkListName();
498499
isAfkListName = !afkListName.equalsIgnoreCase("none");
499500
itemSpawnBl = _getItemSpawnBlacklist();
@@ -893,6 +894,17 @@ private boolean _cancelAfkOnInteract() {
893894
return config.getBoolean("cancel-afk-on-interact", true);
894895
}
895896

897+
private boolean sleepIgnoresAfkPlayers;
898+
899+
@Override
900+
public boolean sleepIgnoresAfkPlayers() {
901+
return sleepIgnoresAfkPlayers;
902+
}
903+
904+
private boolean _sleepIgnoresAfkPlayers() {
905+
return config.getBoolean("sleep-ignores-afk-players", true);
906+
}
907+
896908
private String afkListName;
897909
private boolean isAfkListName;
898910

Essentials/src/com/earth2me/essentials/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public void setAfk(final boolean set) {
465465
return;
466466
}
467467

468-
this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
468+
this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") || set && ess.getSettings().sleepIgnoresAfkPlayers());
469469
if (set && !isAfk()) {
470470
afkPosition = this.getLocation();
471471
this.afkSince = System.currentTimeMillis();

Essentials/src/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,11 @@ cancel-afk-on-interact: true
405405
# Disable this to reduce server lag.
406406
cancel-afk-on-move: true
407407

408+
# Should AFK players be ignored when other players are trying to sleep?
409+
# When this setting is false, players won't be able to skip the night if some players are AFK.
410+
# Users with the permission node essentials.sleepingignored will always be ignored.
411+
sleep-ignores-afk-players: true
412+
408413
# Set the player's list name when they are AFK. This is none by default which specifies that Essentials
409414
# should not interfere with the AFK player's list name.
410415
# You may use color codes, use {USERNAME} the player's name or {PLAYER} for the player's displayname.

0 commit comments

Comments
 (0)