9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00

add strip color codes support

This commit is contained in:
XiaoMoMi
2025-06-21 00:20:01 +08:00
parent e01dec757e
commit 3cbf4698ed
4 changed files with 17 additions and 2 deletions

View File

@@ -338,6 +338,7 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
protected String configVersion;
protected float minPackVersion;
protected boolean stripChatColorTags;
/**
* Constructs a new {@code ConfigManager} for the specified {@code CustomNameplates} plugin instance.
@@ -478,6 +479,7 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
otherActionBarStayTime = config.getInt("other-settings.other-actionbar-stay-time", 3000);
displaySystemChat = config.getBoolean("other-settings.display-system-actionbar", true);
hideTeamNames = config.getBoolean("other-settings.hide-team-names", true);
stripChatColorTags = config.getBoolean("other-settings.strip-chat-color-tags", false);
}
@Override
@@ -916,6 +918,10 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
return instance.chatChatty;
}
public static boolean stripChatColorTags() {
return instance.stripChatColorTags;
}
/**
* Returns the configuration file at the specified path with a custom route separator.
*

View File

@@ -77,6 +77,7 @@ other-settings:
display-system-actionbar: true # Should the plugin display system actionbar and temporarily hide the custom actionbar?
hide-team-names: true # Hide the team name sent by other plugins or vanilla team system
unsafe-chat-event: false # Listen for canceled(unsafe) chat events from unknown plugins
strip-chat-color-tags: false # Strip color codes from messages provided by external chat API
default-condition-refresh-interval: 10 # Set default condition refresh interval in ticks
default-placeholder-refresh-interval: 1 # Set default placeholder refresh interval in ticks
placeholder-refresh-interval: # Custom placeholder refresh intervals for performance optimization

View File

@@ -1,7 +1,7 @@
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=3.0.28
config_version=37
config_version=38
project_group=net.momirealms
# Supported languages

View File

@@ -22,9 +22,11 @@ import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
import mineverse.Aust1n46.chat.api.events.VentureChatEvent;
import mineverse.Aust1n46.chat.channel.ChatChannel;
import net.momirealms.customnameplates.api.CNPlayer;
import net.momirealms.customnameplates.api.ConfigManager;
import net.momirealms.customnameplates.api.CustomNameplates;
import net.momirealms.customnameplates.api.feature.chat.AbstractChatMessageProvider;
import net.momirealms.customnameplates.api.feature.chat.ChatManager;
import net.momirealms.customnameplates.api.helper.AdventureHelper;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -51,8 +53,14 @@ public class VentureChatProvider extends AbstractChatMessageProvider implements
if (cnPlayer == null) {
return;
}
String chatMessage;
if (ConfigManager.stripChatColorTags()) {
chatMessage = AdventureHelper.stripTags(AdventureHelper.legacyToMiniMessage(event.getChat()));
} else {
chatMessage = event.getChat();
}
plugin.getScheduler().async().execute(() -> {
manager.onChat(cnPlayer, event.getChat(), channelName);
manager.onChat(cnPlayer, chatMessage, channelName);
});
}