feat: add color support (&#RRGGBB and #RRGGBB) to all configs

This commit is contained in:
loki5512344 2025-12-30 21:47:02 +01:00
parent 76f3c480ad
commit 036382b71a
2 changed files with 13 additions and 13 deletions

View file

@ -1,6 +1,7 @@
package com.loki.lochat.config; package com.loki.lochat.config;
import com.loki.lochat.LoChat; import com.loki.lochat.LoChat;
import com.loki.lochat.utils.ChatFormatter;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import java.util.List; import java.util.List;
@ -97,11 +98,11 @@ public class ConfigManager {
} }
public String getGlobalPrefix() { public String getGlobalPrefix() {
return config.getString("chat.global.prefix", "[G]"); return ChatFormatter.convertAllColors(config.getString("chat.global.prefix", "[G]"));
} }
public String getGlobalFormat() { public String getGlobalFormat() {
return config.getString("chat.global.format", "<prefix><player>: <message>"); return ChatFormatter.convertAllColors(config.getString("chat.global.format", "<prefix><player>: <message>"));
} }
public String getGlobalSymbol() { public String getGlobalSymbol() {
@ -122,11 +123,11 @@ public class ConfigManager {
} }
public String getLocalPrefix() { public String getLocalPrefix() {
return config.getString("chat.local.prefix", "[L]"); return ChatFormatter.convertAllColors(config.getString("chat.local.prefix", "[L]"));
} }
public String getLocalFormat() { public String getLocalFormat() {
return config.getString("chat.local.format", "<player>: <message>"); return ChatFormatter.convertAllColors(config.getString("chat.local.format", "<player>: <message>"));
} }
public int getLocalCooldown() { public int getLocalCooldown() {
@ -164,11 +165,11 @@ public class ConfigManager {
} }
public String getMentionHighlight() { public String getMentionHighlight() {
return config.getString("mentions.highlight", "&#FFFF00@{player}"); return ChatFormatter.convertAllColors(config.getString("mentions.highlight", "&#FFFF00@{player}"));
} }
public String getSelfMentionHighlight() { public String getSelfMentionHighlight() {
return config.getString("mentions.self-highlight", "&#FFD700{player}"); return ChatFormatter.convertAllColors(config.getString("mentions.self-highlight", "&#FFD700{player}"));
} }
// Filter // Filter
@ -220,7 +221,7 @@ public class ConfigManager {
// Formats // Formats
public String getAnnouncementFormat() { public String getAnnouncementFormat() {
return config.getString("formats.announcement", "&#FFD700[ОБЪЯВЛЕНИЕ] <message>"); return ChatFormatter.convertAllColors(config.getString("formats.announcement", "&#FFD700[ОБЪЯВЛЕНИЕ] <message>"));
} }
// Announcements // Announcements
@ -229,7 +230,7 @@ public class ConfigManager {
} }
public String getAnnouncementTitleHeader() { public String getAnnouncementTitleHeader() {
return config.getString("announcements.title-header", "&#FFD700ОБЪЯВЛЕНИЕ"); return ChatFormatter.convertAllColors(config.getString("announcements.title-header", "&#FFD700ОБЪЯВЛЕНИЕ"));
} }
public boolean isAnnouncementActionBarEnabled() { public boolean isAnnouncementActionBarEnabled() {

View file

@ -31,17 +31,16 @@ public class MessageConfig {
} }
public String get(String path) { public String get(String path) {
return messages.getString(path, "&#FF0000Message not found: " + path); String message = messages.getString(path, "&#FF0000Message not found: " + path);
return ChatFormatter.convertAllColors(message);
} }
public String get(String path, String... replacements) { public String get(String path, String... replacements) {
String message = get(path); String message = messages.getString(path, "&#FF0000Message not found: " + path);
for (int i = 0; i < replacements.length - 1; i += 2) { for (int i = 0; i < replacements.length - 1; i += 2) {
message = message.replace(replacements[i], replacements[i + 1]); message = message.replace(replacements[i], replacements[i + 1]);
} }
// Убираем все цветовые коды и конвертируем заново return ChatFormatter.convertAllColors(message);
message = ChatFormatter.stripAllColors(message);
return message;
} }
// Shortcuts // Shortcuts