Add option to ignore vanished players from sleeping (#4200)

This commit is contained in:
Josh Roy 2021-06-06 17:05:16 -04:00 committed by GitHub
parent a4fbfbef02
commit fed26071ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 0 deletions

View File

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

View File

@ -1101,6 +1101,11 @@ public class Settings implements net.ess3.api.ISettings {
return config.getBoolean("sleep-ignores-afk-players", true);
}
@Override
public boolean sleepIgnoresVanishedPlayers() {
return config.getBoolean("sleep-ignores-vanished-player", true);
}
public String _getAfkListName() {
return FormatUtil.replaceFormat(config.getString("afk-list-name", "none"));
}

View File

@ -889,6 +889,9 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
if (isAuthorized("essentials.vanish.effect")) {
this.getBase().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
}
if (ess.getSettings().sleepIgnoresVanishedPlayers()) {
getBase().setSleepingIgnored(true);
}
} else {
for (final Player p : ess.getOnlinePlayers()) {
p.showPlayer(getBase());
@ -898,6 +901,9 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
if (isAuthorized("essentials.vanish.effect")) {
this.getBase().removePotionEffect(PotionEffectType.INVISIBILITY);
}
if (ess.getSettings().sleepIgnoresVanishedPlayers()) {
getBase().setSleepingIgnored(false);
}
}
}

View File

@ -471,6 +471,11 @@ cancel-afk-on-chat: true
# Users with the permission node essentials.sleepingignored will always be ignored.
sleep-ignores-afk-players: true
# Should vanished players be ignored when other players are trying to sleep?
# When this setting is false, player's won't be able to skip the night if vanished players are not sleeping.
# Users with the permission node essentials.sleepingignored will always be ignored.
sleep-ignores-vanished-player: 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.