Fix color preservation when changing prefix and add LibertyBans integration
- Fixed issue where gradient colors were lost when changing prefix - Updated GradientGUIListener to preserve existing colors when setting prefix - Updated GradientPrefixCommand to pass existing colors to confirmation GUI - Added LibertyBans integration (simple version without API dependency) - Added LibertyBans to softdepend in plugin.yml - LibertyBans integration detects plugin presence but relies on LibertyBans own mute handling
This commit is contained in:
parent
ef1a6320cb
commit
ee626c8d8b
6 changed files with 91 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import com.loki.lochat.commands.*;
|
||||||
import com.loki.lochat.config.ConfigManager;
|
import com.loki.lochat.config.ConfigManager;
|
||||||
import com.loki.lochat.config.MessageConfig;
|
import com.loki.lochat.config.MessageConfig;
|
||||||
import com.loki.lochat.gradient.GradientModule;
|
import com.loki.lochat.gradient.GradientModule;
|
||||||
|
import com.loki.lochat.integrations.LibertyBansHook;
|
||||||
import com.loki.lochat.integrations.PlaceholderAPIHook;
|
import com.loki.lochat.integrations.PlaceholderAPIHook;
|
||||||
import com.loki.lochat.listeners.ChatListener;
|
import com.loki.lochat.listeners.ChatListener;
|
||||||
import com.loki.lochat.managers.*;
|
import com.loki.lochat.managers.*;
|
||||||
|
|
@ -27,6 +28,7 @@ public final class LoChat extends JavaPlugin {
|
||||||
private EmojiManager emojiManager;
|
private EmojiManager emojiManager;
|
||||||
private CustomCommandManager customCommandManager;
|
private CustomCommandManager customCommandManager;
|
||||||
private GradientModule gradientModule;
|
private GradientModule gradientModule;
|
||||||
|
private LibertyBansHook libertyBansHook;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
@ -54,6 +56,9 @@ public final class LoChat extends JavaPlugin {
|
||||||
getLogger().info("Gradient модуль (LoPreff) загружен!");
|
getLogger().info("Gradient модуль (LoPreff) загружен!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Инициализация LibertyBans интеграции
|
||||||
|
libertyBansHook = new LibertyBansHook(this);
|
||||||
|
|
||||||
// Регистрация команд
|
// Регистрация команд
|
||||||
registerCommands();
|
registerCommands();
|
||||||
|
|
||||||
|
|
@ -174,4 +179,8 @@ public final class LoChat extends JavaPlugin {
|
||||||
return customCommandManager;
|
return customCommandManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LibertyBansHook getLibertyBansHook() {
|
||||||
|
return libertyBansHook;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,9 @@ public class GradientPrefixCommand implements CommandExecutor, TabCompleter {
|
||||||
}
|
}
|
||||||
|
|
||||||
GradientConfirmGUI gui = new GradientConfirmGUI(module, player,
|
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);
|
FoliaUtil.runEntityTask(module.getPlugin(), player, gui::open);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,11 @@ public class GradientGUIListener implements Listener {
|
||||||
data.setPrefixEnabled(true);
|
data.setPrefixEnabled(true);
|
||||||
data.setPrefixPurchased(true);
|
data.setPrefixPurchased(true);
|
||||||
data.setLastPrefixChange(System.currentTimeMillis());
|
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));
|
module.getLuckPermsHook().setPrefix(player, DisplayNameUtil.buildColoredPrefix(module, data));
|
||||||
msg.send(player, price > 0 ? "prefix-success" : "prefix-success-free",
|
msg.send(player, price > 0 ? "prefix-success" : "prefix-success-free",
|
||||||
"price", String.valueOf(price));
|
"price", String.valueOf(price));
|
||||||
|
|
|
||||||
|
|
@ -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<Boolean> - всегда false в простой версии
|
||||||
|
*/
|
||||||
|
public CompletableFuture<Boolean> isMuted(Player player) {
|
||||||
|
// В простой версии без API мы не можем проверить мут
|
||||||
|
// Пользователи должны использовать команды LibertyBans
|
||||||
|
return CompletableFuture.completedFuture(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* В простой версии без API недоступно
|
||||||
|
*/
|
||||||
|
public CompletableFuture<Object> getActiveMute(Player player) {
|
||||||
|
return CompletableFuture.completedFuture(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPluginPresent() {
|
||||||
|
return libertyBansPlugin != null && libertyBansPlugin.isEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -37,6 +37,18 @@ public class ChatListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processChat(Player player, Component message, String plainMessage) {
|
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 =====
|
// ===== GLOBAL / LOCAL =====
|
||||||
String globalSymbol = plugin.getConfigManager().getGlobalSymbol();
|
String globalSymbol = plugin.getConfigManager().getGlobalSymbol();
|
||||||
boolean isGlobal = plainMessage.startsWith(globalSymbol)
|
boolean isGlobal = plainMessage.startsWith(globalSymbol)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ softdepend:
|
||||||
- PlaceholderAPI
|
- PlaceholderAPI
|
||||||
- PlayerPoints
|
- PlayerPoints
|
||||||
- LuckPerms
|
- LuckPerms
|
||||||
|
- LibertyBans
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
g:
|
g:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue