Add workaround to display nickname when tagging a player in chat.
This commit is contained in:
parent
773638c222
commit
804e619e8a
|
|
@ -136,11 +136,12 @@ public class ChatListener implements Listener {
|
||||||
Pattern nickPattern = Pattern.compile("\\b(?<!\\\\)" + nickName + "\\b", Pattern.CASE_INSENSITIVE);
|
Pattern nickPattern = Pattern.compile("\\b(?<!\\\\)" + nickName + "\\b", Pattern.CASE_INSENSITIVE);
|
||||||
// Pattern escapedNickPattern = Pattern.compile("\\b\\\\" + nickName + "\\b", Pattern.CASE_INSENSITIVE);
|
// Pattern escapedNickPattern = Pattern.compile("\\b\\\\" + nickName + "\\b", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
||||||
|
ChatUser onlinePlayerUser = ChatUserManager.getChatUser(onlinePlayer.getUniqueId());
|
||||||
if (namePattern.matcher(modifiableString.string()).find()) {
|
if (namePattern.matcher(modifiableString.string()).find()) {
|
||||||
modifiableString.replace(TextReplacementConfig.builder()
|
modifiableString.replace(TextReplacementConfig.builder()
|
||||||
.once()
|
.once()
|
||||||
.match(namePattern)
|
.match(namePattern)
|
||||||
.replacement(mention.append(onlinePlayer.displayName()))
|
.replacement(mention.append(onlinePlayerUser.getDisplayName()))
|
||||||
.build());
|
.build());
|
||||||
//TODO replace all instances of \name with just name but using the match result so the capitalization doesn't change
|
//TODO replace all instances of \name with just name but using the match result so the capitalization doesn't change
|
||||||
// modifiableString.replace(TextReplacementConfig.builder()
|
// modifiableString.replace(TextReplacementConfig.builder()
|
||||||
|
|
@ -156,7 +157,7 @@ public class ChatListener implements Listener {
|
||||||
modifiableString.replace(TextReplacementConfig.builder()
|
modifiableString.replace(TextReplacementConfig.builder()
|
||||||
.once()
|
.once()
|
||||||
.match(nickPattern)
|
.match(nickPattern)
|
||||||
.replacement(mention.append(onlinePlayer.displayName()))
|
.replacement(mention.append(onlinePlayerUser.getDisplayName()))
|
||||||
.build());
|
.build());
|
||||||
if (!ChatUserManager.getChatUser(onlinePlayer.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId()))
|
if (!ChatUserManager.getChatUser(onlinePlayer.getUniqueId()).getIgnoredPlayers().contains(player.getUniqueId()))
|
||||||
playersToPing.add(onlinePlayer);
|
playersToPing.add(onlinePlayer);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user