Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9b41c11
refactor: simplify SurfCoreApi companion object and instance retrieval
twisti-dev Feb 7, 2026
9865169
refactor: introduce SurfMiniMessageHolder for centralized MiniMessage…
twisti-dev Feb 7, 2026
b5ddbd6
refactor: remove empty file
twisti-dev Feb 7, 2026
bff820d
refactor: suppress deprecation warnings for DazzlConf usage in config…
twisti-dev Feb 7, 2026
e36b563
refactor: enhance small caps conversion with CharSequence extension a…
twisti-dev Feb 7, 2026
63276e3
refactor: enhance VoxelLineTracer with detailed documentation and usa…
twisti-dev Feb 7, 2026
2c4521c
refactor: replace TranslationRegistry with TranslationStore for impro…
twisti-dev Feb 7, 2026
5953629
Merge branch 'version/1.21.11' into refactor/refactor
twisti-dev Feb 8, 2026
69c4e72
feat: add suspend pagination support with new builder and renderer in…
twisti-dev Feb 8, 2026
68769bb
refactor: improve documentation and color descriptions in Colors.kt
twisti-dev Feb 8, 2026
a96b9a6
refactor: update warning color and adjust variable value color in Col…
twisti-dev Feb 8, 2026
e35199a
refactor: update variable key color in Colors.kt
twisti-dev Feb 8, 2026
3a3b9d7
refactor: rename MAP_SEPERATOR to MAP_SEPARATOR and update references
twisti-dev Feb 8, 2026
7b56262
refactor: enhance formatTime function for improved readability and ef…
twisti-dev Feb 8, 2026
57200db
refactor: correct spelling of MAP_SEPARATOR and enhance documentation…
twisti-dev Feb 8, 2026
29c6699
refactor: suppress EnumEntryName warning in DefaultFontInfo.kt
twisti-dev Feb 8, 2026
5a59d8d
refactor: enhance CollectionBinaryTag with additional methods and doc…
twisti-dev Feb 8, 2026
ad6eeb7
refactor: enhance FastCompoundBinaryTag with additional methods and d…
twisti-dev Feb 8, 2026
f1475e2
refactor: add utility functions for Audience UUID and permission hand…
twisti-dev Feb 9, 2026
a659f1f
refactor: add click callback extension functions for Audience handling
twisti-dev Feb 9, 2026
ea2f89f
refactor: update title duration properties to use default values from…
twisti-dev Feb 9, 2026
dbfee42
refactor: integrate Apache Commons Math3 for enhanced random number g…
twisti-dev Feb 9, 2026
a02587f
refactor: introduce ProxyCreationException and ProxyInvocationExcepti…
twisti-dev Feb 9, 2026
0330ce9
refactor: implement custom cache expiry policy for player lookups and…
twisti-dev Feb 9, 2026
f73bc12
refactor: mark BlockStateFactory and BlockStateFactoryImpl as deprecated
twisti-dev Feb 9, 2026
4e7837c
refactor: enhance PlayerLookupService with cache statistics and resul…
twisti-dev Feb 9, 2026
1d93a52
refactor: mark ItemStackFactory, LocationFactory, and ParticleFactory…
twisti-dev Feb 10, 2026
485c61e
refactor: enhance date and reflection utilities with additional forma…
twisti-dev Feb 10, 2026
2ee469c
refactor: update requiredService function to throw ServiceConfigurati…
twisti-dev Feb 10, 2026
9968e4e
refactor: enhance SurfTypeParameterMatcher with improved documentatio…
twisti-dev Feb 10, 2026
5ba1658
refactor: improve documentation and structure of utility functions in…
twisti-dev Feb 10, 2026
4c642d9
Merge branch 'version/1.21.11' into refactor/refactor
twisti-dev Feb 10, 2026
4f816ed
chore(abi): dump abi
twisti-dev Feb 10, 2026
824ad36
refactor: deprecate getEM_DASH function for binary compatibility and …
twisti-dev Feb 10, 2026
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=1.21.11
group=dev.slne.surf
version=1.21.11-2.58.0
version=1.21.11-2.59.0
relocationPrefix=dev.slne.surf.surfapi.libs
snapshot=false
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ gson = "2.13.2"
commons-lang3 = "3.20.0"
commons-text = "1.15.0"
commons-math4-core = "4.0-beta1"
commons-math3 = "3.6.1"
plugin-yml-paper = "0.8.0"
spongepowered-math = "2.0.1"
fastutil = "8.5.18"
Expand Down Expand Up @@ -139,6 +140,7 @@ gson = { module = "com.google.code.gson:gson", version.ref = "gson" }
commons-lang3 = { module = "org.apache.commons:commons-lang3", version.ref = "commons-lang3" }
commons-text = { module = "org.apache.commons:commons-text", version.ref = "commons-text" }
commons-math4-core = { module = "org.apache.commons:commons-math4-core", version.ref = "commons-math4-core" }
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
spongepowered-math = { module = "org.spongepowered:math", version.ref = "spongepowered-math" }
fastutil = { module = "it.unimi.dsi:fastutil", version.ref = "fastutil" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
Expand Down
1 change: 1 addition & 0 deletions surf-api-bukkit/surf-api-bukkit-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
paperLibrary(libs.flogger)
paperLibrary(libs.flogger.slf4j.backend)
paperLibrary(libs.commons.math4.core)
paperLibrary(libs.commons.math3)
paperLibrary(libs.aide.reflection)
api(libs.mccoroutine.folia.api)
api(libs.mccoroutine.folia.core)
Expand Down
352 changes: 320 additions & 32 deletions surf-api-core/surf-api-core-api/api/surf-api-core-api.api

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions surf-api-core/surf-api-core-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
api(libs.configurate.kotlin)
compileOnlyApi(libs.flogger)
compileOnlyApi(libs.commons.math4.core)
compileOnlyApi(libs.commons.math3)
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

commons-math3 is referenced from surf-api-core-api code (e.g., RandomSelectorImpl uses org.apache.commons.math3.*), so declaring it as compileOnlyApi will compile but can fail at runtime for consumers that depend on surf-api-core-api without also pulling a server module. Consider using api(libs.commons.math3) (or otherwise ensuring it is on the runtime classpath transitively) so RandomSelector works out-of-the-box.

Suggested change
compileOnlyApi(libs.commons.math3)
api(libs.commons.math3)

Copilot uses AI. Check for mistakes.
compileOnlyApi(libs.aide.reflection)
api(libs.glm)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ interface SurfCoreApi {
*/
fun getPlayer(playerUuid: UUID): Any?

companion object {
companion object : SurfCoreApi by surfCoreApi {

/**
* The instance of the SurfCoreApi.
*/
@JvmStatic
val instance = requiredService<SurfCoreApi>()
val instance = surfCoreApi
}
}

/**
* The instance of the SurfCoreApi.
*/
val surfCoreApi get() = SurfCoreApi.instance
val surfCoreApi = requiredService<SurfCoreApi>()
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.slne.surf.surfapi.core.api.config

import dev.slne.surf.surfapi.core.api.config.manager.DazzlConfDeprecationMessageHolder
import dev.slne.surf.surfapi.core.api.config.manager.PreferUsingSpongeConfigOverDazzlConf
import dev.slne.surf.surfapi.core.api.config.manager.SpongeConfigManager
import dev.slne.surf.surfapi.core.api.util.requiredService
Expand All @@ -21,6 +22,7 @@ interface SurfConfigApi {
* @return An instance of the configuration class [C].
*/
@PreferUsingSpongeConfigOverDazzlConf
@Deprecated(message = DazzlConfDeprecationMessageHolder.MESSAGE, level = DeprecationLevel.ERROR)
fun <C> createDazzlConfig(
configClass: Class<C>,
configFolder: Path,
Expand All @@ -35,6 +37,7 @@ interface SurfConfigApi {
* @return An instance of the configuration class [C].
*/
@PreferUsingSpongeConfigOverDazzlConf
@Deprecated(message = DazzlConfDeprecationMessageHolder.MESSAGE, level = DeprecationLevel.ERROR)
fun <C> getDazzlConfig(configClass: Class<C>): C

/**
Expand All @@ -45,6 +48,7 @@ interface SurfConfigApi {
* @return The reloaded instance of the configuration class [C].
*/
@PreferUsingSpongeConfigOverDazzlConf
@Deprecated(message = DazzlConfDeprecationMessageHolder.MESSAGE, level = DeprecationLevel.ERROR)
fun <C> reloadDazzlConfig(configClass: Class<C>): C

/**
Expand Down Expand Up @@ -134,18 +138,18 @@ interface SurfConfigApi {
*/
fun <C> getSpongeConfigManagerForConfig(configClass: Class<C>): SpongeConfigManager<C>

companion object {
companion object: SurfConfigApi by surfConfigApi {
/**
* Retrieves the singleton instance of [SurfConfigApi].
*/
val instance = requiredService<SurfConfigApi>()
val instance = surfConfigApi
}
}

/**
* Retrieves the singleton instance of [SurfConfigApi].
*/
val surfConfigApi get() = SurfConfigApi.instance
val surfConfigApi = requiredService<SurfConfigApi>()

/**
* Creates a DazzlConf configuration using a reified type.
Expand All @@ -156,6 +160,8 @@ val surfConfigApi get() = SurfConfigApi.instance
* @return An instance of the configuration class [C].
*/
@PreferUsingSpongeConfigOverDazzlConf
@Deprecated(message = DazzlConfDeprecationMessageHolder.MESSAGE, level = DeprecationLevel.ERROR)
@Suppress("DEPRECATION_ERROR")
inline fun <reified C> SurfConfigApi.createDazzlConfig(
configFolder: Path,
configFileName: @YamlConfigFileNamePattern String,
Expand All @@ -168,6 +174,8 @@ inline fun <reified C> SurfConfigApi.createDazzlConfig(
* @return An instance of the configuration class [C].
*/
@PreferUsingSpongeConfigOverDazzlConf
@Deprecated(message = DazzlConfDeprecationMessageHolder.MESSAGE, level = DeprecationLevel.ERROR)
@Suppress("DEPRECATION_ERROR")
inline fun <reified C> SurfConfigApi.getDazzlConfig() = getDazzlConfig(C::class.java)

/**
Expand All @@ -177,6 +185,8 @@ inline fun <reified C> SurfConfigApi.getDazzlConfig() = getDazzlConfig(C::class.
* @return The reloaded instance of the configuration class [C].
*/
@PreferUsingSpongeConfigOverDazzlConf
@Deprecated(message = DazzlConfDeprecationMessageHolder.MESSAGE, level = DeprecationLevel.ERROR)
@Suppress("DEPRECATION_ERROR")
inline fun <reified C> SurfConfigApi.reloadDazzlConfig() = reloadDazzlConfig(C::class.java)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dev.slne.surf.surfapi.core.api.config.manager
import dev.slne.surf.surfapi.core.api.config.YamlConfigFileNamePattern
import dev.slne.surf.surfapi.core.api.config.serializer.DefaultDazzlConfSerializers
import dev.slne.surf.surfapi.core.api.util.logger
import dev.slne.surf.surfapi.shared.api.util.InternalSurfApi
import space.arim.dazzleconf.ConfigurationOptions
import space.arim.dazzleconf.error.ConfigFormatSyntaxException
import space.arim.dazzleconf.error.InvalidConfigException
Expand All @@ -16,12 +17,19 @@ import java.nio.file.Path
import java.util.concurrent.TimeUnit

@RequiresOptIn(
level = RequiresOptIn.Level.WARNING,
message = "Prefer using Sponge's Configurate library over DazzlConf"
level = RequiresOptIn.Level.ERROR,
message = DazzlConfDeprecationMessageHolder.MESSAGE
)
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class PreferUsingSpongeConfigOverDazzlConf
annotation class PreferUsingSpongeConfigOverDazzlConf {
}

@InternalSurfApi
object DazzlConfDeprecationMessageHolder {
const val MESSAGE =
"Prefer using Sponge's Configurate library over DazzlConf. DazzlConf will be removed in a future release. If you need to use DazzlConf, please contact the developers to discuss your use case."
}

/**
* Manages configurations using the DazzlConf library, including loading, saving, and reloading configurations.
Expand All @@ -31,6 +39,7 @@ annotation class PreferUsingSpongeConfigOverDazzlConf
* @property config The current configuration instance, or `null` if not yet loaded.
*/
@PreferUsingSpongeConfigOverDazzlConf
@Deprecated(message = DazzlConfDeprecationMessageHolder.MESSAGE, level = DeprecationLevel.ERROR)
class DazzlConfConfigManager<C> private constructor(private val helper: ConfigurationHelper<C>) {
@Volatile
var config: C? = null
Expand Down Expand Up @@ -102,6 +111,9 @@ class DazzlConfConfigManager<C> private constructor(private val helper: Configur
* @return A new instance of [DazzlConfConfigManager].
*/
@JvmStatic
@Deprecated(message = DazzlConfDeprecationMessageHolder.MESSAGE, level = DeprecationLevel.ERROR)
@PreferUsingSpongeConfigOverDazzlConf
@Suppress("DEPRECATION_ERROR")
fun <C> create(
configClass: Class<C>,
configFolder: Path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import dev.slne.surf.surfapi.core.api.config.JsonConfigFileNamePattern
import dev.slne.surf.surfapi.core.api.config.YamlConfigFileNamePattern
import dev.slne.surf.surfapi.core.api.config.serializer.SpongeConfigSerializers
import dev.slne.surf.surfapi.core.api.util.logger
import org.jetbrains.annotations.Contract
import org.spongepowered.configurate.ConfigurateException
import org.spongepowered.configurate.ConfigurationNode
import org.spongepowered.configurate.ScopedConfigurationNode
Expand All @@ -15,6 +14,7 @@ import org.spongepowered.configurate.serialize.SerializationException
import org.spongepowered.configurate.yaml.NodeStyle
import org.spongepowered.configurate.yaml.YamlConfigurationLoader
import java.io.Serial
import java.io.UncheckedIOException
import java.nio.file.Path

/**
Expand All @@ -24,7 +24,7 @@ import java.nio.file.Path
* @param C The type of the configuration class.
* @property config The current configuration instance.
*/
class SpongeConfigManager<C> @Contract(pure = true) private constructor(
class SpongeConfigManager<C> private constructor(
private val configClass: Class<C>,
@JvmField @field:Volatile var config: C,
private val loader: ConfigurationLoader<out ConfigurationNode>,
Expand All @@ -34,8 +34,9 @@ class SpongeConfigManager<C> @Contract(pure = true) private constructor(
/**
* Saves the current configuration to the file.
*
* @throws RuntimeException if an I/O error or serialization error occurs.
* @throws UncheckedIOException if an I/O error or serialization error occurs.
*/
@Throws(UncheckedIOException::class)
fun save() {
try {
node.set(configClass, config)
Expand All @@ -44,15 +45,15 @@ class SpongeConfigManager<C> @Contract(pure = true) private constructor(
log.atSevere()
.withCause(e)
.log("Failed to save config")
throw RuntimeException(e)
throw UncheckedIOException(e)
}
}

/**
* Reloads the configuration from the file. If loading fails, the current configuration remains unchanged.
*
* @return The reloaded configuration instance.
* @throws RuntimeException if a critical error occurs during reload.
* @throws UncheckedIOException if an I/O error occurs during reload.
*/
fun reloadFromFile(): C {
try {
Expand All @@ -74,7 +75,7 @@ class SpongeConfigManager<C> @Contract(pure = true) private constructor(
log.atSevere()
.withCause(e)
.log("Failed to reload config")
throw RuntimeException(e)
throw UncheckedIOException(e)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package dev.slne.surf.surfapi.core.api.config.serializer

import dev.slne.surf.surfapi.core.api.config.manager.PreferUsingSpongeConfigOverDazzlConf
import dev.slne.surf.surfapi.core.api.messages.Colors
import dev.slne.surf.surfapi.core.api.minimessage.SurfMiniMessageHolder
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.TextColor
import net.kyori.adventure.text.minimessage.MiniMessage
import net.kyori.adventure.text.minimessage.ParsingException
import net.kyori.adventure.text.minimessage.tag.Tag
import space.arim.dazzleconf.serialiser.Decomposer
import space.arim.dazzleconf.serialiser.FlexibleType
import space.arim.dazzleconf.serialiser.ValueSerialiser
import java.util.concurrent.CopyOnWriteArrayList

/**
* Default serializers for DazzlConf configuration files. Provides support for custom types such as Adventure [Component].
Expand All @@ -20,7 +19,11 @@ object DefaultDazzlConfSerializers {
/**
* The default list of serializers used in DazzlConf configurations.
*/
val DEFAULTS = mutableListOf<ValueSerialiser<*>>(ComponentSerializer())
val DEFAULTS = CopyOnWriteArrayList<ValueSerialiser<*>>()

init {
DEFAULTS.add(ComponentSerializer())
}

/**
* Serializer for [Component] objects in DazzlConf configurations.
Expand All @@ -29,7 +32,7 @@ object DefaultDazzlConfSerializers {
override fun getTargetClass() = Component::class.java
override fun deserialise(flexibleType: FlexibleType): Component {
try {
return miniMessage.deserialize(flexibleType.string)
return SurfMiniMessageHolder.miniMessage().deserialize(flexibleType.string)
} catch (e: ParsingException) {
throw flexibleType.badValueExceptionBuilder()
.message(
Expand All @@ -45,48 +48,24 @@ object DefaultDazzlConfSerializers {
}

override fun serialise(value: Component, decomposer: Decomposer?) =
miniMessage.serialize(value)
SurfMiniMessageHolder.miniMessage().serialize(value)

companion object {
private val builder = MiniMessage.builder()
.editTags {
val tags = mapOf(
"primary" to Colors.PRIMARY,
"secondary" to Colors.SECONDARY,
"info" to Colors.INFO,
"success" to Colors.SUCCESS,
"warning" to Colors.WARNING,
"error" to Colors.ERROR,
"variable_key" to Colors.VARIABLE_KEY,
"variable_value" to Colors.VARIABLE_VALUE,
"spacer" to Colors.SPACER,
"dark_spacer" to Colors.DARK_SPACER,
"prefix_color" to Colors.PREFIX_COLOR
)

tags.forEach { (tag, color) ->
it.tag(tag) { _, _ -> colorTag(color) }
}
}

@JvmStatic
var miniMessage: MiniMessage = builder.build()
get() {
if (modified) {
field = builder.build()
modified = false
}

return field
}
private set
private var modified = false

private fun colorTag(color: TextColor) = Tag.styling { it.color(color) }
@Deprecated(
message = "Configs now use the MiniMessage instance supplied by the SurfMiniMessageHolder",
replaceWith = ReplaceWith(
"SurfMiniMessageHolder.miniMessage()",
"dev.slne.surf.surfapi.core.api.minimessage.SurfMiniMessageHolder"
)
)
val miniMessage: MiniMessage = SurfMiniMessageHolder.miniMessage()

@Deprecated(
message = "Cannot customize MiniMessage anymore. If you need custom tags, use your own MiniMessage instance instead and use a String in the config, then parse it manually (Consider caching the parsed value in a lazy value though).",
level = DeprecationLevel.ERROR
)
fun customizeMiniMessage(modifier: (MiniMessage.Builder) -> Unit) {
modifier(builder)
modified = true
}
}
}
Expand Down
Loading