Browse Source

Created the boot class

After creating an object from this class, the game will start by here.
Added the CommandListener
This listener will add the commands which the game has and will have
remotes/origin/locations
David Hermann 2 years ago
parent
commit
41ae408d8c
  1. 23
      src/main/java/org/bitbiome/Boot.java
  2. 38
      src/main/java/org/bitbiome/commands/CommandListener.java

23
src/main/java/org/bitbiome/Boot.java

@ -0,0 +1,23 @@
package org.bitbiome;
import org.bitbiome.commands.CommandListener;
public class Boot {
private CommandListener cmdListener;
public static Boot instance;
public Boot() {
instance = this;
cmdListener = new CommandListener();
InteractionLoop game = new InteractionLoop();
game.run();
}
public CommandListener getCmdListener(){
return cmdListener;
}
}

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

@ -0,0 +1,38 @@
package org.bitbiome.commands;
import java.util.HashMap;
import java.util.Scanner;
public class CommandListener {
private HashMap<String, CommandAPI> commands;
public CommandListener() {
commands = new HashMap<>();
/*
* Commandfield
*
* commands.put("CommandName", new CommandClass());
*
*
*/
}
public HashMap<String, CommandAPI> returnCommands() {
return commands;
}
public boolean perform(String command, Scanner scanner, boolean isRunning, String message) {
CommandAPI cmd;
if ((cmd = commands.get(command)) != null) {
cmd.performCommand(scanner, isRunning, message);
return true;
}
return false;
}
}
Loading…
Cancel
Save