diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index b597d21e4..c736ad5c2 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -160,6 +160,10 @@ public interface ISettings extends IConf { boolean cancelAfkOnInteract(); + boolean isAfkListName(); + + String getAfkListName(); + boolean areDeathMessagesEnabled(); void setDebug(boolean debug); diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index b9e8b2d9e..413809e26 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -495,6 +495,8 @@ public class Settings implements net.ess3.api.ISettings { cancelAfkOnInteract = _cancelAfkOnInteract(); cancelAfkOnMove = _cancelAfkOnMove() && cancelAfkOnInteract; getFreezeAfkPlayers = _getFreezeAfkPlayers(); + afkListName = _getAfkListName(); + isAfkListName = !afkListName.equalsIgnoreCase("none"); itemSpawnBl = _getItemSpawnBlacklist(); loginAttackDelay = _getLoginAttackDelay(); signUsePerSecond = _getSignUsePerSecond(); @@ -862,6 +864,23 @@ public class Settings implements net.ess3.api.ISettings { return config.getBoolean("cancel-afk-on-interact", true); } + private String afkListName; + private boolean isAfkListName; + + public String _getAfkListName() { + return FormatUtil.replaceFormat(config.getString("afk-list-name", "none")); + } + + @Override + public boolean isAfkListName() { + return isAfkListName; + } + + @Override + public String getAfkListName() { + return afkListName; + } + @Override public boolean areDeathMessagesEnabled() { return config.getBoolean("death-messages", true); diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 1535a0fbe..2697eae68 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -418,6 +418,14 @@ public class User extends UserData implements Comparable, IMessageRecipien } else if (!set && isAfk()) { afkPosition = null; } + if (ess.getSettings().isAfkListName()) { + if(set) { + String afkName = ess.getSettings().getAfkListName().replace("{PLAYER}", getDisplayName()).replace("{USERNAME}", getName()); + getBase().setPlayerListName(afkName); + } else { + getBase().setPlayerListName(null); + } + } _setAfk(set); } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 6a93aa35e..14c4496ba 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -391,6 +391,11 @@ cancel-afk-on-interact: true # Disable this to reduce server lag. cancel-afk-on-move: 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. +afk-list-name: none + # You can disable the death messages of Minecraft here. death-messages: true