Add afk-list-name config property for changing the player list name of AFK players.

This commit is contained in:
Ali Moghnieh 2016-01-20 14:15:53 +00:00
parent c6d2746959
commit bbf657e251
4 changed files with 36 additions and 0 deletions

View File

@ -160,6 +160,10 @@ public interface ISettings extends IConf {
boolean cancelAfkOnInteract();
boolean isAfkListName();
String getAfkListName();
boolean areDeathMessagesEnabled();
void setDebug(boolean debug);

View File

@ -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);

View File

@ -418,6 +418,14 @@ public class User extends UserData implements Comparable<User>, 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);
}

View File

@ -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