diff --git a/pom.xml b/pom.xml index 8d9fa71..28c7ee4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.lupus LCommandFramework - 0.7.3 + 0.7.31 LCommandFramework diff --git a/src/main/java/org/lupus/commands/core/components/command/response/ArrayResponseComponent.kt b/src/main/java/org/lupus/commands/core/components/command/response/ArrayResponseComponent.kt index ef1d830..6f44e63 100644 --- a/src/main/java/org/lupus/commands/core/components/command/response/ArrayResponseComponent.kt +++ b/src/main/java/org/lupus/commands/core/components/command/response/ArrayResponseComponent.kt @@ -1,21 +1,26 @@ package org.lupus.commands.core.components.command.response import net.kyori.adventure.text.Component +import net.kyori.adventure.text.ComponentLike +import net.kyori.adventure.text.JoinConfiguration import net.kyori.adventure.text.minimessage.MiniMessage +import org.lupus.commands.core.components.command.response.arrays.ArrayResponseType +import org.lupus.commands.core.components.command.response.arrays.ComponentLikeResponse +import org.lupus.commands.core.components.command.response.arrays.StringResponse import org.lupus.commands.core.data.CommandLupi import org.lupus.commands.core.utils.StringUtil class ArrayResponseComponent(command: CommandLupi) : CommandResponseComponent(command, Array::class.java) { + val arrayResponseTypes = mutableListOf(ComponentLikeResponse(command), StringResponse(command)) + override fun run(input: Any): Component { input as Array<*> - if (input.first() is String) { - if (!StringUtil.isThatI18nSyntax(input.first() as String)) { - return MiniMessage.miniMessage().deserialize(input.first() as String) - } - - return StringUtil.getI18nSyntax(command.pluginRegistering, (input as Array).toList()).getI18nResponse() - } + for (arrayResponseType in arrayResponseTypes) { + if (arrayResponseType.check(input)) { + return arrayResponseType.componentResponse(input) + } + } return Component.text("") } -} \ No newline at end of file +} diff --git a/src/main/java/org/lupus/commands/core/components/command/response/arrays/ArrayResponseType.kt b/src/main/java/org/lupus/commands/core/components/command/response/arrays/ArrayResponseType.kt new file mode 100644 index 0000000..a1f8b90 --- /dev/null +++ b/src/main/java/org/lupus/commands/core/components/command/response/arrays/ArrayResponseType.kt @@ -0,0 +1,10 @@ +package org.lupus.commands.core.components.command.response.arrays + +import net.kyori.adventure.text.Component +import org.lupus.commands.core.data.CommandLupi + +interface ArrayResponseType { + val command: CommandLupi + fun check(array: Array<*>): Boolean + fun componentResponse(array: Array<*>): Component +} diff --git a/src/main/java/org/lupus/commands/core/components/command/response/arrays/ComponentLikeResponse.kt b/src/main/java/org/lupus/commands/core/components/command/response/arrays/ComponentLikeResponse.kt new file mode 100644 index 0000000..86ac4d1 --- /dev/null +++ b/src/main/java/org/lupus/commands/core/components/command/response/arrays/ComponentLikeResponse.kt @@ -0,0 +1,22 @@ +package org.lupus.commands.core.components.command.response.arrays + +import net.kyori.adventure.text.Component +import net.kyori.adventure.text.ComponentLike +import net.kyori.adventure.text.JoinConfiguration +import net.kyori.adventure.text.minimessage.MiniMessage +import org.lupus.commands.core.data.CommandLupi + +class ComponentLikeResponse(override val command: CommandLupi) : ArrayResponseType { + override fun check(array: Array<*>): Boolean { + return array.first() is ComponentLike + } + + override fun componentResponse(array: Array<*>): Component { + return Component.join( + JoinConfiguration.separator( + MiniMessage.miniMessage().deserialize("\n") + ), + (array as Array).toList() + ) + } +} diff --git a/src/main/java/org/lupus/commands/core/components/command/response/arrays/StringResponse.kt b/src/main/java/org/lupus/commands/core/components/command/response/arrays/StringResponse.kt new file mode 100644 index 0000000..be2c6d3 --- /dev/null +++ b/src/main/java/org/lupus/commands/core/components/command/response/arrays/StringResponse.kt @@ -0,0 +1,21 @@ +package org.lupus.commands.core.components.command.response.arrays + +import net.kyori.adventure.text.Component +import net.kyori.adventure.text.minimessage.MiniMessage +import org.lupus.commands.core.data.CommandLupi +import org.lupus.commands.core.utils.StringUtil + +class StringResponse(override val command: CommandLupi) : ArrayResponseType { + + override fun check(array: Array<*>): Boolean { + return array.first() is String + } + + override fun componentResponse(array: Array<*>): Component { + if (!StringUtil.isThatI18nSyntax(array.first() as String)) { + return MiniMessage.miniMessage().deserialize(array.first() as String) + } + + return StringUtil.getI18nSyntax(command.pluginRegistering, (array as Array).toList()).getI18nResponse() + } +} diff --git a/src/main/java/org/lupus/commands/core/scanner/DefaultModifiers.kt b/src/main/java/org/lupus/commands/core/scanner/DefaultModifiers.kt index f652722..8314ffb 100644 --- a/src/main/java/org/lupus/commands/core/scanner/DefaultModifiers.kt +++ b/src/main/java/org/lupus/commands/core/scanner/DefaultModifiers.kt @@ -6,6 +6,7 @@ import org.lupus.commands.core.scanner.modifiers.any.* import org.lupus.commands.core.scanner.modifiers.clazz.ContinuousMod import org.lupus.commands.core.scanner.modifiers.clazz.HelpMod import org.lupus.commands.core.scanner.modifiers.fields.DependencyModifier +import org.lupus.commands.core.scanner.modifiers.fields.NamedDependencyModifier import org.lupus.commands.core.scanner.modifiers.method.CMDPassMod import org.lupus.commands.core.scanner.modifiers.method.DefaultMod import org.lupus.commands.core.scanner.modifiers.method.FilterPassMod @@ -26,5 +27,5 @@ object DefaultModifiers { SyntaxMod, ) val paramModifiers = mutableListOf() - val fieldsModifier = mutableListOf(DependencyModifier) + val fieldsModifier = mutableListOf(DependencyModifier, NamedDependencyModifier) }