From 41ae408d8c4db7bfe22fd950e3480fc55873aeca Mon Sep 17 00:00:00 2001 From: David Hermann Date: Wed, 4 Jan 2023 02:43:00 +0100 Subject: [PATCH] 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 --- src/main/java/org/bitbiome/Boot.java | 23 +++++++++++ .../bitbiome/commands/CommandListener.java | 38 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/main/java/org/bitbiome/Boot.java create mode 100644 src/main/java/org/bitbiome/commands/CommandListener.java diff --git a/src/main/java/org/bitbiome/Boot.java b/src/main/java/org/bitbiome/Boot.java new file mode 100644 index 0000000..590ef38 --- /dev/null +++ b/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; + } + +} + + + diff --git a/src/main/java/org/bitbiome/commands/CommandListener.java b/src/main/java/org/bitbiome/commands/CommandListener.java new file mode 100644 index 0000000..9ed47ee --- /dev/null +++ b/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 commands; + + public CommandListener() { + commands = new HashMap<>(); + + /* + * Commandfield + * + * commands.put("CommandName", new CommandClass()); + * + * + */ + } + + public HashMap 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; + } + + +}