mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-22 16:39:24 +00:00
add strip color codes support
This commit is contained in:
@@ -338,6 +338,7 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
|
|||||||
protected String configVersion;
|
protected String configVersion;
|
||||||
|
|
||||||
protected float minPackVersion;
|
protected float minPackVersion;
|
||||||
|
protected boolean stripChatColorTags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new {@code ConfigManager} for the specified {@code CustomNameplates} plugin instance.
|
* 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);
|
otherActionBarStayTime = config.getInt("other-settings.other-actionbar-stay-time", 3000);
|
||||||
displaySystemChat = config.getBoolean("other-settings.display-system-actionbar", true);
|
displaySystemChat = config.getBoolean("other-settings.display-system-actionbar", true);
|
||||||
hideTeamNames = config.getBoolean("other-settings.hide-team-names", true);
|
hideTeamNames = config.getBoolean("other-settings.hide-team-names", true);
|
||||||
|
stripChatColorTags = config.getBoolean("other-settings.strip-chat-color-tags", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -916,6 +918,10 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
|
|||||||
return instance.chatChatty;
|
return instance.chatChatty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean stripChatColorTags() {
|
||||||
|
return instance.stripChatColorTags;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the configuration file at the specified path with a custom route separator.
|
* Returns the configuration file at the specified path with a custom route separator.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ other-settings:
|
|||||||
display-system-actionbar: true # Should the plugin display system actionbar and temporarily hide the custom actionbar?
|
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
|
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
|
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-condition-refresh-interval: 10 # Set default condition refresh interval in ticks
|
||||||
default-placeholder-refresh-interval: 1 # Set default placeholder 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
|
placeholder-refresh-interval: # Custom placeholder refresh intervals for performance optimization
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Project settings
|
# Project settings
|
||||||
# Rule: [major update].[feature update].[bug fix]
|
# Rule: [major update].[feature update].[bug fix]
|
||||||
project_version=3.0.28
|
project_version=3.0.28
|
||||||
config_version=37
|
config_version=38
|
||||||
project_group=net.momirealms
|
project_group=net.momirealms
|
||||||
|
|
||||||
# Supported languages
|
# Supported languages
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
|
|||||||
import mineverse.Aust1n46.chat.api.events.VentureChatEvent;
|
import mineverse.Aust1n46.chat.api.events.VentureChatEvent;
|
||||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
import mineverse.Aust1n46.chat.channel.ChatChannel;
|
||||||
import net.momirealms.customnameplates.api.CNPlayer;
|
import net.momirealms.customnameplates.api.CNPlayer;
|
||||||
|
import net.momirealms.customnameplates.api.ConfigManager;
|
||||||
import net.momirealms.customnameplates.api.CustomNameplates;
|
import net.momirealms.customnameplates.api.CustomNameplates;
|
||||||
import net.momirealms.customnameplates.api.feature.chat.AbstractChatMessageProvider;
|
import net.momirealms.customnameplates.api.feature.chat.AbstractChatMessageProvider;
|
||||||
import net.momirealms.customnameplates.api.feature.chat.ChatManager;
|
import net.momirealms.customnameplates.api.feature.chat.ChatManager;
|
||||||
|
import net.momirealms.customnameplates.api.helper.AdventureHelper;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -51,8 +53,14 @@ public class VentureChatProvider extends AbstractChatMessageProvider implements
|
|||||||
if (cnPlayer == null) {
|
if (cnPlayer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String chatMessage;
|
||||||
|
if (ConfigManager.stripChatColorTags()) {
|
||||||
|
chatMessage = AdventureHelper.stripTags(AdventureHelper.legacyToMiniMessage(event.getChat()));
|
||||||
|
} else {
|
||||||
|
chatMessage = event.getChat();
|
||||||
|
}
|
||||||
plugin.getScheduler().async().execute(() -> {
|
plugin.getScheduler().async().execute(() -> {
|
||||||
manager.onChat(cnPlayer, event.getChat(), channelName);
|
manager.onChat(cnPlayer, chatMessage, channelName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user