diff --git a/src/main/java/land/chipmunk/chipmunkbot/commands/EchoCommand.java b/src/main/java/land/chipmunk/chipmunkbot/commands/EchoCommand.java new file mode 100644 index 0000000..b126870 --- /dev/null +++ b/src/main/java/land/chipmunk/chipmunkbot/commands/EchoCommand.java @@ -0,0 +1,37 @@ +package land.chipmunk.chipmunkbot.commands; + +import land.chipmunk.chipmunkbot.ChipmunkBot; +import land.chipmunk.chipmunkbot.command.*; +import static land.chipmunk.chipmunkbot.plugins.CommandManager.literal; +import static land.chipmunk.chipmunkbot.plugins.CommandManager.argument; +import static com.mojang.brigadier.arguments.StringArgumentType.greedyString; +import static com.mojang.brigadier.arguments.StringArgumentType.getString; +import com.mojang.brigadier.context.CommandContext; +import net.kyori.adventure.text.Component; + +public class EchoCommand extends Command { + public EchoCommand () { + super(); + + this.node( + literal("echo") + .then( + argument("command", greedyString()) + .executes(this::run) + argument("text", greedyString()) + .executes(this::echo) + ) + ); + } + + public int echo (CommandContext context) { + final CommandSource source = context.getSource(); + final ChipmunkBot client = source.client(); + + client.core().run(getString(context, "command")); + final String text = getString(context, "command"); + source.sendOutput(Component.text(text)); + + return 1; + } +} \ No newline at end of file