Skip to content

Commit

Permalink
Merge pull request #2329 from triagonal/issue-2311
Browse files Browse the repository at this point in the history
Implement config option for sleep ignoring AFK players
  • Loading branch information
mdcfe authored Mar 8, 2019
2 parents 585f2be + 3d004d2 commit 25ddaef
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Essentials/src/com/earth2me/essentials/ISettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ public interface ISettings extends IConf {

boolean cancelAfkOnInteract();

boolean sleepIgnoresAfkPlayers();

boolean isAfkListName();

String getAfkListName();
Expand Down
12 changes: 12 additions & 0 deletions Essentials/src/com/earth2me/essentials/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ public void reloadConfig() {
cancelAfkOnInteract = _cancelAfkOnInteract();
cancelAfkOnMove = _cancelAfkOnMove();
getFreezeAfkPlayers = _getFreezeAfkPlayers();
sleepIgnoresAfkPlayers = _sleepIgnoresAfkPlayers();
afkListName = _getAfkListName();
isAfkListName = !afkListName.equalsIgnoreCase("none");
itemSpawnBl = _getItemSpawnBlacklist();
Expand Down Expand Up @@ -893,6 +894,17 @@ private boolean _cancelAfkOnInteract() {
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 boolean isAfkListName;

Expand Down
2 changes: 1 addition & 1 deletion Essentials/src/com/earth2me/essentials/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public void setAfk(final boolean set) {
return;
}

this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
this.getBase().setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") || set && ess.getSettings().sleepIgnoresAfkPlayers());
if (set && !isAfk()) {
afkPosition = this.getLocation();
this.afkSince = System.currentTimeMillis();
Expand Down
5 changes: 5 additions & 0 deletions Essentials/src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ cancel-afk-on-interact: true
# Disable this to reduce server lag.
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
# 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.
Expand Down

0 comments on commit 25ddaef

Please sign in to comment.