diff --git a/README.md b/README.md index 2d2d5a7..146c447 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ # VCMI Plugin VCMI Velocity Plugin - This one offers a variety of modules for detailed server management and monitoring. Each module can be turned on or off as needed. The plugin is designed to be as flexible as possible, allowing you to customize your server's functionality to your specific needs. +## Commands +- `/vcmi`: Help command to display all available commands. +- `/vcmireload`: Reloads the plugin configuration file. +- `/vcmimodules`: Displays a list of all available modules. +- `/vpl -v`: Display plugin list. ## Modules ### PlayerTime: diff --git a/src/main/java/com/vcmi/commands/HelpCommand.java b/src/main/java/com/vcmi/commands/HelpCommand.java index de68144..80d273e 100644 --- a/src/main/java/com/vcmi/commands/HelpCommand.java +++ b/src/main/java/com/vcmi/commands/HelpCommand.java @@ -13,9 +13,7 @@ public void execute(Invocation invocation) { source.sendMessage(Lang.no_perms.get()); return; } - source.sendMessage(Lang.help.get()); - } @Override diff --git a/src/main/java/com/vcmi/commands/PluginsCommand.java b/src/main/java/com/vcmi/commands/PluginsCommand.java new file mode 100644 index 0000000..459a1f5 --- /dev/null +++ b/src/main/java/com/vcmi/commands/PluginsCommand.java @@ -0,0 +1,39 @@ +package com.vcmi.commands; +import com.vcmi.Message; +import com.vcmi.VCMI; +import com.vcmi.config.Lang; +import com.velocitypowered.api.command.CommandSource; +import com.velocitypowered.api.command.SimpleCommand; +import com.velocitypowered.api.plugin.PluginContainer; +import java.util.Collection; +import java.util.stream.Collectors; + +public class PluginsCommand implements SimpleCommand { + @Override + public void execute(Invocation invocation) { + CommandSource source = invocation.source(); + String[] args = invocation.arguments(); + if (!hasPermission(invocation)) { + source.sendMessage(Lang.no_perms.get()); + return; + } + Collection plugins = VCMI.server.getPluginManager().getPlugins(); + + if (args.length == 1 && args[0].equals("-v")) { + String pluginList = plugins.stream() + .map(plugin -> "&6"+plugin.getDescription().getName().orElse("Unknown") + " &7" + plugin.getDescription().getVersion().orElse("Unknown")) + .collect(Collectors.joining(", ")); + source.sendMessage(Message.convert("&aPlugins: " + pluginList)); + return; + } + String pluginList = plugins.stream() + .map(plugin -> "&6"+plugin.getDescription().getName().orElse("Unknown")) + .collect(java.util.stream.Collectors.joining(", ")); + source.sendMessage(Message.convert("&aPlugins: &6" + pluginList)); + } + + @Override + public boolean hasPermission(final Invocation invocation) { + return invocation.source().hasPermission("vcmi.plugins"); + } +} diff --git a/src/main/java/com/vcmi/config/data/LangYAML.java b/src/main/java/com/vcmi/config/data/LangYAML.java index 3b682f0..469dac0 100644 --- a/src/main/java/com/vcmi/config/data/LangYAML.java +++ b/src/main/java/com/vcmi/config/data/LangYAML.java @@ -82,6 +82,7 @@ public static void reload() { + "\n&6/vcmi &7- &6Show help." + "\n&6/vcmireload &7- &6Reload all configurations." + "\n&6/vcmimodules &7- &6Show all modules." + + "\n&6/vpl &7- &6Show all plugins." + "\n&6/vptime &7- &6Returns your total playing time." + "\n&6/vptime [player] &7- &6Returns the specified player's total playing time." + "\n&6/rcon [server/all/reload] [command] &7- &6Sends the specified command to the specified server or all servers." diff --git a/src/main/java/com/vcmi/modules/Modules.java b/src/main/java/com/vcmi/modules/Modules.java index 2d813cc..83782d2 100644 --- a/src/main/java/com/vcmi/modules/Modules.java +++ b/src/main/java/com/vcmi/modules/Modules.java @@ -2,6 +2,7 @@ import com.vcmi.commands.HelpCommand; import com.vcmi.commands.ModulesCommand; +import com.vcmi.commands.PluginsCommand; import com.vcmi.config.Config; import com.vcmi.Message; import com.vcmi.Util; @@ -14,7 +15,6 @@ import com.vcmi.modules.rcon.server.RconServerModule; import com.vcmi.modules.requests.RequestsModule; import com.vcmi.modules.text.TextReaderModule; - import java.util.Map; public class Modules { @@ -30,13 +30,11 @@ public class Modules { ); public Modules() { - Util.registerCommand("vcmireload", "vreload", new ReloadCommand()); - Util.registerCommand("vcmi", "vcmihelp", new HelpCommand()); - Util.registerCommand("vcmimodules", "vmodules", new ModulesCommand()); Message.info("..."); Message.info("VCMI loading modules..."); Config.databaseInitializer(); Config.getModules().forEach(this::loadModules); + registerCommands(); } public static void load() { @@ -51,6 +49,13 @@ private void loadModules(String module) { } } + private void registerCommands() { + Util.registerCommand("vcmireload", "vreload", new ReloadCommand()); + Util.registerCommand("vcmi", "vcmihelp", new HelpCommand()); + Util.registerCommand("vcmimodules", "vmodules", new ModulesCommand()); + Util.registerCommand("vpl", "vplugins", new PluginsCommand()); + } + private static class ModuleConfig { private final Runnable enableAction; private final Runnable disableAction; diff --git a/src/main/resources/langs/uk.yml b/src/main/resources/langs/uk.yml index 0f15cf7..62adebf 100644 --- a/src/main/resources/langs/uk.yml +++ b/src/main/resources/langs/uk.yml @@ -51,6 +51,7 @@ help: |- &6/vcmi &7- &6Показати допомогу. &6/vcmireload &7- &6Перезавантажте всі конфігурації. &6/vcmimodules &7- &6Показати всі модулі. + &6/vpl &7- &6Показати всі плагіни. &6/vptime &7- &6Повертає ваш загальний час гри. &6/vptime [player] &7- &6Повертає загальний час гри вказаного гравця. &6/rcon [server/all/reload] [command] &7- &6Надсилає вказану команду на вказаний сервер або на всі сервери.