Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ private void joinFlow(final User user, final long currentTime, final String mess

final String lastAccountName = user.getLastAccountName(); // For comparison
user.setLastAccountName(user.getBase().getName());

// If the Minecraft account name changed, reset the nickname so the old one doesn't persist
if (ess.getSettings().isResetNickOnNameChange() && lastAccountName != null && !lastAccountName.equals(user.getBase().getName()) && user.getNickname() != null) {
user.setNickname(null);
}

user.setLastLogin(currentTime);
user.setDisplayNick();
updateCompass(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ public interface IEssentials extends Plugin {

RandomTeleport getRandomTeleport();

boolean isResetNickOnNameChange();

UpdateChecker getUpdateChecker();

BukkitTask runTaskAsynchronously(Runnable run);
Expand Down
11 changes: 11 additions & 0 deletions Essentials/src/main/java/com/earth2me/essentials/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public class Settings implements net.ess3.api.ISettings {
private boolean logCommandBlockCommands;
private boolean logConsoleCommands;
private Set<Predicate<String>> nickBlacklist;
private boolean resetNickOnNameChange = false;
private double maxProjectileSpeed;
private boolean removeEffectsOnHeal;
private Map<String, String> worldAliases;
Expand Down Expand Up @@ -508,11 +509,20 @@ private String _getNicknamePrefix() {
return config.getString("nickname-prefix", "~");
}

private boolean _resetNickOnNameChange() {
return config.getBoolean("reset-nick-on-name-change", false);
}

@Override
public String getNicknamePrefix() {
return nicknamePrefix;
}

@Override
public boolean isResetNickOnNameChange() {
return resetNickOnNameChange;
}

@Override
public double getTeleportCooldown() {
return config.getDouble("teleport-cooldown", 0);
Expand Down Expand Up @@ -886,6 +896,7 @@ public void reloadConfig() {
}

nicknamePrefix = _getNicknamePrefix();
resetNickOnNameChange = _resetNickOnNameChange();
operatorColor = _getOperatorColor();
changePlayerListName = _changePlayerListName();
configDebug = _isDebug();
Expand Down
4 changes: 4 additions & 0 deletions Essentials/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ nick-blacklist:
# For example, if "&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, any nickname set by a player will be reset when their Minecraft account name changes.
# This prevents old nicknames (including RGB-formatted ones) from persisting after a name change.
reset-nick-on-name-change: false

# When this option is enabled, display names for hidden players will not be shown. This prevents players from being
# able to see that they are online while vanished.
hide-displayname-in-vanish: true
Expand Down