fix all
This commit is contained in:
parent
5088e3ad1c
commit
d1d2b93742
82 changed files with 4008 additions and 3032 deletions
106
src/main/java/com/loki/lochat/commands/CommandManager.java
Normal file
106
src/main/java/com/loki/lochat/commands/CommandManager.java
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
package com.loki.lochat.commands;
|
||||
|
||||
import com.loki.lochat.LoChat;
|
||||
import com.loki.lochat.commands.admin.*;
|
||||
import com.loki.lochat.commands.chat.*;
|
||||
import com.loki.lochat.commands.messaging.*;
|
||||
import com.loki.lochat.commands.moderation.*;
|
||||
import com.loki.lochat.commands.nick.*;
|
||||
import com.loki.lochat.commands.rp.*;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Централизованная регистрация всех команд плагина.
|
||||
*/
|
||||
public class CommandManager {
|
||||
|
||||
private final LoChat plugin;
|
||||
private final Map<String, com.loki.lochat.commands.base.BaseCommand> commands = new HashMap<>();
|
||||
|
||||
public CommandManager(LoChat plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void registerCommands() {
|
||||
|
||||
// ── Чат ──────────────────────────────────────────────────────────────
|
||||
reg("g", new GlobalChatCommand(plugin));
|
||||
reg("l", new LocalChatCommand(plugin));
|
||||
|
||||
// ── Личные сообщения / игнор ──────────────────────────────────────────
|
||||
reg("msg", new MsgCommand(plugin));
|
||||
reg("reply", new ReplyCommand(plugin));
|
||||
reg("ignore", new IgnoreCommand(plugin));
|
||||
reg("unignore", new UnignoreCommand(plugin));
|
||||
reg("ignorelist", new IgnoreListCommand(plugin));
|
||||
|
||||
// ── Модерация ─────────────────────────────────────────────────────────
|
||||
regTab("lmute", new MuteCommand(plugin));
|
||||
regTab("lunmute", new UnmuteCommand(plugin));
|
||||
reg("lmutelist", new MuteListCommand(plugin));
|
||||
regTab("lmutehistory", new MuteHistoryCommand(plugin));
|
||||
regTab("lmuteblame", new MuteBlameCommand(plugin));
|
||||
|
||||
// ── Ник / профиль ─────────────────────────────────────────────────────
|
||||
regTab("nick", new NickCommand(plugin));
|
||||
reg("playerinfo", new PlayerInfoCommand(plugin));
|
||||
|
||||
// ── Админ ─────────────────────────────────────────────────────────────
|
||||
reg("announce", new AnnounceCommand(plugin));
|
||||
reg("chatspy", new ChatSpyCommand(plugin));
|
||||
reg("clearchat", new ClearChatCommand(plugin));
|
||||
regTab("clearchatconfig", new ClearChatConfigCommand(plugin));
|
||||
regTab("lochat", new LoChatCommand(plugin));
|
||||
reg("lochatreload", new ReloadConfigCommand(plugin));
|
||||
regTab("discordadmin", new DiscordCommand(plugin, plugin.getDiscordIntegration()));
|
||||
|
||||
// ── RP ────────────────────────────────────────────────────────────────
|
||||
registerBaseCommand("me", new MeCommand(plugin));
|
||||
registerBaseCommand("try", new TryCommand(plugin));
|
||||
registerBaseCommand("do", new DoCommand(plugin));
|
||||
regTab("roll", new RollCommand(plugin));
|
||||
|
||||
// ── Кастомные команды ─────────────────────────────────────────────────
|
||||
regTab("customcommands", new CustomCommandsCommand(plugin, plugin.getCustomCommandManager()));
|
||||
|
||||
plugin.getLogger().info("[LoChat] Команды зарегистрированы.");
|
||||
}
|
||||
|
||||
// ── Вспомогательные методы ────────────────────────────────────────────────
|
||||
|
||||
/** Регистрирует команду только как CommandExecutor */
|
||||
private void reg(String name, org.bukkit.command.CommandExecutor executor) {
|
||||
PluginCommand cmd = plugin.getCommand(name);
|
||||
if (cmd != null) {
|
||||
cmd.setExecutor(executor);
|
||||
} else {
|
||||
plugin.getLogger().warning("[LoChat] Команда '" + name + "' не найдена в plugin.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
/** Регистрирует команду как CommandExecutor + TabCompleter */
|
||||
private void regTab(String name, Object executor) {
|
||||
PluginCommand cmd = plugin.getCommand(name);
|
||||
if (cmd != null) {
|
||||
cmd.setExecutor((org.bukkit.command.CommandExecutor) executor);
|
||||
if (executor instanceof org.bukkit.command.TabCompleter tc) cmd.setTabCompleter(tc);
|
||||
} else {
|
||||
plugin.getLogger().warning("[LoChat] Команда '" + name + "' не найдена в plugin.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
/** Регистрирует BaseCommand (executor + tab-completer из одного класса) */
|
||||
private void registerBaseCommand(String name, com.loki.lochat.commands.base.BaseCommand command) {
|
||||
PluginCommand cmd = plugin.getCommand(name);
|
||||
if (cmd != null) {
|
||||
cmd.setExecutor(command);
|
||||
cmd.setTabCompleter(command);
|
||||
commands.put(name, command);
|
||||
} else {
|
||||
plugin.getLogger().warning("[LoChat] Команда '" + name + "' не найдена в plugin.yml!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue