From ff41cdbee939d5e809722be0c6a70324dc7115ad Mon Sep 17 00:00:00 2001 From: oglassdev <23040613+oglassdev@users.noreply.github.com> Date: Wed, 14 Oct 2026 18:50:32 -0400 Subject: [PATCH 1/2] refactor(dsl): move DSL markers to where they take effect Kotlin 2.4 warns that @DslMarker annotations on functions and properties have no effect. Drop them from functions whose lambda parameter is already marked, mark KommandSyntaxBuilder itself, and narrow each marker's @Target so the no-op placement can't come back. @ItemDsl stays on the ItemStack.Builder properties, with the warning suppressed, since that is the only way IDEs highlight them. --- .../bladehunt/kotstom/coroutines/kommand/KommandExt.kt | 2 -- .../bladehunt/kotstom/coroutines/kommand/SyntaxExt.kt | 2 -- src/main/kotlin/net/bladehunt/kotstom/dsl/Event.kt | 2 +- .../net/bladehunt/kotstom/dsl/instance/Instance.kt | 3 +-- src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt | 9 ++++----- .../kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt | 5 +---- .../kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt | 9 +-------- 7 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/main/kotlin/net/bladehunt/kotstom/coroutines/kommand/KommandExt.kt b/src/main/kotlin/net/bladehunt/kotstom/coroutines/kommand/KommandExt.kt index d5f150c..bc21177 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/coroutines/kommand/KommandExt.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/coroutines/kommand/KommandExt.kt @@ -21,7 +21,6 @@ internal typealias SuspendKommandExecutor = suspend context(CommandContext) (Com * @param block The suspending code to run * @author oglassdev */ -@KommandDSL inline fun Kommand.defaultExecutorAsync( context: CoroutineContext = MinestomDispatcher, crossinline block: @KommandDSL SuspendKommandExecutor @@ -37,7 +36,6 @@ inline fun Kommand.defaultExecutorAsync( * @param block The suspending code to run * @author oglassdev */ -@KommandDSL inline fun Kommand.defaultExecutorBlocking( coroutineContext: CoroutineContext = Dispatchers.Default, crossinline block: @KommandDSL SuspendKommandExecutor diff --git a/src/main/kotlin/net/bladehunt/kotstom/coroutines/kommand/SyntaxExt.kt b/src/main/kotlin/net/bladehunt/kotstom/coroutines/kommand/SyntaxExt.kt index 7952207..4d1f6f6 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/coroutines/kommand/SyntaxExt.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/coroutines/kommand/SyntaxExt.kt @@ -16,7 +16,6 @@ import kotlin.coroutines.CoroutineContext * @return The command executor * @author oglassdev */ -@KommandDSL inline fun KommandSyntaxBuilder.executorAsync( context: CoroutineContext = MinestomDispatcher, crossinline block: @KommandDSL SuspendKommandExecutor @@ -33,7 +32,6 @@ inline fun KommandSyntaxBuilder.executorAsync( * @return The command executor * @author oglassdev */ -@KommandDSL inline fun KommandSyntaxBuilder.executorBlocking( crossinline block: @KommandDSL SuspendKommandExecutor ) = diff --git a/src/main/kotlin/net/bladehunt/kotstom/dsl/Event.kt b/src/main/kotlin/net/bladehunt/kotstom/dsl/Event.kt index 54bbdb9..9d303e2 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/dsl/Event.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/dsl/Event.kt @@ -5,7 +5,7 @@ import net.minestom.server.event.EventListener import net.minestom.server.event.EventNode @DslMarker -@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE) +@Target(AnnotationTarget.TYPE) annotation class EventDSL /** diff --git a/src/main/kotlin/net/bladehunt/kotstom/dsl/instance/Instance.kt b/src/main/kotlin/net/bladehunt/kotstom/dsl/instance/Instance.kt index 915ccc4..2ec5685 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/dsl/instance/Instance.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/dsl/instance/Instance.kt @@ -12,7 +12,7 @@ import net.minestom.server.world.DimensionType import java.util.* @DslMarker -@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.PROPERTY) +@Target(AnnotationTarget.TYPE) annotation class InstanceDsl inline var InstanceContainer.chunkAutoLoad: Boolean @@ -28,7 +28,6 @@ inline fun InstanceContainer.generator(crossinline block: GenerationUnit.() -> U block(it) } -@InstanceDsl inline fun buildInstance( registries: Registries = MinecraftServer.getRegistries(), dimensionType: RegistryKey = DimensionType.OVERWORLD, diff --git a/src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt b/src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt index 79a4524..ba4547f 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt @@ -1,3 +1,6 @@ +// @ItemDsl on the ItemStack.Builder properties only drives IDE DSL highlighting +@file:Suppress("DSL_MARKER_APPLIED_TO_WRONG_TARGET") + package net.bladehunt.kotstom.dsl.item import net.bladehunt.kotstom.extension.adventure.asMini @@ -7,7 +10,7 @@ import net.minestom.server.item.ItemStack import net.minestom.server.item.Material @DslMarker -@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.PROPERTY) +@Target(AnnotationTarget.TYPE, AnnotationTarget.PROPERTY) annotation class ItemDsl /** @@ -43,7 +46,6 @@ value class ItemLore( * * @author oglassdev */ -@ItemDsl inline fun ItemStack.Builder.lore(block: @ItemDsl ItemLore.() -> Unit) { set(DataComponents.LORE, ItemLore(arrayListOf()).apply(block)) } @@ -117,7 +119,6 @@ inline var ItemStack.Builder.unbreakable: Boolean * * @author oglassdev */ -@ItemDsl inline fun item( material: Material = Material.STONE, block: @ItemDsl ItemStack.Builder.() -> Unit, @@ -128,7 +129,6 @@ inline fun item( * * @author oglassdev */ -@ItemDsl fun item(material: Material): ItemStack = ItemStack.of(material) /** @@ -136,5 +136,4 @@ fun item(material: Material): ItemStack = ItemStack.of(material) * * @author oglassdev */ -@ItemDsl inline fun ItemStack.builder(block: @ItemDsl ItemStack.Builder.() -> Unit): ItemStack = builder().apply(block).build() diff --git a/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt b/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt index 1dd55d3..e049540 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt @@ -8,7 +8,7 @@ import net.minestom.server.command.builder.CommandExecutor internal typealias KommandExecutor = context(CommandContext) (CommandSender) -> Unit @DslMarker -@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE) +@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE) annotation class KommandDSL /** @@ -16,7 +16,6 @@ annotation class KommandDSL * * @author oglassdev */ -@KommandDSL inline fun Kommand.defaultExecutor(crossinline block: @KommandDSL KommandExecutor) = CommandExecutor { sender, context -> block(context, sender) } .also { defaultExecutor = it } @@ -27,7 +26,6 @@ inline fun Kommand.defaultExecutor(crossinline block: @KommandDSL KommandExecuto * @param block The suspending code to run * @author oglassdev */ -@KommandDSL inline fun Kommand.subkommand(name: String, vararg aliases: String, block: @KommandDSL Kommand.() -> Unit): Kommand = Kommand(name, *aliases).apply(block).also { command -> addSubcommand(command) @@ -39,6 +37,5 @@ inline fun Kommand.subkommand(name: String, vararg aliases: String, block: @Komm * @see net.bladehunt.kotstom.command.Kommand * @author oglassdev */ -@KommandDSL inline fun kommand(name: String, vararg aliases: String, block: @KommandDSL Kommand.() -> Unit): Kommand = Kommand(name, *aliases).apply(block) diff --git a/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt b/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt index 3f071cb..d711bc0 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt @@ -19,6 +19,7 @@ import java.util.function.Function * @property arguments The list of command arguments * @author oglassdev */ +@KommandDSL data class KommandSyntaxBuilder( val conditions: MutableList = arrayListOf(), var executor: CommandExecutor? = null, @@ -31,7 +32,6 @@ data class KommandSyntaxBuilder( * @return The player-only command condition * @author oglassdev */ - @KommandDSL fun onlyPlayers(): CommandCondition = CommandCondition { commandSender, _ -> commandSender is Player }.also(conditions::add) @@ -42,7 +42,6 @@ data class KommandSyntaxBuilder( * @return The custom command condition * @author oglassdev */ - @KommandDSL fun condition( condition: CommandCondition ) { @@ -56,7 +55,6 @@ data class KommandSyntaxBuilder( * @return The command executor * @author oglassdev */ - @KommandDSL inline fun executor( crossinline block: @KommandDSL KommandExecutor ): CommandExecutor = @@ -71,7 +69,6 @@ data class KommandSyntaxBuilder( * @return The function providing the default value * @author oglassdev */ - @KommandDSL inline fun default( argument: Argument, crossinline block: @KommandDSL (CommandSender) -> T @@ -88,7 +85,6 @@ data class KommandSyntaxBuilder( * @return The function providing the default value * @author oglassdev */ - @KommandDSL inline fun default( key: String, crossinline block: @KommandDSL (CommandSender) -> Any @@ -130,7 +126,6 @@ data class KommandSyntaxBuilder( * @param block The executor logic * @author oglassdev */ -@KommandDSL inline fun Kommand.syntax( vararg arguments: Argument<*>, crossinline condition: @KommandDSL (sender: CommandSender, label: String?) -> Boolean = @@ -157,7 +152,6 @@ inline fun Kommand.syntax( * @param block The `SyntaxBuilder` logic * @author oglassdev */ -@KommandDSL inline fun Kommand.buildSyntax( vararg arguments: Argument<*>, block: @KommandDSL KommandSyntaxBuilder.() -> Unit @@ -173,7 +167,6 @@ inline fun Kommand.buildSyntax( * @param block The `SyntaxBuilder` logic. * @author oglassdev */ -@KommandDSL inline fun Kommand.buildSyntax(block: @KommandDSL KommandSyntaxBuilder.() -> Unit) = KommandSyntaxBuilder().let { it.block() From 25723ef6d944520a633335068ebe7a92212e1783 Mon Sep 17 00:00:00 2001 From: oglassdev <23040613+oglassdev@users.noreply.github.com> Date: Wed, 14 Oct 2026 18:52:28 -0400 Subject: [PATCH 2/2] refactor(dsl): drop DSL markers kept only for IDE highlighting Removes @ItemDsl from the ItemStack.Builder properties along with its warning suppression, and the class-level @KommandDSL on KommandSyntaxBuilder. Every marker now targets TYPE only. --- src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt | 10 +--------- .../net/bladehunt/kotstom/dsl/kommand/Kommand.kt | 2 +- .../kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt | 1 - 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt b/src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt index ba4547f..f60d402 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt @@ -1,6 +1,3 @@ -// @ItemDsl on the ItemStack.Builder properties only drives IDE DSL highlighting -@file:Suppress("DSL_MARKER_APPLIED_TO_WRONG_TARGET") - package net.bladehunt.kotstom.dsl.item import net.bladehunt.kotstom.extension.adventure.asMini @@ -10,7 +7,7 @@ import net.minestom.server.item.ItemStack import net.minestom.server.item.Material @DslMarker -@Target(AnnotationTarget.TYPE, AnnotationTarget.PROPERTY) +@Target(AnnotationTarget.TYPE) annotation class ItemDsl /** @@ -55,7 +52,6 @@ inline fun ItemStack.Builder.lore(block: @ItemDsl ItemLore.() -> Unit) { * * @author oglassdev */ -@ItemDsl inline var ItemStack.Builder.amount: Int get() = throw NotImplementedError("Cannot get amount from ItemStack.Builder") set(value) { @@ -67,7 +63,6 @@ inline var ItemStack.Builder.amount: Int * * @author oglassdev */ -@ItemDsl inline var ItemStack.Builder.itemName: Component get() = throw NotImplementedError("Cannot get ItemComponent from ItemStack.Builder") set(value) { @@ -79,7 +74,6 @@ inline var ItemStack.Builder.itemName: Component * * @author oglassdev */ -@ItemDsl inline var ItemStack.Builder.customName: Component get() = throw NotImplementedError("Cannot get ItemComponent from ItemStack.Builder") set(value) { @@ -91,7 +85,6 @@ inline var ItemStack.Builder.customName: Component * * @author oglassdev */ -@ItemDsl inline var ItemStack.Builder.damage: Int get() = throw NotImplementedError("Cannot get ItemComponent from ItemStack.Builder") set(value) { @@ -103,7 +96,6 @@ inline var ItemStack.Builder.damage: Int * * @author oglassdev */ -@ItemDsl inline var ItemStack.Builder.unbreakable: Boolean get() = throw NotImplementedError("Cannot get ItemComponent from ItemStack.Builder") set(value) { diff --git a/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt b/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt index e049540..ed26434 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt @@ -8,7 +8,7 @@ import net.minestom.server.command.builder.CommandExecutor internal typealias KommandExecutor = context(CommandContext) (CommandSender) -> Unit @DslMarker -@Target(AnnotationTarget.CLASS, AnnotationTarget.TYPE) +@Target(AnnotationTarget.TYPE) annotation class KommandDSL /** diff --git a/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt b/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt index d711bc0..82e363e 100644 --- a/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt +++ b/src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt @@ -19,7 +19,6 @@ import java.util.function.Function * @property arguments The list of command arguments * @author oglassdev */ -@KommandDSL data class KommandSyntaxBuilder( val conditions: MutableList = arrayListOf(), var executor: CommandExecutor? = null,