Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +32,6 @@ inline fun KommandSyntaxBuilder.executorAsync(
* @return The command executor
* @author oglassdev
*/
@KommandDSL
inline fun KommandSyntaxBuilder.executorBlocking(
crossinline block: @KommandDSL SuspendKommandExecutor
) =
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/net/bladehunt/kotstom/dsl/Event.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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> = DimensionType.OVERWORLD,
Expand Down
11 changes: 1 addition & 10 deletions src/main/kotlin/net/bladehunt/kotstom/dsl/item/Item.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import net.minestom.server.item.ItemStack
import net.minestom.server.item.Material

@DslMarker
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.PROPERTY)
@Target(AnnotationTarget.TYPE)
annotation class ItemDsl

/**
Expand Down Expand Up @@ -43,7 +43,6 @@ value class ItemLore(
*
* @author oglassdev
*/
@ItemDsl
inline fun ItemStack.Builder.lore(block: @ItemDsl ItemLore.() -> Unit) {
set(DataComponents.LORE, ItemLore(arrayListOf()).apply(block))
}
Expand All @@ -53,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) {
Expand All @@ -65,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) {
Expand All @@ -77,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) {
Expand All @@ -89,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) {
Expand All @@ -101,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) {
Expand All @@ -117,7 +111,6 @@ inline var ItemStack.Builder.unbreakable: Boolean
*
* @author oglassdev
*/
@ItemDsl
inline fun item(
material: Material = Material.STONE,
block: @ItemDsl ItemStack.Builder.() -> Unit,
Expand All @@ -128,13 +121,11 @@ inline fun item(
*
* @author oglassdev
*/
@ItemDsl
fun item(material: Material): ItemStack = ItemStack.of(material)

/**
* ItemStack builder extension DSL
*
* @author oglassdev
*/
@ItemDsl
inline fun ItemStack.builder(block: @ItemDsl ItemStack.Builder.() -> Unit): ItemStack = builder().apply(block).build()
5 changes: 1 addition & 4 deletions src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Kommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import net.minestom.server.command.builder.CommandExecutor
internal typealias KommandExecutor = context(CommandContext) (CommandSender) -> Unit

@DslMarker
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE)
@Target(AnnotationTarget.TYPE)
annotation class KommandDSL

/**
* Sets the default executor of the Kommand
*
* @author oglassdev
*/
@KommandDSL
inline fun Kommand.defaultExecutor(crossinline block: @KommandDSL KommandExecutor) =
CommandExecutor { sender, context -> block(context, sender) }
.also { defaultExecutor = it }
Expand All @@ -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)
Expand All @@ -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)
8 changes: 0 additions & 8 deletions src/main/kotlin/net/bladehunt/kotstom/dsl/kommand/Syntax.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ data class KommandSyntaxBuilder(
* @return The player-only command condition
* @author oglassdev
*/
@KommandDSL
fun onlyPlayers(): CommandCondition =
CommandCondition { commandSender, _ -> commandSender is Player }.also(conditions::add)

Expand All @@ -42,7 +41,6 @@ data class KommandSyntaxBuilder(
* @return The custom command condition
* @author oglassdev
*/
@KommandDSL
fun condition(
condition: CommandCondition
) {
Expand All @@ -56,7 +54,6 @@ data class KommandSyntaxBuilder(
* @return The command executor
* @author oglassdev
*/
@KommandDSL
inline fun executor(
crossinline block: @KommandDSL KommandExecutor
): CommandExecutor =
Expand All @@ -71,7 +68,6 @@ data class KommandSyntaxBuilder(
* @return The function providing the default value
* @author oglassdev
*/
@KommandDSL
inline fun <T> default(
argument: Argument<T>,
crossinline block: @KommandDSL (CommandSender) -> T
Expand All @@ -88,7 +84,6 @@ data class KommandSyntaxBuilder(
* @return The function providing the default value
* @author oglassdev
*/
@KommandDSL
inline fun default(
key: String,
crossinline block: @KommandDSL (CommandSender) -> Any
Expand Down Expand Up @@ -130,7 +125,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 =
Expand All @@ -157,7 +151,6 @@ inline fun Kommand.syntax(
* @param block The `SyntaxBuilder` logic
* @author oglassdev
*/
@KommandDSL
inline fun Kommand.buildSyntax(
vararg arguments: Argument<*>,
block: @KommandDSL KommandSyntaxBuilder.() -> Unit
Expand All @@ -173,7 +166,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()
Expand Down
Loading