Browse Source

Added the help command

This command prints a list of all commands which are available
remotes/origin/locations
David Hermann 2 years ago
parent
commit
0933a56a4d
  1. 8
      src/main/java/org/bitbiome/commands/CommandListener.java
  2. 22
      src/main/java/org/bitbiome/commands/HelpCommand.java

8
src/main/java/org/bitbiome/commands/CommandListener.java

@ -10,13 +10,7 @@ public class CommandListener {
public CommandListener() {
commands = new HashMap<>();
/*
* Commandfield
*
* commands.put("CommandName", new CommandClass());
*
*
*/
commands.put("help", new HelpCommand());
}
public HashMap<String, CommandAPI> returnCommands() {

22
src/main/java/org/bitbiome/commands/HelpCommand.java

@ -0,0 +1,22 @@
package org.bitbiome.commands;
import org.bitbiome.Boot;
import java.util.HashMap;
import java.util.Scanner;
public class HelpCommand implements CommandAPI {
@Override
public void performCommand(Scanner scanner, boolean isRunning, String message) {
HashMap<String, CommandAPI> commands = Boot.instance.getCmdListener().returnCommands();
StringBuilder outputMessage = new StringBuilder();
outputMessage.append("Hier ist eine Liste der Commands:\n");
commands.forEach((key, value) -> {
outputMessage.append("- ").append(key).append("\n");
});
System.out.println(outputMessage.toString());
}
}
Loading…
Cancel
Save