diff --git a/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt b/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt index b1c0b58..ad40b30 100644 --- a/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt +++ b/api/src/main/kotlin/com/undefined/stellar/manager/CommandManager.kt @@ -9,6 +9,7 @@ import org.jetbrains.annotations.ApiStatus @ApiStatus.Internal object CommandManager { val registrars: Map = mapOf( + "1.20.4" to com.undefined.stellar.v1_20_4.CommandRegistrar, "1.20.5" to com.undefined.stellar.v1_20_6.CommandRegistrar, "1.20.6" to com.undefined.stellar.v1_20_6.CommandRegistrar, "1.21" to com.undefined.stellar.v1_21.CommandRegistrar, diff --git a/common/src/main/kotlin/com/undefined/stellar/AbstractStellarCommand.kt b/common/src/main/kotlin/com/undefined/stellar/AbstractStellarCommand.kt index 048a8ac..0cd6780 100644 --- a/common/src/main/kotlin/com/undefined/stellar/AbstractStellarCommand.kt +++ b/common/src/main/kotlin/com/undefined/stellar/AbstractStellarCommand.kt @@ -96,7 +96,7 @@ abstract class AbstractStellarCommand(val name: String, var description: Stri } inline fun addRequirement(noinline requirement: C.() -> Boolean): T = - addRequirements(StellarRequirement(requirement)) + addRequirements(StellarRequirement(C::class, requirement)) fun setFailureMessages(messages: List): T { failureMessages.clear() @@ -158,7 +158,7 @@ abstract class AbstractStellarCommand(val name: String, var description: Stri addGlobalFailureMessages(messages.toList()) inline fun addFailureExecution(noinline execution: CommandContext.() -> Unit): T { - failureExecutions.add(StellarExecution(execution)) + failureExecutions.add(StellarExecution(C::class, execution)) return this as T } @@ -173,7 +173,7 @@ abstract class AbstractStellarCommand(val name: String, var description: Stri } inline fun addExecution(noinline execution: CommandContext.() -> Unit): T { - executions.add(StellarExecution(execution)) + executions.add(StellarExecution(C::class, execution)) return this as T } @@ -183,7 +183,7 @@ abstract class AbstractStellarCommand(val name: String, var description: Stri } inline fun addRunnable(noinline runnable: CommandContext.() -> Boolean): T { - runnables.add(StellarRunnable(runnable)) + runnables.add(StellarRunnable(C::class, runnable)) return this as T } diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/AbstractStellarSubCommand.kt b/common/src/main/kotlin/com/undefined/stellar/argument/AbstractStellarSubCommand.kt index d575357..7f15940 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/AbstractStellarSubCommand.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/AbstractStellarSubCommand.kt @@ -19,56 +19,56 @@ abstract class AbstractStellarArgument(val parent: AbstractStellarCommand<*>, } fun addSuggestion(suggestion: Suggestion): T { - suggestions.add(StellarSuggestion { listOf(suggestion) }) + suggestions.add(StellarSuggestion(CommandSender::class) { listOf(suggestion) }) return this as T } fun addSuggestions(list: List): T { - suggestions.add(StellarSuggestion { list }) + suggestions.add(StellarSuggestion(CommandSender::class) { list }) return this as T } fun addSuggestions(vararg list: Suggestion): T { - suggestions.add(StellarSuggestion { list.toList() }) + suggestions.add(StellarSuggestion(CommandSender::class) { list.toList() }) return this as T } fun addSuggestionsWithoutTooltip(list: List): T { - suggestions.add(StellarSuggestion { list.map { Suggestion(it, "") } }) + suggestions.add(StellarSuggestion(CommandSender::class) { list.map { Suggestion(it, "") } }) return this as T } fun addSuggestions(vararg list: String): T { - suggestions.add(StellarSuggestion { list.map { Suggestion(it, "") } }) + suggestions.add(StellarSuggestion(CommandSender::class) { list.map { Suggestion(it, "") } }) return this as T } fun setSuggestions(vararg suggestion: Suggestion): T { suggestions.clear() - suggestions.add(StellarSuggestion { suggestion.toList() }) + suggestions.add(StellarSuggestion(CommandSender::class) { suggestion.toList() }) return this as T } fun setSuggestions(vararg suggestion: String): T { suggestions.clear() - suggestions.add(StellarSuggestion { suggestion.map { Suggestion(it, "") } }) + suggestions.add(StellarSuggestion(CommandSender::class) { suggestion.map { Suggestion(it, "") } }) return this as T } fun setSuggestions(suggestion: List): T { suggestions.clear() - suggestions.add(StellarSuggestion { suggestion.toList() }) + suggestions.add(StellarSuggestion(CommandSender::class) { suggestion.toList() }) return this as T } fun setSuggestionsWithoutTooltip(suggestion: List): T { suggestions.clear() - suggestions.add(StellarSuggestion { suggestion.map { Suggestion(it, "") } }) + suggestions.add(StellarSuggestion(CommandSender::class) { suggestion.map { Suggestion(it, "") } }) return this as T } inline fun addSuggestion(noinline suggestion: CommandContext.() -> List): T { - suggestions.add(StellarSuggestion(suggestion)) + suggestions.add(StellarSuggestion(C::class, suggestion)) return this as T } diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/CustomArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/CustomArgument.kt index c1b13c7..e509e6e 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/CustomArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/types/custom/CustomArgument.kt @@ -19,21 +19,21 @@ abstract class CustomArgument( override val arguments: MutableList> get() = (super.arguments + getArgumentsList()).toMutableList() override val failureExecutions: MutableList> - get() = (super.failureExecutions + StellarExecution { + get() = (super.failureExecutions + StellarExecution(CommandSender::class) { failureExecution(this, arguments.values.last()) }).toMutableList() override val requirements: MutableList> - get() = (super.requirements + StellarRequirement { requirement() }).toMutableList() + get() = (super.requirements + StellarRequirement(CommandSender::class) { requirement() }).toMutableList() override val executions: MutableList> - get() = (super.executions + StellarExecution { + get() = (super.executions + StellarExecution(CommandSender::class) { execution(this, this.arguments.values.last()) }).toMutableList() override val runnables: MutableList> - get() = (super.runnables + StellarRunnable { + get() = (super.runnables + StellarRunnable(CommandSender::class) { runnable(this, this[name]) }).toMutableList() override val suggestions: MutableList> - get() = (super.suggestions + StellarSuggestion { + get() = (super.suggestions + StellarSuggestion(CommandSender::class) { listSuggestions(this) }).toMutableList() diff --git a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/GreedyWordArgument.kt b/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/GreedyWordArgument.kt index f7deb98..23cf06f 100644 --- a/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/GreedyWordArgument.kt +++ b/common/src/main/kotlin/com/undefined/stellar/argument/types/primitive/GreedyWordArgument.kt @@ -20,56 +20,56 @@ class GreedyWordArgument { } fun addSuggestion(suggestion: Suggestion): GreedyWordArgument { - suggestions.add(GreedyStellarSuggestion { listOf(suggestion) }) + suggestions.add(GreedyStellarSuggestion(CommandSender::class) { listOf(suggestion) }) return this } fun addSuggestions(list: List): GreedyWordArgument { - suggestions.add(GreedyStellarSuggestion { list }) + suggestions.add(GreedyStellarSuggestion(CommandSender::class) { list }) return this } fun addSuggestions(vararg list: Suggestion): GreedyWordArgument { - suggestions.add(GreedyStellarSuggestion { list.toList() }) + suggestions.add(GreedyStellarSuggestion(CommandSender::class) { list.toList() }) return this } - fun addSuggestionsWithoutGreedyWordArgumentooltip(list: List): GreedyWordArgument { - suggestions.add(GreedyStellarSuggestion { list.map { Suggestion(it, "") } }) + fun addSuggestionsWithoutGreedyWordArgumenTooltip(list: List): GreedyWordArgument { + suggestions.add(GreedyStellarSuggestion(CommandSender::class) { list.map { Suggestion(it, "") } }) return this } fun addSuggestions(vararg list: String): GreedyWordArgument { - suggestions.add(GreedyStellarSuggestion { list.map { Suggestion(it, "") } }) + suggestions.add(GreedyStellarSuggestion(CommandSender::class) { list.map { Suggestion(it, "") } }) return this } fun setSuggestions(vararg suggestion: Suggestion): GreedyWordArgument { suggestions.clear() - suggestions.add(GreedyStellarSuggestion { suggestion.toList() }) + suggestions.add(GreedyStellarSuggestion(CommandSender::class) { suggestion.toList() }) return this } fun setSuggestions(vararg suggestion: String): GreedyWordArgument { suggestions.clear() - suggestions.add(GreedyStellarSuggestion { suggestion.map { Suggestion(it, "") } }) + suggestions.add(GreedyStellarSuggestion(CommandSender::class) { suggestion.map { Suggestion(it, "") } }) return this } fun setSuggestions(suggestion: List): GreedyWordArgument { suggestions.clear() - suggestions.add(GreedyStellarSuggestion { suggestion.toList() }) + suggestions.add(GreedyStellarSuggestion(CommandSender::class) { suggestion.toList() }) return this } fun setSuggestionsWithoutTooltip(suggestion: List): GreedyWordArgument { suggestions.clear() - suggestions.add(GreedyStellarSuggestion { suggestion.map { Suggestion(it, "") } }) + suggestions.add(GreedyStellarSuggestion(CommandSender::class) { suggestion.map { Suggestion(it, "") } }) return this } inline fun addSuggestion(noinline suggestion: GreedyCommandContext.() -> List): GreedyWordArgument { - suggestions.add(GreedyStellarSuggestion(suggestion)) + suggestions.add(GreedyStellarSuggestion(C::class, suggestion)) return this } @@ -79,7 +79,7 @@ class GreedyWordArgument { } inline fun addExecution(noinline execution: GreedyCommandContext.() -> Unit): GreedyWordArgument { - executions.add(GreedyStellarExecution(execution)) + executions.add(GreedyStellarExecution(C::class, execution)) return this } @@ -89,7 +89,7 @@ class GreedyWordArgument { } inline fun addRunnable(noinline runnable: GreedyCommandContext.() -> Boolean): GreedyWordArgument { - runnables.add(GreedyStellarRunnable(runnable)) + runnables.add(GreedyStellarRunnable(C::class, runnable)) return this } diff --git a/common/src/main/kotlin/com/undefined/stellar/data/argument/GreedyCommandContext.kt b/common/src/main/kotlin/com/undefined/stellar/data/argument/GreedyCommandContext.kt index e4516b9..509cc1a 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/argument/GreedyCommandContext.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/argument/GreedyCommandContext.kt @@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender typealias GreedyCommandNode = List @Suppress("UNCHECKED_CAST", "UNUSED") -class GreedyCommandContext(val arguments: GreedyCommandNode, val source: T, val input: String) { +class GreedyCommandContext(val arguments: GreedyCommandNode, val sender: T, val input: String) { fun getArgument(index: Int): String = arguments[index] operator fun get(index: Int) = arguments[index] } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/data/execution/GreedyStellarExecution.kt b/common/src/main/kotlin/com/undefined/stellar/data/execution/GreedyStellarExecution.kt index 684e66f..b82f144 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/execution/GreedyStellarExecution.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/execution/GreedyStellarExecution.kt @@ -2,10 +2,13 @@ package com.undefined.stellar.data.execution import com.undefined.stellar.data.argument.GreedyCommandContext import org.bukkit.command.CommandSender +import kotlin.reflect.KClass +import kotlin.reflect.safeCast @Suppress("UNCHECKED_CAST") -data class GreedyStellarExecution(val execution: GreedyCommandContext.() -> Unit) { +data class GreedyStellarExecution(val clazz: KClass, val execution: GreedyCommandContext.() -> Unit) { operator fun invoke(context: GreedyCommandContext) { - execution(context as? GreedyCommandContext ?: return) + if (clazz.safeCast(context.sender) == null) return + execution(context as GreedyCommandContext) } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/data/execution/GreedyStellarRunnable.kt b/common/src/main/kotlin/com/undefined/stellar/data/execution/GreedyStellarRunnable.kt index 8c0b700..e09a919 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/execution/GreedyStellarRunnable.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/execution/GreedyStellarRunnable.kt @@ -2,10 +2,13 @@ package com.undefined.stellar.data.execution import com.undefined.stellar.data.argument.GreedyCommandContext import org.bukkit.command.CommandSender +import kotlin.reflect.KClass +import kotlin.reflect.safeCast @Suppress("UNCHECKED_CAST") -data class GreedyStellarRunnable(val execution: GreedyCommandContext.() -> Boolean) { +data class GreedyStellarRunnable(val clazz: KClass, val execution: GreedyCommandContext.() -> Boolean) { operator fun invoke(context: GreedyCommandContext): Boolean { - return execution(context as? GreedyCommandContext ?: return true) + if (clazz.safeCast(context.sender) == null) return true + return execution(context as GreedyCommandContext) } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/data/execution/StellarExecution.kt b/common/src/main/kotlin/com/undefined/stellar/data/execution/StellarExecution.kt index 4017af1..1e83f5b 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/execution/StellarExecution.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/execution/StellarExecution.kt @@ -2,10 +2,13 @@ package com.undefined.stellar.data.execution import com.undefined.stellar.data.argument.CommandContext import org.bukkit.command.CommandSender +import kotlin.reflect.KClass +import kotlin.reflect.safeCast @Suppress("UNCHECKED_CAST") -data class StellarExecution(val execution: CommandContext.() -> Unit) { +data class StellarExecution(val clazz: KClass, val execution: CommandContext.() -> Unit) { operator fun invoke(context: CommandContext) { - execution(context as? CommandContext ?: return) + if (clazz.safeCast(context.sender) == null) return + execution(context as? CommandContext ?: return) } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/data/execution/StellarRunnable.kt b/common/src/main/kotlin/com/undefined/stellar/data/execution/StellarRunnable.kt index dc07670..5f6a8c8 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/execution/StellarRunnable.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/execution/StellarRunnable.kt @@ -2,10 +2,13 @@ package com.undefined.stellar.data.execution import com.undefined.stellar.data.argument.CommandContext import org.bukkit.command.CommandSender +import kotlin.reflect.KClass +import kotlin.reflect.safeCast @Suppress("UNCHECKED_CAST") -data class StellarRunnable(val execution: CommandContext.() -> Boolean) { +data class StellarRunnable(val clazz: KClass, val execution: CommandContext.() -> Boolean) { operator fun invoke(context: CommandContext): Boolean { + if (clazz.safeCast(context.sender) == null) return true return execution(context as? CommandContext ?: return true) } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/data/requirement/StellarRequirement.kt b/common/src/main/kotlin/com/undefined/stellar/data/requirement/StellarRequirement.kt index d69ac4e..f7f38d1 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/requirement/StellarRequirement.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/requirement/StellarRequirement.kt @@ -1,10 +1,11 @@ package com.undefined.stellar.data.requirement import org.bukkit.command.CommandSender +import kotlin.reflect.KClass +import kotlin.reflect.safeCast -@Suppress("UNCHECKED_CAST") -data class StellarRequirement(val execution: C.() -> Boolean) { +data class StellarRequirement(val clazz: KClass, val requirement: C.() -> Boolean) { operator fun invoke(sender: CommandSender): Boolean { - return execution(sender as? C ?: return true) + return requirement(clazz.safeCast(sender) ?: return true) } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/data/suggestion/GreedyStellarSuggestion.kt b/common/src/main/kotlin/com/undefined/stellar/data/suggestion/GreedyStellarSuggestion.kt index e7d3a46..75b0ef9 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/suggestion/GreedyStellarSuggestion.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/suggestion/GreedyStellarSuggestion.kt @@ -2,7 +2,12 @@ package com.undefined.stellar.data.suggestion import com.undefined.stellar.data.argument.GreedyCommandContext import org.bukkit.command.CommandSender +import kotlin.reflect.KClass +import kotlin.reflect.safeCast -data class GreedyStellarSuggestion(val suggestion: GreedyCommandContext.() -> List) { - fun get(context: GreedyCommandContext): List = suggestion(context) +data class GreedyStellarSuggestion(val clazz: KClass, val suggestion: GreedyCommandContext.() -> List) { + fun get(context: GreedyCommandContext): List { + if (clazz.safeCast(context.sender) == null) return listOf() + return suggestion(context) + } } \ No newline at end of file diff --git a/common/src/main/kotlin/com/undefined/stellar/data/suggestion/StellarSuggestion.kt b/common/src/main/kotlin/com/undefined/stellar/data/suggestion/StellarSuggestion.kt index 657cbcb..1459fd5 100644 --- a/common/src/main/kotlin/com/undefined/stellar/data/suggestion/StellarSuggestion.kt +++ b/common/src/main/kotlin/com/undefined/stellar/data/suggestion/StellarSuggestion.kt @@ -2,7 +2,12 @@ package com.undefined.stellar.data.suggestion import com.undefined.stellar.data.argument.CommandContext import org.bukkit.command.CommandSender +import kotlin.reflect.KClass +import kotlin.reflect.safeCast -data class StellarSuggestion(val suggestion: CommandContext.() -> List) { - fun get(context: CommandContext): List = suggestion(context) +data class StellarSuggestion(val clazz: KClass, val suggestion: CommandContext.() -> List) { + fun get(context: CommandContext): List { + if (clazz.safeCast(context.sender) == null) return listOf() + return suggestion(context) + } } \ No newline at end of file diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 47c1aff..94af2a6 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -9,7 +9,7 @@ val groupIdVar = "com.undefined" val artifactIdVar = "stellar" dependencies { - compileOnly("org.spigotmc:spigot-api:1.20.5-R0.1-SNAPSHOT") + compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT") implementation(project(":api")) implementation(project(":common")) @@ -19,7 +19,7 @@ dependencies { implementation(project(":v1_21_1:", "reobf")) implementation(project(":v1_21_3:", "reobf")) implementation(project(":v1_21_4:", "reobf")) - compileOnly(project(":v1_21_4")) + compileOnly(project(":v1_20_4")) } tasks { @@ -36,7 +36,7 @@ tasks { } runServer { - minecraftVersion("1.20.5") + minecraftVersion("1.20.4") jvmArgs("-Xmx2G") } } diff --git a/server/src/main/kotlin/com/undefined/stellar/Main.kt b/server/src/main/kotlin/com/undefined/stellar/Main.kt index b2c4c96..7cc95b0 100644 --- a/server/src/main/kotlin/com/undefined/stellar/Main.kt +++ b/server/src/main/kotlin/com/undefined/stellar/Main.kt @@ -8,7 +8,7 @@ class Main : JavaPlugin() { override fun onEnable() { StellarCommand("test") .addLocationArgument("location") - .addWolfVariantArgument("test") + .addStringArgument("string") .addExecution { sender.sendMessage(arguments.toList().withIndex().joinToString(", ") { "${it.index}: ${it.value.first}" }) } diff --git a/server/src/main/resources/plugin.yml b/server/src/main/resources/plugin.yml index b40230b..1053801 100644 --- a/server/src/main/resources/plugin.yml +++ b/server/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ name: Stellar version: '${version}' main: com.undefined.stellar.Main -api-version: '1.20.6' \ No newline at end of file +api-version: '1.20' \ No newline at end of file diff --git a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt similarity index 98% rename from v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt rename to v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt index fa6c184..bc1ddce 100644 --- a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/ArgumentHelper.kt +++ b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/ArgumentHelper.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.v1_20_6 +package com.undefined.stellar.v1_20_4 import com.mojang.brigadier.arguments.* import com.mojang.brigadier.builder.ArgumentBuilder @@ -41,7 +41,7 @@ import com.undefined.stellar.data.argument.ParticleData import com.undefined.stellar.exception.ArgumentVersionMismatchException import com.undefined.stellar.exception.LiteralArgumentMismatchException import com.undefined.stellar.exception.UnsupportedArgumentException -import com.undefined.stellar.v1_20_6.BrigadierCommandHelper.version +import com.undefined.stellar.v1_20_4.BrigadierCommandHelper.version import net.kyori.adventure.text.format.Style import net.kyori.adventure.text.format.TextColor import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer @@ -129,9 +129,13 @@ object ArgumentHelper { LocationType.DOUBLE_LOCATION_2D -> Vec2Argument.vec2() } is BlockDataArgument -> BlockStateArgument.block(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.types.block.BlockPredicateArgument -> BlockPredicateArgument.blockPredicate( + COMMAND_BUILD_CONTEXT + ) is com.undefined.stellar.argument.types.item.ItemArgument -> ItemArgument.item(COMMAND_BUILD_CONTEXT) - is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.types.item.ItemPredicateArgument -> ItemPredicateArgument.itemPredicate( + COMMAND_BUILD_CONTEXT + ) is com.undefined.stellar.argument.types.text.ColorArgument -> ColorArgument.color() is com.undefined.stellar.argument.types.text.ComponentArgument -> ComponentArgument.textComponent() is com.undefined.stellar.argument.types.text.StyleArgument -> StyleArgument.style() @@ -139,7 +143,9 @@ object ArgumentHelper { is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> ObjectiveArgument.objective() is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.criteria() is com.undefined.stellar.argument.types.math.OperationArgument -> OperationArgument.operation() - is com.undefined.stellar.argument.types.item.ParticleArgument -> ParticleArgument.particle(COMMAND_BUILD_CONTEXT) + is com.undefined.stellar.argument.types.item.ParticleArgument -> ParticleArgument.particle( + COMMAND_BUILD_CONTEXT + ) is com.undefined.stellar.argument.types.math.AngleArgument -> AngleArgument.angle() is com.undefined.stellar.argument.types.math.RotationArgument -> RotationArgument.rotation() is DisplaySlotArgument -> ScoreboardSlotArgument.displaySlot() @@ -218,7 +224,8 @@ object ArgumentHelper { } is com.undefined.stellar.argument.types.text.ColorArgument -> ColorArgument.getColor(context, argument.name).color?.let { Style.style(TextColor.color(it)) } ?: Style.empty() is com.undefined.stellar.argument.types.text.ComponentArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(ComponentArgument.getComponent(context, argument.name))) - is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize(getArgumentInput(context, argument.name) ?: return null).style() + is com.undefined.stellar.argument.types.text.StyleArgument -> GsonComponentSerializer.gson().deserialize( + getArgumentInput(context, argument.name) ?: return null).style() is com.undefined.stellar.argument.types.text.MessageArgument -> GsonComponentSerializer.gson().deserialize(Component.Serializer.toJson(MessageArgument.getMessage(context, argument.name))) is com.undefined.stellar.argument.types.scoreboard.ObjectiveArgument -> Bukkit.getScoreboardManager().mainScoreboard.getObjective(ObjectiveArgument.getObjective(context, argument.name).name) is com.undefined.stellar.argument.types.scoreboard.ObjectiveCriteriaArgument -> ObjectiveCriteriaArgument.getCriteria(context, argument.name).name diff --git a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/BrigadierCommandHelper.kt b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/BrigadierCommandHelper.kt similarity index 97% rename from v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/BrigadierCommandHelper.kt rename to v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/BrigadierCommandHelper.kt index 2581fbd..9c52b97 100644 --- a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/BrigadierCommandHelper.kt +++ b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/BrigadierCommandHelper.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.v1_20_6 +package com.undefined.stellar.v1_20_4 import com.mojang.brigadier.builder.LiteralArgumentBuilder import com.mojang.brigadier.context.CommandContext @@ -31,6 +31,7 @@ object BrigadierCommandHelper { } fun fulfillsRequirements(command: AbstractStellarCommand<*>, source: CommandSourceStack): Boolean { + println(source.bukkitSender::class.simpleName) val fulfillsExecutionRequirements = command.requirements.all { it(source.bukkitSender) } val fulfillsPermissionRequirements = command.permissionRequirements.all { source.hasPermission(it.level, it.permission) } return fulfillsExecutionRequirements.and(fulfillsPermissionRequirements) diff --git a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandAdapter.kt b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandAdapter.kt similarity index 98% rename from v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandAdapter.kt rename to v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandAdapter.kt index e472913..87764ad 100644 --- a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandAdapter.kt +++ b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandAdapter.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.v1_20_6 +package com.undefined.stellar.v1_20_4 import com.mojang.brigadier.Command import com.mojang.brigadier.builder.ArgumentBuilder diff --git a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandContextAdapter.kt similarity index 99% rename from v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt rename to v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandContextAdapter.kt index 2cc02b5..0ab8048 100644 --- a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandContextAdapter.kt +++ b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandContextAdapter.kt @@ -1,4 +1,4 @@ -package com.undefined.stellar.v1_20_6 +package com.undefined.stellar.v1_20_4 import com.mojang.brigadier.context.CommandContext import com.undefined.stellar.AbstractStellarCommand diff --git a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandRegistrar.kt b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandRegistrar.kt similarity index 93% rename from v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandRegistrar.kt rename to v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandRegistrar.kt index e964307..c991e5a 100644 --- a/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_6/CommandRegistrar.kt +++ b/v1_20_4/src/main/kotlin/com/undefined/stellar/v1_20_4/CommandRegistrar.kt @@ -1,9 +1,9 @@ -package com.undefined.stellar.v1_20_6 +package com.undefined.stellar.v1_20_4 import com.undefined.stellar.AbstractStellarCommand import com.undefined.stellar.StellarCommands import com.undefined.stellar.registrar.AbstractCommandRegistrar -import com.undefined.stellar.v1_20_6.BrigadierCommandHelper.dispatcher +import com.undefined.stellar.v1_20_4.BrigadierCommandHelper.dispatcher import org.bukkit.command.CommandSender object CommandRegistrar : AbstractCommandRegistrar {