mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
Revert "Remove non-functional Chat Placeholders"
This reverts commit 403c3a3059.
This commit is contained in:
1 parent
403c3a3059
commit
f2fa2b5d92
5 files changed
+36
-8
No files matched your search
@@ -71,6 +71,9 @@ public class PrimaryConfig {
|
||||
@Comment("The suggestions shown when using the TAB key in chat.")
|
||||
private List<String> customChatSuggestions = List.of();
|
||||
|
||||
@Comment("The placeholders replaced in chat messages, this WILL work with chat previews.")
|
||||
private Map<String, String> chatPlaceholders = Map.of();
|
||||
|
||||
@Comment("Various settings related to pinging players in channels.")
|
||||
private PingSettings pingSettings = new PingSettings();
|
||||
|
||||
@@ -113,7 +116,7 @@ public class PrimaryConfig {
|
||||
|
||||
public String applyCustomPlaceholders(final String string) {
|
||||
String placeholderResolvedMessage = string;
|
||||
for (final var entry : this.customPlaceholders().entrySet()) {
|
||||
for (final var entry : this.customPlaceholders.entrySet()) {
|
||||
placeholderResolvedMessage = placeholderResolvedMessage.replace("<" + entry.getKey() + ">",
|
||||
entry.getValue());
|
||||
}
|
||||
@@ -124,6 +127,10 @@ public class PrimaryConfig {
|
||||
return this.customChatSuggestions;
|
||||
}
|
||||
|
||||
public @Nullable Map<String, String> chatPlaceholders() {
|
||||
return this.chatPlaceholders;
|
||||
}
|
||||
|
||||
public PingSettings pings() {
|
||||
return this.pingSettings;
|
||||
}
|
||||
|
||||
@@ -21,12 +21,14 @@ package net.draycia.carbon.common.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.event.events.CarbonChatEvent;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.KeyedRenderer;
|
||||
import net.draycia.carbon.common.channels.ConfigChatChannel;
|
||||
import net.draycia.carbon.common.config.ConfigFactory;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.chat.SignedMessage;
|
||||
@@ -35,19 +37,28 @@ import net.kyori.adventure.text.Component;
|
||||
|
||||
public abstract class ChatListenerInternal {
|
||||
|
||||
private final ConfigFactory configFactory;
|
||||
private final CarbonMessages carbonMessages;
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
protected ChatListenerInternal(
|
||||
final CarbonChat carbonChat,
|
||||
final CarbonMessages carbonMessages
|
||||
final CarbonMessages carbonMessages,
|
||||
final ConfigFactory configFactory
|
||||
) {
|
||||
this.configFactory = configFactory;
|
||||
this.carbonMessages = carbonMessages;
|
||||
this.carbonChat = carbonChat;
|
||||
}
|
||||
|
||||
protected CarbonChatEvent prepareAndEmitChatEvent(final CarbonPlayer sender, final String messageContent, final SignedMessage signedMessage) {
|
||||
Component message = ConfigChatChannel.parseMessageTags(sender, messageContent);
|
||||
String content = messageContent;
|
||||
|
||||
for (final Map.Entry<String, String> placeholder : this.configFactory.primaryConfig().chatPlaceholders().entrySet()) {
|
||||
content = content.replace(placeholder.getKey(), placeholder.getValue());
|
||||
}
|
||||
|
||||
Component message = ConfigChatChannel.parseMessageTags(sender, content);
|
||||
|
||||
final CarbonPlayer.ChannelMessage channelMessage = sender.channelForMessage(message);
|
||||
final ChatChannel channel = channelMessage.channel();
|
||||
|
||||
Reference in new issue
Block a user