diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index a2dad42c2..0eb86dd70 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -12,4 +12,5 @@ dependencies { implementation(libs.ksp.gradle.plugin) implementation(libs.kotlin.serialization) implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) + implementation(libs.asm) } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3a2181ad7..8fbe82cde 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.25.0 +version=3.26.0 relocationPrefix=dev.slne.surf.api.libs -snapshot=false +snapshot=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c874b51c6..df93bacfd 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,7 +23,7 @@ luckpermsplugin-bukkit = "v5.5.17-bukkit" # "luckpermsplugin" is written without scoreboard-library = "2.7.4" # Adventure -adventure-api = "4.26.1" +adventure-api = "5.1.1" # Velocity velocity-api = "3.5.0-SNAPSHOT" @@ -35,6 +35,8 @@ placeholder-api = "2.12.2" mccoroutine = "2.22.2" # Miscellaneous Libraries +asm = "9.8" +slf4j = "2.0.1" guava = "33.6.0-jre" caffeine = "3.2.4" caffeine-courotines = "3.0.4" @@ -128,6 +130,8 @@ mccoroutine-velocity-api = { module = "dev.slne.forks.mccoroutine:mccoroutine-ve mccoroutine-velocity-core = { module = "dev.slne.forks.mccoroutine:mccoroutine-velocity-core", version.ref = "mccoroutine" } # Miscellaneous Libraries +asm = { module = "org.ow2.asm:asm", version.ref = "asm" } +slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } guava = { module = "com.google.guava:guava", version.ref = "guava" } caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "caffeine" } caffeine-courotines = { module = "com.sksamuel.aedile:aedile-core", version.ref = "caffeine-courotines" } diff --git a/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/api/core/server/impl/nbt/FastCompoundBinaryTagImpl.kt b/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/api/core/server/impl/nbt/FastCompoundBinaryTagImpl.kt index bd838b692..c60a63fc2 100644 --- a/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/api/core/server/impl/nbt/FastCompoundBinaryTagImpl.kt +++ b/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/api/core/server/impl/nbt/FastCompoundBinaryTagImpl.kt @@ -5,8 +5,6 @@ import dev.slne.surf.api.core.util.freeze import dev.slne.surf.api.core.util.mutableObject2ObjectMapOf import dev.slne.surf.api.core.util.synchronize import net.kyori.adventure.nbt.* -import net.kyori.examination.ExaminableProperty -import net.kyori.examination.string.StringExaminer import java.util.function.Consumer import java.util.stream.Stream @@ -22,7 +20,6 @@ class FastCompoundBinaryTagImpl(synchronize: Boolean) : FastCompoundBinaryTag { override fun contains(key: String, type: BinaryTagType<*>): Boolean { val tag = tags[key] ?: return false - return type.test(tag.type()) } @@ -91,7 +88,6 @@ class FastCompoundBinaryTagImpl(synchronize: Boolean) : FastCompoundBinaryTag { override fun getByteArray(key: String, defaultValue: ByteArray?): ByteArray? { val tag = tags[key] as? ByteArrayBinaryTag ?: return defaultValue - return tag.value() } @@ -137,21 +133,15 @@ class FastCompoundBinaryTagImpl(synchronize: Boolean) : FastCompoundBinaryTag { override fun stream(): Stream> = tags.entries.stream() - override fun examinableProperties(): Stream = Stream.of( - ExaminableProperty.of("tags", tags) - ) - override fun iterator() = tags.object2ObjectEntrySet().iterator() override fun forEach(action: Consumer>) { tags.object2ObjectEntrySet().forEach(action) } - override fun examinableName(): String { - return type().toString() + override fun asBinaryTag(): CompoundBinaryTag { + return CompoundBinaryTag.from(tags) } - override fun toString(): String { - return examine(StringExaminer.simpleEscaping()) - } -} \ No newline at end of file + override fun toString(): String = "FastCompoundBinaryTag{tags=$tags}" +} diff --git a/surf-api-core/surf-api-core/api/surf-api-core.api b/surf-api-core/surf-api-core/api/surf-api-core.api index 7a087f62a..53872fe00 100644 --- a/surf-api-core/surf-api-core/api/surf-api-core.api +++ b/surf-api-core/surf-api-core/api/surf-api-core.api @@ -7160,16 +7160,22 @@ public final class dev/slne/surf/api/core/messages/CommonComponents { public final fun formatTime-gRj5Bb8 (JZZLnet/kyori/adventure/text/Component;Lnet/kyori/adventure/text/format/TextColor;)Lnet/kyori/adventure/text/Component; public static synthetic fun formatTime-gRj5Bb8$default (Ldev/slne/surf/api/core/messages/CommonComponents;JZZLnet/kyori/adventure/text/Component;Lnet/kyori/adventure/text/format/TextColor;ILjava/lang/Object;)Lnet/kyori/adventure/text/Component; public final synthetic fun getEM_DASH ()Lnet/kyori/adventure/text/TextComponent; + public final fun renderDisconnectMessage (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lnet/kyori/adventure/text/TextComponent; + public final fun renderDisconnectMessage (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Z)Lnet/kyori/adventure/text/TextComponent; public final fun renderDisconnectMessage (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lnet/kyori/adventure/text/TextComponent; public final fun renderDisconnectMessage (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Z)Lnet/kyori/adventure/text/TextComponent; public final fun renderDisconnectMessage (Lnet/kyori/adventure/text/TextComponent$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lnet/kyori/adventure/text/TextComponent; public final fun renderDisconnectMessage (Lnet/kyori/adventure/text/TextComponent$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Z)Lnet/kyori/adventure/text/TextComponent; + public static synthetic fun renderDisconnectMessage$default (Ldev/slne/surf/api/core/messages/CommonComponents;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lnet/kyori/adventure/text/TextComponent; public static synthetic fun renderDisconnectMessage$default (Ldev/slne/surf/api/core/messages/CommonComponents;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lnet/kyori/adventure/text/TextComponent; public static synthetic fun renderDisconnectMessage$default (Ldev/slne/surf/api/core/messages/CommonComponents;Lnet/kyori/adventure/text/TextComponent$Builder;Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lnet/kyori/adventure/text/TextComponent; + public final fun renderKickDisconnectMessage (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lnet/kyori/adventure/text/TextComponent; + public final fun renderKickDisconnectMessage (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Lkotlin/jvm/functions/Function1;Z)Lnet/kyori/adventure/text/TextComponent; public final fun renderKickDisconnectMessage (Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lnet/kyori/adventure/text/TextComponent; public final fun renderKickDisconnectMessage (Lkotlin/jvm/functions/Function1;Z)Lnet/kyori/adventure/text/TextComponent; public final fun renderKickDisconnectMessage (Lnet/kyori/adventure/text/TextComponent$Builder;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)Lnet/kyori/adventure/text/TextComponent; public final fun renderKickDisconnectMessage (Lnet/kyori/adventure/text/TextComponent$Builder;Lkotlin/jvm/functions/Function1;Z)Lnet/kyori/adventure/text/TextComponent; + public static synthetic fun renderKickDisconnectMessage$default (Ldev/slne/surf/api/core/messages/CommonComponents;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lnet/kyori/adventure/text/TextComponent; public static synthetic fun renderKickDisconnectMessage$default (Ldev/slne/surf/api/core/messages/CommonComponents;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lnet/kyori/adventure/text/TextComponent; public static synthetic fun renderKickDisconnectMessage$default (Ldev/slne/surf/api/core/messages/CommonComponents;Lnet/kyori/adventure/text/TextComponent$Builder;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lnet/kyori/adventure/text/TextComponent; } @@ -7646,21 +7652,15 @@ public final class dev/slne/surf/api/core/messages/builder/ComponentBuilderColor public static fun yellow (Ldev/slne/surf/api/core/messages/builder/ComponentBuilderColors;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Z[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; } -public abstract interface class dev/slne/surf/api/core/messages/builder/SurfComponentBuilder : dev/slne/surf/api/core/messages/builder/ComponentBuilderColors, net/kyori/adventure/text/TextComponent$Builder { +public abstract interface class dev/slne/surf/api/core/messages/builder/SurfComponentBuilder : dev/slne/surf/api/core/messages/builder/ComponentBuilderColors, net/kyori/adventure/text/ComponentLike { public static final field Companion Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder$Companion; public abstract fun append (Ljava/lang/Iterable;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun append (Ljava/lang/Iterable;)Lnet/kyori/adventure/text/ComponentBuilder; public fun append (Lkotlin/jvm/functions/Function1;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public abstract fun append (Lnet/kyori/adventure/text/Component;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun append (Lnet/kyori/adventure/text/Component;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun append (Lnet/kyori/adventure/text/ComponentBuilder;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun append (Lnet/kyori/adventure/text/ComponentBuilder;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun append (Lnet/kyori/adventure/text/ComponentLike;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun append (Lnet/kyori/adventure/text/ComponentLike;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun append ([Lnet/kyori/adventure/text/Component;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun append ([Lnet/kyori/adventure/text/Component;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun append ([Lnet/kyori/adventure/text/ComponentLike;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun append ([Lnet/kyori/adventure/text/ComponentLike;)Lnet/kyori/adventure/text/ComponentBuilder; public fun appendAsync (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public fun appendCollection (Ljava/lang/Iterable;Lkotlin/jvm/functions/Function1;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public fun appendCollectionNewLine (Ljava/lang/Iterable;Lnet/kyori/adventure/text/Component;Lkotlin/jvm/functions/Function1;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; @@ -7675,87 +7675,54 @@ public abstract interface class dev/slne/surf/api/core/messages/builder/SurfComp public fun appendMap (Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lnet/kyori/adventure/text/Component;Lnet/kyori/adventure/text/Component;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static synthetic fun appendMap$default (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/util/Map;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lnet/kyori/adventure/text/Component;Lnet/kyori/adventure/text/Component;ILjava/lang/Object;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public abstract fun appendNewline ()Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun appendNewline ()Lnet/kyori/adventure/text/ComponentBuilder; + public fun appendNewline (I)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public fun appendNewline (Lkotlin/jvm/functions/Function1;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public fun appendNewlineAsync (Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public abstract fun appendSpace ()Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun appendSpace ()Lnet/kyori/adventure/text/ComponentBuilder; + public fun appendText (Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public fun appendText (Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;Lkotlin/jvm/functions/Function1;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static synthetic fun appendText$default (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;ILjava/lang/Object;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static synthetic fun appendText$default (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public fun appendTime-gRj5Bb8 (JZZLnet/kyori/adventure/text/Component;Lnet/kyori/adventure/text/format/TextColor;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static synthetic fun appendTime-gRj5Bb8$default (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;JZZLnet/kyori/adventure/text/Component;Lnet/kyori/adventure/text/format/TextColor;ILjava/lang/Object;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public abstract fun applicableApply (Lnet/kyori/adventure/text/ComponentBuilderApplicable;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun applicableApply (Lnet/kyori/adventure/text/ComponentBuilderApplicable;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun apply (Ljava/util/function/Consumer;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun apply (Ljava/util/function/Consumer;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun applyDeep (Ljava/util/function/Consumer;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun applyDeep (Ljava/util/function/Consumer;)Lnet/kyori/adventure/text/ComponentBuilder; + public abstract fun build ()Lnet/kyori/adventure/text/TextComponent; public static fun builder ()Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public abstract fun children ()Ljava/util/List; + public fun clickCopiesToClipboard (Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public abstract fun clickEvent (Lnet/kyori/adventure/text/event/ClickEvent;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun clickEvent (Lnet/kyori/adventure/text/event/ClickEvent;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun clickEvent (Lnet/kyori/adventure/text/event/ClickEvent;)Lnet/kyori/adventure/text/format/StyleSetter; + public fun clickOpensUrl (Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public fun clickRunsCommand (Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public fun clickSuggestsCommand (Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public abstract fun color (Lnet/kyori/adventure/text/format/TextColor;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun color (Lnet/kyori/adventure/text/format/TextColor;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun color (Lnet/kyori/adventure/text/format/TextColor;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun colorIfAbsent (Lnet/kyori/adventure/text/format/TextColor;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun colorIfAbsent (Lnet/kyori/adventure/text/format/TextColor;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun colorIfAbsent (Lnet/kyori/adventure/text/format/TextColor;)Lnet/kyori/adventure/text/format/StyleSetter; + public abstract fun content ()Ljava/lang/String; public abstract fun content (Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun content (Ljava/lang/String;)Lnet/kyori/adventure/text/TextComponent$Builder; public abstract fun decorate (Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun decorate (Lnet/kyori/adventure/text/format/TextDecoration;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun decorate (Lnet/kyori/adventure/text/format/TextDecoration;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun decorate ([Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun decorate ([Lnet/kyori/adventure/text/format/TextDecoration;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun decorate ([Lnet/kyori/adventure/text/format/TextDecoration;)Lnet/kyori/adventure/text/format/MutableStyleSetter; - public synthetic fun decorate ([Lnet/kyori/adventure/text/format/TextDecoration;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun decoration (Lnet/kyori/adventure/text/format/TextDecoration;Lnet/kyori/adventure/text/format/TextDecoration$State;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun decoration (Lnet/kyori/adventure/text/format/TextDecoration;Lnet/kyori/adventure/text/format/TextDecoration$State;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun decoration (Lnet/kyori/adventure/text/format/TextDecoration;Lnet/kyori/adventure/text/format/TextDecoration$State;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun decoration (Lnet/kyori/adventure/text/format/TextDecoration;Z)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun decoration (Lnet/kyori/adventure/text/format/TextDecoration;Z)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun decoration (Lnet/kyori/adventure/text/format/TextDecoration;Z)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun decorationIfAbsent (Lnet/kyori/adventure/text/format/TextDecoration;Lnet/kyori/adventure/text/format/TextDecoration$State;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun decorationIfAbsent (Lnet/kyori/adventure/text/format/TextDecoration;Lnet/kyori/adventure/text/format/TextDecoration$State;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun decorationIfAbsent (Lnet/kyori/adventure/text/format/TextDecoration;Lnet/kyori/adventure/text/format/TextDecoration$State;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun decorations (Ljava/util/Map;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun decorations (Ljava/util/Map;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun decorations (Ljava/util/Map;)Lnet/kyori/adventure/text/format/MutableStyleSetter; - public synthetic fun decorations (Ljava/util/Map;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun decorations (Ljava/util/Set;Z)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun decorations (Ljava/util/Set;Z)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun decorations (Ljava/util/Set;Z)Lnet/kyori/adventure/text/format/MutableStyleSetter; - public synthetic fun decorations (Ljava/util/Set;Z)Lnet/kyori/adventure/text/format/StyleSetter; public fun ellipsis (Lnet/kyori/adventure/text/format/TextColor;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static synthetic fun ellipsis$default (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Lnet/kyori/adventure/text/format/TextColor;ILjava/lang/Object;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public abstract fun font (Lnet/kyori/adventure/key/Key;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun font (Lnet/kyori/adventure/key/Key;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun font (Lnet/kyori/adventure/key/Key;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun hoverEvent (Lnet/kyori/adventure/text/event/HoverEventSource;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun hoverEvent (Lnet/kyori/adventure/text/event/HoverEventSource;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun hoverEvent (Lnet/kyori/adventure/text/event/HoverEventSource;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun insertion (Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun insertion (Ljava/lang/String;)Lnet/kyori/adventure/text/ComponentBuilder; - public synthetic fun insertion (Ljava/lang/String;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun mapChildren (Ljava/util/function/Function;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun mapChildren (Ljava/util/function/Function;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun mapChildrenDeep (Ljava/util/function/Function;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun mapChildrenDeep (Ljava/util/function/Function;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun mergeStyle (Lnet/kyori/adventure/text/Component;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun mergeStyle (Lnet/kyori/adventure/text/Component;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun mergeStyle (Lnet/kyori/adventure/text/Component;Ljava/util/Set;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun mergeStyle (Lnet/kyori/adventure/text/Component;Ljava/util/Set;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun mergeStyle (Lnet/kyori/adventure/text/Component;[Lnet/kyori/adventure/text/format/Style$Merge;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun mergeStyle (Lnet/kyori/adventure/text/Component;[Lnet/kyori/adventure/text/format/Style$Merge;)Lnet/kyori/adventure/text/ComponentBuilder; public fun note (Ljava/lang/Object;[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public abstract fun resetStyle ()Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun resetStyle ()Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun shadowColor (Lnet/kyori/adventure/util/ARGBLike;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun shadowColor (Lnet/kyori/adventure/util/ARGBLike;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun shadowColorIfAbsent (Lnet/kyori/adventure/util/ARGBLike;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun shadowColorIfAbsent (Lnet/kyori/adventure/util/ARGBLike;)Lnet/kyori/adventure/text/format/StyleSetter; public abstract fun style (Ljava/util/function/Consumer;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun style (Ljava/util/function/Consumer;)Lnet/kyori/adventure/text/ComponentBuilder; public abstract fun style (Lnet/kyori/adventure/text/format/Style;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; - public synthetic fun style (Lnet/kyori/adventure/text/format/Style;)Lnet/kyori/adventure/text/ComponentBuilder; public fun text (CLnet/kyori/adventure/text/format/TextColor;[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public fun text (Ljava/lang/Number;Lnet/kyori/adventure/text/format/TextColor;[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public fun text (Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; @@ -7803,9 +7770,14 @@ public final class dev/slne/surf/api/core/messages/builder/SurfComponentBuilder$ public static fun appendNewWarningPrefixedLine (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;I)V public static fun appendNewWarningPrefixedLine (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Lkotlin/jvm/functions/Function1;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun appendNewWarningPrefixedLineAsync (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static fun appendNewline (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;I)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun appendNewline (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Lkotlin/jvm/functions/Function1;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun appendNewlineAsync (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static fun appendSuccessPrefix (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static fun appendText (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static fun appendText (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;Lkotlin/jvm/functions/Function1;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static synthetic fun appendText$default (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;ILjava/lang/Object;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static synthetic fun appendText$default (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun appendTime-gRj5Bb8 (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;JZZLnet/kyori/adventure/text/Component;Lnet/kyori/adventure/text/format/TextColor;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static synthetic fun appendTime-gRj5Bb8$default (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;JZZLnet/kyori/adventure/text/Component;Lnet/kyori/adventure/text/format/TextColor;ILjava/lang/Object;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun appendWarningPrefix (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; @@ -7821,6 +7793,10 @@ public final class dev/slne/surf/api/core/messages/builder/SurfComponentBuilder$ public static fun blue (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/Number;[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun blue (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun blue (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Z[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static fun clickCopiesToClipboard (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static fun clickOpensUrl (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static fun clickRunsCommand (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; + public static fun clickSuggestsCommand (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun coloredComponent (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;CLnet/kyori/adventure/text/format/TextColor;[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun coloredComponent (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/Number;Lnet/kyori/adventure/text/format/TextColor;[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; public static fun coloredComponent (Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder;Ljava/lang/String;Lnet/kyori/adventure/text/format/TextColor;[Lnet/kyori/adventure/text/format/TextDecoration;)Ldev/slne/surf/api/core/messages/builder/SurfComponentBuilder; @@ -8919,12 +8895,66 @@ public final class dev/slne/surf/api/core/nbt/CollectionBinaryTagKt { public static final fun asCollectionOrNull (Lnet/kyori/adventure/nbt/BinaryTag;)Lnet/kyori/adventure/nbt/BinaryTag; } -public abstract interface class dev/slne/surf/api/core/nbt/FastCompoundBinaryTag : net/kyori/adventure/nbt/CompoundBinaryTag { +public abstract interface class dev/slne/surf/api/core/nbt/FastCompoundBinaryTag : net/kyori/adventure/nbt/BinaryTagLike { + public synthetic fun asBinaryTag ()Lnet/kyori/adventure/nbt/BinaryTag; + public abstract fun asBinaryTag ()Lnet/kyori/adventure/nbt/CompoundBinaryTag; public abstract fun clear ()V + public abstract fun contains (Ljava/lang/String;)Z + public abstract fun contains (Ljava/lang/String;Lnet/kyori/adventure/nbt/BinaryTagType;)Z + public abstract fun forEach (Ljava/util/function/Consumer;)V + public abstract fun get (Ljava/lang/String;)Lnet/kyori/adventure/nbt/BinaryTag; + public abstract fun getByte (Ljava/lang/String;B)B + public static synthetic fun getByte$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;BILjava/lang/Object;)B + public abstract fun getByteArray (Ljava/lang/String;)[B + public abstract fun getByteArray (Ljava/lang/String;[B)[B + public abstract fun getCompound (Ljava/lang/String;Lnet/kyori/adventure/nbt/CompoundBinaryTag;)Lnet/kyori/adventure/nbt/CompoundBinaryTag; + public static synthetic fun getCompound$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Lnet/kyori/adventure/nbt/CompoundBinaryTag;ILjava/lang/Object;)Lnet/kyori/adventure/nbt/CompoundBinaryTag; + public abstract fun getDouble (Ljava/lang/String;D)D + public static synthetic fun getDouble$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;DILjava/lang/Object;)D + public abstract fun getFloat (Ljava/lang/String;F)F + public static synthetic fun getFloat$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;FILjava/lang/Object;)F + public abstract fun getInt (Ljava/lang/String;I)I + public static synthetic fun getInt$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;IILjava/lang/Object;)I + public abstract fun getIntArray (Ljava/lang/String;)[I + public abstract fun getIntArray (Ljava/lang/String;[I)[I + public abstract fun getList (Ljava/lang/String;Lnet/kyori/adventure/nbt/BinaryTagType;Lnet/kyori/adventure/nbt/ListBinaryTag;)Lnet/kyori/adventure/nbt/ListBinaryTag; + public abstract fun getList (Ljava/lang/String;Lnet/kyori/adventure/nbt/ListBinaryTag;)Lnet/kyori/adventure/nbt/ListBinaryTag; + public static synthetic fun getList$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Lnet/kyori/adventure/nbt/BinaryTagType;Lnet/kyori/adventure/nbt/ListBinaryTag;ILjava/lang/Object;)Lnet/kyori/adventure/nbt/ListBinaryTag; + public static synthetic fun getList$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Lnet/kyori/adventure/nbt/ListBinaryTag;ILjava/lang/Object;)Lnet/kyori/adventure/nbt/ListBinaryTag; + public abstract fun getLong (Ljava/lang/String;J)J + public static synthetic fun getLong$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;JILjava/lang/Object;)J + public abstract fun getLongArray (Ljava/lang/String;)[J + public abstract fun getLongArray (Ljava/lang/String;[J)[J + public abstract fun getShort (Ljava/lang/String;S)S + public static synthetic fun getShort$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;SILjava/lang/Object;)S + public abstract fun getString (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; + public static synthetic fun getString$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String; + public abstract fun isEmpty ()Z public abstract fun iterator ()Lit/unimi/dsi/fastutil/objects/ObjectIterator; - public synthetic fun iterator ()Ljava/util/Iterator; public abstract fun keySet ()Lit/unimi/dsi/fastutil/objects/ObjectSet; - public synthetic fun keySet ()Ljava/util/Set; + public abstract fun put (Ljava/lang/String;Lnet/kyori/adventure/nbt/BinaryTag;)Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag; + public abstract fun put (Ljava/util/Map;)Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag; + public abstract fun put (Lnet/kyori/adventure/nbt/CompoundBinaryTag;)Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag; + public abstract fun remove (Ljava/lang/String;Ljava/util/function/Consumer;)Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag; + public static synthetic fun remove$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Ljava/util/function/Consumer;ILjava/lang/Object;)Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag; + public abstract fun size ()I + public abstract fun stream ()Ljava/util/stream/Stream; + public fun type ()Lnet/kyori/adventure/nbt/BinaryTagType; +} + +public final class dev/slne/surf/api/core/nbt/FastCompoundBinaryTag$DefaultImpls { + public static synthetic fun getByte$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;BILjava/lang/Object;)B + public static synthetic fun getCompound$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Lnet/kyori/adventure/nbt/CompoundBinaryTag;ILjava/lang/Object;)Lnet/kyori/adventure/nbt/CompoundBinaryTag; + public static synthetic fun getDouble$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;DILjava/lang/Object;)D + public static synthetic fun getFloat$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;FILjava/lang/Object;)F + public static synthetic fun getInt$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;IILjava/lang/Object;)I + public static synthetic fun getList$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Lnet/kyori/adventure/nbt/BinaryTagType;Lnet/kyori/adventure/nbt/ListBinaryTag;ILjava/lang/Object;)Lnet/kyori/adventure/nbt/ListBinaryTag; + public static synthetic fun getList$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Lnet/kyori/adventure/nbt/ListBinaryTag;ILjava/lang/Object;)Lnet/kyori/adventure/nbt/ListBinaryTag; + public static synthetic fun getLong$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;JILjava/lang/Object;)J + public static synthetic fun getShort$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;SILjava/lang/Object;)S + public static synthetic fun getString$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String; + public static synthetic fun remove$default (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;Ljava/lang/String;Ljava/util/function/Consumer;ILjava/lang/Object;)Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag; + public static fun type (Ldev/slne/surf/api/core/nbt/FastCompoundBinaryTag;)Lnet/kyori/adventure/nbt/BinaryTagType; } public final class dev/slne/surf/api/core/nbt/FastCompoundBinaryTagKt { diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/CommonComponents.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/CommonComponents.kt index 11729c98b..4940819bb 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/CommonComponents.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/CommonComponents.kt @@ -11,6 +11,7 @@ import dev.slne.surf.api.core.messages.adventure.appendNewline import dev.slne.surf.api.core.messages.adventure.appendText import dev.slne.surf.api.core.messages.adventure.clickOpensUrl import dev.slne.surf.api.core.messages.adventure.text +import dev.slne.surf.api.core.messages.builder.SurfComponentBuilder import dev.slne.surf.api.core.util.mutableObjectListOf import net.kyori.adventure.text.Component import net.kyori.adventure.text.JoinConfiguration @@ -205,6 +206,32 @@ object CommonComponents { return builder.build() } + inline fun renderKickDisconnectMessage( + builder: SurfComponentBuilder, + messageRenderer: SurfComponentBuilder.() -> Unit, + footerRenderer: SurfComponentBuilder.() -> Unit = { }, + ): TextComponent { + with(builder) { + append(DISCONNECT_HEADER) + appendText("DU WURDEST VOM SERVER GEWORFEN", ERROR) + appendNewline(3) + messageRenderer() + appendNewline(3) + footerRenderer() + } + + return builder.build() + } + + inline fun renderKickDisconnectMessage( + builder: SurfComponentBuilder, + messageRenderer: SurfComponentBuilder.() -> Unit, + issue: Boolean, + ) = renderKickDisconnectMessage(builder, messageRenderer) { + if (issue) append(ISSUE_FOOTER) + else append(RETRY_LATER_FOOTER) + } + /** * Renders a structured kick message with an automatic issue or retry footer. * @@ -397,6 +424,24 @@ object CommonComponents { return builder.build() } + inline fun renderDisconnectMessage( + builder: SurfComponentBuilder, + disconnectReason: @NoLowercase String, + suggestHelp: SurfComponentBuilder.() -> Unit, + footerRenderer: SurfComponentBuilder.() -> Unit = { }, + ): TextComponent { + with(builder) { + append(DISCONNECT_HEADER) + appendText(disconnectReason.uppercase(), ERROR) + appendNewline(3) + suggestHelp() + appendNewline(3) + footerRenderer() + } + + return builder.build() + } + /** * Renders a structured disconnection message with an automatic issue or retry footer. * @@ -469,6 +514,16 @@ object CommonComponents { else append(RETRY_LATER_FOOTER) } + inline fun renderDisconnectMessage( + builder: SurfComponentBuilder, + disconnectReason: @NoLowercase String, + suggestHelp: SurfComponentBuilder.() -> Unit, + issue: Boolean, + ) = renderDisconnectMessage(builder, disconnectReason, suggestHelp) { + if (issue) append(ISSUE_FOOTER) + else append(RETRY_LATER_FOOTER) + } + /** * Formats a collection into a comma-separated list component. * diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/callback-extension.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/callback-extension.kt index 90fa51510..dbad1a96a 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/callback-extension.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/callback-extension.kt @@ -1,9 +1,7 @@ -@file:Suppress("DEPRECATION") - package dev.slne.surf.api.core.messages.adventure import net.kyori.adventure.audience.Audience -import net.kyori.adventure.text.BuildableComponent +import net.kyori.adventure.text.Component import net.kyori.adventure.text.ComponentBuilder import net.kyori.adventure.text.event.ClickCallback import net.kyori.adventure.text.event.ClickEvent @@ -12,24 +10,20 @@ import kotlin.experimental.ExperimentalTypeInference import kotlin.time.Duration import kotlin.time.toJavaDuration -@Suppress("DEPRECATION") -fun , B : ComponentBuilder> ComponentBuilder.clickCallback( +fun > ComponentBuilder.clickCallback( callback: ClickCallback, ) = clickEvent(ClickEvent.callback(callback)) -@Suppress("DEPRECATION") -fun , B : ComponentBuilder> ComponentBuilder.clickCallbackWithOptions( +fun > ComponentBuilder.clickCallbackWithOptions( builder: ClickCallbackWithOptionsBuilder.() -> Unit, ) = clickEvent(ClickCallbackWithOptionsBuilder(Audience::class.java).apply(builder).build()) -@Suppress("DEPRECATION") -inline fun , B : ComponentBuilder> ComponentBuilder.clickCallbackTyped( +inline fun > ComponentBuilder.clickCallbackTyped( callback: ClickCallback, ) = clickEvent(ClickEvent.callback(ClickCallback.widen(callback, T::class.java))) @OptIn(ExperimentalTypeInference::class) -@Suppress("DEPRECATION") -inline fun , B : ComponentBuilder> ComponentBuilder.clickCallbackTypedWithOptions( +inline fun > ComponentBuilder.clickCallbackTypedWithOptions( @BuilderInference builder: ClickCallbackWithOptionsBuilder.() -> Unit ) = clickEvent(ClickCallbackWithOptionsBuilder(T::class.java).apply(builder).build()) @@ -66,7 +60,7 @@ class ClickCallbackWithOptionsBuilder @PublishedApi internal const } @PublishedApi - internal fun build(): ClickEvent { + internal fun build(): ClickEvent<*> { val callback = callback ?: return ClickEvent.callback { } val callbackWithPermission = permission ?.let { permission -> callback.requiringPermission(permission, permissionOtherwise) } @@ -74,4 +68,4 @@ class ClickCallbackWithOptionsBuilder @PublishedApi internal const return ClickEvent.callback(ClickCallback.widen(callbackWithPermission, type), options) } -} \ No newline at end of file +} diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/component-extension.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/component-extension.kt index a12a101d1..31bf0af8f 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/component-extension.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/component-extension.kt @@ -1,9 +1,6 @@ -@file:Suppress("DEPRECATION") - package dev.slne.surf.api.core.messages.adventure import dev.slne.surf.api.core.messages.builder.SurfComponentBuilder -import net.kyori.adventure.text.BuildableComponent import net.kyori.adventure.text.Component import net.kyori.adventure.text.ComponentBuilder import net.kyori.adventure.text.TextComponent @@ -28,8 +25,7 @@ inline fun buildText(block: SurfComponentBuilder.() -> Unit): TextComponent { * @param color The optional text color. * @return The modified builder instance. */ -@Suppress("DEPRECATION") -fun , B : ComponentBuilder> ComponentBuilder.appendText( +fun > ComponentBuilder.appendText( text: String, color: TextColor? = null, ) = append(Component.text(text, color)) @@ -43,8 +39,7 @@ fun , B : ComponentBuilder> ComponentBuilder< * @param block The configuration block for the text component. * @return The modified builder instance. */ -@Suppress("DEPRECATION") -fun , B : ComponentBuilder> ComponentBuilder.appendText( +fun > ComponentBuilder.appendText( text: String, color: TextColor? = null, block: TextComponent.Builder.() -> Unit, @@ -56,8 +51,7 @@ fun , B : ComponentBuilder> ComponentBuilder< * @param url The URL to open on click. * @return The modified builder instance. */ -@Suppress("DEPRECATION") -fun , B : ComponentBuilder> ComponentBuilder.clickOpensUrl( +fun > ComponentBuilder.clickOpensUrl( url: String, ) = clickEvent(ClickEvent.openUrl(url)) @@ -67,8 +61,7 @@ fun , B : ComponentBuilder> ComponentBuilder< * @param command The command to run on click. * @return The modified builder instance. */ -@Suppress("DEPRECATION") -fun , B : ComponentBuilder> ComponentBuilder.clickRunsCommand( +fun > ComponentBuilder.clickRunsCommand( command: String, ) = clickEvent(ClickEvent.runCommand(command)) @@ -78,8 +71,7 @@ fun , B : ComponentBuilder> ComponentBuilder< * @param command The command to suggest on click. * @return The modified builder instance. */ -@Suppress("DEPRECATION") -fun , B : ComponentBuilder> ComponentBuilder.clickSuggestsCommand( +fun > ComponentBuilder.clickSuggestsCommand( command: String, ) = clickEvent(ClickEvent.suggestCommand(command)) @@ -89,8 +81,7 @@ fun , B : ComponentBuilder> ComponentBuilder< * @param value The value to copy to the clipboard on click. * @return The modified builder instance. */ -@Suppress("DEPRECATION") -fun , B : ComponentBuilder> ComponentBuilder.clickCopiesToClipboard( +fun > ComponentBuilder.clickCopiesToClipboard( value: String, ) = clickEvent(ClickEvent.copyToClipboard(value)) @@ -100,8 +91,7 @@ fun , B : ComponentBuilder> ComponentBuilder< * @param amount The number of newline characters to append. * @return The modified builder instance. */ -@Suppress("DEPRECATION") -fun , B : ComponentBuilder> ComponentBuilder.appendNewline( +fun > ComponentBuilder.appendNewline( amount: Int, ) = repeat(amount) { appendNewline() } diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/identity-extensions.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/identity-extensions.kt index 32d5fb26a..7ada34c67 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/identity-extensions.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/adventure/identity-extensions.kt @@ -17,7 +17,7 @@ import java.util.* * val myPointer = pointer(myKey) * ``` */ -inline fun pointer(key: Key) = Pointer.pointer(V::class.java, key) +inline fun pointer(key: Key) = Pointer.pointer(V::class.java, key) /** * Creates an [Identity] instance using the provided [UUID]. diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/builder/SurfComponentBuilder.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/builder/SurfComponentBuilder.kt index 55bb50c78..06a4c17d0 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/builder/SurfComponentBuilder.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/builder/SurfComponentBuilder.kt @@ -22,7 +22,7 @@ import java.util.function.Function import kotlin.time.Duration @ApiStatus.NonExtendable -interface SurfComponentBuilder : TextComponent.Builder, ComponentBuilderColors { +interface SurfComponentBuilder : ComponentBuilderColors, ComponentLike { companion object { @JvmStatic fun builder(): SurfComponentBuilder = SurfComponentBuilderImpl(Component.text()) @@ -44,6 +44,8 @@ interface SurfComponentBuilder : TextComponent.Builder, ComponentBuilderColors { suspend fun appendNewlineAsync(block: suspend SurfComponentBuilder.() -> Unit) = appendNewline().appendAsync(block) + fun appendNewline(amount: Int): SurfComponentBuilder = apply { repeat(amount) { appendNewline() } } + fun text(text: String, color: TextColor? = null, vararg decoration: TextDecoration) = append(Component.text(text, color, *decoration)) @@ -63,6 +65,24 @@ interface SurfComponentBuilder : TextComponent.Builder, ComponentBuilderColors { } ) + fun appendText(text: String, color: TextColor? = null) = this.text(text, color) + + fun appendText( + text: String, + color: TextColor? = null, + block: TextComponent.Builder.() -> Unit + ): SurfComponentBuilder { + val builder = Component.text().content(text) + if (color != null) builder.color(color) + builder.apply(block) + return append(builder.build()) + } + + fun clickOpensUrl(url: String) = clickEvent(ClickEvent.openUrl(url)) + fun clickRunsCommand(command: String) = clickEvent(ClickEvent.runCommand(command)) + fun clickSuggestsCommand(command: String) = clickEvent(ClickEvent.suggestCommand(command)) + fun clickCopiesToClipboard(value: String) = clickEvent(ClickEvent.copyToClipboard(value)) + fun note(any: Any, vararg decoration: TextDecoration) = text(any.toString(), NOTE, *decoration) fun ellipsis(color: TextColor? = SPACER) = append(CommonComponents.ELLIPSIS.color(color)) @@ -128,55 +148,58 @@ interface SurfComponentBuilder : TextComponent.Builder, ComponentBuilderColors { timeColor: TextColor = VARIABLE_VALUE, ) = append(CommonComponents.formatTime(time, showSeconds, shortForms, separator, timeColor)) - override fun content(content: String): SurfComponentBuilder - override fun append(builder: ComponentBuilder<*, *>): SurfComponentBuilder - override fun append(component: Component): SurfComponentBuilder - override fun append(component: ComponentLike): SurfComponentBuilder - override fun append(components: Iterable): SurfComponentBuilder - override fun append(vararg components: Component): SurfComponentBuilder - override fun append(vararg components: ComponentLike): SurfComponentBuilder - override fun appendNewline(): SurfComponentBuilder - override fun appendSpace(): SurfComponentBuilder - override fun applicableApply(applicable: ComponentBuilderApplicable): SurfComponentBuilder - override fun apply(consumer: Consumer>): SurfComponentBuilder - override fun applyDeep(action: Consumer>): SurfComponentBuilder - override fun clickEvent(event: ClickEvent?): SurfComponentBuilder - override fun color(color: TextColor?): SurfComponentBuilder - override fun colorIfAbsent(color: TextColor?): SurfComponentBuilder - override fun decorate(decoration: TextDecoration): SurfComponentBuilder - override fun decorate(vararg decorations: TextDecoration): SurfComponentBuilder - override fun decoration(decoration: TextDecoration, flag: Boolean): SurfComponentBuilder - override fun decoration( + fun content(): String + fun content(content: String): SurfComponentBuilder + fun children(): List + + fun build(): TextComponent + + fun append(builder: ComponentBuilder<*, *>): SurfComponentBuilder + fun append(component: Component): SurfComponentBuilder + fun append(component: ComponentLike): SurfComponentBuilder + fun append(components: Iterable): SurfComponentBuilder + fun append(vararg components: Component): SurfComponentBuilder + fun append(vararg components: ComponentLike): SurfComponentBuilder + fun appendNewline(): SurfComponentBuilder + fun appendSpace(): SurfComponentBuilder + fun applicableApply(applicable: ComponentBuilderApplicable): SurfComponentBuilder + fun apply(consumer: Consumer>): SurfComponentBuilder + fun applyDeep(action: Consumer>): SurfComponentBuilder + fun clickEvent(event: ClickEvent<*>?): SurfComponentBuilder + fun color(color: TextColor?): SurfComponentBuilder + fun colorIfAbsent(color: TextColor?): SurfComponentBuilder + fun decorate(decoration: TextDecoration): SurfComponentBuilder + fun decorate(vararg decorations: TextDecoration): SurfComponentBuilder + fun decoration(decoration: TextDecoration, flag: Boolean): SurfComponentBuilder + fun decoration( decoration: TextDecoration, state: TextDecoration.State, ): SurfComponentBuilder - override fun decorationIfAbsent( + fun decorationIfAbsent( decoration: TextDecoration, state: TextDecoration.State, ): SurfComponentBuilder - override fun decorations(decorations: Map): SurfComponentBuilder - override fun decorations( - decorations: Set, + fun decorations(decorations: Map): SurfComponentBuilder + fun decorations( + decorations: Set, flag: Boolean, ): SurfComponentBuilder - override fun font(font: Key?): SurfComponentBuilder - override fun hoverEvent(source: HoverEventSource<*>?): SurfComponentBuilder - override fun insertion(insertion: String?): SurfComponentBuilder - - @Suppress("DEPRECATION") - override fun mapChildren(function: Function?, out BuildableComponent<*, *>?>): SurfComponentBuilder - - @Suppress("DEPRECATION") - override fun mapChildrenDeep(function: Function?, out BuildableComponent<*, *>?>): SurfComponentBuilder - override fun mergeStyle(that: Component): SurfComponentBuilder - override fun mergeStyle(that: Component, merges: Set): SurfComponentBuilder - override fun mergeStyle(that: Component, vararg merges: Style.Merge): SurfComponentBuilder - override fun resetStyle(): SurfComponentBuilder - override fun style(consumer: Consumer): SurfComponentBuilder - override fun style(style: Style): SurfComponentBuilder - override fun shadowColor(argb: ARGBLike?): SurfComponentBuilder - override fun shadowColorIfAbsent(argb: ARGBLike?): SurfComponentBuilder + fun font(font: Key?): SurfComponentBuilder + fun hoverEvent(source: HoverEventSource<*>?): SurfComponentBuilder + fun insertion(insertion: String?): SurfComponentBuilder + + fun mapChildren(function: Function): SurfComponentBuilder + + fun mapChildrenDeep(function: Function): SurfComponentBuilder + fun mergeStyle(that: Component): SurfComponentBuilder + fun mergeStyle(that: Component, merges: Set): SurfComponentBuilder + fun mergeStyle(that: Component, vararg merges: Style.Merge): SurfComponentBuilder + fun resetStyle(): SurfComponentBuilder + fun style(consumer: Consumer): SurfComponentBuilder + fun style(style: Style): SurfComponentBuilder + fun shadowColor(argb: ARGBLike?): SurfComponentBuilder + fun shadowColorIfAbsent(argb: ARGBLike?): SurfComponentBuilder } diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/builder/SurfComponentBuilderImpl.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/builder/SurfComponentBuilderImpl.kt index aa79a0778..f49c5206b 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/builder/SurfComponentBuilderImpl.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/builder/SurfComponentBuilderImpl.kt @@ -19,10 +19,14 @@ internal class SurfComponentBuilderImpl(private val delegate: TextComponent.Buil } override fun content(content: String) = withDelegate { content(content) } + override fun content() = delegate.content() + override fun children(): List = delegate.children() + override fun build() = delegate.build() + override fun append(builder: ComponentBuilder<*, *>) = withDelegate { append(builder) } override fun append(component: Component) = withDelegate { append(component) } override fun append(component: ComponentLike) = withDelegate { append(component) } - override fun append(components: Iterable) = withDelegate { append(components) } + override fun append(components: Iterable) = withDelegate { append(components) } override fun append(vararg components: Component) = withDelegate { append(*components) } override fun append(vararg components: ComponentLike) = withDelegate { append(*components) } override fun appendNewline() = withDelegate { appendNewline() } @@ -36,7 +40,7 @@ internal class SurfComponentBuilderImpl(private val delegate: TextComponent.Buil override fun applyDeep(action: Consumer>) = withDelegate { applyDeep(action) } - override fun clickEvent(event: ClickEvent?) = withDelegate { clickEvent(event) } + override fun clickEvent(event: ClickEvent<*>?) = withDelegate { clickEvent(event) } override fun color(color: TextColor?) = withDelegate { color(color) } override fun colorIfAbsent(color: TextColor?) = withDelegate { colorIfAbsent(color) } override fun decorate(decoration: TextDecoration) = withDelegate { decorate(decoration) } @@ -58,30 +62,33 @@ internal class SurfComponentBuilderImpl(private val delegate: TextComponent.Buil state: TextDecoration.State, ) = withDelegate { decorationIfAbsent(decoration, state) } - override fun decorations(decorations: Map) = - withDelegate { decorations(decorations) } + override fun decorations(decorations: Map): SurfComponentBuilderImpl { + delegate.decorations(decorations) + return this + } override fun decorations( - decorations: Set, + decorations: Set, flag: Boolean, - ) = withDelegate { decorations(decorations, flag) } + ): SurfComponentBuilderImpl { + delegate.decorations(decorations, flag) + return this + } override fun font(font: Key?) = withDelegate { font(font) } override fun hoverEvent(source: HoverEventSource<*>?) = withDelegate { hoverEvent(source) } override fun insertion(insertion: String?) = withDelegate { insertion(insertion) } - @Suppress("DEPRECATION") - override fun mapChildren(function: Function?, out BuildableComponent<*, *>?>) = + override fun mapChildren(function: Function) = withDelegate { mapChildren(function) } - @Suppress("DEPRECATION") - override fun mapChildrenDeep(function: Function?, out BuildableComponent<*, *>?>) = + override fun mapChildrenDeep(function: Function) = withDelegate { mapChildrenDeep(function) } override fun mergeStyle(that: Component) = withDelegate { mergeStyle(that) } override fun mergeStyle( that: Component, - merges: Set, + merges: Set, ) = withDelegate { mergeStyle(that, merges) } override fun mergeStyle( @@ -90,11 +97,12 @@ internal class SurfComponentBuilderImpl(private val delegate: TextComponent.Buil ) = withDelegate { mergeStyle(that, *merges) } override fun resetStyle() = withDelegate { resetStyle() } - override fun style(consumer: Consumer) = withDelegate { style(consumer) } + override fun style(consumer: Consumer) = withDelegate { style(consumer) } override fun style(style: Style) = withDelegate { style(style) } override fun shadowColor(argb: ARGBLike?) = withDelegate { shadowColor(argb) } override fun shadowColorIfAbsent(argb: ARGBLike?) = withDelegate { shadowColorIfAbsent(argb) } - override fun content() = delegate.content() - override fun children() = delegate.children() - override fun build() = delegate.build() -} \ No newline at end of file + + override fun asComponent(): Component { + return build() + } +} diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/pagination/PaginationClickEventProvider.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/pagination/PaginationClickEventProvider.kt index 2bd3e622b..edb6f0219 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/pagination/PaginationClickEventProvider.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/pagination/PaginationClickEventProvider.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.launch import net.kyori.adventure.text.event.ClickEvent fun interface PaginationClickEventProvider { - fun getCallback(targetPage: Int, pagination: Pagination, content: Collection): ClickEvent + fun getCallback(targetPage: Int, pagination: Pagination, content: Collection): ClickEvent<*> companion object { private object DEFAULT : PaginationClickEventProvider { @@ -13,7 +13,7 @@ fun interface PaginationClickEventProvider { targetPage: Int, pagination: Pagination, content: Collection, - ): ClickEvent = ClickEvent.callback { clicker -> + ): ClickEvent<*> = ClickEvent.callback { clicker -> clicker.sendMessage(pagination.renderComponent(content, targetPage)) } } @@ -30,7 +30,7 @@ fun interface SuspendPaginationClickEventProvider { targetPage: Int, pagination: SuspendPagination, content: Collection - ): ClickEvent + ): ClickEvent<*> companion object { private object DEFAULT : SuspendPaginationClickEventProvider { @@ -38,7 +38,7 @@ fun interface SuspendPaginationClickEventProvider { targetPage: Int, pagination: SuspendPagination, content: Collection - ): ClickEvent = ClickEvent.callback { clicker -> + ): ClickEvent<*> = ClickEvent.callback { clicker -> launch { clicker.sendMessage(pagination.renderComponent(content, targetPage)) } diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/pagination/PaginationRenderer.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/pagination/PaginationRenderer.kt index a5e3b424c..4d49a201c 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/pagination/PaginationRenderer.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/messages/pagination/PaginationRenderer.kt @@ -47,7 +47,7 @@ interface SuspendPaginationRenderer { previousPage: PageButton, nextPage: PageButton, lastPage: PageButton, - changePageEvent: suspend CoroutineScope.(Int) -> ClickEvent?, + changePageEvent: suspend CoroutineScope.(Int) -> ClickEvent<*>?, ): Component = buildText { if (page == 1 && pages == 1) { append(renderFooterSingle(width)) @@ -91,13 +91,13 @@ interface SuspendPaginationRenderer { suspend fun CoroutineScope.renderPreviousPageButton( button: PageButton, - clickEvent: ClickEvent?, + clickEvent: ClickEvent<*>?, enabled: Boolean, ): Component = PaginationRenderer.DEFAULT.renderPreviousPageButton(button, clickEvent, enabled) suspend fun CoroutineScope.renderNextPageButton( button: PageButton, - clickEvent: ClickEvent?, + clickEvent: ClickEvent<*>?, enabled: Boolean, ): Component = PaginationRenderer.DEFAULT.renderNextPageButton(button, clickEvent, enabled) @@ -155,7 +155,7 @@ interface PaginationRenderer { previousPage: PageButton, nextPage: PageButton, lastPage: PageButton, - changePageEvent: (Int) -> ClickEvent?, + changePageEvent: (Int) -> ClickEvent<*>?, ): Component = buildText { if (page == 1 && pages == 1) { append(renderFooterSingle(width)) @@ -180,7 +180,7 @@ interface PaginationRenderer { fun renderPreviousPageButton( button: PageButton, - clickEvent: ClickEvent?, + clickEvent: ClickEvent<*>?, enabled: Boolean, ): Component = buildText { appendSpace() @@ -194,7 +194,7 @@ interface PaginationRenderer { fun renderNextPageButton( button: PageButton, - clickEvent: ClickEvent?, + clickEvent: ClickEvent<*>?, enabled: Boolean, ): Component = buildText { appendSpace() diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/nbt/FastCompoundBinaryTag.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/nbt/FastCompoundBinaryTag.kt index 45c2585f1..40e7258fd 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/nbt/FastCompoundBinaryTag.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/nbt/FastCompoundBinaryTag.kt @@ -3,50 +3,70 @@ package dev.slne.surf.api.core.nbt import it.unimi.dsi.fastutil.objects.Object2ObjectMap import it.unimi.dsi.fastutil.objects.ObjectIterator import it.unimi.dsi.fastutil.objects.ObjectSet -import net.kyori.adventure.nbt.BinaryTag -import net.kyori.adventure.nbt.CompoundBinaryTag +import net.kyori.adventure.nbt.* import org.jetbrains.annotations.UnmodifiableView +import java.util.function.Consumer +import java.util.stream.Stream /** - * A mutable, high-performance implementation of CompoundBinaryTag backed by fastutil collections. + * A mutable, high-performance replacement for CompoundBinaryTag backed by fastutil collections. * - * This interface extends CompoundBinaryTag with additional mutation capabilities and optimized - * iteration through fastutil's specialized collection types. - * - * **Important:** This implementation violates the immutability principle of CompoundBinaryTag. - * All operations (put, remove, etc.) mutate the tag directly, unlike the standard CompoundBinaryTag - * which is immutable and returns a new tag for each operation. + * This interface mirrors the CompoundBinaryTag API but cannot extend it since CompoundBinaryTag + * became sealed in Adventure 5.1.1. All operations (put, remove, etc.) mutate the tag directly, + * unlike the standard CompoundBinaryTag which is immutable. */ -@Suppress("NonExtendableApiUsage") -interface FastCompoundBinaryTag : CompoundBinaryTag { +interface FastCompoundBinaryTag : BinaryTagLike { + + fun type(): BinaryTagType = BinaryTagTypes.COMPOUND + + fun contains(key: String): Boolean + fun contains(key: String, type: BinaryTagType<*>): Boolean + + fun keySet(): @UnmodifiableView ObjectSet + + fun get(key: String): BinaryTag? + fun size(): Int + fun isEmpty(): Boolean + + fun put(key: String, tag: BinaryTag): FastCompoundBinaryTag + fun put(tag: CompoundBinaryTag): FastCompoundBinaryTag + fun put(tags: Map): FastCompoundBinaryTag + fun remove(key: String, removed: Consumer? = null): FastCompoundBinaryTag - /** - * Removes all key-value mappings from this compound tag. - */ fun clear() + fun getByte(key: String, defaultValue: Byte = 0): Byte + fun getShort(key: String, defaultValue: Short = 0): Short + fun getInt(key: String, defaultValue: Int = 0): Int + fun getLong(key: String, defaultValue: Long = 0L): Long + fun getFloat(key: String, defaultValue: Float = 0f): Float + fun getDouble(key: String, defaultValue: Double = 0.0): Double + fun getByteArray(key: String): ByteArray + fun getByteArray(key: String, defaultValue: ByteArray?): ByteArray? + fun getString(key: String, defaultValue: String? = null): String? + fun getList(key: String, defaultValue: ListBinaryTag? = null): ListBinaryTag? + fun getList( + key: String, + expectedType: BinaryTagType, + defaultValue: ListBinaryTag? = null, + ): ListBinaryTag? - /** - * Returns an optimized set view of the keys contained in this compound tag. - * - * @return An ObjectSet providing efficient key iteration - */ - override fun keySet(): @UnmodifiableView ObjectSet + fun getCompound(key: String, defaultValue: CompoundBinaryTag? = null): CompoundBinaryTag? + fun getIntArray(key: String): IntArray + fun getIntArray(key: String, defaultValue: IntArray?): IntArray? + fun getLongArray(key: String): LongArray + fun getLongArray(key: String, defaultValue: LongArray?): LongArray? - /** - * Returns an optimized iterator over the entries in this compound tag. - * - * @return An ObjectIterator for efficient entry traversal - */ - override fun iterator(): ObjectIterator> + fun stream(): Stream> + fun iterator(): ObjectIterator> + fun forEach(action: Consumer>) + + override fun asBinaryTag(): CompoundBinaryTag } /** * Wraps this CompoundBinaryTag in a mutable FastCompoundBinaryTag for improved performance. * - * The returned tag is mutable and all operations modify the tag directly, unlike the immutable - * CompoundBinaryTag interface. - * * @param synchronize If true, wraps the underlying map with synchronization for thread-safe access * @return A mutable FastCompoundBinaryTag backed by fastutil collections */ @@ -59,4 +79,4 @@ fun CompoundBinaryTag.fast(synchronize: Boolean = false) = * @param synchronize If true, wraps the underlying map with synchronization for thread-safe access * @return A mutable FastCompoundBinaryTag backed by fastutil collections */ -fun CompoundBinaryTag.Builder.buildFast(synchronize: Boolean = false) = build().fast(synchronize) \ No newline at end of file +fun CompoundBinaryTag.Builder.buildFast(synchronize: Boolean = false) = build().fast(synchronize) diff --git a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/util/service-util.kt b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/util/service-util.kt index 5c9bba25e..f47da559e 100644 --- a/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/util/service-util.kt +++ b/surf-api-core/surf-api-core/src/main/kotlin/dev/slne/surf/api/core/util/service-util.kt @@ -12,5 +12,9 @@ import java.util.* * @return the service instance of type [T] * @throws ServiceConfigurationError if the service of type [T] is not available */ -inline fun requiredService(): T = Services.serviceWithFallback(T::class.java) - .orElseThrow { ServiceConfigurationError("Service ${T::class.java.name} not available") } \ No newline at end of file +inline fun requiredService(): T = Services.serviceWithFallback( + ServiceLoader.load( + T::class.java, + getCallerClass()?.classLoader ?: T::class.java.classLoader + ), T::class.java +).orElseThrow { ServiceConfigurationError("Service ${T::class.java.name} not available") } \ No newline at end of file diff --git a/surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/PaperBoostrapper.kt b/surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/PaperBoostrapper.kt index 0cc227811..1f3f95652 100644 --- a/surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/PaperBoostrapper.kt +++ b/surf-api-paper/surf-api-paper-server/src/main/kotlin/dev/slne/surf/api/paper/server/PaperBoostrapper.kt @@ -7,8 +7,10 @@ import kotlinx.coroutines.runBlocking @Suppress("unused", "UnstableApiUsage") class PaperBoostrapper : PluginBootstrap { - override fun bootstrap(bootstrapContext: BootstrapContext) = runBlocking { - PaperInstance.bootstrap() + override fun bootstrap(bootstrapContext: BootstrapContext) { + runBlocking { + PaperInstance.bootstrap() + } } override fun createPlugin(context: PluginProviderContext) = PaperMain() diff --git a/surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/dialog/builder/DialogActionBuilder.kt b/surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/dialog/builder/DialogActionBuilder.kt index 57146603f..4717aeceb 100644 --- a/surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/dialog/builder/DialogActionBuilder.kt +++ b/surf-api-paper/surf-api-paper/src/main/kotlin/dev/slne/surf/api/paper/dialog/builder/DialogActionBuilder.kt @@ -23,7 +23,7 @@ class DialogActionBuilder { private var action: DialogAction? = null - fun staticAction(clickEvent: ClickEvent) { + fun staticAction(clickEvent: ClickEvent<*>) { action = DialogAction.staticAction(clickEvent) } diff --git a/surf-api-shared/surf-api-shared-public/build.gradle.kts b/surf-api-shared/surf-api-shared-public/build.gradle.kts index a4934ac7e..4d7b722d8 100644 --- a/surf-api-shared/surf-api-shared-public/build.gradle.kts +++ b/surf-api-shared/surf-api-shared-public/build.gradle.kts @@ -13,6 +13,7 @@ kotlin { dependencies { compileOnlyApi(libs.adventure.api) compileOnlyApi(libs.adventure.text.logger.slf4j) + compileOnlyApi(libs.slf4j) compileOnlyApi(libs.adventure.text.minimessage) compileOnlyApi(libs.adventure.serializer.gson) compileOnlyApi(libs.adventure.serializer.legacy)