diff --git a/gradle.properties b/gradle.properties index afbbbe249..f9e6e5a60 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,6 @@ org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled javaVersion=25 mcVersion=26.2 group=dev.slne.surf.api -version=3.31.0 +version=3.32.0 relocationPrefix=dev.slne.surf.api.libs snapshot=false diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/command/builder/CommandExceptionBuilder.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/command/builder/CommandExceptionBuilder.kt index 552c5296a..d0c6743d4 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/command/builder/CommandExceptionBuilder.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/command/builder/CommandExceptionBuilder.kt @@ -22,11 +22,11 @@ open class CommandExceptionBuilder( private val cursor: Int ) { /** - * Builds the command exception message with the default prefix ([Colors.PREFIX]). + * Builds the command exception message with the default prefix ([Colors.ERROR_PREFIX]). * * @return The built message */ - open fun build(): Component = build(Colors.PREFIX) + open fun build(): Component = build(Colors.ERROR_PREFIX) /** * Builds the command exception message with the given prefix. diff --git a/surf-api-paper/surf-api-paper/api/surf-api-paper.api b/surf-api-paper/surf-api-paper/api/surf-api-paper.api index b4ee7f2e2..55aa047b2 100644 --- a/surf-api-paper/surf-api-paper/api/surf-api-paper.api +++ b/surf-api-paper/surf-api-paper/api/surf-api-paper.api @@ -184,12 +184,20 @@ public final class dev/slne/surf/api/paper/command/args/AsyncSignedMessageArgume } public class dev/slne/surf/api/paper/command/args/MiniMessageArgument : dev/jorel/commandapi/arguments/CustomArgument { - public fun (Ljava/lang/String;)V + public synthetic fun (Ljava/lang/String;)V + public fun (Ljava/lang/String;Z)V + public synthetic fun (Ljava/lang/String;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V } public final class dev/slne/surf/api/paper/command/args/MiniMessageArgumentKt { - public static final fun miniMessageArgument (Ldev/jorel/commandapi/CommandAPICommand;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Ldev/jorel/commandapi/CommandAPICommand; + public static final synthetic fun miniMessageArgument (Ldev/jorel/commandapi/CommandAPICommand;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Ldev/jorel/commandapi/CommandAPICommand; + public static final fun miniMessageArgument (Ldev/jorel/commandapi/CommandAPICommand;Ljava/lang/String;ZZLkotlin/jvm/functions/Function1;)Ldev/jorel/commandapi/CommandAPICommand; + public static final synthetic fun miniMessageArgument (Ldev/jorel/commandapi/CommandTree;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;)Ldev/jorel/commandapi/CommandTree; + public static final fun miniMessageArgument (Ldev/jorel/commandapi/CommandTree;Ljava/lang/String;ZZLkotlin/jvm/functions/Function1;)Ldev/jorel/commandapi/CommandTree; public static synthetic fun miniMessageArgument$default (Ldev/jorel/commandapi/CommandAPICommand;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/jorel/commandapi/CommandAPICommand; + public static synthetic fun miniMessageArgument$default (Ldev/jorel/commandapi/CommandAPICommand;Ljava/lang/String;ZZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/jorel/commandapi/CommandAPICommand; + public static synthetic fun miniMessageArgument$default (Ldev/jorel/commandapi/CommandTree;Ljava/lang/String;ZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/jorel/commandapi/CommandTree; + public static synthetic fun miniMessageArgument$default (Ldev/jorel/commandapi/CommandTree;Ljava/lang/String;ZZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/jorel/commandapi/CommandTree; } public abstract class dev/slne/surf/api/paper/command/args/SuspendCustomArgument : dev/jorel/commandapi/arguments/CustomArgument { diff --git a/surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/command/args/MiniMessageArgument.kt b/surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/command/args/MiniMessageArgument.kt index 25de1c1cc..8360d6046 100644 --- a/surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/command/args/MiniMessageArgument.kt +++ b/surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/command/args/MiniMessageArgument.kt @@ -1,21 +1,28 @@ +@file:OptIn(ExperimentalVersionOverloading::class) + package dev.slne.surf.api.paper.command.args import dev.jorel.commandapi.CommandAPICommand +import dev.jorel.commandapi.CommandTree import dev.jorel.commandapi.arguments.Argument import dev.jorel.commandapi.arguments.CustomArgument +import dev.jorel.commandapi.arguments.GreedyStringArgument import dev.jorel.commandapi.arguments.TextArgument import dev.slne.surf.api.core.command.builder.CommandExceptionBuilder +import dev.slne.surf.api.core.minimessage.miniMessage import net.kyori.adventure.text.Component -import net.kyori.adventure.text.minimessage.MiniMessage import net.kyori.adventure.text.minimessage.ParsingException -open class MiniMessageArgument(nodeName: String) : CustomArgument( - TextArgument(nodeName), +open class MiniMessageArgument( + nodeName: String, + @IntroducedAt("3.32.0") greedy: Boolean = false, +) : CustomArgument( + if (greedy) GreedyStringArgument(nodeName) else TextArgument(nodeName), { info -> val raw = info.currentInput try { - MiniMessage.miniMessage().deserialize(raw) + miniMessage.deserialize(raw) } catch (e: ParsingException) { throw CustomArgumentException.fromAdventureComponent( CommandExceptionBuilder( @@ -31,6 +38,13 @@ open class MiniMessageArgument(nodeName: String) : CustomArgument.() -> Unit = {}, -): CommandAPICommand = - withArguments(MiniMessageArgument(nodeName).setOptional(optional).apply(block)) \ No newline at end of file +): CommandAPICommand = withArguments(MiniMessageArgument(nodeName, greedy).setOptional(optional).apply(block)) + +inline fun CommandTree.miniMessageArgument( + nodeName: String, + optional: Boolean = false, + @IntroducedAt("3.32.0") greedy: Boolean = false, + block: Argument<*>.() -> Unit = {} +): CommandTree = then(MiniMessageArgument(nodeName, greedy).setOptional(optional).apply(block)) \ No newline at end of file