mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
Extract chat placeholder parsing
This commit is contained in:
1 parent
f2fa2b5d92
commit
f459d47bdb
2 files changed
+11
-7
No files matched your search
@@ -127,10 +127,19 @@ public class PrimaryConfig {
|
||||
return this.customChatSuggestions;
|
||||
}
|
||||
|
||||
public @Nullable Map<String, String> chatPlaceholders() {
|
||||
public Map<String, String> chatPlaceholders() {
|
||||
return this.chatPlaceholders;
|
||||
}
|
||||
|
||||
public String applyChatPlaceholders(final String string) {
|
||||
String placeholderResolvedMessage = string;
|
||||
for (final var entry : this.chatPlaceholders().entrySet()) {
|
||||
placeholderResolvedMessage = placeholderResolvedMessage.replace("<" + entry.getKey() + ">",
|
||||
entry.getValue());
|
||||
}
|
||||
return placeholderResolvedMessage;
|
||||
}
|
||||
|
||||
public PingSettings pings() {
|
||||
return this.pingSettings;
|
||||
}
|
||||
|
||||
@@ -52,12 +52,7 @@ public abstract class ChatListenerInternal {
|
||||
}
|
||||
|
||||
protected CarbonChatEvent prepareAndEmitChatEvent(final CarbonPlayer sender, final String messageContent, final SignedMessage signedMessage) {
|
||||
String content = messageContent;
|
||||
|
||||
for (final Map.Entry<String, String> placeholder : this.configFactory.primaryConfig().chatPlaceholders().entrySet()) {
|
||||
content = content.replace(placeholder.getKey(), placeholder.getValue());
|
||||
}
|
||||
|
||||
String content = this.configFactory.primaryConfig().applyChatPlaceholders(messageContent);
|
||||
Component message = ConfigChatChannel.parseMessageTags(sender, content);
|
||||
|
||||
final CarbonPlayer.ChannelMessage channelMessage = sender.channelForMessage(message);
|
||||
|
||||
Reference in new issue
Block a user