Skip to content

Commit

Permalink
added vpl command
Browse files Browse the repository at this point in the history
  • Loading branch information
GIGABAIT93 committed Mar 14, 2024
1 parent 0c8aba1 commit 70c5c7b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 6 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/vcmi/commands/HelpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public void execute(Invocation invocation) {
source.sendMessage(Lang.no_perms.get());
return;
}

source.sendMessage(Lang.help.get());

}

@Override
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/vcmi/commands/PluginsCommand.java
Original file line number Diff line number Diff line change
@@ -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<PluginContainer> 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");
}
}
1 change: 1 addition & 0 deletions src/main/java/com/vcmi/config/data/LangYAML.java
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
13 changes: 9 additions & 4 deletions src/main/java/com/vcmi/modules/Modules.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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() {
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/langs/uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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Надсилає вказану команду на вказаний сервер або на всі сервери.
Expand Down

0 comments on commit 70c5c7b

Please sign in to comment.