Skip to content

Commit

Permalink
Hiding display names (#2248) @AllTheMegahertz
Browse files Browse the repository at this point in the history
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
  • Loading branch information
VirtualParticle authored and mdcfe committed Dec 9, 2018
1 parent 6a63834 commit a18ce40
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Essentials/src/com/earth2me/essentials/ISettings.java
Expand Up @@ -243,6 +243,8 @@ public interface ISettings extends IConf {

boolean ignoreColorsInMaxLength();

boolean hideDisplayNameInVanish();

int getMaxUserCacheCount();

boolean allowSilentJoinQuit();
Expand Down
5 changes: 5 additions & 0 deletions Essentials/src/com/earth2me/essentials/Settings.java
Expand Up @@ -1103,6 +1103,11 @@ public boolean ignoreColorsInMaxLength() {
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() {
Expand Down
2 changes: 1 addition & 1 deletion Essentials/src/com/earth2me/essentials/User.java
Expand Up @@ -360,7 +360,7 @@ public void setDisplayNick() {
}

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
Expand Down
4 changes: 4 additions & 0 deletions Essentials/src/config.yml
Expand Up @@ -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

Expand Down

0 comments on commit a18ce40

Please sign in to comment.