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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 10 additions & 2 deletions surf-api-paper/surf-api-paper/api/surf-api-paper.api
Original file line number Diff line number Diff line change
Expand Up @@ -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 <init> (Ljava/lang/String;)V
public synthetic fun <init> (Ljava/lang/String;)V

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the one-argument constructor source-visible

For Java plugins that recompile against 3.32 and still instantiate new MiniMessageArgument("message"), this changes the old constructor to a synthetic member; javac ignores synthetic members during source resolution, so those callers no longer compile even though greedy defaults to false. Please keep a non-synthetic one-argument overload when adding the new boolean parameter.

Useful? React with 👍 / 👎.

public fun <init> (Ljava/lang/String;Z)V
public synthetic fun <init> (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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Component, String>(
TextArgument(nodeName),
open class MiniMessageArgument(
nodeName: String,
@IntroducedAt("3.32.0") greedy: Boolean = false,
) : CustomArgument<Component, String>(
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(
Expand All @@ -31,6 +38,13 @@ open class MiniMessageArgument(nodeName: String) : CustomArgument<Component, Str
inline fun CommandAPICommand.miniMessageArgument(
nodeName: String,
optional: Boolean = false,
@IntroducedAt("3.32.0") greedy: Boolean = false,
block: Argument<*>.() -> Unit = {},
): CommandAPICommand =
withArguments(MiniMessageArgument(nodeName).setOptional(optional).apply(block))
): 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))