From 261cc7673f0ef611864ff13d14da20cd5d28164b Mon Sep 17 00:00:00 2001 From: Zontreck Date: Wed, 14 Feb 2024 04:26:30 -0700 Subject: [PATCH] Removal of event bus complete --- .../ariaslib/events/CommandEvent.java | 26 --------- .../ariaslib/terminal/ConsolePrompt.java | 12 +---- .../ariaslib/args/ArgumentsParserTest.java | 53 ------------------- 3 files changed, 1 insertion(+), 90 deletions(-) delete mode 100644 src/main/java/dev/zontreck/ariaslib/events/CommandEvent.java delete mode 100644 src/test/java/dev/zontreck/ariaslib/args/ArgumentsParserTest.java diff --git a/src/main/java/dev/zontreck/ariaslib/events/CommandEvent.java b/src/main/java/dev/zontreck/ariaslib/events/CommandEvent.java deleted file mode 100644 index 5f253fa..0000000 --- a/src/main/java/dev/zontreck/ariaslib/events/CommandEvent.java +++ /dev/null @@ -1,26 +0,0 @@ -package dev.zontreck.ariaslib.events; - -import dev.zontreck.eventsbus.Event; -import dev.zontreck.eventsbus.annotations.Cancellable; - -import java.util.ArrayList; -import java.util.List; - -@Cancellable -public class CommandEvent extends Event { - public String command; - public List arguments = new ArrayList<>(); - - public CommandEvent(String commandString) { - String[] cmds = commandString.split(" "); - if (cmds.length > 0) { - command = cmds[0]; - if (cmds.length == 1) return; - for (int i = 1; i < cmds.length; i++) { - arguments.add(cmds[i]); - } - - } else throw new IllegalArgumentException("The command cannot be empty!"); - } - -} diff --git a/src/main/java/dev/zontreck/ariaslib/terminal/ConsolePrompt.java b/src/main/java/dev/zontreck/ariaslib/terminal/ConsolePrompt.java index c278f70..9a86027 100644 --- a/src/main/java/dev/zontreck/ariaslib/terminal/ConsolePrompt.java +++ b/src/main/java/dev/zontreck/ariaslib/terminal/ConsolePrompt.java @@ -1,11 +1,8 @@ package dev.zontreck.ariaslib.terminal; -import dev.zontreck.ariaslib.events.CommandEvent; -import dev.zontreck.ariaslib.util.DelayedExecutorService; -import dev.zontreck.eventsbus.Bus; - import java.io.Console; +@Deprecated public class ConsolePrompt extends Task { public static final Console console = System.console(); @@ -17,13 +14,6 @@ public class ConsolePrompt extends Task { @Override public void run() { // Print a prompt - console.printf("\n" + Terminal.PREFIX + " > "); - String commandInput = console.readLine(); - - CommandEvent event = new CommandEvent(commandInput); - if (!Bus.Post(event)) { - DelayedExecutorService.getInstance().schedule(new ConsolePrompt(), 2); - } } diff --git a/src/test/java/dev/zontreck/ariaslib/args/ArgumentsParserTest.java b/src/test/java/dev/zontreck/ariaslib/args/ArgumentsParserTest.java deleted file mode 100644 index 3ead7e8..0000000 --- a/src/test/java/dev/zontreck/ariaslib/args/ArgumentsParserTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package dev.zontreck.ariaslib.args; - -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.ValueSource; - -import static org.junit.jupiter.api.Assertions.*; - -public class ArgumentsParserTest { - - @ParameterizedTest - @ValueSource(strings = {"--test", "--arg", "--testing2"}) - void testGetNamePart(String entry) { - String arg = ArgumentsParser.getNamePart(entry); - assertFalse(arg.startsWith("--")); - assertFalse(arg.isEmpty()); - } - - @ParameterizedTest - @CsvSource(value = {"test", "test2", "281", "true"}) - void testGetValuePart(String entry) { - assertFalse(entry.isEmpty()); - } - - @ParameterizedTest - @ValueSource(strings = {"test", "1", "922337203685477580", ""}) - void testGetArgumentType(String input) - { - ArgumentType test = ArgumentsParser.getArgumentType(input); - System.out.println("Testing: " + input + "; Type: " + test); - if(input.startsWith("t")) - { - assertTrue(test == ArgumentType.STRING); - }else if(input.startsWith("1")) - { - assertTrue(test == ArgumentType.INTEGER); - } else if(input.startsWith("9")) - { - assertTrue(test == ArgumentType.LONG); - }else assertTrue(test == ArgumentType.BOOLEAN); - } - - @ParameterizedTest - @CsvSource(value = {"--test=1", "--enable", "--set=84375488888444", "--file=test.dat"}) - void testParseArgument(String arg) - { - Argument args = ArgumentsParser.parseArgument(arg); - assertFalse(args.name.isEmpty()); - assertTrue(args.hasValue); - - } - -}