From dc58abef54352702ce0bdfc0b9cb1e94c6d48377 Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Sun, 27 Oct 2024 17:10:19 -0400 Subject: [PATCH] fix: toIdo() called on existing IdoArgumentType incorrectly wraps command twice chore: Remove sample command in ido plugin class --- .../mineinabyss/idofront/IdofrontPlugin.kt | 24 ------------------- .../idofront/commands/brigadier/IdoCommand.kt | 6 ++++- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/idofront-catalog-shaded/src/main/java/com/mineinabyss/idofront/IdofrontPlugin.kt b/idofront-catalog-shaded/src/main/java/com/mineinabyss/idofront/IdofrontPlugin.kt index 3fcabc1..f7c38b0 100644 --- a/idofront-catalog-shaded/src/main/java/com/mineinabyss/idofront/IdofrontPlugin.kt +++ b/idofront-catalog-shaded/src/main/java/com/mineinabyss/idofront/IdofrontPlugin.kt @@ -1,14 +1,8 @@ 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() { @@ -16,23 +10,5 @@ class IdofrontPlugin : JavaPlugin() { 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) - } - } - } - } - } } } diff --git a/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt b/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt index 2c11074..635abd3 100644 --- a/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt +++ b/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt @@ -187,7 +187,11 @@ open class IdoCommand( // ArgumentType extensions fun ArgumentType.toIdo(): IdoArgumentType = IdoArgumentType( - nativeType = (if (this is CustomArgumentType<*, *>) nativeType else this) as ArgumentType, + nativeType = (when (this) { + is CustomArgumentType<*, *> -> nativeType + is IdoArgumentType -> nativeType + else -> this + }) as ArgumentType, suggestions = null, commandExamples = mutableListOf() )