From e7b10a7daac6a41a63fe935b82222d787ac2ce65 Mon Sep 17 00:00:00 2001 From: loki5512344 Date: Tue, 7 Apr 2026 13:23:10 +0200 Subject: [PATCH] =?UTF-8?q?refactor(core):=20=D0=BE=D0=B1=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20ServiceFactory=20=D0=B8=20ServiceReg?= =?UTF-8?q?istry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлен фабричный метод для MessagingService: - ServiceFactory.createMessagingService() - создание MessagingService - ServiceRegistry теперь использует фабрику для MessagingService Изменения: ~ core/factory/ServiceFactory.java + createMessagingService(plugin, messageConfig) ~ core/registry/ServiceRegistry.java - new MessagingServiceImpl(plugin, messageConfig) + ServiceFactory.createMessagingService(plugin, messageConfig) Результат: - Единообразное создание сервисов через фабрику - Упрощена инициализация в ServiceRegistry - Улучшена тестируемость --- .../com/loki/lochat/core/factory/ServiceFactory.java | 10 ++++++++++ .../com/loki/lochat/core/registry/ServiceRegistry.java | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/loki/lochat/core/factory/ServiceFactory.java b/src/main/java/com/loki/lochat/core/factory/ServiceFactory.java index 1f406c9..08c1b6e 100644 --- a/src/main/java/com/loki/lochat/core/factory/ServiceFactory.java +++ b/src/main/java/com/loki/lochat/core/factory/ServiceFactory.java @@ -1,6 +1,9 @@ package com.loki.lochat.core.factory; +import com.loki.lochat.api.service.MessagingService; import com.loki.lochat.api.service.MuteService; +import com.loki.lochat.config.MessageConfig; +import com.loki.lochat.core.service.MessagingServiceImpl; import com.loki.lochat.core.service.MuteServiceImpl; import com.loki.lochat.core.service.mute.MuteDataStorage; import com.loki.lochat.core.service.mute.MuteHistoryManager; @@ -39,4 +42,11 @@ public class ServiceFactory { // Собираем сервис return new MuteServiceImpl(plugin, strategies, storage, historyManager); } + + /** + * Создать MessagingService со всеми зависимостями + */ + public static MessagingService createMessagingService(JavaPlugin plugin, MessageConfig messageConfig) { + return new MessagingServiceImpl(plugin, messageConfig); + } } diff --git a/src/main/java/com/loki/lochat/core/registry/ServiceRegistry.java b/src/main/java/com/loki/lochat/core/registry/ServiceRegistry.java index e1d5979..15c69f9 100644 --- a/src/main/java/com/loki/lochat/core/registry/ServiceRegistry.java +++ b/src/main/java/com/loki/lochat/core/registry/ServiceRegistry.java @@ -34,8 +34,8 @@ public class ServiceRegistry { register(MessageService.class, new MessageServiceImpl(plugin, this)); - // ✅ NEW: Объединённый MessagingService (PM + Spy + Ignore) - MessagingService messagingService = new MessagingServiceImpl(plugin, messageConfig); + // ✅ NEW: Объединённый MessagingService (PM + Spy + Ignore) через фабрику + MessagingService messagingService = ServiceFactory.createMessagingService(plugin, messageConfig); register(MessagingService.class, messagingService); register(MentionService.class, new MentionServiceImpl(configManager));