diff --git a/bin/main/com/loki/lochat/LoChat.class b/bin/main/com/loki/lochat/LoChat.class index 0ea5456..424ce20 100644 Binary files a/bin/main/com/loki/lochat/LoChat.class and b/bin/main/com/loki/lochat/LoChat.class differ diff --git a/bin/main/com/loki/lochat/core/PluginInitializer.class b/bin/main/com/loki/lochat/core/PluginInitializer.class index 3c2bd2c..a9d3ec1 100644 Binary files a/bin/main/com/loki/lochat/core/PluginInitializer.class and b/bin/main/com/loki/lochat/core/PluginInitializer.class differ diff --git a/bin/main/com/loki/lochat/core/registry/ServiceRegistry.class b/bin/main/com/loki/lochat/core/registry/ServiceRegistry.class index 9998c3e..dc6ec99 100644 Binary files a/bin/main/com/loki/lochat/core/registry/ServiceRegistry.class and b/bin/main/com/loki/lochat/core/registry/ServiceRegistry.class differ diff --git a/bin/main/com/loki/lochat/listener/ChatEventListener.class b/bin/main/com/loki/lochat/listener/ChatEventListener.class index 1ccea7d..58a6906 100644 Binary files a/bin/main/com/loki/lochat/listener/ChatEventListener.class and b/bin/main/com/loki/lochat/listener/ChatEventListener.class differ diff --git a/bin/main/com/loki/lochat/listener/ModerationListener.class b/bin/main/com/loki/lochat/listener/ModerationListener.class index 40517d6..bd02c19 100644 Binary files a/bin/main/com/loki/lochat/listener/ModerationListener.class and b/bin/main/com/loki/lochat/listener/ModerationListener.class differ diff --git a/bin/main/com/loki/lochat/listener/PlayerEventListener.class b/bin/main/com/loki/lochat/listener/PlayerEventListener.class index 68f8238..8050db1 100644 Binary files a/bin/main/com/loki/lochat/listener/PlayerEventListener.class and b/bin/main/com/loki/lochat/listener/PlayerEventListener.class differ diff --git a/src/main/java/com/loki/lochat/LoChat.java b/src/main/java/com/loki/lochat/LoChat.java index b1687e5..d8bc22f 100644 --- a/src/main/java/com/loki/lochat/LoChat.java +++ b/src/main/java/com/loki/lochat/LoChat.java @@ -1,5 +1,9 @@ package com.loki.lochat; +import com.loki.lochat.api.service.MessageService; +import com.loki.lochat.api.service.MessagingService; +import com.loki.lochat.api.service.NickService; +import com.loki.lochat.api.service.PlayerService; import com.loki.lochat.api.service.PunishmentService; import com.loki.lochat.commands.CommandManager; import com.loki.lochat.config.ConfigManager; @@ -65,7 +69,12 @@ public final class LoChat extends JavaPlugin { // Команды и слушатели commandManager = new CommandManager(this); commandManager.registerCommands(); - initializer.registerListeners(serviceRegistry, discordIntegration); + initializer.registerListeners(serviceRegistry, discordIntegration, + serviceRegistry.get(MessageService.class), + serviceRegistry.get(PlayerService.class), + serviceRegistry.get(MessagingService.class), + serviceRegistry.get(NickService.class), + serviceRegistry.get(PunishmentService.class)); initializer.registerPluginChannels(); // Автосообщения diff --git a/src/main/java/com/loki/lochat/core/PluginInitializer.java b/src/main/java/com/loki/lochat/core/PluginInitializer.java index 7e77964..24ab0d8 100644 --- a/src/main/java/com/loki/lochat/core/PluginInitializer.java +++ b/src/main/java/com/loki/lochat/core/PluginInitializer.java @@ -1,6 +1,11 @@ package com.loki.lochat.core; import com.loki.lochat.LoChat; +import com.loki.lochat.api.service.MessageService; +import com.loki.lochat.api.service.MessagingService; +import com.loki.lochat.api.service.NickService; +import com.loki.lochat.api.service.PlayerService; +import com.loki.lochat.api.service.PunishmentService; import com.loki.lochat.config.ConfigManager; import com.loki.lochat.config.MessageConfig; import com.loki.lochat.core.filter.AdvancedMessageFilter; @@ -96,18 +101,20 @@ public class PluginInitializer { /** * Зарегистрировать слушатели событий */ - public AdvancedMessageFilter registerListeners(ServiceRegistry serviceRegistry, DiscordIntegration discordIntegration) { - // Создаём один экземпляр фильтра и передаём в оба листенера + public AdvancedMessageFilter registerListeners(ServiceRegistry serviceRegistry, DiscordIntegration discordIntegration, + MessageService messageService, PlayerService playerService, + MessagingService messagingService, NickService nickService, + PunishmentService punishmentService) { AdvancedMessageFilter filter = new AdvancedMessageFilter(plugin.getConfig(), plugin); - + plugin.getServer().getPluginManager().registerEvents( - new ChatEventListener(plugin, serviceRegistry, filter), plugin + new ChatEventListener(plugin, messageService, playerService, filter), plugin ); plugin.getServer().getPluginManager().registerEvents( - new PlayerEventListener(plugin, serviceRegistry, filter), plugin + new PlayerEventListener(plugin, playerService, messagingService, nickService, filter), plugin ); plugin.getServer().getPluginManager().registerEvents( - new ModerationListener(serviceRegistry), plugin + new ModerationListener(punishmentService), plugin ); // Discord listener 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 6cd5fc7..d0cb829 100644 --- a/src/main/java/com/loki/lochat/core/registry/ServiceRegistry.java +++ b/src/main/java/com/loki/lochat/core/registry/ServiceRegistry.java @@ -41,16 +41,15 @@ public class ServiceRegistry { } private void registerServicesWithDeps(ConfigManager configManager, MessageConfig messageConfig) { - register(ChatService.class, new ChatServiceImpl(plugin, this)); - register(MuteService.class, ServiceFactory.createMuteService(plugin)); + MuteService muteService = ServiceFactory.createMuteService(plugin); + register(MuteService.class, muteService); - // ✅ NEW: Объединённый PlayerService (Cooldown + PlayerData) PlayerService playerService = new PlayerServiceImpl(plugin); register(PlayerService.class, playerService); - register(MessageService.class, new MessageServiceImpl(plugin, this)); + register(ChatService.class, new ChatServiceImpl(plugin)); + register(MessageService.class, new MessageServiceImpl(plugin, muteService, playerService)); - // ✅ NEW: Объединённый MessagingService (PM + Spy + Ignore) через фабрику PrivateMessageServiceImpl pmService = new PrivateMessageServiceImpl((LoChat) plugin); MessagingService messagingService = ServiceFactory.createMessagingService(plugin, messageConfig, pmService); pmService.init(messagingService); diff --git a/src/main/java/com/loki/lochat/core/service/ChatServiceImpl.java b/src/main/java/com/loki/lochat/core/service/ChatServiceImpl.java index 1cf050a..42ebbd0 100644 --- a/src/main/java/com/loki/lochat/core/service/ChatServiceImpl.java +++ b/src/main/java/com/loki/lochat/core/service/ChatServiceImpl.java @@ -1,7 +1,6 @@ package com.loki.lochat.core.service; import com.loki.lochat.api.service.ChatService; -import com.loki.lochat.core.registry.ServiceRegistry; import com.loki.lochat.renderer.EnhancedChatRenderer; import com.loki.lochat.utils.format.ChatFormatter; import com.loki.lochat.utils.persistence.FilePersistence; @@ -29,7 +28,7 @@ public class ChatServiceImpl implements ChatService { private final JavaPlugin plugin; private final Set globalChatDisabled = ConcurrentHashMap.newKeySet(); - public ChatServiceImpl(JavaPlugin plugin, ServiceRegistry registry) { + public ChatServiceImpl(JavaPlugin plugin) { this.plugin = plugin; loadDisabled(); } diff --git a/src/main/java/com/loki/lochat/core/service/MessageServiceImpl.java b/src/main/java/com/loki/lochat/core/service/MessageServiceImpl.java index 98b06d6..bac7afa 100644 --- a/src/main/java/com/loki/lochat/core/service/MessageServiceImpl.java +++ b/src/main/java/com/loki/lochat/core/service/MessageServiceImpl.java @@ -6,7 +6,6 @@ import com.loki.lochat.api.service.MuteService; import com.loki.lochat.api.service.PlayerService; import com.loki.lochat.core.filter.CooldownFilter; import com.loki.lochat.core.filter.MuteFilter; -import com.loki.lochat.core.registry.ServiceRegistry; import com.loki.lochat.data.model.ChatMessage; import org.bukkit.entity.Player; @@ -21,13 +20,10 @@ import java.util.List; public class MessageServiceImpl implements MessageService { private final List filters; - public MessageServiceImpl(JavaPlugin plugin, ServiceRegistry registry) { + public MessageServiceImpl(JavaPlugin plugin, MuteService muteService, PlayerService playerService) { this.filters = new ArrayList<>(); - - // Регистрируем фильтры в порядке применения - // MuteFilter теперь получает plugin для доступа к HardcodedMessages - filters.add(new MuteFilter(registry.get(MuteService.class), plugin)); - filters.add(new CooldownFilter(registry.get(PlayerService.class), plugin)); + filters.add(new MuteFilter(muteService, plugin)); + filters.add(new CooldownFilter(playerService, plugin)); } @Override diff --git a/src/main/java/com/loki/lochat/listener/ChatEventListener.java b/src/main/java/com/loki/lochat/listener/ChatEventListener.java index 6c0834c..23e4483 100644 --- a/src/main/java/com/loki/lochat/listener/ChatEventListener.java +++ b/src/main/java/com/loki/lochat/listener/ChatEventListener.java @@ -2,9 +2,9 @@ package com.loki.lochat.listener; import com.loki.lochat.LoChat; import com.loki.lochat.api.service.MessageService; +import com.loki.lochat.api.service.PlayerService; import com.loki.lochat.core.filter.AdvancedMessageFilter; import com.loki.lochat.core.filter.FilterResult; -import com.loki.lochat.core.registry.ServiceRegistry; import com.loki.lochat.renderer.EnhancedChatRenderer; import com.loki.lochat.utils.format.ChatFormatter; @@ -22,11 +22,14 @@ import io.papermc.paper.event.player.AsyncChatEvent; public class ChatEventListener implements Listener { private final JavaPlugin plugin; private final MessageService messageService; + private final PlayerService playerService; private final AdvancedMessageFilter advancedFilter; - public ChatEventListener(JavaPlugin plugin, ServiceRegistry registry, com.loki.lochat.core.filter.AdvancedMessageFilter filter) { + public ChatEventListener(JavaPlugin plugin, MessageService messageService, PlayerService playerService, + AdvancedMessageFilter filter) { this.plugin = plugin; - this.messageService = registry.get(MessageService.class); + this.messageService = messageService; + this.playerService = playerService; this.advancedFilter = filter; } @@ -148,8 +151,6 @@ public class ChatEventListener implements Listener { } private void recordStatistics(LoChat loChat, Player sender, boolean isGlobal) { - com.loki.lochat.api.service.PlayerService playerService = - loChat.getServiceRegistry().get(com.loki.lochat.api.service.PlayerService.class); playerService.recordMessage(sender.getUniqueId(), isGlobal ? "global" : "local"); } diff --git a/src/main/java/com/loki/lochat/listener/ModerationListener.java b/src/main/java/com/loki/lochat/listener/ModerationListener.java index 639385d..9bd513b 100644 --- a/src/main/java/com/loki/lochat/listener/ModerationListener.java +++ b/src/main/java/com/loki/lochat/listener/ModerationListener.java @@ -1,7 +1,6 @@ package com.loki.lochat.listener; import com.loki.lochat.api.service.PunishmentService; -import com.loki.lochat.core.registry.ServiceRegistry; import com.loki.lochat.data.model.BanRecord; import org.bukkit.event.EventHandler; @@ -16,8 +15,8 @@ public class ModerationListener implements Listener { private final PunishmentService punishmentService; - public ModerationListener(ServiceRegistry registry) { - this.punishmentService = registry.get(PunishmentService.class); + public ModerationListener(PunishmentService punishmentService) { + this.punishmentService = punishmentService; } @EventHandler(priority = EventPriority.LOWEST) diff --git a/src/main/java/com/loki/lochat/listener/PlayerEventListener.java b/src/main/java/com/loki/lochat/listener/PlayerEventListener.java index 9fb6d24..8e96066 100644 --- a/src/main/java/com/loki/lochat/listener/PlayerEventListener.java +++ b/src/main/java/com/loki/lochat/listener/PlayerEventListener.java @@ -6,7 +6,6 @@ import com.loki.lochat.api.service.NickService; import com.loki.lochat.api.service.PlayerService; import com.loki.lochat.config.ConfigManager; import com.loki.lochat.core.filter.AdvancedMessageFilter; -import com.loki.lochat.core.registry.ServiceRegistry; import com.loki.lochat.utils.format.ChatFormatter; import net.kyori.adventure.text.Component; @@ -32,11 +31,12 @@ public class PlayerEventListener implements Listener { private final AdvancedMessageFilter advancedFilter; private final ConfigManager configManager; - public PlayerEventListener(LoChat plugin, ServiceRegistry registry, AdvancedMessageFilter advancedFilter) { + public PlayerEventListener(LoChat plugin, PlayerService playerService, MessagingService messagingService, + NickService nickService, AdvancedMessageFilter advancedFilter) { this.plugin = plugin; - this.playerService = registry.get(PlayerService.class); - this.messagingService = registry.get(MessagingService.class); - this.nickService = registry.get(NickService.class); + this.playerService = playerService; + this.messagingService = messagingService; + this.nickService = nickService; this.advancedFilter = advancedFilter; this.configManager = plugin.getConfigManager(); }