Hiding display names (#2248) @AllTheMegahertz

Prevents a user's nickname from appearing if they are hidden, if `hide-displayname-in-vanish: true` in the config. Closes #2221.

* Does not return display name if user is hidden

* Added hide-displayname-in-vanish field

* Added hideDisplayNameInVanish()

* Changed to only hide display name if specified in config

* Changed hideDisplayNameInVanish to default to false if not specified in config.yml
This commit is contained in:
Mark Vadeika 2018-12-09 06:02:45 -05:00 committed by md678685
parent 6a6383462d
commit a18ce40921
4 changed files with 12 additions and 1 deletions

View File

@ -243,6 +243,8 @@ public interface ISettings extends IConf {
boolean ignoreColorsInMaxLength();
boolean hideDisplayNameInVanish();
int getMaxUserCacheCount();
boolean allowSilentJoinQuit();

View File

@ -1103,6 +1103,11 @@ public class Settings implements net.ess3.api.ISettings {
return config.getBoolean("ignore-colors-in-max-nick-length", false);
}
@Override
public boolean hideDisplayNameInVanish() {
return config.getBoolean("hide-displayname-in-vanish", false);
}
private boolean allowSilentJoin;
public boolean _allowSilentJoinQuit() {

View File

@ -360,7 +360,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
}
public String getDisplayName() {
return super.getBase().getDisplayName() == null ? super.getBase().getName() : super.getBase().getDisplayName();
return super.getBase().getDisplayName() == null || (ess.getSettings().hideDisplayNameInVanish() && isHidden()) ? super.getBase().getName() : super.getBase().getDisplayName();
}
@Override

View File

@ -36,6 +36,10 @@ max-nick-length: 15
# ie: "&6Notch" has 7 characters (2 are part of a color code), a length of 5 is used when this option is set to true
ignore-colors-in-max-nick-length: false
# When this option is enabled, display names for hidden users will not be shown. This prevents players from being
# able to see that they are online while vanished.
hide-displayname-in-vanish: true
# Disable this if you have any other plugin, that modifies the displayname of a user.
change-displayname: true