Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
GIGABAIT93 committed Mar 13, 2024
1 parent ac62d7d commit c5ce187
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 21 deletions.
26 changes: 26 additions & 0 deletions src/main/java/com/vcmi/commands/HelpCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.vcmi.commands;

import com.vcmi.config.Lang;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand;
import java.util.List;

public class HelpCommand implements SimpleCommand {

@Override
public void execute(Invocation invocation) {
CommandSource source = invocation.source();
if (!hasPermission(invocation)) {
source.sendMessage(Lang.no_perms.get());
return;
}

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

}

@Override
public boolean hasPermission(Invocation invocation) {
return invocation.source().hasPermission("vcmi.help");
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/vcmi/config/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public enum Lang {
rcon_unknown_error("rcon_unknown_error"), rcon_empty_command("rcon_empty_command"), rcon_invalid_command_or_server("rcon_invalid_command_or_server"),
player_time("player_time"), player_not_found("player_not_found"), player_time_other("player_time_other"), player_time_usage("player_time_usage"),
player_time_days("player_time_days"), player_time_hours("player_time_hours"), player_time_minutes("player_time_minutes"), player_time_seconds("player_time_seconds"),
modules("modules");
modules("modules"), help("help");

private final String key;

Expand Down
58 changes: 38 additions & 20 deletions src/main/java/com/vcmi/config/data/LangYAML.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.vcmi.config.Config;
import com.vcmi.VCMI;
import com.vcmi.config.Lang;
import org.simpleyaml.configuration.file.YamlConfiguration;
import org.simpleyaml.configuration.file.YamlFile;

import java.io.File;
import java.io.IOException;

Expand Down Expand Up @@ -35,13 +37,13 @@ public static void reload() {
setConfigValue("no_command", "&cNo such command");
setConfigValue("reload", "&aAll configurations reloaded");

yamlFile.setComment("rcon_manager_reload","Rcon Manager");
yamlFile.setComment("rcon_manager_reload", "Rcon Manager");
setConfigValue("rcon_manager_reload", "&aConfigurations Rcon Manager reloaded");
setConfigValue("rcon_auth_error", "&6{server}: &cAuthentication Error. Please check your server configuration and ensure the server is available");
setConfigValue("rcon_io_error", "&6{server}: &cIO Error. Please check your server configuration and ensure the server is available");
setConfigValue( "rcon_unknown_error", "&6{server}: &cUnknown host error. Please check the server IP address configuration");
setConfigValue("rcon_unknown_error", "&6{server}: &cUnknown host error. Please check the server IP address configuration");

yamlFile.setComment("rcon_server_reload","Rcon Server");
yamlFile.setComment("rcon_server_reload", "Rcon Server");
setConfigValue("rcon_server_reload", "&aConfigurations Rcon Server reloaded");
setConfigValue("rcon_connect_notify", "&aRcon connection from: &7[&3&l{address}&7] &aCommand: &3&l{command}");
setConfigValue("rcon_usage", "&6Usage: rcon [server/all/reload] [command]");
Expand All @@ -50,35 +52,51 @@ public static void reload() {
setConfigValue("rcon_response", "&6{server}: &a{response}");
setConfigValue("rcon_response_empty", "There is no response from the server");

yamlFile.setComment("bash_usage","Bash Module");
setConfigValue( "bash_usage", "&6Usage: bash [script/reload] [info/(script args)]");
setConfigValue( "bash_runner_reload", "&aConfigurations BASH Runner reloaded");
setConfigValue( "bash_out_script", "{response}");
yamlFile.setComment("bash_usage", "Bash Module");
setConfigValue("bash_usage", "&6Usage: bash [script/reload] [info/(script args)]");
setConfigValue("bash_runner_reload", "&aConfigurations BASH Runner reloaded");
setConfigValue("bash_out_script", "{response}");

yamlFile.setComment("php_usage","Php Module");
setConfigValue( "php_usage", "&6Usage: php [script/reload] [info/(script args)]");
yamlFile.setComment("php_usage", "Php Module");
setConfigValue("php_usage", "&6Usage: php [script/reload] [info/(script args)]");
setConfigValue("php_runner_reload", "&aConfigurations PHP Runner reloaded");
setConfigValue( "php_out_script", "{response}");
setConfigValue("php_out_script", "{response}");

yamlFile.setComment("player_time_usage","PlayerTime Module");
setConfigValue( "player_time_usage", "&6Usage: vptime [Player]");
yamlFile.setComment("player_time_usage", "PlayerTime Module");
setConfigValue("player_time_usage", "&6Usage: vptime [Player]");
setConfigValue("player_time", "&aYour game time: {time}");
setConfigValue( "player_time_other", "&aGame time {player}: {time}");
setConfigValue( "player_not_found", "&c{player} not found");
setConfigValue( "player_time_days", " days ");
setConfigValue( "player_time_hours", " hours ");
setConfigValue( "player_time_minutes", " minutes ");
setConfigValue( "player_time_seconds", " seconds ");
setConfigValue("player_time_other", "&aGame time {player}: {time}");
setConfigValue("player_not_found", "&c{player} not found");
setConfigValue("player_time_days", " days ");
setConfigValue("player_time_hours", " hours ");
setConfigValue("player_time_minutes", " minutes ");
setConfigValue("player_time_seconds", " seconds ");

yamlFile.setComment("modules", "Modules");
setConfigValue("modules", "{module} is {status}");

yamlFile.setComment("help", "Help");
setConfigValue("help", "&6Available commands:"
+ "\n&6/vcmi &7- &6Show help."
+ "\n&6/vcmireload &7- &6Reload all configurations."
+ "\n&6/vcmimodules &7- &6Show all modules."
+ "\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."
+ "\n&6/php [script/reload] [args] &7- &6Executes the specified PHP script."
+ "\n&6/bash [script/reload] [args] &7- &6Executes the specified Bash script."
+ "\n&6/rules &7- &6Reads the specified text file."
+ "\n&6/readme &7- &6Reads the specified text file."
);

yamlFile.setComment("modules","Modules");
setConfigValue("modules","{module} is {status}");

yamlFile.save();

} catch (IOException e) {
e.printStackTrace();
}
}

private static void setConfigValue(String path, Object defaultValue) {
if (!yamlFile.contains(path)) {
yamlFile.set(path, defaultValue);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/vcmi/modules/Modules.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.vcmi.modules;

import com.vcmi.commands.HelpCommand;
import com.vcmi.commands.ModulesCommand;
import com.vcmi.config.Config;
import com.vcmi.Message;
Expand Down Expand Up @@ -30,6 +31,7 @@ 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...");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/vcmi/modules/text/TextReaderModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class TextReaderModule {
public static void load() {
if (dir.toFile().mkdirs()){
Util.copyFile(dir.toString(), "rules.txt");
Util.copyFile(dir.toString(), "readme.txt");
}
Message.info("Text Reader module enabled");
}
Expand Down
33 changes: 33 additions & 0 deletions src/main/resources/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[center]<gold>VCMI Plugin</gold>
[center]<gray>A Velocity Plugin for Comprehensive Server Management</gray>

<gold>Modules:</gold>

<gray>PlayerTime:</gray>
Tracks total playtime. Commands:
- <click:run_command:/vptime><hover:show_text:'<gray>Click to run</gray>'><green>/vptime</green></click> - Shows your total playtime.
- <click:copy_to_clipboard:vptime {player}><hover:show_text:'<gray>Click to copy</gray>'><green>/vptime {player}</green></click> - Shows specified player's playtime.

<gray>RconManager:</gray>
Execute RCON commands remotely.
- <click:copy_to_clipboard:/rcon><hover:show_text:'<gray>Click to copy RCON command</gray>'><green>/rcon {server/all/reload} {command}</green></click> - Command execution.
- <click:run_command:/rcon all list><hover:show_text:'<gray>Click to run example command</gray>'><green>/rcon all list</green></click> - Execute example RCON command.

<gray>PhpModule:</gray>
Extend functionality with PHP scripts.
- <click:copy_to_clipboard:/php><hover:show_text:'<gray>Click to copy PHP command</gray>'><green>/php {script/reload} {args}</green></click> - Execute PHP scripts.
- <click:run_command:/php index info><hover:show_text:'<gray>Click to run example script</gray>'><green>/php index info</green></click> - Execute example PHP script.

<gray>BashModule:</gray>
Execute Bash scripts from the console or chat.
- <click:copy_to_clipboard:/bash><hover:show_text:'<gray>Click to copy Bash command</gray>'><green>/bash {script/reload} {args}</green></click> - Run Bash scripts.
- <click:run_command:/bash run info><hover:show_text:'<gray>Click to run example script</gray>'><green>/bash run</green></click> - Execute example Bash script.

<gray>TextReader:</gray>
Read and display text files.
- <click:run_command:/rules><hover:show_text:'<gray>Click to read rules.txt file</gray>'><green>/rules</green></click> - Display rules.txt file content.

<gray>HttpRequest:</gray>
Perform HTTP requests and command execution based on responses.
- <click:run_command:/linkaccount 12345><hover:show_text:'<gray>Click to run command</gray>'><green>/linkaccount 12345</green></click> - Execute command based on response.

0 comments on commit c5ce187

Please sign in to comment.