refactor: restructure services and filters architecture
- Remove deprecated service interfaces (CooldownService, IgnoreService, PMService, PlayerDataService, SpyService) - Add new unified service interfaces (MessagingService, PlayerService, PunishmentService) - Extract FilterResult as standalone class from AdvancedMessageFilter - Implement individual filter classes (CharacterFilter, FloodFilter, SpamFilter, SwearFilter, UrlFilter) - Add moderation commands (BanCommand, WarnCommand, SilentWarnCommand, UnbanCommand) - Introduce data models for punishment tracking (BanRecord, WarnEntry) - Refactor messaging service with new MessagingServiceImpl implementation - Add mute service utilities (MuteDataStorage, MutePermissionChecker) - Implement PunishmentServiceImpl with snapshot tracking - Add Discord integration components (DiscordConfig, DiscordMessageService) - Introduce command handlers for gradient module (ColorCommandHandler, PrefixCommandHandler) - Add renderer components (EmojiComponent, GradientBuilder, UrlProcessor) - Add utility classes (ColorConverter, MessageSender, PlaceholderProcessor) - Update configuration files and plugin metadata - Add documentation files (CODE_REVIEW_RU.md, REFACTORING_SERVICES.md) - Consolidate service architecture for improved maintainability and separation of concerns
This commit is contained in:
parent
2d79d2a91d
commit
bba480002f
181 changed files with 3455 additions and 2908 deletions
|
|
@ -6,12 +6,12 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Менеджер конфигураций - упрощенная версия
|
||||
*/
|
||||
public class ConfigManager {
|
||||
|
||||
private final LoChat plugin;
|
||||
|
||||
// ✅ THREAD-SAFETY: volatile для безопасного reload из разных потоков
|
||||
// volatile гарантирует что все потоки видят актуальную версию конфига после reload
|
||||
private volatile FileConfiguration config;
|
||||
private volatile AppearanceConfig appearanceConfig;
|
||||
private volatile MessagesConfig messagesConfig;
|
||||
|
|
@ -24,55 +24,42 @@ public class ConfigManager {
|
|||
plugin.saveDefaultConfig();
|
||||
this.config = plugin.getConfig();
|
||||
|
||||
// Инициализируем новые конфигурации
|
||||
// Инициализируем конфигурации
|
||||
this.appearanceConfig = new AppearanceConfig(plugin);
|
||||
this.messagesConfig = new MessagesConfig(plugin);
|
||||
this.muteConfig = new MuteConfig(plugin);
|
||||
this.filtersConfig = new FiltersConfig(plugin);
|
||||
this.soundsConfig = new SoundsConfig(plugin);
|
||||
|
||||
// Инициализируем их после создания
|
||||
this.appearanceConfig.init();
|
||||
|
||||
// Проверяем версию конфига и обновляем при необходимости
|
||||
updateConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить конфигурацию внешнего вида
|
||||
*/
|
||||
// ========== Геттеры конфигураций ==========
|
||||
|
||||
public AppearanceConfig getAppearanceConfig() {
|
||||
return appearanceConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить конфигурацию системных сообщений
|
||||
*/
|
||||
public MessagesConfig getMessagesConfig() {
|
||||
return messagesConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить конфигурацию мутов
|
||||
*/
|
||||
public MuteConfig getMuteConfig() {
|
||||
return muteConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить конфигурацию фильтров
|
||||
*/
|
||||
public FiltersConfig getFiltersConfig() {
|
||||
return filtersConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить конфигурацию звуков
|
||||
*/
|
||||
public SoundsConfig getSoundsConfig() {
|
||||
return soundsConfig;
|
||||
}
|
||||
|
||||
// ========== Обновление и перезагрузка ==========
|
||||
|
||||
private void updateConfig() {
|
||||
int currentVersion = config.getInt("config-version", 1);
|
||||
int requiredVersion = 5;
|
||||
|
|
@ -87,57 +74,37 @@ public class ConfigManager {
|
|||
}
|
||||
|
||||
private void addMissingConfigOptions() {
|
||||
if (!config.contains("announcements")) {
|
||||
config.set("announcements.show-title", true);
|
||||
config.set("announcements.title-header", "&#FFD700ОБЪЯВЛЕНИЕ");
|
||||
config.set("announcements.show-actionbar", true);
|
||||
config.set("announcements.title-duration", 3);
|
||||
}
|
||||
setIfMissing("announcements.show-title", true);
|
||||
setIfMissing("announcements.title-header", "&#FFD700ОБЪЯВЛЕНИЕ");
|
||||
setIfMissing("announcements.show-actionbar", true);
|
||||
setIfMissing("announcements.title-duration", 3);
|
||||
setIfMissing("chat.pm.enabled", true);
|
||||
setIfMissing("mentions.enabled", true);
|
||||
setIfMissing("mentions.sound", true);
|
||||
setIfMissing("mentions.sound-type", "BLOCK_NOTE_BLOCK_PLING");
|
||||
setIfMissing("mentions.highlight", "&#FFFF00@{player}");
|
||||
setIfMissing("mentions.self-highlight", "&#FFD700{player}");
|
||||
setIfMissing("automessages.enabled", true);
|
||||
setIfMissing("automessages.interval", 300);
|
||||
setIfMissing("automessages.random", false);
|
||||
setIfMissing("clearchat.message.enabled", true);
|
||||
setIfMissing("clearchat.message.text", "CADFЧат очищен администратором {player}");
|
||||
setIfMissing("lopreff.enabled", true);
|
||||
setIfMissing("lopreff.use-gradient-name", true);
|
||||
setIfMissing("lopreff.use-custom-prefix", true);
|
||||
setIfMissing("moderation.voice-mute-console-command", "");
|
||||
}
|
||||
|
||||
if (!config.contains("chat.pm.enabled")) {
|
||||
config.set("chat.pm.enabled", true);
|
||||
}
|
||||
|
||||
if (!config.contains("mentions.enabled")) {
|
||||
config.set("mentions.enabled", true);
|
||||
config.set("mentions.sound", true);
|
||||
config.set("mentions.sound-type", "BLOCK_NOTE_BLOCK_PLING");
|
||||
config.set("mentions.highlight", "&#FFFF00@{player}");
|
||||
config.set("mentions.self-highlight", "&#FFD700{player}");
|
||||
}
|
||||
|
||||
if (!config.contains("automessages.enabled")) {
|
||||
config.set("automessages.enabled", true);
|
||||
config.set("automessages.interval", 300);
|
||||
config.set("automessages.random", false);
|
||||
}
|
||||
|
||||
if (!config.contains("clearchat.message.enabled")) {
|
||||
config.set("clearchat.message.enabled", true);
|
||||
config.set("clearchat.message.text", "CADFЧат очищен администратором {player}");
|
||||
}
|
||||
|
||||
if (!config.contains("lopreff.enabled")) {
|
||||
config.set("lopreff.enabled", true);
|
||||
config.set("lopreff.use-gradient-name", true);
|
||||
config.set("lopreff.use-custom-prefix", true);
|
||||
}
|
||||
|
||||
if (!config.contains("moderation.voice-mute-console-command")) {
|
||||
config.set("moderation.voice-mute-console-command", "");
|
||||
private void setIfMissing(String path, Object value) {
|
||||
if (!config.contains(path)) {
|
||||
config.set(path, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Перезагрузить все конфигурации
|
||||
* ✅ THREAD-SAFE: использует volatile для безопасного обновления
|
||||
*/
|
||||
public synchronized void reload() {
|
||||
plugin.reloadConfig();
|
||||
this.config = plugin.getConfig();
|
||||
|
||||
// Перезагружаем новые конфигурации
|
||||
// volatile гарантирует что изменения видны всем потокам
|
||||
this.appearanceConfig.reload();
|
||||
this.messagesConfig.reload();
|
||||
this.muteConfig.reload();
|
||||
|
|
@ -147,6 +114,8 @@ public class ConfigManager {
|
|||
plugin.getLogger().info("Все конфигурации успешно перезагружены");
|
||||
}
|
||||
|
||||
// ========== Базовые методы доступа ==========
|
||||
|
||||
public String getString(String path, String defaultValue) {
|
||||
return config.getString(path, defaultValue);
|
||||
}
|
||||
|
|
@ -167,7 +136,8 @@ public class ConfigManager {
|
|||
return config.getStringList(path);
|
||||
}
|
||||
|
||||
// Global chat
|
||||
// ========== Настройки чата ==========
|
||||
|
||||
public boolean isGlobalEnabled() {
|
||||
return config.getBoolean("chat.global.enabled", true);
|
||||
}
|
||||
|
|
@ -176,7 +146,6 @@ public class ConfigManager {
|
|||
return config.getInt("chat.global.cooldown", 3);
|
||||
}
|
||||
|
||||
// Local chat
|
||||
public boolean isLocalEnabled() {
|
||||
return config.getBoolean("chat.local.enabled", true);
|
||||
}
|
||||
|
|
@ -189,7 +158,8 @@ public class ConfigManager {
|
|||
return config.getInt("chat.local.cooldown", 1);
|
||||
}
|
||||
|
||||
// PM
|
||||
// ========== PM ==========
|
||||
|
||||
public boolean isPmEnabled() {
|
||||
return config.getBoolean("chat.pm.enabled", true);
|
||||
}
|
||||
|
|
@ -199,28 +169,29 @@ public class ConfigManager {
|
|||
}
|
||||
|
||||
public boolean isPmSoundEnabled() {
|
||||
// ✅ Используем SoundsConfig если доступен
|
||||
return soundsConfig != null ? soundsConfig.isPmSoundEnabled() : config.getBoolean("chat.pm.sound", true);
|
||||
return soundsConfig != null ? soundsConfig.isPmSoundEnabled() :
|
||||
config.getBoolean("chat.pm.sound", true);
|
||||
}
|
||||
|
||||
public String getPmSoundType() {
|
||||
// ✅ Используем SoundsConfig если доступен
|
||||
return soundsConfig != null ? soundsConfig.getPmSound() : config.getString("chat.pm.sound-type", "ENTITY_EXPERIENCE_ORB_PICKUP");
|
||||
return soundsConfig != null ? soundsConfig.getPmSound() :
|
||||
config.getString("chat.pm.sound-type", "ENTITY_EXPERIENCE_ORB_PICKUP");
|
||||
}
|
||||
|
||||
// Mentions
|
||||
// ========== Mentions ==========
|
||||
|
||||
public boolean isMentionsEnabled() {
|
||||
return config.getBoolean("mentions.enabled", true);
|
||||
}
|
||||
|
||||
public boolean isMentionSoundEnabled() {
|
||||
// ✅ Используем SoundsConfig если доступен
|
||||
return soundsConfig != null ? soundsConfig.isMentionSoundEnabled() : config.getBoolean("mentions.sound", true);
|
||||
return soundsConfig != null ? soundsConfig.isMentionSoundEnabled() :
|
||||
config.getBoolean("mentions.sound", true);
|
||||
}
|
||||
|
||||
public String getMentionSoundType() {
|
||||
// ✅ Используем SoundsConfig если доступен
|
||||
return soundsConfig != null ? soundsConfig.getMentionSound() : config.getString("mentions.sound-type", "BLOCK_NOTE_BLOCK_PLING");
|
||||
return soundsConfig != null ? soundsConfig.getMentionSound() :
|
||||
config.getString("mentions.sound-type", "BLOCK_NOTE_BLOCK_PLING");
|
||||
}
|
||||
|
||||
public String getMentionHighlight() {
|
||||
|
|
@ -231,7 +202,8 @@ public class ConfigManager {
|
|||
return ChatFormatter.convertAllColors(config.getString("mentions.self-highlight", "&#FFD700{player}"));
|
||||
}
|
||||
|
||||
// Clear chat
|
||||
// ========== Clear chat ==========
|
||||
|
||||
public boolean isClearChatMessageEnabled() {
|
||||
return config.getBoolean("clearchat.message.enabled", true);
|
||||
}
|
||||
|
|
@ -250,7 +222,8 @@ public class ConfigManager {
|
|||
plugin.saveConfig();
|
||||
}
|
||||
|
||||
// Auto messages
|
||||
// ========== Auto messages ==========
|
||||
|
||||
public boolean isAutoMessagesEnabled() {
|
||||
return config.getBoolean("automessages.enabled", true);
|
||||
}
|
||||
|
|
@ -263,18 +236,22 @@ public class ConfigManager {
|
|||
return config.getBoolean("automessages.random", false);
|
||||
}
|
||||
|
||||
// Formats
|
||||
// ========== Formats ==========
|
||||
|
||||
public String getAnnouncementFormat() {
|
||||
return ChatFormatter.convertAllColors(config.getString("formats.announcement", "&#FFD700[ОБЪЯВЛЕНИЕ] <message>"));
|
||||
return ChatFormatter.convertAllColors(config.getString("formats.announcement",
|
||||
"&#FFD700[ОБЪЯВЛЕНИЕ] <message>"));
|
||||
}
|
||||
|
||||
// Announcements
|
||||
// ========== Announcements ==========
|
||||
|
||||
public boolean isAnnouncementTitleEnabled() {
|
||||
return config.getBoolean("announcements.show-title", true);
|
||||
}
|
||||
|
||||
public String getAnnouncementTitleHeader() {
|
||||
return ChatFormatter.convertAllColors(config.getString("announcements.title-header", "&#FFD700ОБЪЯВЛЕНИЕ"));
|
||||
return ChatFormatter.convertAllColors(config.getString("announcements.title-header",
|
||||
"&#FFD700ОБЪЯВЛЕНИЕ"));
|
||||
}
|
||||
|
||||
public boolean isAnnouncementActionBarEnabled() {
|
||||
|
|
@ -285,7 +262,8 @@ public class ConfigManager {
|
|||
return config.getInt("announcements.title-duration", 3);
|
||||
}
|
||||
|
||||
// LoPreff integration
|
||||
// ========== LoPreff integration ==========
|
||||
|
||||
public boolean isLopreffEnabled() {
|
||||
return config.getBoolean("lopreff.enabled", true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue