Add option for tab complete to use displaynames (#4432)

Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com>

This feature adds a new configuration option, `change-tab-complete-name`

When `change-tab-complete-name` is turned on, `getPlayers()` in `EssentialsCommand` will use `getDisplayName()` instead of `getName()`; populating the list with display names instead of player names.

Closes #4431.
This commit is contained in:
CyberKitsune 2021-08-19 13:00:06 -07:00 committed by GitHub
parent 3692740762
commit c062651821
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 5 deletions

View file

@ -172,6 +172,8 @@ public interface ISettings extends IConf {
boolean changePlayerListName();
boolean changeTabCompleteName();
boolean isPlayerCommand(String string);
boolean useBukkitPermissions();

View file

@ -1024,6 +1024,11 @@ public class Settings implements net.ess3.api.ISettings {
return changePlayerListName;
}
@Override
public boolean changeTabCompleteName() {
return config.getBoolean("change-tab-complete-name", false);
}
@Override
public boolean useBukkitPermissions() {
return config.getBoolean("use-bukkit-permissions", false);

View file

@ -294,8 +294,6 @@ public class Commandmail extends EssentialsCommand {
return getPlayers(server, sender);
} else if (args.length == 3 && args[0].equalsIgnoreCase("sendtemp")) {
return COMMON_DATE_DIFFS;
} else if ((args.length > 2 && args[0].equalsIgnoreCase("send")) || (args.length > 1 && args[0].equalsIgnoreCase("sendall"))) {
return null; // Use vanilla handler
} else {
return Collections.emptyList();
}

View file

@ -8,6 +8,7 @@ import com.earth2me.essentials.utils.DateUtil;
import com.earth2me.essentials.utils.FormatUtil;
import org.bukkit.Server;
import java.util.Collections;
import java.util.List;
import static com.earth2me.essentials.I18n.tl;
@ -60,7 +61,7 @@ public class Commandmsg extends EssentialsLoopCommand {
if (args.length == 1) {
return getPlayers(server, sender);
} else {
return null; // It's a chat message, use the default chat handler
return Collections.emptyList(); // It's a chat message, send an empty list.
}
}
}

View file

@ -4,6 +4,7 @@ import com.earth2me.essentials.CommandSource;
import com.earth2me.essentials.IEssentialsModule;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.utils.FormatUtil;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
@ -226,7 +227,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
final List<String> players = Lists.newArrayList();
for (final User user : ess.getOnlineUsers()) {
if (canInteractWith(interactor, user)) {
players.add(user.getName());
players.add(ess.getSettings().changeTabCompleteName() ? FormatUtil.stripFormat(user.getDisplayName()) : user.getName());
}
}
return players;
@ -240,7 +241,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
final List<String> players = Lists.newArrayList();
for (final User user : ess.getOnlineUsers()) {
if (canInteractWith(interactor, user)) {
players.add(user.getName());
players.add(ess.getSettings().changeTabCompleteName() ? FormatUtil.stripFormat(user.getDisplayName()) : user.getName());
}
}
return players;

View file

@ -49,6 +49,9 @@ hide-displayname-in-vanish: true
# Disable this if you have any other plugin, that modifies the displayname of a user.
change-displayname: true
# This option will cause Essentials to show players' displaynames instead of usernames when tab completing Essentials commands.
change-tab-complete-name: false
# When this option is enabled, the (tab) player list will be updated with the displayname.
# The value of change-displayname (above) has to be true.
#change-playerlist: true