diff --git a/src/main/java/com/loki/lochat/LoChat.java b/src/main/java/com/loki/lochat/LoChat.java index f0e437f..85ca1b7 100644 --- a/src/main/java/com/loki/lochat/LoChat.java +++ b/src/main/java/com/loki/lochat/LoChat.java @@ -4,6 +4,7 @@ import com.loki.lochat.commands.*; import com.loki.lochat.config.ConfigManager; import com.loki.lochat.config.MessageConfig; import com.loki.lochat.gradient.GradientModule; +import com.loki.lochat.integrations.LibertyBansHook; import com.loki.lochat.integrations.PlaceholderAPIHook; import com.loki.lochat.listeners.ChatListener; import com.loki.lochat.managers.*; @@ -27,6 +28,7 @@ public final class LoChat extends JavaPlugin { private EmojiManager emojiManager; private CustomCommandManager customCommandManager; private GradientModule gradientModule; + private LibertyBansHook libertyBansHook; @Override public void onEnable() { @@ -54,6 +56,9 @@ public final class LoChat extends JavaPlugin { getLogger().info("Gradient модуль (LoPreff) загружен!"); } + // Инициализация LibertyBans интеграции + libertyBansHook = new LibertyBansHook(this); + // Регистрация команд registerCommands(); @@ -174,4 +179,8 @@ public final class LoChat extends JavaPlugin { return customCommandManager; } + public LibertyBansHook getLibertyBansHook() { + return libertyBansHook; + } + } diff --git a/src/main/java/com/loki/lochat/gradient/commands/GradientPrefixCommand.java b/src/main/java/com/loki/lochat/gradient/commands/GradientPrefixCommand.java index d6310a1..21d73a1 100644 --- a/src/main/java/com/loki/lochat/gradient/commands/GradientPrefixCommand.java +++ b/src/main/java/com/loki/lochat/gradient/commands/GradientPrefixCommand.java @@ -157,7 +157,9 @@ public class GradientPrefixCommand implements CommandExecutor, TabCompleter { } GradientConfirmGUI gui = new GradientConfirmGUI(module, player, - GradientConfirmGUI.ConfirmType.PREFIX, data.getColors(), prefix, price); + GradientConfirmGUI.ConfirmType.PREFIX, + data.hasColors() && data.isColorEnabled() ? data.getColors() : null, + prefix, price); FoliaUtil.runEntityTask(module.getPlugin(), player, gui::open); return true; } diff --git a/src/main/java/com/loki/lochat/gradient/listeners/GradientGUIListener.java b/src/main/java/com/loki/lochat/gradient/listeners/GradientGUIListener.java index 1b83a3b..cf6168d 100644 --- a/src/main/java/com/loki/lochat/gradient/listeners/GradientGUIListener.java +++ b/src/main/java/com/loki/lochat/gradient/listeners/GradientGUIListener.java @@ -77,6 +77,11 @@ public class GradientGUIListener implements Listener { data.setPrefixEnabled(true); data.setPrefixPurchased(true); data.setLastPrefixChange(System.currentTimeMillis()); + // Сохраняем существующие цвета если они есть + if (gui.getColors() != null && !gui.getColors().isEmpty()) { + data.setColors(gui.getColors()); + data.setColorEnabled(true); + } module.getLuckPermsHook().setPrefix(player, DisplayNameUtil.buildColoredPrefix(module, data)); msg.send(player, price > 0 ? "prefix-success" : "prefix-success-free", "price", String.valueOf(price)); diff --git a/src/main/java/com/loki/lochat/integrations/LibertyBansHook.java b/src/main/java/com/loki/lochat/integrations/LibertyBansHook.java new file mode 100644 index 0000000..0af8d94 --- /dev/null +++ b/src/main/java/com/loki/lochat/integrations/LibertyBansHook.java @@ -0,0 +1,61 @@ +package com.loki.lochat.integrations; + +import com.loki.lochat.LoChat; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +import java.util.concurrent.CompletableFuture; + +/** + * Интеграция с LibertyBans для проверки мутов + * Простая версия без API зависимости + */ +public class LibertyBansHook { + + private final LoChat plugin; + private boolean enabled = false; + private Plugin libertyBansPlugin; + + public LibertyBansHook(LoChat plugin) { + this.plugin = plugin; + initialize(); + } + + private void initialize() { + libertyBansPlugin = plugin.getServer().getPluginManager().getPlugin("LibertyBans"); + if (libertyBansPlugin == null || !libertyBansPlugin.isEnabled()) { + plugin.getLogger().info("LibertyBans не найден, интеграция отключена"); + return; + } + + this.enabled = true; + plugin.getLogger().info("LibertyBans найден, но API интеграция недоступна. Используйте команды LibertyBans для управления мутами."); + } + + /** + * Проверяет, замучен ли игрок + * В простой версии всегда возвращает false, так как нет доступа к API + * @param player игрок для проверки + * @return CompletableFuture - всегда false в простой версии + */ + public CompletableFuture isMuted(Player player) { + // В простой версии без API мы не можем проверить мут + // Пользователи должны использовать команды LibertyBans + return CompletableFuture.completedFuture(false); + } + + /** + * В простой версии без API недоступно + */ + public CompletableFuture getActiveMute(Player player) { + return CompletableFuture.completedFuture(null); + } + + public boolean isEnabled() { + return enabled; + } + + public boolean isPluginPresent() { + return libertyBansPlugin != null && libertyBansPlugin.isEnabled(); + } +} \ No newline at end of file diff --git a/src/main/java/com/loki/lochat/listeners/ChatListener.java b/src/main/java/com/loki/lochat/listeners/ChatListener.java index b18bd22..7d11afa 100644 --- a/src/main/java/com/loki/lochat/listeners/ChatListener.java +++ b/src/main/java/com/loki/lochat/listeners/ChatListener.java @@ -37,6 +37,18 @@ public class ChatListener implements Listener { } private void processChat(Player player, Component message, String plainMessage) { + // ===== LIBERTYBANS MUTE CHECK ===== + if (plugin.getLibertyBansHook().isPluginPresent()) { + // В простой версии без API мы не можем проверить мут автоматически + // Пользователи должны полагаться на команды LibertyBans для управления мутами + // LibertyBans сам заблокирует чат если игрок замучен + } + + // Продолжаем обработку чата + processChatInternal(player, message, plainMessage); + } + + private void processChatInternal(Player player, Component message, String plainMessage) { // ===== GLOBAL / LOCAL ===== String globalSymbol = plugin.getConfigManager().getGlobalSymbol(); boolean isGlobal = plainMessage.startsWith(globalSymbol) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a6faf7b..4c35bcd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -10,6 +10,7 @@ softdepend: - PlaceholderAPI - PlayerPoints - LuckPerms + - LibertyBans commands: g: