diff --git a/common/src/main/kotlin/com/undefined/stellar/AbstractStellarCommand.kt b/common/src/main/kotlin/com/undefined/stellar/AbstractStellarCommand.kt index d7fd6e7..c0789ca 100644 --- a/common/src/main/kotlin/com/undefined/stellar/AbstractStellarCommand.kt +++ b/common/src/main/kotlin/com/undefined/stellar/AbstractStellarCommand.kt @@ -13,18 +13,19 @@ import net.kyori.adventure.text.minimessage.MiniMessage import org.bukkit.command.CommandSender import org.bukkit.entity.Player import org.bukkit.plugin.java.JavaPlugin +import org.jetbrains.annotations.ApiStatus @Suppress("UNCHECKED_CAST") abstract class AbstractStellarCommand(val name: String, var description: String = "", var usage: String = "") : SubCommandHandler() { override fun getBase(): AbstractStellarCommand<*> = this - val aliases: MutableList = mutableListOf() - val failureMessages: MutableList = mutableListOf() - val globalFailureMessages: MutableList = mutableListOf() - val failureExecutions: MutableList> = mutableListOf() - var hideDefaultFailureMessages: HideDefaultFailureMessages = HideDefaultFailureMessages(false, false) - private val _requirements: MutableList> = mutableListOf() + @ApiStatus.Internal val aliases: MutableList = mutableListOf() + @ApiStatus.Internal val failureMessages: MutableList = mutableListOf() + @ApiStatus.Internal val globalFailureMessages: MutableList = mutableListOf() + @ApiStatus.Internal val failureExecutions: MutableList> = mutableListOf() + @ApiStatus.Internal var hideDefaultFailureMessages: HideDefaultFailureMessages = HideDefaultFailureMessages(false, false) + @ApiStatus.Internal private val _requirements: MutableList> = mutableListOf() val requirements: List> get() { if (this is CustomSubCommand<*>) @@ -33,9 +34,9 @@ abstract class AbstractStellarCommand(val name: String, var description: Stri ) return _requirements } - val permissionRequirements: MutableList = mutableListOf() - val executions: MutableList> = mutableListOf() - val runnables: MutableList> = mutableListOf() + @ApiStatus.Internal val permissionRequirements: MutableList = mutableListOf() + @ApiStatus.Internal val executions: MutableList> = mutableListOf() + @ApiStatus.Internal val runnables: MutableList> = mutableListOf() fun addAlias(name: String): T { aliases.add(name) diff --git a/common/src/main/kotlin/com/undefined/stellar/data/arguments/Anchor.kt b/common/src/main/kotlin/com/undefined/stellar/data/argument/Anchor.kt similarity index 94% rename from common/src/main/kotlin/com/undefined/stellar/data/arguments/Anchor.kt rename to common/src/main/kotlin/com/undefined/stellar/data/argument/Anchor.kt index 6a37374..1f505bb 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/arguments/Anchor.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/argument/Anchor.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.data.arguments +package com.undefined.stellar.data.argument import org.bukkit.Location import org.bukkit.entity.LivingEntity diff --git a/common/src/main/kotlin/com/undefined/stellar/data/argument/CommandContext.kt b/common/src/main/kotlin/com/undefined/stellar/data/argument/CommandContext.kt new file mode 100644 index 0000000..cd42b0c --- /dev/null +++ b/common/src/main/kotlin/com/undefined/stellar/data/argument/CommandContext.kt @@ -0,0 +1,10 @@ +package com.undefined.stellar.data.argument + +import java.util.* + +typealias CommandNode = LinkedList + +class CommandContext(val arguments: CommandNode, val input: String) { + fun getSubCommand(int: Int): T = arguments[int] as T + operator fun get(int: Int) = arguments[int] +} \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/data/arguments/Operation.kt b/common/src/main/kotlin/com/undefined/stellar/data/argument/Operation.kt similarity index 94% rename from common/src/main/kotlin/com/undefined/stellar/data/arguments/Operation.kt rename to common/src/main/kotlin/com/undefined/stellar/data/argument/Operation.kt index 873f7db..7c50e24 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/arguments/Operation.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/argument/Operation.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.data.arguments +package com.undefined.stellar.data.argument import kotlin.math.max import kotlin.math.min diff --git a/common/src/main/kotlin/com/undefined/stellar/data/arguments/ParticleData.kt b/common/src/main/kotlin/com/undefined/stellar/data/argument/ParticleData.kt similarity index 67% rename from common/src/main/kotlin/com/undefined/stellar/data/arguments/ParticleData.kt rename to common/src/main/kotlin/com/undefined/stellar/data/argument/ParticleData.kt index 1cc249e..d87f147 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/arguments/ParticleData.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/argument/ParticleData.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.data.arguments +package com.undefined.stellar.data.argument import org.bukkit.Particle diff --git a/common/src/main/kotlin/com/undefined/stellar/sub/AbstractStellarSubCommand.kt b/common/src/main/kotlin/com/undefined/stellar/sub/AbstractStellarSubCommand.kt index 25f3d49..86d55b2 100644 --- a/common/src/main/kotlin/com/undefined/stellar/sub/AbstractStellarSubCommand.kt +++ b/common/src/main/kotlin/com/undefined/stellar/sub/AbstractStellarSubCommand.kt @@ -1,9 +1,11 @@ package com.undefined.stellar.sub import com.undefined.stellar.AbstractStellarCommand +import com.undefined.stellar.data.argument.CommandContext +import org.bukkit.command.CommandSender import org.bukkit.plugin.java.JavaPlugin -abstract class AbstractStellarSubCommand(val parent: AbstractStellarCommand<*>, name: String) : AbstractStellarCommand>(name) { +abstract class AbstractStellarSubCommand(val parent: AbstractStellarCommand<*>, name: String) : AbstractStellarCommand(name) { override fun getBase(): AbstractStellarCommand<*> = parent.getBase() override fun register(plugin: JavaPlugin) = parent.register(plugin) } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/sub/BaseStellarSubCommand.kt b/common/src/main/kotlin/com/undefined/stellar/sub/BaseStellarSubCommand.kt index 89eed20..b042ed9 100644 --- a/common/src/main/kotlin/com/undefined/stellar/sub/BaseStellarSubCommand.kt +++ b/common/src/main/kotlin/com/undefined/stellar/sub/BaseStellarSubCommand.kt @@ -1,13 +1,16 @@ package com.undefined.stellar.sub import com.undefined.stellar.AbstractStellarCommand +import com.undefined.stellar.data.argument.CommandContext import com.undefined.stellar.data.suggestion.StellarSuggestion import com.undefined.stellar.data.execution.CustomStellarExecution import com.undefined.stellar.data.execution.CustomStellarRunnable import com.undefined.stellar.data.suggestion.Suggestion import org.bukkit.command.CommandSender +import org.bukkit.plugin.java.JavaPlugin abstract class BaseStellarSubCommand(parent: AbstractStellarCommand<*>, name: String) : AbstractStellarSubCommand(parent, name) { + val suggestions: MutableList> = mutableListOf() val customExecutions: MutableList> = mutableListOf() val customRunnables: MutableList> = mutableListOf() @@ -42,11 +45,6 @@ abstract class BaseStellarSubCommand(parent: AbstractStellarCommand<*>, name: return this as T } - fun addSuggestions(suggestion: Suggestion): T { - suggestions.add(StellarSuggestion(CommandSender::class) { listOf(suggestion) }) - return this as T - } - fun setSuggestions(vararg suggestion: Suggestion): T { suggestions.clear() suggestions.add(StellarSuggestion(CommandSender::class) { suggestion.toList() }) @@ -76,4 +74,12 @@ abstract class BaseStellarSubCommand(parent: AbstractStellarCommand<*>, name: return this as T } + inline fun addSubCommandExecution(noinline execution: C.(CommandContext) -> Unit): T { + customExecutions.add(CustomStellarExecution(C::class, execution) as CustomStellarExecution<*, Any?>) + return this as T + } + + override fun getBase(): AbstractStellarCommand<*> = parent.getBase() + override fun register(plugin: JavaPlugin) = parent.register(plugin) + } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/sub/SubCommandHandler.kt b/common/src/main/kotlin/com/undefined/stellar/sub/SubCommandHandler.kt index c589a57..f11ccf7 100644 --- a/common/src/main/kotlin/com/undefined/stellar/sub/SubCommandHandler.kt +++ b/common/src/main/kotlin/com/undefined/stellar/sub/SubCommandHandler.kt @@ -37,7 +37,6 @@ open class SubCommandHandler { if (base is CustomSubCommand<*>) return _subCommands + base.getSubCommandsList() return _subCommands } - val optionalSubCommands: MutableList> = mutableListOf() fun addSubCommand(subCommand: AbstractStellarSubCommand<*>): AbstractStellarSubCommand<*> { _subCommands.add(subCommand) diff --git a/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/entity/EntityAnchorSubCommand.kt b/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/entity/EntityAnchorSubCommand.kt index 24af08a..701cc64 100644 --- a/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/entity/EntityAnchorSubCommand.kt +++ b/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/entity/EntityAnchorSubCommand.kt @@ -1,7 +1,7 @@ package com.undefined.stellar.sub.brigadier.entity import com.undefined.stellar.AbstractStellarCommand -import com.undefined.stellar.data.arguments.Anchor +import com.undefined.stellar.data.argument.Anchor import com.undefined.stellar.data.execution.CustomStellarExecution import com.undefined.stellar.data.execution.CustomStellarRunnable import com.undefined.stellar.sub.BaseStellarSubCommand diff --git a/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/math/OperationSubCommand.kt b/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/math/OperationSubCommand.kt index cf306eb..15b831f 100644 --- a/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/math/OperationSubCommand.kt +++ b/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/math/OperationSubCommand.kt @@ -1,7 +1,7 @@ package com.undefined.stellar.sub.brigadier.math import com.undefined.stellar.AbstractStellarCommand -import com.undefined.stellar.data.arguments.Operation +import com.undefined.stellar.data.argument.Operation import com.undefined.stellar.data.execution.CustomStellarExecution import com.undefined.stellar.data.execution.CustomStellarRunnable import com.undefined.stellar.sub.BaseStellarSubCommand diff --git a/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/world/ParticleSubCommand.kt b/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/world/ParticleSubCommand.kt index 3855b2e..34a1787 100644 --- a/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/world/ParticleSubCommand.kt +++ b/common/src/main/kotlin/com/undefined/stellar/sub/brigadier/world/ParticleSubCommand.kt @@ -1,7 +1,7 @@ package com.undefined.stellar.sub.brigadier.world import com.undefined.stellar.AbstractStellarCommand -import com.undefined.stellar.data.arguments.ParticleData +import com.undefined.stellar.data.argument.ParticleData import com.undefined.stellar.data.execution.CustomStellarExecution import com.undefined.stellar.data.execution.CustomStellarRunnable import com.undefined.stellar.sub.BaseStellarSubCommand diff --git a/server/src/main/kotlin/com/undefined/stellar/Main.kt b/server/src/main/kotlin/com/undefined/stellar/Main.kt index ff292a6..901ec30 100644 --- a/server/src/main/kotlin/com/undefined/stellar/Main.kt +++ b/server/src/main/kotlin/com/undefined/stellar/Main.kt @@ -1,23 +1,43 @@ package com.undefined.stellar +import com.undefined.stellar.data.argument.CommandContext import com.undefined.stellar.data.suggestion.Suggestion +import org.bukkit.entity.Player import org.bukkit.plugin.java.JavaPlugin +import java.util.LinkedList -class Main : JavaPlugin() { +typealias CommandNode = LinkedList - companion object { - lateinit var INSTANCE: Main - } +class Main : JavaPlugin() { override fun onEnable() { - INSTANCE = this - - StellarCommand("test") + StellarCommand("test", description = "this is a description", "alias") + .addAlias("othertest") .setDescription("This is a description") - .setUsageText("/test ") + .setUsageText("/test ") + .addStringSubCommand("test") .addStringSubCommand("test") - .addSuggestion("Text", "Tooltip") + .addSuggestions(Suggestion("suggestion", "t")) + .alwaysRun { + sendMessage("This will always run no matter what") + true + } + .addExecution { sendMessage("Execution") } + .addSubCommandExecution { context -> + sendMessage(context.getSubCommand(1)) + } + .addFailureExecution { sendMessage("Failure!") } + .addFailureExecution { sendMessage("Incorrect!") } + .hideDefaultFailureMessages() .register(this) + +// val main = StellarCommand("test") +// main.addOnlinePlayersSubCommand("onlinePlayers") +// .addExecution { context -> +// context.input +// context.get(1) +// context[1] +// } } } \ No newline at end of file diff --git a/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt b/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt index edc1908..ce60b6f 100644 --- a/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt +++ b/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt @@ -5,12 +5,12 @@ import com.mojang.brigadier.builder.RequiredArgumentBuilder import com.mojang.brigadier.context.CommandContext import com.mojang.brigadier.context.ParsedArgument import com.mojang.brigadier.context.StringRange -import com.mojang.brigadier.suggestion.SuggestionsBuilder -import com.undefined.stellar.data.arguments.Anchor -import com.undefined.stellar.data.arguments.Operation -import com.undefined.stellar.data.arguments.ParticleData +import com.undefined.stellar.data.argument.Anchor +import com.undefined.stellar.data.argument.Operation +import com.undefined.stellar.data.argument.ParticleData import com.undefined.stellar.exception.ServerTypeMismatchException import com.undefined.stellar.exception.UnsupportedSubCommandException +import com.undefined.stellar.sub.AbstractStellarSubCommand import com.undefined.stellar.sub.BaseStellarSubCommand import com.undefined.stellar.sub.brigadier.entity.EntityAnchorSubCommand import com.undefined.stellar.sub.brigadier.entity.EntityDisplayType @@ -34,8 +34,6 @@ import com.undefined.stellar.sub.brigadier.text.ComponentSubCommand import com.undefined.stellar.sub.brigadier.text.MessageSubCommand import com.undefined.stellar.sub.brigadier.text.StyleSubCommand import com.undefined.stellar.sub.brigadier.world.* -import com.undefined.stellar.sub.custom.CustomSubCommand -import com.undefined.stellar.sub.custom.CustomSubCommandInfo import com.undefined.stellar.sub.custom.EnumSubCommand import com.undefined.stellar.sub.custom.ListSubCommand import net.kyori.adventure.text.format.Style @@ -88,7 +86,7 @@ object ArgumentHelper { when (subCommand) { is ListSubCommand<*> -> RequiredArgumentBuilder.argument(subCommand.name, StringArgumentType.word()).suggestStringList { subCommand.getStringList() } is EnumSubCommand<*> -> RequiredArgumentBuilder.argument(subCommand.name, StringArgumentType.word()).suggestStringList { subCommand.getStringList() } - else -> RequiredArgumentBuilder.argument(subCommand.name, getArgumentTypeFromBrigadierSubCommand(subCommand)) + else -> RequiredArgumentBuilder.argument(subCommand.name, getArgumentTypeFromSubCommand(subCommand)) } fun > handleNativeSubCommandExecutors(subCommand: T, context: CommandContext) { @@ -102,8 +100,9 @@ object ArgumentHelper { for (execution in subCommand.customExecutions) enum?.let { execution.run(context.source.bukkitSender, enum) } } else -> { - val argument = getArgumentFromBrigadierSubCommand(context, subCommand) - for (execution in subCommand.customExecutions) execution.run(context.source.bukkitSender, argument ?: break) + val stellarContext = CommandContextAdapter(context).getStellarCommandContext() +// val argument = getParsedArgumentFromBrigadier(context, subCommand) + for (execution in subCommand.customExecutions) execution.run(context.source.bukkitSender, stellarContext) } } } @@ -117,18 +116,22 @@ object ArgumentHelper { } is EnumSubCommand<*> -> { val enum = subCommand.parse(StringArgumentType.getString(context, subCommand.name)) - for (runnable in subCommand.customRunnables) enum?.let { runnable.run(context.source.bukkitSender, enum) } + for (runnable in subCommand.customRunnables) + enum?.let { runnable.run(context.source.bukkitSender, enum) } } else -> { - val argument = getArgumentFromBrigadierSubCommand(context, subCommand) ?: return true - subCommand.customRunnables.forEach { if (!it.run(context.source.bukkitSender, argument)) return false } +// val argument = getParsedArgumentFromBrigadier(context, subCommand) ?: return true + val stellarContext = CommandContextAdapter(context).getStellarCommandContext() + for (runnable in subCommand.customRunnables) + if (!runnable.run(context.source.bukkitSender, stellarContext)) return false } } return true } - fun > getArgumentTypeFromBrigadierSubCommand(subCommand: T): ArgumentType<*> = + fun > getArgumentTypeFromSubCommand(subCommand: T): ArgumentType<*> = when (subCommand) { + is ListSubCommand<*> -> StringArgumentType.string() is StringSubCommand -> subCommand.type.brigadier() is IntegerSubCommand -> IntegerArgumentType.integer(subCommand.min, subCommand.max) is LongSubCommand -> LongArgumentType.longArg(subCommand.min, subCommand.max) @@ -178,7 +181,7 @@ object ArgumentHelper { else -> throw UnsupportedSubCommandException() } - private fun > getArgumentFromBrigadierSubCommand(context: CommandContext, subCommand: T): Any? { + fun > getParsedArgumentFromSubCommand(context: CommandContext, subCommand: T): Any? { return when (subCommand) { is StringSubCommand -> StringArgumentType.getString(context, subCommand.name) is IntegerSubCommand -> IntegerArgumentType.getInteger(context, subCommand.name) diff --git a/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/BrigadierCommandRegistrar.kt b/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/BrigadierCommandRegistrar.kt index ce1de2d..4758767 100644 --- a/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/BrigadierCommandRegistrar.kt +++ b/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/BrigadierCommandRegistrar.kt @@ -2,7 +2,6 @@ package com.undefined.stellar.v1_20_6 import com.mojang.brigadier.Command import com.mojang.brigadier.CommandDispatcher -import com.mojang.brigadier.Message import com.mojang.brigadier.builder.ArgumentBuilder import com.mojang.brigadier.builder.LiteralArgumentBuilder import com.mojang.brigadier.builder.RequiredArgumentBuilder @@ -10,7 +9,6 @@ import com.mojang.brigadier.context.CommandContext import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.data.help.CustomCommandHelpTopic -import com.undefined.stellar.data.suggestion.Suggestion import com.undefined.stellar.exception.UnsupportedSubCommandException import com.undefined.stellar.sub.AbstractStellarSubCommand import com.undefined.stellar.sub.BaseStellarSubCommand @@ -21,13 +19,7 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer import net.minecraft.commands.CommandSourceStack import net.minecraft.server.MinecraftServer import org.bukkit.Bukkit -import org.bukkit.Server -import org.bukkit.command.CommandMap import org.bukkit.command.CommandSender -import org.bukkit.craftbukkit.CraftServer -import org.bukkit.craftbukkit.help.CustomHelpTopic -import org.bukkit.help.GenericCommandHelpTopic -import org.bukkit.help.HelpTopic import java.util.SortedMap object BrigadierCommandRegistrar { @@ -56,7 +48,7 @@ object BrigadierCommandRegistrar { return baseCommand.hasGlobalHiddenDefaultFailureMessages() } - private fun getSubCommands( + fun getSubCommands( baseCommand: AbstractStellarCommand<*>, context: CommandContext, currentIndex: Int = 1, @@ -111,11 +103,9 @@ object BrigadierCommandRegistrar { private fun BaseStellarSubCommand<*>.handleExecutions(context: CommandContext) { for (subCommand in this.getBase().subCommands) if (subCommand is BaseStellarSubCommand && !handleSubCommandRunnables(subCommand, context)) return - when (this) { - is StellarSubCommand -> for (execution in executions) { execution.run(context.source.bukkitSender) } - is BaseStellarSubCommand -> ArgumentHelper.handleNativeSubCommandExecutors(this, context) - else -> throw UnsupportedSubCommandException() - } + + if (this is StellarSubCommand) for (execution in executions) execution.run(context.source.bukkitSender) + else ArgumentHelper.handleNativeSubCommandExecutors(this, context) } private fun ArgumentBuilder.handleCommand(stellarCommand: AbstractStellarCommand<*>) { @@ -135,7 +125,7 @@ object BrigadierCommandRegistrar { private fun ArgumentBuilder.handleSubCommands(stellarCommand: AbstractStellarCommand<*>) { for (subCommand in stellarCommand.subCommands) { if (subCommand is CustomSubCommand<*>) { - val type = ArgumentHelper.getArgumentTypeFromBrigadierSubCommand(subCommand.type) + val type = ArgumentHelper.getArgumentTypeFromSubCommand(subCommand.type) val argument: RequiredArgumentBuilder = RequiredArgumentBuilder.argument(subCommand.name, type) argument.requires { subCommand.requirement() } argument.suggests { context, builder -> @@ -183,6 +173,6 @@ object BrigadierCommandRegistrar { return ArgumentHelper.handleNativeSubCommandRunnables(subCommand, context) } - private fun commandDispatcher(): CommandDispatcher = (Bukkit.getServer() as CraftServer).server.functions.dispatcher + private fun commandDispatcher(): CommandDispatcher = MinecraftServer.getServer().functions.dispatcher } \ No newline at end of file diff --git a/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt b/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt new file mode 100644 index 0000000..dbf0d50 --- /dev/null +++ b/v1_20_6/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt @@ -0,0 +1,28 @@ +package com.undefined.stellar.v1_20_6 + +import com.mojang.brigadier.context.CommandContext +import com.undefined.stellar.AbstractStellarCommand +import com.undefined.stellar.StellarCommands +import com.undefined.stellar.data.argument.CommandNode +import com.undefined.stellar.sub.BaseStellarSubCommand +import com.undefined.stellar.sub.custom.CustomSubCommand +import net.minecraft.commands.CommandSourceStack + +class CommandContextAdapter(private val context: CommandContext) { + fun getStellarCommandContext(): com.undefined.stellar.data.argument.CommandContext { +// val arguments: CommandNode = CommandNode() +// arguments.addAll(context.nodes.map { ArgumentHelper.getParsedArgumentFromBrigadier(context, BrigadierCommandRegistrar.) }) + println(context.input.startsWith('/')) + val input = context.input.removePrefix("/") + val baseCommand: AbstractStellarCommand<*> = StellarCommands.getStellarCommand(input.substring(input.indexOf('/') + 1, input.indexOf(' ')))!! + val arguments: CommandNode = CommandNode() + arguments.addAll(BrigadierCommandRegistrar.getSubCommands(baseCommand, context).map { + if (it is CustomSubCommand) return@map it.parse(context.source.bukkitSender, input) + ArgumentHelper.getParsedArgumentFromSubCommand(context, it as? BaseStellarSubCommand ?: return@map null) + }) + return com.undefined.stellar.data.argument.CommandContext( + arguments, + input + ) + } +} \ No newline at end of file