Skip to content

Commit

Permalink
fix: toIdo() called on existing IdoArgumentType incorrectly wraps com…
Browse files Browse the repository at this point in the history
…mand twice

chore: Remove sample command in ido plugin class
  • Loading branch information
0ffz committed Oct 27, 2024
1 parent 63df32e commit dc58abe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,14 @@
package com.mineinabyss.idofront

import com.mineinabyss.idofront.commands.brigadier.Args
import com.mineinabyss.idofront.commands.brigadier.ArgsMinecraft
import com.mineinabyss.idofront.commands.brigadier.commands
import com.mineinabyss.idofront.commands.brigadier.executes
import com.mineinabyss.idofront.di.DI
import com.mineinabyss.idofront.plugin.listeners
import com.mineinabyss.idofront.serialization.recipes.options.IngredientOptionsListener
import kotlinx.coroutines.flow.merge
import org.bukkit.entity.Player
import org.bukkit.plugin.java.JavaPlugin

class IdofrontPlugin : JavaPlugin() {
override fun onEnable() {
val recipeOptionsListener = IngredientOptionsListener(this)
DI.add(recipeOptionsListener)
listeners(recipeOptionsListener)

commands {
"idofront" {
"msg" {
executes(
Args.string(),
ArgsMinecraft.player().resolve()
.map { it.single() }
.default { sender as? Player ?: fail("Receiver should be player") },
Args.integer(min = 0).default { 1 }
) { msg, player, times ->
repeat(times) {
player.sendMessage(msg)
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ open class IdoCommand(
// ArgumentType extensions

fun <T : Any> ArgumentType<T>.toIdo(): IdoArgumentType<T> = IdoArgumentType(
nativeType = (if (this is CustomArgumentType<*, *>) nativeType else this) as ArgumentType<Any>,
nativeType = (when (this) {
is CustomArgumentType<*, *> -> nativeType
is IdoArgumentType<T> -> nativeType
else -> this
}) as ArgumentType<Any>,
suggestions = null,
commandExamples = mutableListOf()
)
Expand Down

0 comments on commit dc58abe

Please sign in to comment.