From 7cb1ed6f75802d12624417b3aed33af55c39ed1c Mon Sep 17 00:00:00 2001 From: "Ansgar [Hiajen]" Date: Sun, 23 May 2021 14:44:16 +0200 Subject: [PATCH] rework stuff --- src/main/java/net/saltymc/eaa/EaaMod.java | 1 + src/main/java/net/saltymc/eaa/handler/CommandHandler.java | 3 ++- .../java/net/saltymc/eaa/handler/commands/Command.java | 8 ++++++++ src/main/java/net/saltymc/eaa/mixin/ExampleMixin.java | 1 - 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/saltymc/eaa/EaaMod.java b/src/main/java/net/saltymc/eaa/EaaMod.java index 722d304..a956c01 100644 --- a/src/main/java/net/saltymc/eaa/EaaMod.java +++ b/src/main/java/net/saltymc/eaa/EaaMod.java @@ -14,6 +14,7 @@ public class EaaMod implements ModInitializer { private final List handler; public EaaMod(){ + instance = this; handler = new ArrayList<>(); } diff --git a/src/main/java/net/saltymc/eaa/handler/CommandHandler.java b/src/main/java/net/saltymc/eaa/handler/CommandHandler.java index 89feb82..de41017 100644 --- a/src/main/java/net/saltymc/eaa/handler/CommandHandler.java +++ b/src/main/java/net/saltymc/eaa/handler/CommandHandler.java @@ -57,7 +57,8 @@ public class CommandHandler implements HandlerInterface { LOGGER.debug("Valid Prefix received"); for (Command command : commands){ - if (command.run(commandSource, args)) { // Try execute command + if (command.acceptInput()) { // Try execute command + command.run(commandSource, args); LOGGER.debug("Executed following command: " + message); return command.intercept(); // if executed return interception flag } diff --git a/src/main/java/net/saltymc/eaa/handler/commands/Command.java b/src/main/java/net/saltymc/eaa/handler/commands/Command.java index 050d01e..f4aa26d 100644 --- a/src/main/java/net/saltymc/eaa/handler/commands/Command.java +++ b/src/main/java/net/saltymc/eaa/handler/commands/Command.java @@ -2,10 +2,18 @@ package net.saltymc.eaa.handler.commands; import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; +import java.util.Set; + public interface Command { boolean run(final FabricClientCommandSource cs, String[] args); + String getCommand(); + + Set getAlias(); + + boolean acceptInput(); + /** * should message get intercepted and not send to Server? */ diff --git a/src/main/java/net/saltymc/eaa/mixin/ExampleMixin.java b/src/main/java/net/saltymc/eaa/mixin/ExampleMixin.java index 3236563..869803c 100644 --- a/src/main/java/net/saltymc/eaa/mixin/ExampleMixin.java +++ b/src/main/java/net/saltymc/eaa/mixin/ExampleMixin.java @@ -2,7 +2,6 @@ package net.saltymc.eaa.mixin; import net.minecraft.client.network.ClientPlayerEntity; import net.saltymc.eaa.EaaMod; -import net.saltymc.eaa.handler.CommandHandler; import net.saltymc.eaa.util.ResponseEntity; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;