mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
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:
parent
3692740762
commit
c062651821
6 changed files with 15 additions and 5 deletions
|
@ -172,6 +172,8 @@ public interface ISettings extends IConf {
|
||||||
|
|
||||||
boolean changePlayerListName();
|
boolean changePlayerListName();
|
||||||
|
|
||||||
|
boolean changeTabCompleteName();
|
||||||
|
|
||||||
boolean isPlayerCommand(String string);
|
boolean isPlayerCommand(String string);
|
||||||
|
|
||||||
boolean useBukkitPermissions();
|
boolean useBukkitPermissions();
|
||||||
|
|
|
@ -1024,6 +1024,11 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
return changePlayerListName;
|
return changePlayerListName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean changeTabCompleteName() {
|
||||||
|
return config.getBoolean("change-tab-complete-name", false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean useBukkitPermissions() {
|
public boolean useBukkitPermissions() {
|
||||||
return config.getBoolean("use-bukkit-permissions", false);
|
return config.getBoolean("use-bukkit-permissions", false);
|
||||||
|
|
|
@ -294,8 +294,6 @@ public class Commandmail extends EssentialsCommand {
|
||||||
return getPlayers(server, sender);
|
return getPlayers(server, sender);
|
||||||
} else if (args.length == 3 && args[0].equalsIgnoreCase("sendtemp")) {
|
} else if (args.length == 3 && args[0].equalsIgnoreCase("sendtemp")) {
|
||||||
return COMMON_DATE_DIFFS;
|
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 {
|
} else {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.earth2me.essentials.utils.DateUtil;
|
||||||
import com.earth2me.essentials.utils.FormatUtil;
|
import com.earth2me.essentials.utils.FormatUtil;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n.tl;
|
import static com.earth2me.essentials.I18n.tl;
|
||||||
|
@ -60,7 +61,7 @@ public class Commandmsg extends EssentialsLoopCommand {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
return getPlayers(server, sender);
|
return getPlayers(server, sender);
|
||||||
} else {
|
} 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.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.earth2me.essentials.CommandSource;
|
||||||
import com.earth2me.essentials.IEssentialsModule;
|
import com.earth2me.essentials.IEssentialsModule;
|
||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import com.earth2me.essentials.utils.FormatUtil;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
@ -226,7 +227,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
||||||
final List<String> players = Lists.newArrayList();
|
final List<String> players = Lists.newArrayList();
|
||||||
for (final User user : ess.getOnlineUsers()) {
|
for (final User user : ess.getOnlineUsers()) {
|
||||||
if (canInteractWith(interactor, user)) {
|
if (canInteractWith(interactor, user)) {
|
||||||
players.add(user.getName());
|
players.add(ess.getSettings().changeTabCompleteName() ? FormatUtil.stripFormat(user.getDisplayName()) : user.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
|
@ -240,7 +241,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
||||||
final List<String> players = Lists.newArrayList();
|
final List<String> players = Lists.newArrayList();
|
||||||
for (final User user : ess.getOnlineUsers()) {
|
for (final User user : ess.getOnlineUsers()) {
|
||||||
if (canInteractWith(interactor, user)) {
|
if (canInteractWith(interactor, user)) {
|
||||||
players.add(user.getName());
|
players.add(ess.getSettings().changeTabCompleteName() ? FormatUtil.stripFormat(user.getDisplayName()) : user.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
|
|
|
@ -49,6 +49,9 @@ hide-displayname-in-vanish: true
|
||||||
# Disable this if you have any other plugin, that modifies the displayname of a user.
|
# Disable this if you have any other plugin, that modifies the displayname of a user.
|
||||||
change-displayname: true
|
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.
|
# 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.
|
# The value of change-displayname (above) has to be true.
|
||||||
#change-playerlist: true
|
#change-playerlist: true
|
||||||
|
|
Loading…
Reference in a new issue