From 9776e9687f0850353094477221b977784cfbbe8c Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Sun, 5 Jan 2025 07:49:38 +0100 Subject: [PATCH 01/61] feature: abstracted repository to be more flexible across other projects that may implement this api --- .../shared/repository/LoadableRepository.kt | 9 ++ .../api/shared/repository/Repository.kt | 13 +++ .../repository/YamlDirectoryRepository.kt | 86 +++++++------------ 3 files changed, 55 insertions(+), 53 deletions(-) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/Repository.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt new file mode 100644 index 0000000..3be5eab --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt @@ -0,0 +1,9 @@ +package app.simplecloud.plugin.api.shared.repository + +import org.spongepowered.configurate.serialize.TypeSerializerCollection + +interface LoadableRepository : Repository { + + fun load(serializers: TypeSerializerCollection? = null): List + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/Repository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/Repository.kt new file mode 100644 index 0000000..7bd8177 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/Repository.kt @@ -0,0 +1,13 @@ +package app.simplecloud.plugin.api.shared.repository + +interface Repository { + + fun delete(element: E): Boolean + + fun save(element: E) + + fun find(identifier: I): E? + + fun getAll(): List + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt index 6260d4f..ecc15cc 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt @@ -1,51 +1,55 @@ package app.simplecloud.plugin.api.shared.repository import kotlinx.coroutines.* -import org.spongepowered.configurate.ConfigurationNode import org.spongepowered.configurate.ConfigurationOptions import org.spongepowered.configurate.kotlin.objectMapperFactory import org.spongepowered.configurate.loader.ParsingException -import org.spongepowered.configurate.serialize.SerializationException -import org.spongepowered.configurate.serialize.TypeSerializer +import org.spongepowered.configurate.serialize.TypeSerializerCollection import org.spongepowered.configurate.yaml.NodeStyle import org.spongepowered.configurate.yaml.YamlConfigurationLoader import java.io.File -import java.lang.reflect.Type -import java.nio.file.* +import java.nio.file.FileSystems +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.StandardWatchEventKinds -abstract class YamlDirectoryRepository( +abstract class YamlDirectoryRepository( private val directory: Path, private val clazz: Class, -) { +) : LoadableRepository { private val watchService = FileSystems.getDefault().newWatchService() private val loaders = mutableMapOf() - protected val entities = mutableMapOf() + private val entities = mutableMapOf() - fun delete(element: E): Boolean { + private var serializers: TypeSerializerCollection? = null + + abstract fun getFileName(identifier: I): String + + override fun delete(element: E): Boolean { val file = entities.keys.find { entities[it] == element } ?: return false return deleteFile(file) } - fun getAll(): List { + override fun getAll(): List { return entities.values.toList() } - fun load(): List { + override fun load(serializers: TypeSerializerCollection?): List { + this.serializers = serializers + if (!directory.toFile().exists()) { directory.toFile().mkdirs() } registerWatcher() - return Files.list(directory) + return Files.walk(directory) .toList() .filter { !it.toFile().isDirectory && it.toString().endsWith(".yml") } .mapNotNull { load(it.toFile()) } } - open fun watchUpdateEvent(file: File) {} - private fun load(file: File): E? { try { val loader = getOrCreateLoader(file) @@ -58,6 +62,7 @@ abstract class YamlDirectoryRepository( if (existedBefore) { return null } + return null } } @@ -68,12 +73,10 @@ abstract class YamlDirectoryRepository( return deletedSuccessfully && removedSuccessfully } - fun save(fileName: String, entity: E) { + protected fun save(fileName: String, entity: E) { val file = directory.resolve(fileName).toFile() val loader = getOrCreateLoader(file) - val node = loader.createNode(ConfigurationOptions.defaults().serializers { - it.register(Enum::class.java, GenericEnumSerializer) - }) + val node = loader.createNode(ConfigurationOptions.defaults()) node.set(clazz, entity) loader.save(node) entities[file] = entity @@ -84,11 +87,11 @@ abstract class YamlDirectoryRepository( YamlConfigurationLoader.builder() .path(file.toPath()) .nodeStyle(NodeStyle.BLOCK) - .nodeStyle(NodeStyle.BLOCK) .defaultOptions { options -> options.serializers { builder -> + serializers?.let { builder.registerAll(it) } + builder.registerAnnotatedObjects(objectMapperFactory()) - builder.register(Enum::class.java, GenericEnumSerializer) } }.build() } @@ -105,21 +108,19 @@ abstract class YamlDirectoryRepository( return CoroutineScope(Dispatchers.IO).launch { while (isActive) { val key = watchService.take() - for (event in key.pollEvents()) { - val path = event.context() as? Path ?: continue + + key.pollEvents().forEach { event -> + val path = event.context() as? Path ?: return@forEach + if (!path.toString().endsWith(".yml")) return@forEach + val resolvedPath = directory.resolve(path) - if (Files.isDirectory(resolvedPath) || !resolvedPath.toString().endsWith(".yml")) { - continue - } - val kind = event.kind() - when (kind) { - StandardWatchEventKinds.ENTRY_CREATE -> { - load(resolvedPath.toFile()) - } + if (Files.isDirectory(resolvedPath)) return@forEach + when (event.kind()) { + StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY -> { + delay(100) load(resolvedPath.toFile()) - watchUpdateEvent(resolvedPath.toFile()) } StandardWatchEventKinds.ENTRY_DELETE -> { @@ -127,30 +128,9 @@ abstract class YamlDirectoryRepository( } } } - key.reset() - } - } - } - - private object GenericEnumSerializer : TypeSerializer> { - override fun deserialize(type: Type, node: ConfigurationNode): Enum<*> { - val value = node.string ?: throw SerializationException("No value present in node") - if (type !is Class<*> || !type.isEnum) { - throw SerializationException("Type is not an enum class") - } - - @Suppress("UNCHECKED_CAST") - return try { - java.lang.Enum.valueOf(type as Class>, value) - } catch (e: IllegalArgumentException) { - throw SerializationException("Invalid enum constant") + key.reset() } } - - override fun serialize(type: Type, obj: Enum<*>?, node: ConfigurationNode) { - node.set(obj?.name) - } } - } \ No newline at end of file From df538d57638ea5ccffcec97cbddacf1dfa8af6b4 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Sun, 5 Jan 2025 17:39:54 +0100 Subject: [PATCH 02/61] feature: updated Abstraction --- .../repository/GenericEnumSerializer.kt | 29 +++++++++++++++++++ .../repository/YamlDirectoryRepository.kt | 3 ++ 2 files changed, 32 insertions(+) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/GenericEnumSerializer.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/GenericEnumSerializer.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/GenericEnumSerializer.kt new file mode 100644 index 0000000..26b4da9 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/GenericEnumSerializer.kt @@ -0,0 +1,29 @@ +package app.simplecloud.plugin.api.shared.repository + +import org.spongepowered.configurate.ConfigurationNode +import org.spongepowered.configurate.serialize.SerializationException +import org.spongepowered.configurate.serialize.TypeSerializer +import java.lang.reflect.Type + +object GenericEnumSerializer : TypeSerializer> { + + @Suppress("UNCHECKED_CAST") + override fun deserialize(type: Type, node: ConfigurationNode): Enum<*> { + val value = node.string ?: throw SerializationException("No value present in node") + + if (type !is Class<*> || !type.isEnum) { + throw SerializationException("Type is not an enum class") + } + + return try { + java.lang.Enum.valueOf(type as Class>, value) + } catch (e: IllegalArgumentException) { + throw SerializationException("Invalid enum constant") + } + } + + override fun serialize(type: Type, obj: Enum<*>?, node: ConfigurationNode) { + node.set(obj?.name) + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt index ecc15cc..25d5509 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt @@ -82,6 +82,8 @@ abstract class YamlDirectoryRepository( entities[file] = entity } + open fun watchUpdateEvent(file: File) {} + private fun getOrCreateLoader(file: File): YamlConfigurationLoader { return loaders.getOrPut(file) { YamlConfigurationLoader.builder() @@ -92,6 +94,7 @@ abstract class YamlDirectoryRepository( serializers?.let { builder.registerAll(it) } builder.registerAnnotatedObjects(objectMapperFactory()) + builder.register(Enum::class.java, GenericEnumSerializer) } }.build() } From 36d3e6339046462bbd44501abd2a37edfa4558f0 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Sun, 5 Jan 2025 17:43:32 +0100 Subject: [PATCH 03/61] fix: now calling watchUpdateEvent on Modify Trigger --- .../plugin/api/shared/repository/YamlDirectoryRepository.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt index 25d5509..3ba2fcf 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt @@ -124,6 +124,7 @@ abstract class YamlDirectoryRepository( StandardWatchEventKinds.ENTRY_MODIFY -> { delay(100) load(resolvedPath.toFile()) + watchUpdateEvent(resolvedPath.toFile()) } StandardWatchEventKinds.ENTRY_DELETE -> { From 9364765650e16ba9f0e67137ec26bcb3d8dbb3f8 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Mon, 6 Jan 2025 11:12:13 +0100 Subject: [PATCH 04/61] fix: removed specific serializer init (should be done only if needed in impl) --- .../placeholder/provider/GroupPlaceholderProvider.kt | 5 +++-- .../plugin/api/shared/repository/LoadableRepository.kt | 4 +--- .../api/shared/repository/YamlDirectoryRepository.kt | 9 +-------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/GroupPlaceholderProvider.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/GroupPlaceholderProvider.kt index 67e5dd8..1d68f33 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/GroupPlaceholderProvider.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/GroupPlaceholderProvider.kt @@ -2,8 +2,9 @@ package app.simplecloud.plugin.api.shared.placeholder.provider import app.simplecloud.controller.api.ControllerApi import app.simplecloud.controller.shared.group.Group -import app.simplecloud.plugin.api.shared.placeholder.argument.* -import app.simplecloud.plugin.api.shared.placeholder.argument.group.* +import app.simplecloud.plugin.api.shared.placeholder.argument.PropertiesArgumentsResolver +import app.simplecloud.plugin.api.shared.placeholder.argument.group.PlayerCountArgumentsResolver +import app.simplecloud.plugin.api.shared.placeholder.argument.group.ServerCountArgumentsResolver import app.simplecloud.plugin.api.shared.placeholder.single.SingleGroupPlaceholderExecutor /** diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt index 3be5eab..822a537 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt @@ -1,9 +1,7 @@ package app.simplecloud.plugin.api.shared.repository -import org.spongepowered.configurate.serialize.TypeSerializerCollection - interface LoadableRepository : Repository { - fun load(serializers: TypeSerializerCollection? = null): List + fun load(): List } \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt index 3ba2fcf..3755f1a 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt @@ -4,7 +4,6 @@ import kotlinx.coroutines.* import org.spongepowered.configurate.ConfigurationOptions import org.spongepowered.configurate.kotlin.objectMapperFactory import org.spongepowered.configurate.loader.ParsingException -import org.spongepowered.configurate.serialize.TypeSerializerCollection import org.spongepowered.configurate.yaml.NodeStyle import org.spongepowered.configurate.yaml.YamlConfigurationLoader import java.io.File @@ -22,8 +21,6 @@ abstract class YamlDirectoryRepository( private val loaders = mutableMapOf() private val entities = mutableMapOf() - private var serializers: TypeSerializerCollection? = null - abstract fun getFileName(identifier: I): String override fun delete(element: E): Boolean { @@ -35,9 +32,7 @@ abstract class YamlDirectoryRepository( return entities.values.toList() } - override fun load(serializers: TypeSerializerCollection?): List { - this.serializers = serializers - + override fun load(): List { if (!directory.toFile().exists()) { directory.toFile().mkdirs() } @@ -91,8 +86,6 @@ abstract class YamlDirectoryRepository( .nodeStyle(NodeStyle.BLOCK) .defaultOptions { options -> options.serializers { builder -> - serializers?.let { builder.registerAll(it) } - builder.registerAnnotatedObjects(objectMapperFactory()) builder.register(Enum::class.java, GenericEnumSerializer) } From e00507aeb440f471349132704ff2ed6100d53750 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Mon, 6 Jan 2025 11:28:49 +0100 Subject: [PATCH 05/61] fix: add a way to add serializers in projects that are implementing this class --- .../plugin/api/shared/repository/YamlDirectoryRepository.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt index 3755f1a..228eb7f 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt @@ -4,6 +4,7 @@ import kotlinx.coroutines.* import org.spongepowered.configurate.ConfigurationOptions import org.spongepowered.configurate.kotlin.objectMapperFactory import org.spongepowered.configurate.loader.ParsingException +import org.spongepowered.configurate.serialize.TypeSerializerCollection import org.spongepowered.configurate.yaml.NodeStyle import org.spongepowered.configurate.yaml.YamlConfigurationLoader import java.io.File @@ -79,6 +80,8 @@ abstract class YamlDirectoryRepository( open fun watchUpdateEvent(file: File) {} + protected abstract fun addSerializers(builder: TypeSerializerCollection.Builder) + private fun getOrCreateLoader(file: File): YamlConfigurationLoader { return loaders.getOrPut(file) { YamlConfigurationLoader.builder() @@ -88,6 +91,7 @@ abstract class YamlDirectoryRepository( options.serializers { builder -> builder.registerAnnotatedObjects(objectMapperFactory()) builder.register(Enum::class.java, GenericEnumSerializer) + addSerializers(builder) } }.build() } From 610523a9395c9efe636a191adf1d7be0305617a1 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Mon, 6 Jan 2025 11:36:00 +0100 Subject: [PATCH 06/61] fix: made addSerializers open --- .../plugin/api/shared/repository/YamlDirectoryRepository.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt index 228eb7f..732bd7b 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt @@ -80,7 +80,7 @@ abstract class YamlDirectoryRepository( open fun watchUpdateEvent(file: File) {} - protected abstract fun addSerializers(builder: TypeSerializerCollection.Builder) + protected open fun addSerializers(builder: TypeSerializerCollection.Builder) {} private fun getOrCreateLoader(file: File): YamlConfigurationLoader { return loaders.getOrPut(file) { From dbafc9484c9a4fe5adb6c0c684b39ef964f2bb8d Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Mon, 6 Jan 2025 13:51:24 +0100 Subject: [PATCH 07/61] fix: added Pattern and NotEquals Operations to Matcher --- .../matcher/{MatcherType.kt => OperationType.kt} | 4 +++- .../shared/matcher/ServerMatcherConfiguration.kt | 2 +- .../matcher/operation/NotEqualsOperationMatcher.kt | 12 ++++++++++++ .../matcher/operation/PatternOperationMatcher.kt | 13 +++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) rename plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/{MatcherType.kt => OperationType.kt} (89%) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NotEqualsOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/PatternOperationMatcher.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/MatcherType.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt similarity index 89% rename from plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/MatcherType.kt rename to plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt index afcd098..87ae32e 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/MatcherType.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt @@ -2,12 +2,14 @@ package app.simplecloud.plugin.api.shared.matcher import app.simplecloud.plugin.api.shared.matcher.operation.* -enum class MatcherType( +enum class OperationType( private val matcher: OperationMatcher ) { REGEX(RegexOperationMatcher), + PATTERN(PatternOperationMatcher), EQUALS(EqualsOperationMatcher), + NOT_EQUALS(NotEqualsOperationMatcher), CONTAINS(ContainsOperationMatcher), STARTS_WITH(StartsWithOperationMatcher), ENDS_WITH(EndsWithOperationMatcher); diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/ServerMatcherConfiguration.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/ServerMatcherConfiguration.kt index 5056bf5..9ffa5c0 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/ServerMatcherConfiguration.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/ServerMatcherConfiguration.kt @@ -8,7 +8,7 @@ import org.spongepowered.configurate.objectmapping.ConfigSerializable @ConfigSerializable data class ServerMatcherConfiguration( - val operation: MatcherType = MatcherType.STARTS_WITH, + val operation: OperationType = OperationType.STARTS_WITH, val value: String = "", val negate: Boolean = false, ) { diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NotEqualsOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NotEqualsOperationMatcher.kt new file mode 100644 index 0000000..d544ced --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NotEqualsOperationMatcher.kt @@ -0,0 +1,12 @@ +package app.simplecloud.plugin.api.shared.matcher.operation + +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +@ConfigSerializable +object NotEqualsOperationMatcher : OperationMatcher { + + override fun matches(name: String, value: String): Boolean { + return !name.equals(value, ignoreCase = true) + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/PatternOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/PatternOperationMatcher.kt new file mode 100644 index 0000000..1745b1c --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/PatternOperationMatcher.kt @@ -0,0 +1,13 @@ +package app.simplecloud.plugin.api.shared.matcher.operation + +import org.spongepowered.configurate.objectmapping.ConfigSerializable +import java.util.regex.Pattern + +@ConfigSerializable +object PatternOperationMatcher : OperationMatcher { + + override fun matches(name: String, value: String): Boolean { + return Pattern.matches(name, value) + } + +} \ No newline at end of file From f34b7cef6e4d420699a2b55e490f3e981019b67c Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Mon, 6 Jan 2025 14:09:01 +0100 Subject: [PATCH 08/61] fix: removed group_ from AsyncPlaceholder identifier for better readability and usability --- .../shared/placeholder/single/SingleGroupPlaceholderExecutor.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleGroupPlaceholderExecutor.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleGroupPlaceholderExecutor.kt index 5e09542..d81439d 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleGroupPlaceholderExecutor.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleGroupPlaceholderExecutor.kt @@ -11,7 +11,7 @@ import app.simplecloud.plugin.api.shared.placeholder.async.AsyncPlaceholder class SingleGroupPlaceholderExecutor : SinglePlaceholderExecutor { override fun getAsyncPlaceholders(controllerApi: ControllerApi.Coroutine) = listOf>( - AsyncPlaceholder("group_name") { it.name }, + AsyncPlaceholder("name") { it.name }, AsyncPlaceholder("type") { it.type }, AsyncPlaceholder("max_players") { it.maxPlayers }, AsyncPlaceholder("min_memory") { it.minMemory }, From 4b5b687354f771f1c535ed3ca66f04066aa7edb8 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Mon, 6 Jan 2025 14:15:46 +0100 Subject: [PATCH 09/61] fix: removed group_ from AsyncPlaceholder identifier for better readability and usability --- .../plugin/api/shared/matcher/OperationType.kt | 1 - .../matcher/operation/NotEqualsOperationMatcher.kt | 12 ------------ 2 files changed, 13 deletions(-) delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NotEqualsOperationMatcher.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt index 87ae32e..d99c5f8 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt @@ -9,7 +9,6 @@ enum class OperationType( REGEX(RegexOperationMatcher), PATTERN(PatternOperationMatcher), EQUALS(EqualsOperationMatcher), - NOT_EQUALS(NotEqualsOperationMatcher), CONTAINS(ContainsOperationMatcher), STARTS_WITH(StartsWithOperationMatcher), ENDS_WITH(EndsWithOperationMatcher); diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NotEqualsOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NotEqualsOperationMatcher.kt deleted file mode 100644 index d544ced..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NotEqualsOperationMatcher.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.simplecloud.plugin.api.shared.matcher.operation - -import org.spongepowered.configurate.objectmapping.ConfigSerializable - -@ConfigSerializable -object NotEqualsOperationMatcher : OperationMatcher { - - override fun matches(name: String, value: String): Boolean { - return !name.equals(value, ignoreCase = true) - } - -} \ No newline at end of file From 95a58776e42fc2a0d088cbf4edc302a6cf53452c Mon Sep 17 00:00:00 2001 From: Niklas <57962465+niklasnieberler@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:40:08 +0100 Subject: [PATCH 10/61] feat: add plugin-velocity sub-project --- build.gradle.kts | 1 + plugin-velocity/build.gradle.kts | 9 +++++++++ settings.gradle.kts | 4 ++++ 3 files changed, 14 insertions(+) create mode 100644 plugin-velocity/build.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index de93257..a5cb9b3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,6 +19,7 @@ allprojects { maven("https://buf.build/gen/maven") maven("https://repo.simplecloud.app/snapshots") maven("https://buf.build/gen/maven") + maven("https://repo.papermc.io/repository/maven-public") } } diff --git a/plugin-velocity/build.gradle.kts b/plugin-velocity/build.gradle.kts new file mode 100644 index 0000000..3daeb6c --- /dev/null +++ b/plugin-velocity/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + kotlin("kapt") +} + +dependencies { + compileOnly(project(":plugin-shared")) + compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") + kapt("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index fdc78e6..9f48b5b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,2 +1,6 @@ +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} rootProject.name = "plugin-api" include("plugin-shared") +include("plugin-velocity") From e695c3bde7cdfc56d3164ccced75fc73dcbf3f84 Mon Sep 17 00:00:00 2001 From: Niklas <57962465+niklasnieberler@users.noreply.github.com> Date: Tue, 7 Jan 2025 14:40:19 +0100 Subject: [PATCH 11/61] feat: add permission checker --- .../api/shared/permission/PermissionChecker.kt | 16 ++++++++++++++++ .../permission/VelocityPermissionChecker.kt | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/permission/PermissionChecker.kt create mode 100644 plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/permission/VelocityPermissionChecker.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/permission/PermissionChecker.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/permission/PermissionChecker.kt new file mode 100644 index 0000000..216cb80 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/permission/PermissionChecker.kt @@ -0,0 +1,16 @@ +package app.simplecloud.plugin.api.shared.permission + +/** + * @author Niklas Nieberler + */ + +fun interface PermissionChecker

{ + + /** + * Checks the permission by a player + * @param player to check the permission + * @param name of the permission + */ + fun checkPermission(player: P, name: String): Boolean + +} \ No newline at end of file diff --git a/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/permission/VelocityPermissionChecker.kt b/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/permission/VelocityPermissionChecker.kt new file mode 100644 index 0000000..a2bb7e7 --- /dev/null +++ b/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/permission/VelocityPermissionChecker.kt @@ -0,0 +1,16 @@ +package app.simplecloud.plugin.api.velocity.permission + +import app.simplecloud.plugin.api.shared.permission.PermissionChecker +import com.velocitypowered.api.proxy.Player + +/** + * @author Niklas Nieberler + */ + +class VelocityPermissionChecker : PermissionChecker { + + override fun checkPermission(player: Player, name: String): Boolean { + return player.hasPermission(name) + } + +} \ No newline at end of file From 26ee0d0d0ccb02e21b0f1423ac57209ac1db6276 Mon Sep 17 00:00:00 2001 From: Niklas <57962465+niklasnieberler@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:10:32 +0100 Subject: [PATCH 12/61] feat: add motd placeholder in SingleServerPlaceholderExecutor --- .../placeholder/single/SingleServerPlaceholderExecutor.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt index 812cc8d..8dccdfb 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt @@ -21,7 +21,8 @@ class SingleServerPlaceholderExecutor : SinglePlaceholderExecutor { AsyncPlaceholder("online_players") { it.playerCount }, AsyncPlaceholder("max_players") { it.maxPlayers }, AsyncPlaceholder("min_memory") { it.minMemory }, - AsyncPlaceholder("max_memory") { it.maxMemory } + AsyncPlaceholder("max_memory") { it.maxMemory }, + AsyncPlaceholder("motd") { it.properties["motd"] ?: "A Minecraft server" } ) } \ No newline at end of file From b6f2fc884a2ab4dfaa3a15288042f30f09176d40 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Thu, 9 Jan 2025 18:17:22 +0100 Subject: [PATCH 13/61] Create LICENSE --- LICENSE | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2cd34d3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2025] [SimpleCloud] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 6675bdaf41c3ad5b7fa897d2e0133177e04833d8 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 10 Jan 2025 00:22:23 +0100 Subject: [PATCH 14/61] feat: added ResourcedYamlDirectoryRepository --- .../ResourcedYamlDirectoryRepository.kt | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/ResourcedYamlDirectoryRepository.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/ResourcedYamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/ResourcedYamlDirectoryRepository.kt new file mode 100644 index 0000000..8436502 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/ResourcedYamlDirectoryRepository.kt @@ -0,0 +1,91 @@ +package app.simplecloud.plugin.api.shared.repository + +import java.io.File +import java.io.FileOutputStream +import java.net.URL +import java.nio.file.Path +import java.util.jar.JarFile +import kotlin.io.path.exists +import kotlin.io.path.pathString + +/** + * An extension of [YamlDirectoryRepository] that adds resource loading capabilities + * + * Key differences from [YamlDirectoryRepository] + * - Automatically load default yml configuration files from resources if the target directory doesn't exist + * - Supports both file and jar protocols for loading resources + * - Handles both standalone file system resources and jar-packed resources + * + * Use this implementation of [YamlDirectoryRepository] when you need to + * - Ship default configurations with your plugin + * - Ensure configuration files exist on first run + * - Handle both development (file) and production (jar) environments + */ +abstract class ResourcedYamlDirectoryRepository( + private val directory: Path, + private val clazz: Class, +) : YamlDirectoryRepository(directory, clazz) { + + override fun load(): List { + if (!directory.exists()) loadDefaults() + + return super.load() + } + + private fun loadDefaults() { + val targetDirectory = File(directory.toUri()).apply { mkdirs() } + + val last = directory.pathString.split('/').last() + + val resourceUrl = YamlDirectoryRepository::class.java.getResource("/$last") ?: run { + println("$last folder not found in resources") + return + } + + when (resourceUrl.protocol) { + "file" -> handleFileProtocol(resourceUrl, targetDirectory) + "jar" -> handleJarProtocol(resourceUrl, targetDirectory) + else -> println("Unsupported protocol: ${resourceUrl.protocol}") + } + } + + private fun handleFileProtocol(resourceUrl: URL, targetDirectory: File) { + val resourceDir = File(resourceUrl.toURI()) + if (resourceDir.exists()) { + resourceDir.copyRecursively(targetDirectory, overwrite = true) + } else { + println("Resource directory does not exist: ${resourceUrl.path}") + } + } + + private fun handleJarProtocol(resourceUrl: URL, targetDirectory: File) { + val jarPath = resourceUrl.path.substringBefore("!").removePrefix("file:") + try { + JarFile(jarPath).use { jarFile -> + val last = directory.pathString.split('/').last() + jarFile.entries().asSequence() + .filter { it.name.startsWith("$last/") && !it.isDirectory } + .forEach { entry -> + val targetFile = File(targetDirectory, entry.name.removePrefix("$last/")) + targetFile.parentFile.mkdirs() + try { + jarFile.getInputStream(entry).use { inputStream -> + FileOutputStream(targetFile).use { fos -> + fos.write(0xEF) + fos.write(0xBB) + fos.write(0xBF) + + inputStream.copyTo(fos) + } + } + } catch (e: Exception) { + println("Error copying file ${entry.name}: ${e.message}") + } + } + } + } catch (e: Exception) { + println("Error processing JAR file: ${e.message}") + e.printStackTrace() + } + } +} \ No newline at end of file From 1a9ee8f03c735eaf7f865a543e594b221d191461 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 10 Jan 2025 00:41:39 +0100 Subject: [PATCH 15/61] feat: added NumericOperationMatcher and GreaterThanOperation --- .../api/shared/matcher/OperationType.kt | 32 ++++++++++++++----- .../operation/ContainsOperationMatcher.kt | 12 ------- .../operation/EndsWithOperationMatcher.kt | 12 ------- .../operation/EqualsOperationMatcher.kt | 12 ------- .../operation/NumericOperationMatcher.kt | 3 ++ .../matcher/operation/OperationMatcher.kt | 4 +-- .../operation/PatternOperationMatcher.kt | 13 -------- .../operation/RegexOperationMatcher.kt | 12 ------- .../operation/StartsWithOperationMatcher.kt | 12 ------- .../operation/StringOperationMatcher.kt | 3 ++ .../impl/ContainsOperationMatcher.kt | 13 ++++++++ .../impl/EndsWithOperationMatcher.kt | 13 ++++++++ .../operation/impl/EqualsOperationMatcher.kt | 13 ++++++++ .../impl/GreaterThanOperationMatcher.kt | 11 +++++++ .../operation/impl/PatternOperationMatcher.kt | 14 ++++++++ .../operation/impl/RegexOperationMatcher.kt | 13 ++++++++ .../impl/StartsWithOperationMatcher.kt | 13 ++++++++ 17 files changed, 122 insertions(+), 83 deletions(-) delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/ContainsOperationMatcher.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/EndsWithOperationMatcher.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/EqualsOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NumericOperationMatcher.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/PatternOperationMatcher.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/RegexOperationMatcher.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/StartsWithOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/StringOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/ContainsOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/EndsWithOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/EqualsOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/GreaterThanOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/PatternOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/RegexOperationMatcher.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/StartsWithOperationMatcher.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt index d99c5f8..581d2d8 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/OperationType.kt @@ -1,9 +1,12 @@ package app.simplecloud.plugin.api.shared.matcher -import app.simplecloud.plugin.api.shared.matcher.operation.* +import app.simplecloud.plugin.api.shared.matcher.operation.NumericOperationMatcher +import app.simplecloud.plugin.api.shared.matcher.operation.OperationMatcher +import app.simplecloud.plugin.api.shared.matcher.operation.StringOperationMatcher +import app.simplecloud.plugin.api.shared.matcher.operation.impl.* enum class OperationType( - private val matcher: OperationMatcher + private val matcher: OperationMatcher<*, *> ) { REGEX(RegexOperationMatcher), @@ -11,14 +14,27 @@ enum class OperationType( EQUALS(EqualsOperationMatcher), CONTAINS(ContainsOperationMatcher), STARTS_WITH(StartsWithOperationMatcher), - ENDS_WITH(EndsWithOperationMatcher); + ENDS_WITH(EndsWithOperationMatcher), + GREATER_THAN(GreaterThanOperationMatcher); - fun matches(name: String, value: String, negate: Boolean): Boolean { - val matches = this.matcher.matches(name, value) - if (negate) { - return matches.not() + fun matches(key: Any, value: Any, negate: Boolean): Boolean { + val matches = when (matcher) { + is StringOperationMatcher -> { + if (key is String && value is String) { + matcher.matches(key, value) + } else false + } + + is NumericOperationMatcher -> { + if (key is Int && value is Int) { + matcher.matches(key, value) + } else false + } + + else -> false } - return matches + + return if (negate) matches.not() else matches } fun anyMatches(names: List, value: String, negate: Boolean): Boolean { diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/ContainsOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/ContainsOperationMatcher.kt deleted file mode 100644 index 497e607..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/ContainsOperationMatcher.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.simplecloud.plugin.api.shared.matcher.operation - -import org.spongepowered.configurate.objectmapping.ConfigSerializable - -@ConfigSerializable -object ContainsOperationMatcher : OperationMatcher { - - override fun matches(name: String, value: String): Boolean { - return name.contains(value, ignoreCase = true) - } - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/EndsWithOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/EndsWithOperationMatcher.kt deleted file mode 100644 index ef4f5b3..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/EndsWithOperationMatcher.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.simplecloud.plugin.api.shared.matcher.operation - -import org.spongepowered.configurate.objectmapping.ConfigSerializable - -@ConfigSerializable -object EndsWithOperationMatcher : OperationMatcher { - - override fun matches(name: String, value: String): Boolean { - return name.endsWith(value, ignoreCase = true) - } - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/EqualsOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/EqualsOperationMatcher.kt deleted file mode 100644 index 1051bb9..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/EqualsOperationMatcher.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.simplecloud.plugin.api.shared.matcher.operation - -import org.spongepowered.configurate.objectmapping.ConfigSerializable - -@ConfigSerializable -object EqualsOperationMatcher : OperationMatcher { - - override fun matches(name: String, value: String): Boolean { - return name.equals(value, ignoreCase = true) - } - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NumericOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NumericOperationMatcher.kt new file mode 100644 index 0000000..dfdc488 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/NumericOperationMatcher.kt @@ -0,0 +1,3 @@ +package app.simplecloud.plugin.api.shared.matcher.operation + +interface NumericOperationMatcher : OperationMatcher \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/OperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/OperationMatcher.kt index cfe5e80..d597e0b 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/OperationMatcher.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/OperationMatcher.kt @@ -1,7 +1,7 @@ package app.simplecloud.plugin.api.shared.matcher.operation -interface OperationMatcher { +interface OperationMatcher { - fun matches(name: String, value: String): Boolean + fun matches(key: K, value: V): Boolean } \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/PatternOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/PatternOperationMatcher.kt deleted file mode 100644 index 1745b1c..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/PatternOperationMatcher.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.simplecloud.plugin.api.shared.matcher.operation - -import org.spongepowered.configurate.objectmapping.ConfigSerializable -import java.util.regex.Pattern - -@ConfigSerializable -object PatternOperationMatcher : OperationMatcher { - - override fun matches(name: String, value: String): Boolean { - return Pattern.matches(name, value) - } - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/RegexOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/RegexOperationMatcher.kt deleted file mode 100644 index 23b0006..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/RegexOperationMatcher.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.simplecloud.plugin.api.shared.matcher.operation - -import org.spongepowered.configurate.objectmapping.ConfigSerializable - -@ConfigSerializable -object RegexOperationMatcher : OperationMatcher { - - override fun matches(name: String, value: String): Boolean { - return Regex(value).matches(name) - } - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/StartsWithOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/StartsWithOperationMatcher.kt deleted file mode 100644 index c0ca9b4..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/StartsWithOperationMatcher.kt +++ /dev/null @@ -1,12 +0,0 @@ -package app.simplecloud.plugin.api.shared.matcher.operation - -import org.spongepowered.configurate.objectmapping.ConfigSerializable - -@ConfigSerializable -object StartsWithOperationMatcher : OperationMatcher { - - override fun matches(name: String, value: String): Boolean { - return name.startsWith(value, ignoreCase = true) - } - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/StringOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/StringOperationMatcher.kt new file mode 100644 index 0000000..c976d0e --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/StringOperationMatcher.kt @@ -0,0 +1,3 @@ +package app.simplecloud.plugin.api.shared.matcher.operation + +interface StringOperationMatcher : OperationMatcher diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/ContainsOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/ContainsOperationMatcher.kt new file mode 100644 index 0000000..3a0243e --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/ContainsOperationMatcher.kt @@ -0,0 +1,13 @@ +package app.simplecloud.plugin.api.shared.matcher.operation.impl + +import app.simplecloud.plugin.api.shared.matcher.operation.StringOperationMatcher +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +@ConfigSerializable +object ContainsOperationMatcher : StringOperationMatcher { + + override fun matches(key: String, value: String): Boolean { + return key.contains(value, ignoreCase = true) + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/EndsWithOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/EndsWithOperationMatcher.kt new file mode 100644 index 0000000..dd369fe --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/EndsWithOperationMatcher.kt @@ -0,0 +1,13 @@ +package app.simplecloud.plugin.api.shared.matcher.operation.impl + +import app.simplecloud.plugin.api.shared.matcher.operation.StringOperationMatcher +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +@ConfigSerializable +object EndsWithOperationMatcher : StringOperationMatcher { + + override fun matches(key: String, value: String): Boolean { + return key.endsWith(value, ignoreCase = true) + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/EqualsOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/EqualsOperationMatcher.kt new file mode 100644 index 0000000..98c2729 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/EqualsOperationMatcher.kt @@ -0,0 +1,13 @@ +package app.simplecloud.plugin.api.shared.matcher.operation.impl + +import app.simplecloud.plugin.api.shared.matcher.operation.StringOperationMatcher +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +@ConfigSerializable +object EqualsOperationMatcher : StringOperationMatcher { + + override fun matches(key: String, value: String): Boolean { + return key.equals(value, ignoreCase = true) + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/GreaterThanOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/GreaterThanOperationMatcher.kt new file mode 100644 index 0000000..41dfc72 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/GreaterThanOperationMatcher.kt @@ -0,0 +1,11 @@ +package app.simplecloud.plugin.api.shared.matcher.operation.impl + +import app.simplecloud.plugin.api.shared.matcher.operation.NumericOperationMatcher + +object GreaterThanOperationMatcher : NumericOperationMatcher { + + override fun matches(key: Int, value: Int): Boolean { + return key > value + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/PatternOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/PatternOperationMatcher.kt new file mode 100644 index 0000000..7dd32bd --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/PatternOperationMatcher.kt @@ -0,0 +1,14 @@ +package app.simplecloud.plugin.api.shared.matcher.operation.impl + +import app.simplecloud.plugin.api.shared.matcher.operation.StringOperationMatcher +import org.spongepowered.configurate.objectmapping.ConfigSerializable +import java.util.regex.Pattern + +@ConfigSerializable +object PatternOperationMatcher : StringOperationMatcher { + + override fun matches(key: String, value: String): Boolean { + return Pattern.matches(key, value) + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/RegexOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/RegexOperationMatcher.kt new file mode 100644 index 0000000..4bc5c14 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/RegexOperationMatcher.kt @@ -0,0 +1,13 @@ +package app.simplecloud.plugin.api.shared.matcher.operation.impl + +import app.simplecloud.plugin.api.shared.matcher.operation.StringOperationMatcher +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +@ConfigSerializable +object RegexOperationMatcher : StringOperationMatcher { + + override fun matches(key: String, value: String): Boolean { + return Regex(value).matches(key) + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/StartsWithOperationMatcher.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/StartsWithOperationMatcher.kt new file mode 100644 index 0000000..d641d1c --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/matcher/operation/impl/StartsWithOperationMatcher.kt @@ -0,0 +1,13 @@ +package app.simplecloud.plugin.api.shared.matcher.operation.impl + +import app.simplecloud.plugin.api.shared.matcher.operation.StringOperationMatcher +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +@ConfigSerializable +object StartsWithOperationMatcher : StringOperationMatcher { + + override fun matches(key: String, value: String): Boolean { + return key.startsWith(value, ignoreCase = true) + } + +} \ No newline at end of file From a9f8dd2f2d7257d2d370c859a49c4f10e7fe6f98 Mon Sep 17 00:00:00 2001 From: Niklas <57962465+niklasnieberler@users.noreply.github.com> Date: Sun, 12 Jan 2025 23:04:11 +0100 Subject: [PATCH 16/61] feat: add ConfigFactory --- .../plugin/api/shared/config/ConfigFactory.kt | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt new file mode 100644 index 0000000..56085a4 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt @@ -0,0 +1,100 @@ +package app.simplecloud.plugin.api.shared.config + +import app.simplecloud.plugin.api.shared.repository.GenericEnumSerializer +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.delay +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import org.spongepowered.configurate.ConfigurationOptions +import org.spongepowered.configurate.kotlin.objectMapperFactory +import org.spongepowered.configurate.kotlin.toNode +import org.spongepowered.configurate.yaml.NodeStyle +import org.spongepowered.configurate.yaml.YamlConfigurationLoader +import java.io.File +import java.nio.file.FileSystems +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.StandardWatchEventKinds + +/** + * @author Niklas Nieberler + */ + +class ConfigFactory( + private val file: File, + private val defaultConfig: E +) { + + private var config = defaultConfig + private val path = file.toPath() + + private val configurationLoader = YamlConfigurationLoader.builder() + .path(this.path) + .nodeStyle(NodeStyle.BLOCK) + .defaultOptions { options -> + options.serializers { builder -> + builder.registerAnnotatedObjects(objectMapperFactory()) + builder.register(Enum::class.java, GenericEnumSerializer) + } + } + .build() + + fun loadOrCreate() { + registerWatcher() + if (this.file.exists()) { + loadConfig() + return + } + createDefaultConfig() + } + + private fun createDefaultConfig() { + this.path.parent?.let { Files.createDirectories(it) } + Files.createFile(this.path) + + val configurationNode = this.configurationLoader.load(ConfigurationOptions.defaults()) + this.defaultConfig!!.toNode(configurationNode) + this.configurationLoader.save(configurationNode) + } + + fun getConfig(): E = this.config + + private fun loadConfig() { + val configurationNode = this.configurationLoader.load(ConfigurationOptions.defaults()) + this.config = configurationNode.get(this.defaultConfig!!::class.java) + ?: throw IllegalStateException("Config could not be loaded") + } + + private fun registerWatcher(): Job { + val watchService = FileSystems.getDefault().newWatchService() + this.path.register( + watchService, + StandardWatchEventKinds.ENTRY_CREATE, + StandardWatchEventKinds.ENTRY_MODIFY + ) + + return CoroutineScope(Dispatchers.IO).launch { + while (isActive) { + val key = watchService.take() + + key.pollEvents().forEach { event -> + val path = event.context() as? Path ?: return@forEach + if (!file.name.contains(path.toString())) return@launch + + when (event.kind()) { + StandardWatchEventKinds.ENTRY_CREATE, + StandardWatchEventKinds.ENTRY_MODIFY -> { + delay(100) + loadConfig() + } + } + } + + key.reset() + } + } + } + +} \ No newline at end of file From e2d6ec32f404a4045c049d316acc68db135aba74 Mon Sep 17 00:00:00 2001 From: Niklas <57962465+niklasnieberler@users.noreply.github.com> Date: Sun, 12 Jan 2025 23:04:29 +0100 Subject: [PATCH 17/61] ref: rename libs.versions.toml libraries --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 85d6996..c17b92f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,12 +10,12 @@ kotlinJvm = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = simpleCloudControllerApi = { module = "app.simplecloud.controller:controller-api", version.ref = "simpleCloudController" } simpleCloudControllerShared = { module = "app.simplecloud.controller:controller-shared", version.ref = "simpleCloudController" } -adventureApi = { module = "net.kyori:adventure-api", version.ref = "adventure" } +adventure = { module = "net.kyori:adventure-api", version.ref = "adventure" } adventureMiniMessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } [bundles] simpleCloudController = ["simpleCloudControllerApi", "simpleCloudControllerShared"] -adventure = ["adventureApi", "adventureMiniMessage"] +adventure = ["adventure", "adventureMiniMessage"] [plugins] kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } From 860c6b87a546d860e62c0a46b524d576b5e50f2f Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Sun, 12 Jan 2025 23:20:24 +0100 Subject: [PATCH 18/61] feat: ConfigFactory.kt --- .../plugin/api/shared/config/ConfigFactory.kt | 133 +++++++++++------- .../exception/ConfigurationException.kt | 4 + 2 files changed, 84 insertions(+), 53 deletions(-) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/ConfigurationException.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt index 56085a4..d3cffdd 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt @@ -1,37 +1,28 @@ package app.simplecloud.plugin.api.shared.config +import app.simplecloud.plugin.api.shared.exception.ConfigurationException import app.simplecloud.plugin.api.shared.repository.GenericEnumSerializer -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.delay -import kotlinx.coroutines.isActive -import kotlinx.coroutines.launch +import kotlinx.coroutines.* import org.spongepowered.configurate.ConfigurationOptions import org.spongepowered.configurate.kotlin.objectMapperFactory -import org.spongepowered.configurate.kotlin.toNode import org.spongepowered.configurate.yaml.NodeStyle import org.spongepowered.configurate.yaml.YamlConfigurationLoader import java.io.File -import java.nio.file.FileSystems -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.StandardWatchEventKinds +import java.nio.file.* +import kotlin.coroutines.CoroutineContext -/** - * @author Niklas Nieberler - */ - -class ConfigFactory( +class ConfigFactory( private val file: File, - private val defaultConfig: E -) { + private val configClass: Class<*>, + private val coroutineContext: CoroutineContext = Dispatchers.IO +) : AutoCloseable { - private var config = defaultConfig - private val path = file.toPath() + private var config: Any? = null + private val path: Path = file.toPath() + private var watchJob: Job? = null private val configurationLoader = YamlConfigurationLoader.builder() - .path(this.path) + .path(path) .nodeStyle(NodeStyle.BLOCK) .defaultOptions { options -> options.serializers { builder -> @@ -41,60 +32,96 @@ class ConfigFactory( } .build() - fun loadOrCreate() { - registerWatcher() - if (this.file.exists()) { + fun loadOrCreate(defaultConfig: Any) { + if (!configClass.isInstance(defaultConfig)) { + throw IllegalArgumentException("Default config must be an instance of ${configClass.name}") + } + + if (file.exists()) { loadConfig() - return + } else { + createDefaultConfig(defaultConfig) } - createDefaultConfig() + startWatching() } - private fun createDefaultConfig() { - this.path.parent?.let { Files.createDirectories(it) } - Files.createFile(this.path) + private fun createDefaultConfig(defaultConfig: Any) { + path.parent?.let { Files.createDirectories(it) } + Files.createFile(path) - val configurationNode = this.configurationLoader.load(ConfigurationOptions.defaults()) - this.defaultConfig!!.toNode(configurationNode) - this.configurationLoader.save(configurationNode) + val node = configurationLoader.createNode() + node.set(configClass, defaultConfig) + configurationLoader.save(node) + config = defaultConfig } - fun getConfig(): E = this.config + @Suppress("UNCHECKED_CAST") + fun getConfig(): T { + return config as? T ?: throw IllegalStateException("Configuration not loaded or invalid type") + } + @Throws(ConfigurationException::class) private fun loadConfig() { - val configurationNode = this.configurationLoader.load(ConfigurationOptions.defaults()) - this.config = configurationNode.get(this.defaultConfig!!::class.java) - ?: throw IllegalStateException("Config could not be loaded") + try { + val node = configurationLoader.load(ConfigurationOptions.defaults()) + config = node.get(configClass) + ?: throw ConfigurationException("Failed to parse configuration file") + } catch (e: Exception) { + throw ConfigurationException("Failed to load configuration", e) + } } - private fun registerWatcher(): Job { + private fun startWatching() { val watchService = FileSystems.getDefault().newWatchService() - this.path.register( + path.parent?.register( watchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY ) - return CoroutineScope(Dispatchers.IO).launch { - while (isActive) { - val key = watchService.take() - - key.pollEvents().forEach { event -> - val path = event.context() as? Path ?: return@forEach - if (!file.name.contains(path.toString())) return@launch - - when (event.kind()) { - StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_MODIFY -> { - delay(100) - loadConfig() - } + watchJob = CoroutineScope(coroutineContext).launch { + watchService.use { watchService -> + while (isActive) { + val key = watchService.take() + key.pollEvents().forEach { event -> + handleWatchEvent(event) + } + if (!key.reset()) { + break } } + } + } + } - key.reset() + /** + * Handles a single watch event. + */ + private suspend fun handleWatchEvent(event: WatchEvent<*>) { + val path = event.context() as? Path ?: return + if (!file.name.contains(path.toString())) return + + when (event.kind()) { + StandardWatchEventKinds.ENTRY_CREATE, + StandardWatchEventKinds.ENTRY_MODIFY -> { + delay(100) + try { + loadConfig() + } catch (e: ConfigurationException) { + println("Failed to reload configuration: ${e.message}") + } } } } + override fun close() { + watchJob?.cancel() + } + + companion object { + inline fun create( + file: File, + coroutineContext: CoroutineContext = Dispatchers.IO + ): ConfigFactory = ConfigFactory(file, T::class.java, coroutineContext) + } } \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/ConfigurationException.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/ConfigurationException.kt new file mode 100644 index 0000000..b22ab88 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/ConfigurationException.kt @@ -0,0 +1,4 @@ +package app.simplecloud.plugin.api.shared.exception + +class ConfigurationException(message: String, cause: Throwable? = null) : + Exception(message, cause) \ No newline at end of file From 2f9040bdfbad00bed4b69931b0619818a906970c Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Sun, 12 Jan 2025 23:24:28 +0100 Subject: [PATCH 19/61] fix: ConfigFactory.kt --- .../plugin/api/shared/config/ConfigFactory.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt index d3cffdd..a2e4b38 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt @@ -42,7 +42,8 @@ class ConfigFactory( } else { createDefaultConfig(defaultConfig) } - startWatching() + + registerWatcher() } private fun createDefaultConfig(defaultConfig: Any) { @@ -71,7 +72,7 @@ class ConfigFactory( } } - private fun startWatching() { + private fun registerWatcher(): Job { val watchService = FileSystems.getDefault().newWatchService() path.parent?.register( watchService, @@ -79,7 +80,7 @@ class ConfigFactory( StandardWatchEventKinds.ENTRY_MODIFY ) - watchJob = CoroutineScope(coroutineContext).launch { + return CoroutineScope(coroutineContext).launch { watchService.use { watchService -> while (isActive) { val key = watchService.take() @@ -91,12 +92,9 @@ class ConfigFactory( } } } - } + }.also { watchJob = it } } - /** - * Handles a single watch event. - */ private suspend fun handleWatchEvent(event: WatchEvent<*>) { val path = event.context() as? Path ?: return if (!file.name.contains(path.toString())) return From 0966944196f99a4b28eb85422c80ca259e97b74e Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Sun, 12 Jan 2025 23:33:24 +0100 Subject: [PATCH 20/61] fix: ConfigFactory.kt --- .../plugin/api/shared/config/ConfigFactory.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt index a2e4b38..577cb1b 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt @@ -11,6 +11,19 @@ import java.io.File import java.nio.file.* import kotlin.coroutines.CoroutineContext +/** + * A configuration factory that loads, saves and watches configuration files. + * The factory automatically reloads the configuration when the file changes. + * + * Usage: + * ``` + * // Using create + * val factory = ConfigFactory.create(File("config.yaml")) + * + * // Using create with custom coroutineContext + * val factory = ConfigFactory.create(File("config.json"), Dispatchers.Default) + * ``` + */ class ConfigFactory( private val file: File, private val configClass: Class<*>, From 6e6dcbf9baf0c0bd2a3004f3cda96861698ea64d Mon Sep 17 00:00:00 2001 From: Niklas <57962465+niklasnieberler@users.noreply.github.com> Date: Mon, 13 Jan 2025 01:11:16 +0100 Subject: [PATCH 21/61] ref: change any to t in ConfigFactory.kt --- .../plugin/api/shared/config/ConfigFactory.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt index 577cb1b..4ce7053 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt @@ -24,13 +24,13 @@ import kotlin.coroutines.CoroutineContext * val factory = ConfigFactory.create(File("config.json"), Dispatchers.Default) * ``` */ -class ConfigFactory( +class ConfigFactory( private val file: File, - private val configClass: Class<*>, + private val configClass: Class, private val coroutineContext: CoroutineContext = Dispatchers.IO ) : AutoCloseable { - private var config: Any? = null + private var config: T? = null private val path: Path = file.toPath() private var watchJob: Job? = null @@ -45,7 +45,7 @@ class ConfigFactory( } .build() - fun loadOrCreate(defaultConfig: Any) { + fun loadOrCreate(defaultConfig: T) { if (!configClass.isInstance(defaultConfig)) { throw IllegalArgumentException("Default config must be an instance of ${configClass.name}") } @@ -59,7 +59,7 @@ class ConfigFactory( registerWatcher() } - private fun createDefaultConfig(defaultConfig: Any) { + private fun createDefaultConfig(defaultConfig: T) { path.parent?.let { Files.createDirectories(it) } Files.createFile(path) @@ -70,8 +70,8 @@ class ConfigFactory( } @Suppress("UNCHECKED_CAST") - fun getConfig(): T { - return config as? T ?: throw IllegalStateException("Configuration not loaded or invalid type") + fun getConfig(): T { + return config ?: throw IllegalStateException("Configuration not loaded or invalid type") } @Throws(ConfigurationException::class) @@ -133,6 +133,6 @@ class ConfigFactory( inline fun create( file: File, coroutineContext: CoroutineContext = Dispatchers.IO - ): ConfigFactory = ConfigFactory(file, T::class.java, coroutineContext) + ): ConfigFactory = ConfigFactory(file, T::class.java, coroutineContext) } } \ No newline at end of file From 1644f36201eb7bd6020095cc4b2290206a426989 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Mon, 13 Jan 2025 08:06:01 +0100 Subject: [PATCH 22/61] fix: removed unnecessary @Suppress("UNCHECKED_CAST") --- .../plugin/api/shared/config/ConfigFactory.kt | 137 +++++++++++------- 1 file changed, 87 insertions(+), 50 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt index 56085a4..cf02c32 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt @@ -1,37 +1,41 @@ package app.simplecloud.plugin.api.shared.config +import app.simplecloud.plugin.api.shared.exception.ConfigurationException import app.simplecloud.plugin.api.shared.repository.GenericEnumSerializer -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.delay -import kotlinx.coroutines.isActive -import kotlinx.coroutines.launch +import kotlinx.coroutines.* import org.spongepowered.configurate.ConfigurationOptions import org.spongepowered.configurate.kotlin.objectMapperFactory -import org.spongepowered.configurate.kotlin.toNode import org.spongepowered.configurate.yaml.NodeStyle import org.spongepowered.configurate.yaml.YamlConfigurationLoader import java.io.File -import java.nio.file.FileSystems -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.StandardWatchEventKinds +import java.nio.file.* +import kotlin.coroutines.CoroutineContext /** - * @author Niklas Nieberler + * A configuration factory that loads, saves and watches configuration files. + * The factory automatically reloads the configuration when the file changes. + * + * Usage: + * ``` + * // Using create + * val factory = ConfigFactory.create(File("config.yaml")) + * + * // Using create with custom coroutineContext + * val factory = ConfigFactory.create(File("config.json"), Dispatchers.Default) + * ``` */ - -class ConfigFactory( +class ConfigFactory( private val file: File, - private val defaultConfig: E -) { + private val configClass: Class, + private val coroutineContext: CoroutineContext = Dispatchers.IO +) : AutoCloseable { - private var config = defaultConfig - private val path = file.toPath() + private var config: T? = null + private val path: Path = file.toPath() + private var watchJob: Job? = null private val configurationLoader = YamlConfigurationLoader.builder() - .path(this.path) + .path(path) .nodeStyle(NodeStyle.BLOCK) .defaultOptions { options -> options.serializers { builder -> @@ -41,60 +45,93 @@ class ConfigFactory( } .build() - fun loadOrCreate() { - registerWatcher() - if (this.file.exists()) { + fun loadOrCreate(defaultConfig: T) { + if (!configClass.isInstance(defaultConfig)) { + throw IllegalArgumentException("Default config must be an instance of ${configClass.name}") + } + + if (file.exists()) { loadConfig() - return + } else { + createDefaultConfig(defaultConfig) } - createDefaultConfig() + + registerWatcher() } - private fun createDefaultConfig() { - this.path.parent?.let { Files.createDirectories(it) } - Files.createFile(this.path) + private fun createDefaultConfig(defaultConfig: T) { + path.parent?.let { Files.createDirectories(it) } + Files.createFile(path) - val configurationNode = this.configurationLoader.load(ConfigurationOptions.defaults()) - this.defaultConfig!!.toNode(configurationNode) - this.configurationLoader.save(configurationNode) + val node = configurationLoader.createNode() + node.set(configClass, defaultConfig) + configurationLoader.save(node) + config = defaultConfig } - fun getConfig(): E = this.config + fun getConfig(): T { + return config ?: throw IllegalStateException("Configuration not loaded or invalid type") + } + @Throws(ConfigurationException::class) private fun loadConfig() { - val configurationNode = this.configurationLoader.load(ConfigurationOptions.defaults()) - this.config = configurationNode.get(this.defaultConfig!!::class.java) - ?: throw IllegalStateException("Config could not be loaded") + try { + val node = configurationLoader.load(ConfigurationOptions.defaults()) + config = node.get(configClass) + ?: throw ConfigurationException("Failed to parse configuration file") + } catch (e: Exception) { + throw ConfigurationException("Failed to load configuration", e) + } } private fun registerWatcher(): Job { val watchService = FileSystems.getDefault().newWatchService() - this.path.register( + path.parent?.register( watchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY ) - return CoroutineScope(Dispatchers.IO).launch { - while (isActive) { - val key = watchService.take() - - key.pollEvents().forEach { event -> - val path = event.context() as? Path ?: return@forEach - if (!file.name.contains(path.toString())) return@launch - - when (event.kind()) { - StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_MODIFY -> { - delay(100) - loadConfig() - } + return CoroutineScope(coroutineContext).launch { + watchService.use { watchService -> + while (isActive) { + val key = watchService.take() + key.pollEvents().forEach { event -> + handleWatchEvent(event) + } + if (!key.reset()) { + break } } + } + }.also { watchJob = it } + } - key.reset() + private suspend fun handleWatchEvent(event: WatchEvent<*>) { + val path = event.context() as? Path ?: return + if (!file.name.contains(path.toString())) return + + when (event.kind()) { + StandardWatchEventKinds.ENTRY_CREATE, + StandardWatchEventKinds.ENTRY_MODIFY -> { + delay(100) + try { + loadConfig() + } catch (e: ConfigurationException) { + println("Failed to reload configuration: ${e.message}") + } } } } + override fun close() { + watchJob?.cancel() + } + + companion object { + inline fun create( + file: File, + coroutineContext: CoroutineContext = Dispatchers.IO + ): ConfigFactory = ConfigFactory(file, T::class.java, coroutineContext) + } } \ No newline at end of file From f8e3e5ca5b21a19c65eefb8c8057b5d784def825 Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 13 Jan 2025 17:54:43 +0100 Subject: [PATCH 23/61] feat: pretty group names --- build.gradle.kts | 3 +- gradle/libs.versions.toml | 5 +- .../shared/pattern/ServerPatternIdentifier.kt | 2 + .../single/SingleServerPlaceholderExecutor.kt | 4 ++ .../plugin/api/shared/pretty/PrettifyCase.kt | 10 +++ .../api/shared/pretty/StringPrettifier.kt | 64 ++++++++++++++++++ .../api/shared/pretty/StringPrettifierTest.kt | 65 +++++++++++++++++++ 7 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pretty/PrettifyCase.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pretty/StringPrettifier.kt create mode 100644 plugin-shared/src/test/kotlin/app/simplecloud/plugin/api/shared/pretty/StringPrettifierTest.kt diff --git a/build.gradle.kts b/build.gradle.kts index a5cb9b3..eaab743 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,7 +28,8 @@ subprojects { apply(plugin = "net.thebugmc.gradle.sonatype-central-portal-publisher") dependencies { - compileOnly(rootProject.libs.kotlinJvm) + testImplementation(rootProject.libs.kotlin.test) + compileOnly(rootProject.libs.kotlin.jvm) compileOnly(rootProject.libs.bundles.simpleCloudController) compileOnly(rootProject.libs.bundles.adventure) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c17b92f..842a576 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,12 @@ [versions] -kotlin = "2.0.0" +kotlin = "2.0.20" simpleCloudController = "0.0.30-dev.e3e27fc" sonatype-central-portal-publisher = "1.2.3" adventure = "4.18.0" [libraries] -kotlinJvm = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } +kotlin-jvm = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } +kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } simpleCloudControllerApi = { module = "app.simplecloud.controller:controller-api", version.ref = "simpleCloudController" } simpleCloudControllerShared = { module = "app.simplecloud.controller:controller-shared", version.ref = "simpleCloudController" } diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pattern/ServerPatternIdentifier.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pattern/ServerPatternIdentifier.kt index 92c9cba..1f06f4d 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pattern/ServerPatternIdentifier.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pattern/ServerPatternIdentifier.kt @@ -3,6 +3,7 @@ package app.simplecloud.plugin.api.shared.pattern import app.simplecloud.controller.api.ControllerApi import app.simplecloud.controller.shared.group.Group import app.simplecloud.controller.shared.server.Server +import app.simplecloud.plugin.api.shared.pretty.StringPrettifier /** * @author Niklas Nieberler @@ -42,6 +43,7 @@ class ServerPatternIdentifier( fun parseServerToPattern(server: Server): String { return this.pattern .replace("", server.group) + .replace("", server.properties["pretty-name"] ?: StringPrettifier.prettify(server.group)) .replace("", server.uniqueId) .replace("", server.uniqueId) .replace("", server.numericalId.toString()) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt index 8dccdfb..938642e 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt @@ -3,6 +3,7 @@ package app.simplecloud.plugin.api.shared.placeholder.single import app.simplecloud.controller.api.ControllerApi import app.simplecloud.controller.shared.server.Server import app.simplecloud.plugin.api.shared.placeholder.async.AsyncPlaceholder +import app.simplecloud.plugin.api.shared.pretty.StringPrettifier /** * @author Niklas Nieberler @@ -14,6 +15,9 @@ class SingleServerPlaceholderExecutor : SinglePlaceholderExecutor { AsyncPlaceholder("id") { it.uniqueId }, AsyncPlaceholder("numerical_id") { it.numericalId }, AsyncPlaceholder("group_name") { it.group }, + AsyncPlaceholder("group_pretty_name") { + it.properties["pretty-name"] ?: StringPrettifier.prettify(it.group) + }, AsyncPlaceholder("type") { it.type }, AsyncPlaceholder("state") { it.state }, AsyncPlaceholder("ip") { it.ip }, diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pretty/PrettifyCase.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pretty/PrettifyCase.kt new file mode 100644 index 0000000..4ae7f66 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pretty/PrettifyCase.kt @@ -0,0 +1,10 @@ +package app.simplecloud.plugin.api.shared.pretty + +enum class PrettifyCase { + TITLE, + CAMEL, + PASCAL, + SENTENCE, + KEBAB, + SNAKE +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pretty/StringPrettifier.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pretty/StringPrettifier.kt new file mode 100644 index 0000000..e188366 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pretty/StringPrettifier.kt @@ -0,0 +1,64 @@ +package app.simplecloud.plugin.api.shared.pretty + +object StringPrettifier { + + /** + * Converts various string formats to different cases + */ + fun prettify(input: String, case: PrettifyCase = PrettifyCase.TITLE): String { + return when (case) { + PrettifyCase.TITLE -> toTitleCase(input) + PrettifyCase.CAMEL -> toCamelCase(input) + PrettifyCase.PASCAL -> toPascalCase(input) + PrettifyCase.SENTENCE -> toSentenceCase(input) + PrettifyCase.KEBAB -> toKebabCase(input) + PrettifyCase.SNAKE -> toSnakeCase(input) + } + } + + private fun toTitleCase(input: String): String { + return input.split(Regex("[\\s_-]")) + .filter { it.isNotEmpty() } + .joinToString(" ") { word -> + word.lowercase().replaceFirstChar { it.uppercase() } + } + } + + private fun toCamelCase(input: String): String { + return input.split(Regex("[\\s_-]")) + .filter { it.isNotEmpty() } + .mapIndexed { index, word -> + if (index == 0) word.lowercase() + else word.lowercase().replaceFirstChar { it.uppercase() } + } + .joinToString("") + } + + private fun toPascalCase(input: String): String { + return input.split(Regex("[\\s_-]")) + .filter { it.isNotEmpty() } + .joinToString("") { word -> + word.lowercase().replaceFirstChar { it.uppercase() } + } + } + + private fun toSentenceCase(input: String): String { + return input.split(Regex("[\\s_-]")) + .filter { it.isNotEmpty() } + .joinToString(" ") { it.lowercase() } + .replaceFirstChar { it.uppercase() } + } + + private fun toKebabCase(input: String): String { + return input.split(Regex("[\\s_]")) + .filter { it.isNotEmpty() } + .joinToString("-") { it.lowercase() } + } + + private fun toSnakeCase(input: String): String { + return input.split(Regex("[\\s-]")) + .filter { it.isNotEmpty() } + .joinToString("_") { it.lowercase() } + } + +} \ No newline at end of file diff --git a/plugin-shared/src/test/kotlin/app/simplecloud/plugin/api/shared/pretty/StringPrettifierTest.kt b/plugin-shared/src/test/kotlin/app/simplecloud/plugin/api/shared/pretty/StringPrettifierTest.kt new file mode 100644 index 0000000..28cca93 --- /dev/null +++ b/plugin-shared/src/test/kotlin/app/simplecloud/plugin/api/shared/pretty/StringPrettifierTest.kt @@ -0,0 +1,65 @@ +package app.simplecloud.plugin.api.shared.pretty + +import kotlin.test.* + +class StringPrettifierTest { + + @Test + fun testTitleCaseConversion() { + assertEquals("Hello World", StringPrettifier.prettify("hello-world")) + assertEquals("Hello World", StringPrettifier.prettify("hello_world")) + assertEquals("Hello World", StringPrettifier.prettify("hello world")) + assertEquals("Hello Beautiful World", StringPrettifier.prettify("hello-beautiful_world")) + } + + @Test + fun testCamelCaseConversion() { + assertEquals("helloWorld", StringPrettifier.prettify("hello-world", PrettifyCase.CAMEL)) + assertEquals("helloWorld", StringPrettifier.prettify("hello_world", PrettifyCase.CAMEL)) + assertEquals("helloBeautifulWorld", StringPrettifier.prettify("hello beautiful world", PrettifyCase.CAMEL)) + assertEquals("myVariableName", StringPrettifier.prettify("my-variable-name", PrettifyCase.CAMEL)) + } + + @Test + fun testPascalCaseConversion() { + assertEquals("HelloWorld", StringPrettifier.prettify("hello-world", PrettifyCase.PASCAL)) + assertEquals("HelloWorld", StringPrettifier.prettify("hello_world", PrettifyCase.PASCAL)) + assertEquals("HelloBeautifulWorld", StringPrettifier.prettify("hello beautiful world", PrettifyCase.PASCAL)) + assertEquals("MyVariableName", StringPrettifier.prettify("my-variable-name", PrettifyCase.PASCAL)) + } + + @Test + fun testSentenceCaseConversion() { + assertEquals("Hello world", StringPrettifier.prettify("hello-world", PrettifyCase.SENTENCE)) + assertEquals("Hello beautiful world", StringPrettifier.prettify("hello_beautiful_world", PrettifyCase.SENTENCE)) + assertEquals("My variable name", StringPrettifier.prettify("my-variable-name", PrettifyCase.SENTENCE)) + } + + @Test + fun testKebabCaseConversion() { + assertEquals("hello-world", StringPrettifier.prettify("hello world", PrettifyCase.KEBAB)) + assertEquals("hello-beautiful-world", StringPrettifier.prettify("hello_beautiful_world", PrettifyCase.KEBAB)) + assertEquals("my-variable-name", StringPrettifier.prettify("my variable name", PrettifyCase.KEBAB)) + } + + @Test + fun testSnakeCaseConversion() { + assertEquals("hello_world", StringPrettifier.prettify("hello-world", PrettifyCase.SNAKE)) + assertEquals("hello_beautiful_world", StringPrettifier.prettify("hello beautiful world", PrettifyCase.SNAKE)) + assertEquals("my_variable_name", StringPrettifier.prettify("my-variable-name", PrettifyCase.SNAKE)) + } + + @Test + fun testEmptyStringHandling() { + assertEquals("", StringPrettifier.prettify("")) + assertEquals("", StringPrettifier.prettify("", PrettifyCase.CAMEL)) + assertEquals("", StringPrettifier.prettify("", PrettifyCase.PASCAL)) + } + + @Test + fun testMultipleDelimiterHandling() { + assertEquals("Hello Beautiful World", StringPrettifier.prettify("hello-beautiful_world")) + assertEquals("helloBeautifulWorld", StringPrettifier.prettify("hello-beautiful_world", PrettifyCase.CAMEL)) + assertEquals("HelloBeautifulWorld", StringPrettifier.prettify("hello-beautiful_world", PrettifyCase.PASCAL)) + } +} From 738f28e92b103b32049b97303cc5d8aae8570484 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Thu, 30 Jan 2025 12:35:36 +0100 Subject: [PATCH 24/61] feat: wasn't happy with my ConfigFactory so improved it immensely --- .../plugin/api/shared/config/ConfigFactory.kt | 163 ++++++++++++++++-- 1 file changed, 148 insertions(+), 15 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt index cf02c32..b6f8d74 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt @@ -3,18 +3,26 @@ package app.simplecloud.plugin.api.shared.config import app.simplecloud.plugin.api.shared.exception.ConfigurationException import app.simplecloud.plugin.api.shared.repository.GenericEnumSerializer import kotlinx.coroutines.* +import org.slf4j.LoggerFactory import org.spongepowered.configurate.ConfigurationOptions import org.spongepowered.configurate.kotlin.objectMapperFactory import org.spongepowered.configurate.yaml.NodeStyle import org.spongepowered.configurate.yaml.YamlConfigurationLoader import java.io.File import java.nio.file.* +import java.util.concurrent.atomic.AtomicReference import kotlin.coroutines.CoroutineContext /** * A configuration factory that loads, saves and watches configuration files. * The factory automatically reloads the configuration when the file changes. * + * Features: + * - Thread-safe configuration handling + * - File watching with automatic reloading + * - Configuration change callbacks + * - Validation support + * * Usage: * ``` * // Using create @@ -22,17 +30,34 @@ import kotlin.coroutines.CoroutineContext * * // Using create with custom coroutineContext * val factory = ConfigFactory.create(File("config.json"), Dispatchers.Default) + * + * // Add change listener + * factory.onConfigChanged { oldConfig, newConfig -> + * println("Config updated from $oldConfig to $newConfig") + * } + * + * // Save the modified config + * factory.save(modifiedConfig) + * + * // Optionally with validation + * factory.save(modifiedConfig) { config -> + * config.someField.isNotEmpty() // return true/false for validation + * } * ``` */ -class ConfigFactory( +class ConfigFactory( private val file: File, private val configClass: Class, private val coroutineContext: CoroutineContext = Dispatchers.IO ) : AutoCloseable { - private var config: T? = null + private val logger = LoggerFactory.getLogger(ConfigFactory::class.java) + private val configRef = AtomicReference() private val path: Path = file.toPath() private var watchJob: Job? = null + private val changeListeners = mutableListOf Unit>() + private val saveLock = Object() + private val scope = CoroutineScope(coroutineContext + SupervisorJob()) private val configurationLoader = YamlConfigurationLoader.builder() .path(path) @@ -45,45 +70,145 @@ class ConfigFactory( } .build() - fun loadOrCreate(defaultConfig: T) { + /** + * Loads existing configuration or creates a new one with default values. + * @param defaultConfig The default configuration to use if no file exists + * @param validator Optional validation function for the configuration + */ + fun loadOrCreate(defaultConfig: T, validator: ((T) -> Boolean)? = null) { if (!configClass.isInstance(defaultConfig)) { throw IllegalArgumentException("Default config must be an instance of ${configClass.name}") } if (file.exists()) { - loadConfig() + loadConfig(validator) } else { - createDefaultConfig(defaultConfig) + createDefaultConfig(defaultConfig, validator) } registerWatcher() } - private fun createDefaultConfig(defaultConfig: T) { + /** + * Checks if the configuration file exists. + * @return true if the configuration file exists + */ + fun exists(): Boolean = file.exists() + + /** + * Adds a listener that will be called whenever the configuration changes. + * @param listener The listener function that receives old and new config + */ + fun onConfigChanged(listener: suspend (T?, T) -> Unit) { + synchronized(changeListeners) { + changeListeners.add(listener) + } + } + + private fun createDefaultConfig(defaultConfig: T, validator: ((T) -> Boolean)?) { path.parent?.let { Files.createDirectories(it) } Files.createFile(path) - val node = configurationLoader.createNode() - node.set(configClass, defaultConfig) - configurationLoader.save(node) - config = defaultConfig + if (validator?.invoke(defaultConfig) == false) { + throw ConfigurationException("Default configuration failed validation") + } + + synchronized(saveLock) { + try { + val node = configurationLoader.createNode() + node.set(configClass, defaultConfig) + configurationLoader.save(node) + runBlocking(coroutineContext) { + updateConfig(defaultConfig) + } + } catch (e: Exception) { + throw ConfigurationException("Failed to save default configuration", e) + } + } } + /** + * Gets the current configuration. + * @throws IllegalStateException if configuration is not loaded + */ fun getConfig(): T { - return config ?: throw IllegalStateException("Configuration not loaded or invalid type") + return configRef.get() ?: throw IllegalStateException("Configuration not loaded or invalid type") } + /** + * Manually reloads the configuration from disk. + * @param validator Optional validation function for the loaded configuration + * @throws ConfigurationException if loading or validation fails + */ @Throws(ConfigurationException::class) - private fun loadConfig() { + fun reloadConfig(validator: ((T) -> Boolean)? = null) { + loadConfig(validator) + } + + @Throws(ConfigurationException::class) + private fun loadConfig(validator: ((T) -> Boolean)? = null) { try { val node = configurationLoader.load(ConfigurationOptions.defaults()) - config = node.get(configClass) + val loadedConfig = node.get(configClass) ?: throw ConfigurationException("Failed to parse configuration file") + + if (validator?.invoke(loadedConfig) == false) { + throw ConfigurationException("Configuration failed validation") + } + + runBlocking(coroutineContext) { + updateConfig(loadedConfig) + } } catch (e: Exception) { throw ConfigurationException("Failed to load configuration", e) } } + /** + * Saves the provided configuration to disk. + * @param config The configuration to save + * @param validator Optional validation function to run before saving + * @throws ConfigurationException if saving or validation fails + */ + @Throws(ConfigurationException::class) + fun save(config: T, validator: ((T) -> Boolean)? = null) { + if (validator?.invoke(config) == false) { + throw ConfigurationException("Configuration failed validation") + } + + synchronized(saveLock) { + try { + val node = configurationLoader.createNode() + node.set(configClass, config) + configurationLoader.save(node) + runBlocking(coroutineContext) { + updateConfig(config) + } + } catch (e: Exception) { + throw ConfigurationException("Failed to save configuration", e) + } + } + } + + private suspend fun updateConfig(newConfig: T) { + val oldConfig = configRef.get() + configRef.set(newConfig) + + val listeners = synchronized(changeListeners) { + changeListeners.toList() + } + + listeners.forEach { listener -> + try { + withContext(coroutineContext) { + listener(oldConfig, newConfig) + } + } catch (e: Exception) { + logger.error("Error in config change listener", e) + } + } + } + private fun registerWatcher(): Job { val watchService = FileSystems.getDefault().newWatchService() path.parent?.register( @@ -92,7 +217,7 @@ class ConfigFactory( StandardWatchEventKinds.ENTRY_MODIFY ) - return CoroutineScope(coroutineContext).launch { + return scope.launch { watchService.use { watchService -> while (isActive) { val key = watchService.take() @@ -118,17 +243,25 @@ class ConfigFactory( try { loadConfig() } catch (e: ConfigurationException) { - println("Failed to reload configuration: ${e.message}") + logger.error("Failed to reload configuration: ${e.message}", e) } } + + else -> {} } } override fun close() { + scope.cancel() watchJob?.cancel() } companion object { + /** + * Creates a new ConfigFactory instance. + * @param file The configuration file + * @param coroutineContext The coroutine context to use for async operations + */ inline fun create( file: File, coroutineContext: CoroutineContext = Dispatchers.IO From 2976b9dfcdac34ad8c581899a0cb25c8fa295984 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 31 Jan 2025 00:20:36 +0100 Subject: [PATCH 25/61] feat: added a more abstract DirectoryRepository implementation --- .../config/repository/DirectoryRepository.kt | 343 ++++++++++++++++++ .../config/repository/handler/FileHandler.kt | 15 + .../repository/handler/PNGFileHandler.kt | 22 ++ .../repository/handler/YamlFileHandler.kt | 48 +++ .../shared/exception/RepositoryException.kt | 3 + 5 files changed, 431 insertions(+) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/FileHandler.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/PNGFileHandler.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/RepositoryException.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt new file mode 100644 index 0000000..3a223c5 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt @@ -0,0 +1,343 @@ +package app.simplecloud.plugin.api.shared.config.repository + +import app.simplecloud.plugin.api.shared.config.repository.handler.FileHandler +import app.simplecloud.plugin.api.shared.exception.RepositoryException +import kotlinx.coroutines.* +import org.slf4j.LoggerFactory +import java.io.File +import java.io.FileOutputStream +import java.net.URL +import java.nio.file.* +import java.util.concurrent.ConcurrentHashMap +import java.util.concurrent.atomic.AtomicReference +import java.util.jar.JarFile +import kotlin.coroutines.CoroutineContext + +/** + * A directory repository that manages files of a specific type. + * Features: + * - Thread-safe entity handling + * - File watching with automatic reloading + * - Entity change callbacks + * - Validation support + * - Automatic resource cleanup + * + * @param I The type of the identifier + * @param T The type of the entity + */ +class DirectoryRepository constructor( + private val directory: Path, + private val fileHandler: FileHandler, + private val coroutineContext: CoroutineContext, + private val validator: ((T) -> Boolean)? = null +) : AutoCloseable { + + private val logger = LoggerFactory.getLogger(DirectoryRepository::class.java) + private val entities = ConcurrentHashMap>() + private val identifiers = ConcurrentHashMap() + private val changeListeners = mutableListOf Unit>() + private val errorHandlers = mutableListOf<(Exception) -> Unit>() + private val saveLock = Object() + private val scope = CoroutineScope(coroutineContext + SupervisorJob()) + private var watchJob: Job? = null + + init { + if (!directory.toFile().exists()) { + directory.toFile().mkdirs() + } + } + + /** + * Loads all entities from the directory or creates them using default values. + * @param defaultEntities Default entities to use if no existing files are found + * @throws RepositoryException if loading or creation fails + */ + @Throws(RepositoryException::class) + fun loadOrCreate(defaultEntities: Map = emptyMap()) { + try { + if (directory.toFile().list()?.isEmpty() != false) { + loadDefaultsFromResources(defaultEntities) + } + + load() + registerWatcher() + } catch (e: Exception) { + handleError(RepositoryException("Failed to load repository", e)) + } + } + + private fun loadDefaultsFromResources(defaultEntities: Map) { + if (directory.toFile().list()?.isEmpty() == true) { + val resourceUrl = DirectoryRepository::class.java.getResource("/defaults/") ?: run { + println("Resource folder '/defaults/' not found.") + return + } + + when (resourceUrl.protocol) { + "file" -> handleFileProtocol(resourceUrl, directory.toFile()) + "jar" -> handleJarProtocol(resourceUrl, directory.toFile()) + + else -> println("Unsupported protocol: ${resourceUrl.protocol}") + } + + defaultEntities.forEach { (id, entity) -> save(id, entity) } + } + } + + private fun handleFileProtocol(resourceUrl: URL, targetDirectory: File) { + val resourceDir = File(resourceUrl.toURI()) + + if (resourceDir.exists()) { + resourceDir.copyRecursively(targetDirectory, overwrite = true) + } else { + println("Resource directory does not exist: ${resourceUrl.path}") + } + } + + private fun handleJarProtocol(resourceUrl: URL, targetDirectory: File) { + val jarPath = resourceUrl.path.substringBefore("!").removePrefix("file:") + + try { + JarFile(jarPath).use { jarFile -> + jarFile.entries().asSequence() + .filter { it.name.startsWith("defaults/") && !it.isDirectory } + .forEach { entry -> + val targetFile = File(targetDirectory, entry.name.removePrefix("defaults/")) + targetFile.parentFile.mkdirs() + try { + jarFile.getInputStream(entry).use { inputStream -> + FileOutputStream(targetFile).use { fos -> + fos.write(0xEF) + fos.write(0xBB) + fos.write(0xBF) + inputStream.copyTo(fos) + } + } + } catch (e: Exception) { + println("Error copying file ${entry.name}: ${e.message}") + } + } + } + } catch (e: Exception) { + println("Error processing JAR file: ${e.message}") + e.printStackTrace() + } + } + + private fun load() { + Files.walk(directory) + .filter { !it.toFile().isDirectory && it.toString().endsWith(fileHandler.fileExtension) } + .forEach { loadFile(it.toFile()) } + } + + private fun loadFile(file: File) { + try { + fileHandler.load(file)?.let { entity -> + if (validateEntity(entity)) { + entities[file] = AtomicReference(entity) + } + } + } catch (e: Exception) { + handleError(RepositoryException("Error loading file ${file.name}", e)) + } + } + + /** + * Saves an entity to the repository + * @throws RepositoryException if saving fails or validation fails + */ + @Throws(RepositoryException::class) + fun save(identifier: I, entity: T) { + if (!validateEntity(entity)) { + throw RepositoryException("Entity validation failed") + } + + synchronized(saveLock) { + try { + val file = getFile(identifier) + file.parentFile?.mkdirs() + + fileHandler.save(file, entity) + val oldEntity = entities[file]?.get() + entities[file] = AtomicReference(entity) + identifiers[file] = identifier + + scope.launch { + notifyChangeListeners(identifier, oldEntity, entity) + } + } catch (e: Exception) { + handleError(RepositoryException("Failed to save entity", e)) + throw e + } + } + } + + /** + * Deletes an entity from the repository + */ + fun delete(identifier: I): Boolean { + val file = getFile(identifier) + if (!file.exists()) return false + + synchronized(saveLock) { + return try { + val deleted = file.delete() + + if (deleted) { + val oldEntity = entities.remove(file)?.get() + identifiers.remove(file) + if (oldEntity != null) { + scope.launch { + notifyChangeListeners(identifier, oldEntity, null) + } + } + } + + deleted + } catch (e: Exception) { + handleError(RepositoryException("Failed to delete entity", e)) + false + } + } + } + + /** + * Finds an entity by identifier + */ + fun find(identifier: I): T? = + entities[getFile(identifier)]?.get() + + + /** + * Gets all entities in the repository + */ + fun getAll(): List = entities.values.mapNotNull { it.get() } + + /** + * Gets all identifiers in the repository + */ + fun getAllIdentifiers(): Set = identifiers.values.toSet() + + /** + * Adds a listener for entity changes + */ + fun onEntityChanged(listener: suspend (I, T?, T?) -> Unit) { + synchronized(changeListeners) { + changeListeners.add(listener) + } + } + + /** + * Adds an error handler + */ + fun onError(handler: (Exception) -> Unit) { + synchronized(errorHandlers) { + errorHandlers.add(handler) + } + } + + private fun validateEntity(entity: T): Boolean { + return validator?.invoke(entity) ?: fileHandler.validate(entity) + } + + private fun handleError(error: Exception) { + logger.error(error.message, error) + synchronized(errorHandlers) { + errorHandlers.forEach { it(error) } + } + } + + private suspend fun notifyChangeListeners(identifier: I, oldEntity: T?, newEntity: T?) { + val listeners = synchronized(changeListeners) { changeListeners.toList() } + + listeners.forEach { listener -> + try { + withContext(coroutineContext) { + if (oldEntity != newEntity) { + listener(identifier, oldEntity, newEntity) + } + } + } catch (e: Exception) { + handleError(RepositoryException("Error in change listener", e)) + } + } + } + + private fun getFile(identifier: I): File = + directory.resolve("$identifier${fileHandler.fileExtension}").toFile() + + + private fun registerWatcher(): Job { + val watchService = FileSystems.getDefault().newWatchService() + directory.register( + watchService, + StandardWatchEventKinds.ENTRY_CREATE, + StandardWatchEventKinds.ENTRY_MODIFY, + StandardWatchEventKinds.ENTRY_DELETE + ) + + return scope.launch { + watchService.use { service -> + while (isActive) { + val key = service.take() + + key.pollEvents().forEach { event -> + handleWatchEvent(event) + } + + if (!key.reset()) break + } + } + }.also { watchJob = it } + } + + private suspend fun handleWatchEvent(event: WatchEvent<*>) { + val path = event.context() as? Path ?: return + if (!path.toString().endsWith(fileHandler.fileExtension)) return + + val resolvedPath = directory.resolve(path) + if (Files.isDirectory(resolvedPath)) return + + when (event.kind()) { + StandardWatchEventKinds.ENTRY_CREATE, + StandardWatchEventKinds.ENTRY_MODIFY -> { + delay(100) + loadFile(resolvedPath.toFile()) + } + + StandardWatchEventKinds.ENTRY_DELETE -> { + val file = resolvedPath.toFile() + val identifier = identifiers[file] + val oldEntity = entities.remove(file)?.get() + + if (identifier != null && oldEntity != null) { + notifyChangeListeners(identifier, oldEntity, null) + } + } + + else -> {} + } + } + + override fun close() { + scope.cancel() + watchJob?.cancel() + } + + companion object { + /** + * Creates a new DirectoryRepository instance + */ + inline fun create( + directory: Path, + fileHandler: FileHandler, + noinline validator: ((T) -> Boolean)? = null, + coroutineContext: CoroutineContext = Dispatchers.IO + ): DirectoryRepository = DirectoryRepository( + directory = directory, + fileHandler = fileHandler, + validator = validator, + coroutineContext = coroutineContext + ) + } +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/FileHandler.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/FileHandler.kt new file mode 100644 index 0000000..a144ba6 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/FileHandler.kt @@ -0,0 +1,15 @@ +package app.simplecloud.plugin.api.shared.config.repository.handler + +import java.io.File + +interface FileHandler { + + val fileExtension: String + + fun load(file: File): T? + + fun save(file: File, entity: T) + + fun validate(entity: T): Boolean = true + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/PNGFileHandler.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/PNGFileHandler.kt new file mode 100644 index 0000000..2135c4e --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/PNGFileHandler.kt @@ -0,0 +1,22 @@ +package app.simplecloud.plugin.api.shared.config.repository.handler + +import java.awt.image.BufferedImage +import java.io.File +import javax.imageio.ImageIO + +class PNGFileHandler : FileHandler { + + override val fileExtension: String = ".png" + + override fun load(file: File): BufferedImage? = + runCatching { ImageIO.read(file) }.getOrNull() + + + override fun save(file: File, entity: BufferedImage) { + ImageIO.write(entity, "png", file) + } + + override fun validate(entity: BufferedImage): Boolean = + entity.width > 0 && entity.height > 0 + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt new file mode 100644 index 0000000..9522680 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt @@ -0,0 +1,48 @@ +package app.simplecloud.plugin.api.shared.config.repository.handler + +import app.simplecloud.plugin.api.shared.repository.GenericEnumSerializer +import org.spongepowered.configurate.kotlin.objectMapperFactory +import org.spongepowered.configurate.yaml.NodeStyle +import org.spongepowered.configurate.yaml.YamlConfigurationLoader +import java.io.File + +class YamlFileHandler( + private val clazz: Class +) : FileHandler { + + override val fileExtension: String = ".yml" + + private val loaders = mutableMapOf() + + private fun getOrCreateLoader(file: File): YamlConfigurationLoader { + return loaders.getOrPut(file) { + YamlConfigurationLoader.builder() + .path(file.toPath()) + .nodeStyle(NodeStyle.BLOCK) + .defaultOptions { options -> + options.serializers { builder -> + builder.registerAnnotatedObjects(objectMapperFactory()) + builder.register(Enum::class.java, GenericEnumSerializer) + } + } + .build() + } + } + + override fun load(file: File): T? { + return try { + val loader = getOrCreateLoader(file) + val node = loader.load() + node.get(clazz) + } catch (e: Exception) { + null + } + } + + override fun save(file: File, entity: T) { + val loader = getOrCreateLoader(file) + val node = loader.createNode() + node.set(clazz, entity) + loader.save(node) + } +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/RepositoryException.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/RepositoryException.kt new file mode 100644 index 0000000..a698774 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/RepositoryException.kt @@ -0,0 +1,3 @@ +package app.simplecloud.plugin.api.shared.exception + +class RepositoryException(message: String, cause: Throwable? = null) : Exception(message, cause) \ No newline at end of file From 3be999a3314ad1d84e0ba2ed718bff542194d96d Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 31 Jan 2025 03:47:09 +0100 Subject: [PATCH 26/61] fix: using correct resource directory for default config loading --- .../config/repository/DirectoryRepository.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt index 3a223c5..3087563 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt @@ -12,6 +12,7 @@ import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.atomic.AtomicReference import java.util.jar.JarFile import kotlin.coroutines.CoroutineContext +import kotlin.io.path.pathString /** * A directory repository that manages files of a specific type. @@ -68,8 +69,11 @@ class DirectoryRepository constructor( private fun loadDefaultsFromResources(defaultEntities: Map) { if (directory.toFile().list()?.isEmpty() == true) { - val resourceUrl = DirectoryRepository::class.java.getResource("/defaults/") ?: run { - println("Resource folder '/defaults/' not found.") + + val last = directory.pathString.split('/').last() + + val resourceUrl = DirectoryRepository::class.java.getResource("/$last") ?: run { + logger.warn("Resource folder '/$last' not found.") return } @@ -77,7 +81,7 @@ class DirectoryRepository constructor( "file" -> handleFileProtocol(resourceUrl, directory.toFile()) "jar" -> handleJarProtocol(resourceUrl, directory.toFile()) - else -> println("Unsupported protocol: ${resourceUrl.protocol}") + else -> logger.warn("Unsupported protocol: ${resourceUrl.protocol}") } defaultEntities.forEach { (id, entity) -> save(id, entity) } @@ -90,7 +94,7 @@ class DirectoryRepository constructor( if (resourceDir.exists()) { resourceDir.copyRecursively(targetDirectory, overwrite = true) } else { - println("Resource directory does not exist: ${resourceUrl.path}") + logger.warn("Resource directory does not exist: ${resourceUrl.path}") } } @@ -114,21 +118,20 @@ class DirectoryRepository constructor( } } } catch (e: Exception) { - println("Error copying file ${entry.name}: ${e.message}") + logger.error("Error copying file ${entry.name}: ${e.message}") } } } } catch (e: Exception) { - println("Error processing JAR file: ${e.message}") + logger.error("Error processing JAR file: ${e.message}") e.printStackTrace() } } - private fun load() { + private fun load() = Files.walk(directory) .filter { !it.toFile().isDirectory && it.toString().endsWith(fileHandler.fileExtension) } .forEach { loadFile(it.toFile()) } - } private fun loadFile(file: File) { try { From f82afcb494172f79971cc799efee719928fd8209 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 31 Jan 2025 04:15:02 +0100 Subject: [PATCH 27/61] fix: resource directory resource loading --- .../config/repository/DirectoryRepository.kt | 69 +++++++++++-------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt index 3087563..56ce578 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt @@ -56,8 +56,8 @@ class DirectoryRepository constructor( @Throws(RepositoryException::class) fun loadOrCreate(defaultEntities: Map = emptyMap()) { try { - if (directory.toFile().list()?.isEmpty() != false) { - loadDefaultsFromResources(defaultEntities) + if (Files.newDirectoryStream(directory).use { it.none() }) { + loadFromResources(defaultEntities) } load() @@ -67,25 +67,25 @@ class DirectoryRepository constructor( } } - private fun loadDefaultsFromResources(defaultEntities: Map) { - if (directory.toFile().list()?.isEmpty() == true) { + private fun loadFromResources( + defaultEntities: Map, + writeBom: Boolean = true + ) { + val targetDirectory = File(directory.toUri()).apply { mkdirs() } + val last = directory.pathString.split('/').last() - val last = directory.pathString.split('/').last() - - val resourceUrl = DirectoryRepository::class.java.getResource("/$last") ?: run { - logger.warn("Resource folder '/$last' not found.") - return - } - - when (resourceUrl.protocol) { - "file" -> handleFileProtocol(resourceUrl, directory.toFile()) - "jar" -> handleJarProtocol(resourceUrl, directory.toFile()) - - else -> logger.warn("Unsupported protocol: ${resourceUrl.protocol}") - } + val resourceUrl = DirectoryRepository::class.java.getResource("/$last") ?: run { + logger.warn("$last folder not found in resources") + return + } - defaultEntities.forEach { (id, entity) -> save(id, entity) } + when (resourceUrl.protocol) { + "file" -> handleFileProtocol(resourceUrl, targetDirectory) + "jar" -> handleJarProtocol(resourceUrl, targetDirectory, writeBom) + else -> logger.error("Unsupported protocol: ${resourceUrl.protocol}") } + + defaultEntities.forEach { (id, entity) -> save(id, entity) } } private fun handleFileProtocol(resourceUrl: URL, targetDirectory: File) { @@ -98,33 +98,46 @@ class DirectoryRepository constructor( } } - private fun handleJarProtocol(resourceUrl: URL, targetDirectory: File) { + private fun handleJarProtocol( + resourceUrl: URL, + targetDirectory: File, + writeBom: Boolean + ) { val jarPath = resourceUrl.path.substringBefore("!").removePrefix("file:") - try { JarFile(jarPath).use { jarFile -> + val last = directory.pathString.split('/').last() + var filesProcessed = 0 + var filesFailed = 0 + jarFile.entries().asSequence() - .filter { it.name.startsWith("defaults/") && !it.isDirectory } + .filter { it.name.startsWith("$last/") && !it.isDirectory } .forEach { entry -> - val targetFile = File(targetDirectory, entry.name.removePrefix("defaults/")) + val targetFile = File(targetDirectory, entry.name.removePrefix("$last/")) targetFile.parentFile.mkdirs() try { jarFile.getInputStream(entry).use { inputStream -> FileOutputStream(targetFile).use { fos -> - fos.write(0xEF) - fos.write(0xBB) - fos.write(0xBF) + if (writeBom) { + fos.write(0xEF) + fos.write(0xBB) + fos.write(0xBF) + } inputStream.copyTo(fos) } } + filesProcessed++ + logger.debug("Successfully extracted: ${entry.name}") } catch (e: Exception) { - logger.error("Error copying file ${entry.name}: ${e.message}") + filesFailed++ + logger.error("Error copying file ${entry.name}") } } + + logger.debug("Processed $filesProcessed files from JAR ($filesFailed failed)") } } catch (e: Exception) { - logger.error("Error processing JAR file: ${e.message}") - e.printStackTrace() + logger.error("Error processing JAR file") } } From be30ed197121effb506458665ab42d81420aa0cc Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 31 Jan 2025 04:22:42 +0100 Subject: [PATCH 28/61] fix: resource directory resource loading --- .../plugin/api/shared/config/repository/DirectoryRepository.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt index 56ce578..05ea6a1 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt @@ -74,6 +74,8 @@ class DirectoryRepository constructor( val targetDirectory = File(directory.toUri()).apply { mkdirs() } val last = directory.pathString.split('/').last() + logger.info("Loading repository from $last") + val resourceUrl = DirectoryRepository::class.java.getResource("/$last") ?: run { logger.warn("$last folder not found in resources") return @@ -127,6 +129,7 @@ class DirectoryRepository constructor( } } filesProcessed++ + logger.info("Successfully extracted: ${entry.name}") logger.debug("Successfully extracted: ${entry.name}") } catch (e: Exception) { filesFailed++ From 18953ff32682275b2876f71a02914d4efa2bbf91 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 31 Jan 2025 04:30:01 +0100 Subject: [PATCH 29/61] fix: resource directory resource loading --- .../api/shared/config/repository/DirectoryRepository.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt index 05ea6a1..6d33f2f 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt @@ -74,8 +74,6 @@ class DirectoryRepository constructor( val targetDirectory = File(directory.toUri()).apply { mkdirs() } val last = directory.pathString.split('/').last() - logger.info("Loading repository from $last") - val resourceUrl = DirectoryRepository::class.java.getResource("/$last") ?: run { logger.warn("$last folder not found in resources") return @@ -129,7 +127,6 @@ class DirectoryRepository constructor( } } filesProcessed++ - logger.info("Successfully extracted: ${entry.name}") logger.debug("Successfully extracted: ${entry.name}") } catch (e: Exception) { filesFailed++ @@ -151,8 +148,10 @@ class DirectoryRepository constructor( private fun loadFile(file: File) { try { + logger.info("Loading file ${file.name}") fileHandler.load(file)?.let { entity -> if (validateEntity(entity)) { + logger.info("Reached ${file.name}") entities[file] = AtomicReference(entity) } } From 132bf6972e4bdbc6437f0a08aec95d163ef5b537 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 31 Jan 2025 04:35:37 +0100 Subject: [PATCH 30/61] fix: resource directory resource loading --- .../plugin/api/shared/config/repository/DirectoryRepository.kt | 1 + .../api/shared/config/repository/handler/YamlFileHandler.kt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt index 6d33f2f..a3b7805 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt @@ -150,6 +150,7 @@ class DirectoryRepository constructor( try { logger.info("Loading file ${file.name}") fileHandler.load(file)?.let { entity -> + logger.info("Reached First ${file.name}") if (validateEntity(entity)) { logger.info("Reached ${file.name}") entities[file] = AtomicReference(entity) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt index 9522680..4a7b4bc 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt @@ -35,6 +35,8 @@ class YamlFileHandler( val node = loader.load() node.get(clazz) } catch (e: Exception) { + println("Error loading file ${file.name}: ${e.message}") + e.printStackTrace() null } } From 79b43a6d48fd15b210600a74125d052eea480b65 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 31 Jan 2025 04:41:13 +0100 Subject: [PATCH 31/61] fix: resource directory resource loading --- build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index eaab743..945f334 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,8 @@ plugins { val baseVersion = "0.0.1" val commitHash = System.getenv("COMMIT_HASH") -val snapshotVersion = "${baseVersion}-dev.$commitHash" +val timestamp = System.currentTimeMillis() // Temporary to be able to build and publish directly out of fix branch with same commit hash +val snapshotVersion = "${baseVersion}-dev.${timestamp}-${commitHash}" allprojects { group = "app.simplecloud.plugin" From 47445722d958b43687f23b9ecf8bba744b7e1e7a Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 31 Jan 2025 04:49:20 +0100 Subject: [PATCH 32/61] Update release-dev.yml --- .github/workflows/release-dev.yml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index c45de60..5429227 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -12,7 +12,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 with: - ref: develop # Ensure it works from the develop branch + ref: develop - name: Set up JDK 21 uses: actions/setup-java@v3 @@ -20,6 +20,10 @@ jobs: distribution: 'adopt' java-version: '21' + - name: Get Commit Hash + id: commit_hash + run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + - name: Cache Gradle packages uses: actions/cache@v3 with: @@ -33,13 +37,14 @@ jobs: - name: Make gradlew executable run: chmod +x ./gradlew - - name: Get Gradle Version - id: gradle_version - run: echo "GRADLE_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_ENV - - - name: Get Commit Hash - id: commit_hash - run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + # Get version after setting COMMIT_HASH + - name: Get Project Version + id: project_version + run: | + VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}') + echo "PROJECT_VERSION=$VERSION" >> $GITHUB_ENV + env: + COMMIT_HASH: ${{ env.COMMIT_HASH }} - name: Publish to SimpleCloud Repository run: ./gradlew publishMavenJavaPublicationToSimplecloudRepository @@ -52,12 +57,12 @@ jobs: id: create_release uses: actions/create-release@v1 with: - tag_name: v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }} - release_name: v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }} + tag_name: v${{ env.PROJECT_VERSION }} + release_name: v${{ env.PROJECT_VERSION }} draft: false prerelease: true commitish: develop body: | This release contains dev builds for all Gradle modules. env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 704229ed8fd659cf370e193608440a6b0bbb22e8 Mon Sep 17 00:00:00 2001 From: PrexorJustin Date: Fri, 31 Jan 2025 04:53:03 +0100 Subject: [PATCH 33/61] Update release-dev.yml --- .github/workflows/release-dev.yml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 5429227..35672f9 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -12,7 +12,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 with: - ref: develop + ref: develop # Ensure it works from the develop branch - name: Set up JDK 21 uses: actions/setup-java@v3 @@ -20,10 +20,6 @@ jobs: distribution: 'adopt' java-version: '21' - - name: Get Commit Hash - id: commit_hash - run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - name: Cache Gradle packages uses: actions/cache@v3 with: @@ -37,14 +33,13 @@ jobs: - name: Make gradlew executable run: chmod +x ./gradlew - # Get version after setting COMMIT_HASH - - name: Get Project Version - id: project_version - run: | - VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}') - echo "PROJECT_VERSION=$VERSION" >> $GITHUB_ENV - env: - COMMIT_HASH: ${{ env.COMMIT_HASH }} + - name: Get Gradle Version + id: gradle_version + run: echo "GRADLE_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_ENV + + - name: Get Commit Hash + id: commit_hash + run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Publish to SimpleCloud Repository run: ./gradlew publishMavenJavaPublicationToSimplecloudRepository @@ -57,8 +52,8 @@ jobs: id: create_release uses: actions/create-release@v1 with: - tag_name: v${{ env.PROJECT_VERSION }} - release_name: v${{ env.PROJECT_VERSION }} + tag_name: v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }} + release_name: v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }} draft: false prerelease: true commitish: develop From 4f42353794acf6520f45e43ad713984d54970e5e Mon Sep 17 00:00:00 2001 From: fllipeis Date: Wed, 17 Dec 2025 20:44:35 +0100 Subject: [PATCH 34/61] refactor: migrate to platform CloudApi and remove ControllerApi usage --- build.gradle.kts | 8 ++-- gradle/libs.versions.toml | 23 +++++++--- .../plugin/api/shared/extension/Extension.kt | 4 +- .../shared/pattern/ServerPatternIdentifier.kt | 46 ++++++------------- .../argument/PropertiesArgumentsResolver.kt | 4 +- .../group/PlayerCountArgumentsResolver.kt | 29 ++++++------ .../group/ServerCountArgumentsResolver.kt | 30 ++++++------ .../provider/AbstractPlaceholderProvider.kt | 12 ++--- .../provider/GroupPlaceholderProvider.kt | 16 +++---- .../provider/ServerPlaceholderProvider.kt | 6 +-- .../single/SingleGroupPlaceholderExecutor.kt | 22 ++++----- .../single/SinglePlaceholderExecutor.kt | 12 ++--- .../single/SingleServerPlaceholderExecutor.kt | 14 +++--- 13 files changed, 103 insertions(+), 123 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 945f334..54a111e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { val baseVersion = "0.0.1" val commitHash = System.getenv("COMMIT_HASH") val timestamp = System.currentTimeMillis() // Temporary to be able to build and publish directly out of fix branch with same commit hash -val snapshotVersion = "${baseVersion}-dev.${timestamp}-${commitHash}" +val snapshotVersion = "${baseVersion}-platform.${timestamp}-${commitHash}" allprojects { group = "app.simplecloud.plugin" @@ -19,7 +19,6 @@ allprojects { maven("https://libraries.minecraft.net") maven("https://buf.build/gen/maven") maven("https://repo.simplecloud.app/snapshots") - maven("https://buf.build/gen/maven") maven("https://repo.papermc.io/repository/maven-public") } } @@ -31,8 +30,11 @@ subprojects { dependencies { testImplementation(rootProject.libs.kotlin.test) compileOnly(rootProject.libs.kotlin.jvm) - compileOnly(rootProject.libs.bundles.simpleCloudController) + compileOnly(rootProject.libs.kotlin.coroutines) + compileOnly(rootProject.libs.simplecloud.api) compileOnly(rootProject.libs.bundles.adventure) + compileOnly(rootProject.libs.bundles.configurate) + compileOnly(rootProject.libs.slf4j.api) } kotlin { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 842a576..246a962 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,22 +1,31 @@ [versions] -kotlin = "2.0.20" -simpleCloudController = "0.0.30-dev.e3e27fc" +kotlin = "2.1.0" +kotlin-coroutines = "1.10.2" +simplecloud-api = "0.1.0-platform.5-dev.1765910097897-3d59340" sonatype-central-portal-publisher = "1.2.3" adventure = "4.18.0" +configurate = "4.2.0" +slf4j = "2.0.17" [libraries] kotlin-jvm = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } +kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" } -simpleCloudControllerApi = { module = "app.simplecloud.controller:controller-api", version.ref = "simpleCloudController" } -simpleCloudControllerShared = { module = "app.simplecloud.controller:controller-shared", version.ref = "simpleCloudController" } +simplecloud-api = { module = "app.simplecloud.api:api", version.ref = "simplecloud-api" } adventure = { module = "net.kyori:adventure-api", version.ref = "adventure" } -adventureMiniMessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } +adventure-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } + +configurate-yaml = { module = "org.spongepowered:configurate-yaml", version.ref = "configurate" } +configurate-gson = { module = "org.spongepowered:configurate-gson", version.ref = "configurate" } +configurate-extra-kotlin = { module = "org.spongepowered:configurate-extra-kotlin", version.ref = "configurate" } + +slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } [bundles] -simpleCloudController = ["simpleCloudControllerApi", "simpleCloudControllerShared"] -adventure = ["adventure", "adventureMiniMessage"] +adventure = ["adventure", "adventure-minimessage"] +configurate = ["configurate-yaml", "configurate-gson", "configurate-extra-kotlin"] [plugins] kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/extension/Extension.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/extension/Extension.kt index 913c9b7..2fdc7fc 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/extension/Extension.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/extension/Extension.kt @@ -1,7 +1,7 @@ package app.simplecloud.plugin.api.shared.extension -import app.simplecloud.controller.shared.group.Group -import app.simplecloud.controller.shared.server.Server +import app.simplecloud.api.group.Group +import app.simplecloud.api.server.Server import app.simplecloud.plugin.api.shared.placeholder.PlaceholderProvider import app.simplecloud.plugin.api.shared.placeholder.argument.ArgumentsResolver import net.kyori.adventure.text.Component diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pattern/ServerPatternIdentifier.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pattern/ServerPatternIdentifier.kt index 1f06f4d..e1ce9b4 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pattern/ServerPatternIdentifier.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/pattern/ServerPatternIdentifier.kt @@ -1,29 +1,21 @@ package app.simplecloud.plugin.api.shared.pattern -import app.simplecloud.controller.api.ControllerApi -import app.simplecloud.controller.shared.group.Group -import app.simplecloud.controller.shared.server.Server +import app.simplecloud.api.CloudApi +import app.simplecloud.api.group.Group +import app.simplecloud.api.server.Server import app.simplecloud.plugin.api.shared.pretty.StringPrettifier - -/** - * @author Niklas Nieberler - */ +import kotlinx.coroutines.future.await class ServerPatternIdentifier( private val pattern: String = "-", regexPattern: String = pattern .replace("", "(?[a-zA-Z]+)") .replace("", "(?\\d+)"), - private val controllerApi: ControllerApi.Coroutine = ControllerApi.createCoroutineApi() + private val cloudApi: CloudApi = CloudApi.create() ) { private val regex = Regex(regexPattern) - /** - * Gets the group and numerical id matching the [pattern] in a [Pair] - * @param name the server name - * @param customRegex custom regex pattern - */ fun parse(name: String, customRegex: Regex? = null): Pair { val matchResult = customRegex?.matchEntire(name) ?: this.regex.matchEntire(name) if (matchResult == null) @@ -36,34 +28,26 @@ class ServerPatternIdentifier( return Pair(groupName, numericalId) } - /** - * Gets a server string as a set in the pattern - * @param server replaces it to pattern - */ fun parseServerToPattern(server: Server): String { return this.pattern - .replace("", server.group) - .replace("", server.properties["pretty-name"] ?: StringPrettifier.prettify(server.group)) - .replace("", server.uniqueId) - .replace("", server.uniqueId) + .replace("", server.serverBase.name) + .replace("", server.properties["pretty-name"]?.toString() ?: StringPrettifier.prettify(server.serverBase.name)) + .replace("", server.serverId) + .replace("", server.serverId) .replace("", server.numericalId.toString()) } - /** - * Gets the [Group] by the matching [pattern] - * @param name the server name - */ suspend fun getGroup(name: String): Group? { val groupName = parse(name).first - return this.controllerApi.getGroups().getGroupByName(groupName) + return try { + this.cloudApi.group().getGroupByName(groupName).await() + } catch (e: Exception) { + null + } } - /** - * Gets the numerical id by the matching [pattern] - * @param name the server name - */ fun getNumericalId(name: String): Int { return parse(name).second } -} \ No newline at end of file +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/PropertiesArgumentsResolver.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/PropertiesArgumentsResolver.kt index 5ae25e2..44badb3 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/PropertiesArgumentsResolver.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/PropertiesArgumentsResolver.kt @@ -8,7 +8,7 @@ import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue */ class PropertiesArgumentsResolver( - private val properties: Map + private val properties: Map ) : ArgumentsResolver { override fun getKey() = "property" @@ -17,7 +17,7 @@ class PropertiesArgumentsResolver( val argumentName = arguments.popOr("property expected").value() val defaultArgument = arguments.peek()?.value() ?: "" val string = this.properties[argumentName] ?: defaultArgument - return Tag.preProcessParsed(string) + return Tag.preProcessParsed(string.toString()) } } \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/group/PlayerCountArgumentsResolver.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/group/PlayerCountArgumentsResolver.kt index ee13478..c319290 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/group/PlayerCountArgumentsResolver.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/group/PlayerCountArgumentsResolver.kt @@ -1,21 +1,15 @@ package app.simplecloud.plugin.api.shared.placeholder.argument.group -import app.simplecloud.controller.api.ControllerApi -import app.simplecloud.controller.shared.group.Group +import app.simplecloud.api.CloudApi +import app.simplecloud.api.group.Group +import app.simplecloud.api.server.ServerState import app.simplecloud.plugin.api.shared.placeholder.argument.ArgumentsResolver -import build.buf.gen.simplecloud.controller.v1.ServerState +import kotlinx.coroutines.future.await import net.kyori.adventure.text.minimessage.tag.Tag import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue -import kotlin.collections.filter -import kotlin.collections.firstOrNull -import kotlin.collections.sumOf - -/** - * @author Niklas Nieberler - */ class PlayerCountArgumentsResolver( - private val controllerApi: ControllerApi.Coroutine, + private val cloudApi: CloudApi, private val group: Group, ) : ArgumentsResolver { @@ -27,10 +21,13 @@ class PlayerCountArgumentsResolver( return Tag.preProcessParsed(findPlayerCount(this.group, serverState).toString()) } - private suspend fun findPlayerCount(group: Group, state: ServerState?): Long { - return this.controllerApi.getServers().getServersByGroup(group) - .filter { it.state == state } - .sumOf { it.playerCount } + private suspend fun findPlayerCount(group: Group, state: ServerState?): Int { + val servers = this.cloudApi.server().getServersByGroup(group.name).await() + return if (state != null) { + servers.filter { it.state == state }.sumOf { it.playerCount } + } else { + servers.sumOf { it.playerCount } + } } -} \ No newline at end of file +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/group/ServerCountArgumentsResolver.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/group/ServerCountArgumentsResolver.kt index 5e2dd5c..2afedc6 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/group/ServerCountArgumentsResolver.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/argument/group/ServerCountArgumentsResolver.kt @@ -1,20 +1,15 @@ package app.simplecloud.plugin.api.shared.placeholder.argument.group -import app.simplecloud.controller.api.ControllerApi -import app.simplecloud.controller.shared.group.Group +import app.simplecloud.api.CloudApi +import app.simplecloud.api.group.Group +import app.simplecloud.api.server.ServerState import app.simplecloud.plugin.api.shared.placeholder.argument.ArgumentsResolver -import build.buf.gen.simplecloud.controller.v1.ServerState +import kotlinx.coroutines.future.await import net.kyori.adventure.text.minimessage.tag.Tag import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue -import kotlin.collections.filter -import kotlin.collections.firstOrNull - -/** - * @author Niklas Nieberler - */ class ServerCountArgumentsResolver( - private val controllerApi: ControllerApi.Coroutine, + private val cloudApi: CloudApi, private val group: Group, ) : ArgumentsResolver { @@ -23,13 +18,16 @@ class ServerCountArgumentsResolver( override suspend fun resolve(arguments: ArgumentQueue): Tag? { val text = arguments.popOr("all").value() val serverState = ServerState.entries.firstOrNull { it.name.equals(text, true) } - return Tag.preProcessParsed(findPlayerCount(this.group, serverState).toString()) + return Tag.preProcessParsed(findServerCount(this.group, serverState).toString()) } - private suspend fun findPlayerCount(group: Group, state: ServerState?): Int { - return this.controllerApi.getServers().getServersByGroup(group) - .filter { it.state == state } - .size + private suspend fun findServerCount(group: Group, state: ServerState?): Int { + val servers = this.cloudApi.server().getServersByGroup(group.name).await() + return if (state != null) { + servers.filter { it.state == state }.size + } else { + servers.size + } } -} \ No newline at end of file +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt index bffc9dd..d8b9427 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt @@ -1,6 +1,6 @@ package app.simplecloud.plugin.api.shared.placeholder.provider -import app.simplecloud.controller.api.ControllerApi +import app.simplecloud.api.CloudApi import app.simplecloud.plugin.api.shared.extension.text import app.simplecloud.plugin.api.shared.placeholder.argument.ArgumentsResolver import app.simplecloud.plugin.api.shared.placeholder.single.SinglePlaceholderExecutor @@ -16,15 +16,15 @@ abstract class AbstractPlaceholderProvider( private val executor: SinglePlaceholderExecutor, ) { - private val controllerApi = ControllerApi.createCoroutineApi() + private val cloudApi = CloudApi.create() /** * Gets the list of all available [ArgumentsResolver] - * @param controllerApi the instance of [ControllerApi.Coroutine] + * @param cloudApi the instance of [CloudApi] * @param value for the placeholder */ abstract suspend fun getArgumentsResolvers( - controllerApi: ControllerApi.Coroutine, + cloudApi: CloudApi, value: T, ): List @@ -39,10 +39,10 @@ abstract class AbstractPlaceholderProvider( vararg argumentsResolver: ArgumentsResolver, ): TagResolver { val availableArgumentsResolver = listOf( - *getArgumentsResolvers(this.controllerApi, value).toTypedArray(), + *getArgumentsResolvers(this.cloudApi, value).toTypedArray(), *argumentsResolver ) - val singleTagResolver = this.executor.getTagResolver(this.controllerApi, value, prefix) + val singleTagResolver = this.executor.getTagResolver(this.cloudApi, value, prefix) return TagResolver.resolver( singleTagResolver, *availableArgumentsResolver diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/GroupPlaceholderProvider.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/GroupPlaceholderProvider.kt index 1d68f33..16e9726 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/GroupPlaceholderProvider.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/GroupPlaceholderProvider.kt @@ -1,24 +1,20 @@ package app.simplecloud.plugin.api.shared.placeholder.provider -import app.simplecloud.controller.api.ControllerApi -import app.simplecloud.controller.shared.group.Group +import app.simplecloud.api.CloudApi +import app.simplecloud.api.group.Group import app.simplecloud.plugin.api.shared.placeholder.argument.PropertiesArgumentsResolver import app.simplecloud.plugin.api.shared.placeholder.argument.group.PlayerCountArgumentsResolver import app.simplecloud.plugin.api.shared.placeholder.argument.group.ServerCountArgumentsResolver import app.simplecloud.plugin.api.shared.placeholder.single.SingleGroupPlaceholderExecutor -/** - * @author Niklas Nieberler - */ - class GroupPlaceholderProvider : AbstractPlaceholderProvider( SingleGroupPlaceholderExecutor() ) { - override suspend fun getArgumentsResolvers(controllerApi: ControllerApi.Coroutine, value: Group) = listOf( + override suspend fun getArgumentsResolvers(cloudApi: CloudApi, value: Group) = listOf( PropertiesArgumentsResolver(value.properties), - PlayerCountArgumentsResolver(controllerApi, value), - ServerCountArgumentsResolver(controllerApi, value) + PlayerCountArgumentsResolver(cloudApi, value), + ServerCountArgumentsResolver(cloudApi, value) ) -} \ No newline at end of file +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/ServerPlaceholderProvider.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/ServerPlaceholderProvider.kt index c08f797..8a78b99 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/ServerPlaceholderProvider.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/ServerPlaceholderProvider.kt @@ -1,7 +1,7 @@ package app.simplecloud.plugin.api.shared.placeholder.provider -import app.simplecloud.controller.api.ControllerApi -import app.simplecloud.controller.shared.server.Server +import app.simplecloud.api.CloudApi +import app.simplecloud.api.server.Server import app.simplecloud.plugin.api.shared.placeholder.argument.* import app.simplecloud.plugin.api.shared.placeholder.single.SingleServerPlaceholderExecutor @@ -13,7 +13,7 @@ class ServerPlaceholderProvider : AbstractPlaceholderProvider( SingleServerPlaceholderExecutor() ) { - override suspend fun getArgumentsResolvers(controllerApi: ControllerApi.Coroutine, value: Server) = listOf( + override suspend fun getArgumentsResolvers(cloudApi: CloudApi, value: Server) = listOf( PropertiesArgumentsResolver(value.properties) ) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleGroupPlaceholderExecutor.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleGroupPlaceholderExecutor.kt index d81439d..0eb254d 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleGroupPlaceholderExecutor.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleGroupPlaceholderExecutor.kt @@ -1,30 +1,24 @@ package app.simplecloud.plugin.api.shared.placeholder.single -import app.simplecloud.controller.api.ControllerApi -import app.simplecloud.controller.shared.group.Group +import app.simplecloud.api.CloudApi +import app.simplecloud.api.group.Group import app.simplecloud.plugin.api.shared.placeholder.async.AsyncPlaceholder - -/** - * @author Niklas Nieberler - */ +import kotlinx.coroutines.future.await class SingleGroupPlaceholderExecutor : SinglePlaceholderExecutor { - override fun getAsyncPlaceholders(controllerApi: ControllerApi.Coroutine) = listOf>( + override fun getAsyncPlaceholders(cloudApi: CloudApi) = listOf>( AsyncPlaceholder("name") { it.name }, AsyncPlaceholder("type") { it.type }, AsyncPlaceholder("max_players") { it.maxPlayers }, AsyncPlaceholder("min_memory") { it.minMemory }, AsyncPlaceholder("max_memory") { it.maxMemory }, - AsyncPlaceholder("start_port") { it.startPort }, - AsyncPlaceholder("min_online_count") { it.minOnlineCount }, - AsyncPlaceholder("max_online_count") { it.maxOnlineCount }, - AsyncPlaceholder("online_players") { getOnlinePlayersByGroup(controllerApi, it) }, + AsyncPlaceholder("online_players") { getOnlinePlayersByGroup(cloudApi, it) }, ) - private suspend fun getOnlinePlayersByGroup(controllerApi: ControllerApi.Coroutine, group: Group): Long { - return controllerApi.getServers().getServersByGroup(group) + private suspend fun getOnlinePlayersByGroup(cloudApi: CloudApi, group: Group): Int { + return cloudApi.server().getServersByGroup(group.name).await() .sumOf { it.playerCount } } -} \ No newline at end of file +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePlaceholderExecutor.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePlaceholderExecutor.kt index 5140084..bd80632 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePlaceholderExecutor.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePlaceholderExecutor.kt @@ -1,6 +1,6 @@ package app.simplecloud.plugin.api.shared.placeholder.single -import app.simplecloud.controller.api.ControllerApi +import app.simplecloud.api.CloudApi import app.simplecloud.plugin.api.shared.placeholder.async.AsyncPlaceholder import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver @@ -12,22 +12,22 @@ interface SinglePlaceholderExecutor { /** * Gets a list with all available [AsyncPlaceholder] - * @param controllerApi the instance of [ControllerApi.Coroutine] + * @param cloudApi the instance of [app.simplecloud.api.CloudApi] */ - fun getAsyncPlaceholders(controllerApi: ControllerApi.Coroutine): List> + fun getAsyncPlaceholders(cloudApi: CloudApi): List> /** * Gets a [TagResolver] with all available tag resolvers from the [getAsyncPlaceholders] method - * @param controllerApi the instance of [ControllerApi.Coroutine] + * @param cloudApi the instance of [CloudApi] * @param value for the placeholder * @param prefix first name for the placeholder key */ suspend fun getTagResolver( - controllerApi: ControllerApi.Coroutine, + cloudApi: CloudApi, value: T, prefix: String? = null, ): TagResolver { - return TagResolver.resolver(getAsyncPlaceholders(controllerApi) + return TagResolver.resolver(getAsyncPlaceholders(cloudApi) .map { it.invokeTagResolver(value, prefix) }) } diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt index 938642e..d66bdc4 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SingleServerPlaceholderExecutor.kt @@ -1,7 +1,7 @@ package app.simplecloud.plugin.api.shared.placeholder.single -import app.simplecloud.controller.api.ControllerApi -import app.simplecloud.controller.shared.server.Server +import app.simplecloud.api.CloudApi +import app.simplecloud.api.server.Server import app.simplecloud.plugin.api.shared.placeholder.async.AsyncPlaceholder import app.simplecloud.plugin.api.shared.pretty.StringPrettifier @@ -11,14 +11,14 @@ import app.simplecloud.plugin.api.shared.pretty.StringPrettifier class SingleServerPlaceholderExecutor : SinglePlaceholderExecutor { - override fun getAsyncPlaceholders(controllerApi: ControllerApi.Coroutine) = listOf>( - AsyncPlaceholder("id") { it.uniqueId }, + override fun getAsyncPlaceholders(cloudApi: CloudApi) = listOf>( + AsyncPlaceholder("id") { it.serverId }, AsyncPlaceholder("numerical_id") { it.numericalId }, - AsyncPlaceholder("group_name") { it.group }, + AsyncPlaceholder("group_name") { it.serverBase.name }, AsyncPlaceholder("group_pretty_name") { - it.properties["pretty-name"] ?: StringPrettifier.prettify(it.group) + it.properties["pretty-name"] ?: StringPrettifier.prettify(it.serverBase.name) }, - AsyncPlaceholder("type") { it.type }, + AsyncPlaceholder("type") { it.serverBase.type }, AsyncPlaceholder("state") { it.state }, AsyncPlaceholder("ip") { it.ip }, AsyncPlaceholder("port") { it.port }, From e57ed95dcaf38f88de1593363c73a2e83c6923c2 Mon Sep 17 00:00:00 2001 From: fllipeis Date: Wed, 17 Dec 2025 20:45:43 +0100 Subject: [PATCH 35/61] feat: add branch input support for release-dev workflow --- .github/workflows/release-dev.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml index 35672f9..ce42184 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release-dev.yml @@ -2,6 +2,15 @@ name: Create Release on: workflow_dispatch: + inputs: + branch: + description: 'Branch to build and publish' + required: true + default: 'develop' + type: choice + options: + - develop + - feat/platform jobs: build: @@ -12,7 +21,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 with: - ref: develop # Ensure it works from the develop branch + ref: ${{ inputs.branch }} - name: Set up JDK 21 uses: actions/setup-java@v3 @@ -56,7 +65,7 @@ jobs: release_name: v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }} draft: false prerelease: true - commitish: develop + commitish: ${{ inputs.branch }} body: | This release contains dev builds for all Gradle modules. env: From 95a0407305117f874d75820789285a475c5fd6d7 Mon Sep 17 00:00:00 2001 From: "niklas.nieberler" Date: Mon, 6 Apr 2026 14:07:04 +0200 Subject: [PATCH 36/61] feat: add PersistentServerPlaceholder support --- gradle/libs.versions.toml | 2 +- .../plugin/api/shared/extension/Extension.kt | 9 ++++++ .../shared/placeholder/PlaceholderProvider.kt | 3 ++ .../PersistentServerPlaceholderProvider.kt | 20 +++++++++++++ ...nglePersistentServerPlaceholderExecutor.kt | 29 +++++++++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/PersistentServerPlaceholderProvider.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePersistentServerPlaceholderExecutor.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 246a962..fc805a0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] kotlin = "2.1.0" kotlin-coroutines = "1.10.2" -simplecloud-api = "0.1.0-platform.5-dev.1765910097897-3d59340" +simplecloud-api = "0.1.0-platform.22-dev.1774376168759-1e20f57" sonatype-central-portal-publisher = "1.2.3" adventure = "4.18.0" configurate = "4.2.0" diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/extension/Extension.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/extension/Extension.kt index 2fdc7fc..9ac234a 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/extension/Extension.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/extension/Extension.kt @@ -1,6 +1,7 @@ package app.simplecloud.plugin.api.shared.extension import app.simplecloud.api.group.Group +import app.simplecloud.api.persistentserver.PersistentServer import app.simplecloud.api.server.Server import app.simplecloud.plugin.api.shared.placeholder.PlaceholderProvider import app.simplecloud.plugin.api.shared.placeholder.argument.ArgumentsResolver @@ -32,4 +33,12 @@ suspend fun String.appendToComponent( vararg argumentsResolver: ArgumentsResolver ): Component { return PlaceholderProvider.groupPlaceholderProvider.append(group, this, prefix, *argumentsResolver) +} + +suspend fun String.appendToComponent( + persistentServer: PersistentServer, + prefix: String? = null, + vararg argumentsResolver: ArgumentsResolver +): Component { + return PlaceholderProvider.persistentServerPlaceholderProvider.append(persistentServer, this, prefix, *argumentsResolver) } \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/PlaceholderProvider.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/PlaceholderProvider.kt index ea02261..24205dd 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/PlaceholderProvider.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/PlaceholderProvider.kt @@ -1,6 +1,7 @@ package app.simplecloud.plugin.api.shared.placeholder import app.simplecloud.plugin.api.shared.placeholder.provider.GroupPlaceholderProvider +import app.simplecloud.plugin.api.shared.placeholder.provider.PersistentServerPlaceholderProvider import app.simplecloud.plugin.api.shared.placeholder.provider.ServerPlaceholderProvider /** @@ -13,4 +14,6 @@ object PlaceholderProvider { val groupPlaceholderProvider = GroupPlaceholderProvider() + val persistentServerPlaceholderProvider = PersistentServerPlaceholderProvider() + } \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/PersistentServerPlaceholderProvider.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/PersistentServerPlaceholderProvider.kt new file mode 100644 index 0000000..1ade4b9 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/PersistentServerPlaceholderProvider.kt @@ -0,0 +1,20 @@ +package app.simplecloud.plugin.api.shared.placeholder.provider + +import app.simplecloud.api.CloudApi +import app.simplecloud.api.persistentserver.PersistentServer +import app.simplecloud.plugin.api.shared.placeholder.argument.* +import app.simplecloud.plugin.api.shared.placeholder.single.SinglePersistentServerPlaceholderExecutor + +/** + * @author Niklas Nieberler + */ + +class PersistentServerPlaceholderProvider : AbstractPlaceholderProvider( + SinglePersistentServerPlaceholderExecutor() +) { + + override suspend fun getArgumentsResolvers(cloudApi: CloudApi, value: PersistentServer) = listOf( + PropertiesArgumentsResolver(value.properties) + ) + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePersistentServerPlaceholderExecutor.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePersistentServerPlaceholderExecutor.kt new file mode 100644 index 0000000..2e99d5c --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePersistentServerPlaceholderExecutor.kt @@ -0,0 +1,29 @@ +package app.simplecloud.plugin.api.shared.placeholder.single + +import app.simplecloud.api.CloudApi +import app.simplecloud.api.persistentserver.PersistentServer +import app.simplecloud.api.server.Server +import app.simplecloud.plugin.api.shared.placeholder.async.AsyncPlaceholder +import app.simplecloud.plugin.api.shared.pretty.StringPrettifier + +/** + * @author Niklas Nieberler + */ + +class SinglePersistentServerPlaceholderExecutor : SinglePlaceholderExecutor { + + override fun getAsyncPlaceholders(cloudApi: CloudApi) = listOf>( + AsyncPlaceholder("id") { it.persistentServerId }, + AsyncPlaceholder("name") { it.name }, + AsyncPlaceholder("pretty_name") { + it.properties["pretty-name"] ?: StringPrettifier.prettify(it.name) + }, + AsyncPlaceholder("type") { it.type }, + AsyncPlaceholder("online_players") { it.playerCount }, + AsyncPlaceholder("max_players") { it.maxPlayers }, + AsyncPlaceholder("min_memory") { it.minMemory }, + AsyncPlaceholder("max_memory") { it.maxMemory }, + AsyncPlaceholder("motd") { it.properties["motd"] ?: "A Minecraft server" } + ) + +} \ No newline at end of file From ae9df6d5c0435acff2866d824b32d66308e3c01e Mon Sep 17 00:00:00 2001 From: "niklas.nieberler" Date: Mon, 6 Apr 2026 17:21:39 +0200 Subject: [PATCH 37/61] ref: create configs or config repositories --- .../plugin/api/shared/config/ConfigFactory.kt | 270 ------------- .../config/ConfigurateWatcherRegistry.kt | 75 ++++ .../api/shared/config/ConfigurationFactory.kt | 51 +++ .../shared/config/YamlDirectoryRepository.kt | 96 +++++ .../api/shared/config/YamlFileConfigurator.kt | 50 +++ .../config/repository/DirectoryRepository.kt | 362 ------------------ .../config/repository/handler/FileHandler.kt | 15 - .../repository/handler/PNGFileHandler.kt | 22 -- .../repository/handler/YamlFileHandler.kt | 50 --- .../serializer}/GenericEnumSerializer.kt | 11 +- .../exception/ConfigurationException.kt | 4 - .../shared/exception/RepositoryException.kt | 3 - .../shared/repository/LoadableRepository.kt | 7 - .../api/shared/repository/Repository.kt | 13 - .../ResourcedYamlDirectoryRepository.kt | 91 ----- .../repository/YamlDirectoryRepository.kt | 137 ------- 16 files changed, 279 insertions(+), 978 deletions(-) delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurateWatcherRegistry.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/FileHandler.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/PNGFileHandler.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt rename plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/{repository => config/serializer}/GenericEnumSerializer.kt (81%) delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/ConfigurationException.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/RepositoryException.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/Repository.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/ResourcedYamlDirectoryRepository.kt delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt deleted file mode 100644 index b6f8d74..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigFactory.kt +++ /dev/null @@ -1,270 +0,0 @@ -package app.simplecloud.plugin.api.shared.config - -import app.simplecloud.plugin.api.shared.exception.ConfigurationException -import app.simplecloud.plugin.api.shared.repository.GenericEnumSerializer -import kotlinx.coroutines.* -import org.slf4j.LoggerFactory -import org.spongepowered.configurate.ConfigurationOptions -import org.spongepowered.configurate.kotlin.objectMapperFactory -import org.spongepowered.configurate.yaml.NodeStyle -import org.spongepowered.configurate.yaml.YamlConfigurationLoader -import java.io.File -import java.nio.file.* -import java.util.concurrent.atomic.AtomicReference -import kotlin.coroutines.CoroutineContext - -/** - * A configuration factory that loads, saves and watches configuration files. - * The factory automatically reloads the configuration when the file changes. - * - * Features: - * - Thread-safe configuration handling - * - File watching with automatic reloading - * - Configuration change callbacks - * - Validation support - * - * Usage: - * ``` - * // Using create - * val factory = ConfigFactory.create(File("config.yaml")) - * - * // Using create with custom coroutineContext - * val factory = ConfigFactory.create(File("config.json"), Dispatchers.Default) - * - * // Add change listener - * factory.onConfigChanged { oldConfig, newConfig -> - * println("Config updated from $oldConfig to $newConfig") - * } - * - * // Save the modified config - * factory.save(modifiedConfig) - * - * // Optionally with validation - * factory.save(modifiedConfig) { config -> - * config.someField.isNotEmpty() // return true/false for validation - * } - * ``` - */ -class ConfigFactory( - private val file: File, - private val configClass: Class, - private val coroutineContext: CoroutineContext = Dispatchers.IO -) : AutoCloseable { - - private val logger = LoggerFactory.getLogger(ConfigFactory::class.java) - private val configRef = AtomicReference() - private val path: Path = file.toPath() - private var watchJob: Job? = null - private val changeListeners = mutableListOf Unit>() - private val saveLock = Object() - private val scope = CoroutineScope(coroutineContext + SupervisorJob()) - - private val configurationLoader = YamlConfigurationLoader.builder() - .path(path) - .nodeStyle(NodeStyle.BLOCK) - .defaultOptions { options -> - options.serializers { builder -> - builder.registerAnnotatedObjects(objectMapperFactory()) - builder.register(Enum::class.java, GenericEnumSerializer) - } - } - .build() - - /** - * Loads existing configuration or creates a new one with default values. - * @param defaultConfig The default configuration to use if no file exists - * @param validator Optional validation function for the configuration - */ - fun loadOrCreate(defaultConfig: T, validator: ((T) -> Boolean)? = null) { - if (!configClass.isInstance(defaultConfig)) { - throw IllegalArgumentException("Default config must be an instance of ${configClass.name}") - } - - if (file.exists()) { - loadConfig(validator) - } else { - createDefaultConfig(defaultConfig, validator) - } - - registerWatcher() - } - - /** - * Checks if the configuration file exists. - * @return true if the configuration file exists - */ - fun exists(): Boolean = file.exists() - - /** - * Adds a listener that will be called whenever the configuration changes. - * @param listener The listener function that receives old and new config - */ - fun onConfigChanged(listener: suspend (T?, T) -> Unit) { - synchronized(changeListeners) { - changeListeners.add(listener) - } - } - - private fun createDefaultConfig(defaultConfig: T, validator: ((T) -> Boolean)?) { - path.parent?.let { Files.createDirectories(it) } - Files.createFile(path) - - if (validator?.invoke(defaultConfig) == false) { - throw ConfigurationException("Default configuration failed validation") - } - - synchronized(saveLock) { - try { - val node = configurationLoader.createNode() - node.set(configClass, defaultConfig) - configurationLoader.save(node) - runBlocking(coroutineContext) { - updateConfig(defaultConfig) - } - } catch (e: Exception) { - throw ConfigurationException("Failed to save default configuration", e) - } - } - } - - /** - * Gets the current configuration. - * @throws IllegalStateException if configuration is not loaded - */ - fun getConfig(): T { - return configRef.get() ?: throw IllegalStateException("Configuration not loaded or invalid type") - } - - /** - * Manually reloads the configuration from disk. - * @param validator Optional validation function for the loaded configuration - * @throws ConfigurationException if loading or validation fails - */ - @Throws(ConfigurationException::class) - fun reloadConfig(validator: ((T) -> Boolean)? = null) { - loadConfig(validator) - } - - @Throws(ConfigurationException::class) - private fun loadConfig(validator: ((T) -> Boolean)? = null) { - try { - val node = configurationLoader.load(ConfigurationOptions.defaults()) - val loadedConfig = node.get(configClass) - ?: throw ConfigurationException("Failed to parse configuration file") - - if (validator?.invoke(loadedConfig) == false) { - throw ConfigurationException("Configuration failed validation") - } - - runBlocking(coroutineContext) { - updateConfig(loadedConfig) - } - } catch (e: Exception) { - throw ConfigurationException("Failed to load configuration", e) - } - } - - /** - * Saves the provided configuration to disk. - * @param config The configuration to save - * @param validator Optional validation function to run before saving - * @throws ConfigurationException if saving or validation fails - */ - @Throws(ConfigurationException::class) - fun save(config: T, validator: ((T) -> Boolean)? = null) { - if (validator?.invoke(config) == false) { - throw ConfigurationException("Configuration failed validation") - } - - synchronized(saveLock) { - try { - val node = configurationLoader.createNode() - node.set(configClass, config) - configurationLoader.save(node) - runBlocking(coroutineContext) { - updateConfig(config) - } - } catch (e: Exception) { - throw ConfigurationException("Failed to save configuration", e) - } - } - } - - private suspend fun updateConfig(newConfig: T) { - val oldConfig = configRef.get() - configRef.set(newConfig) - - val listeners = synchronized(changeListeners) { - changeListeners.toList() - } - - listeners.forEach { listener -> - try { - withContext(coroutineContext) { - listener(oldConfig, newConfig) - } - } catch (e: Exception) { - logger.error("Error in config change listener", e) - } - } - } - - private fun registerWatcher(): Job { - val watchService = FileSystems.getDefault().newWatchService() - path.parent?.register( - watchService, - StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_MODIFY - ) - - return scope.launch { - watchService.use { watchService -> - while (isActive) { - val key = watchService.take() - key.pollEvents().forEach { event -> - handleWatchEvent(event) - } - if (!key.reset()) { - break - } - } - } - }.also { watchJob = it } - } - - private suspend fun handleWatchEvent(event: WatchEvent<*>) { - val path = event.context() as? Path ?: return - if (!file.name.contains(path.toString())) return - - when (event.kind()) { - StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_MODIFY -> { - delay(100) - try { - loadConfig() - } catch (e: ConfigurationException) { - logger.error("Failed to reload configuration: ${e.message}", e) - } - } - - else -> {} - } - } - - override fun close() { - scope.cancel() - watchJob?.cancel() - } - - companion object { - /** - * Creates a new ConfigFactory instance. - * @param file The configuration file - * @param coroutineContext The coroutine context to use for async operations - */ - inline fun create( - file: File, - coroutineContext: CoroutineContext = Dispatchers.IO - ): ConfigFactory = ConfigFactory(file, T::class.java, coroutineContext) - } -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurateWatcherRegistry.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurateWatcherRegistry.kt new file mode 100644 index 0000000..8cc2660 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurateWatcherRegistry.kt @@ -0,0 +1,75 @@ +package app.simplecloud.plugin.api.shared.config + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import java.io.File +import java.nio.file.FileSystems +import java.nio.file.Path +import java.nio.file.WatchEvent + +/** + * @author Niklas Nieberler + */ + +class ConfigurateWatcherRegistry { + + private val events = hashMapOf, (File) -> Unit>() + private var watcherRequirements: (Path) -> Boolean = { false } + + /** + * Adds an event for the watcher + * @param event to register + * @param function to handle + */ + fun withEvent(vararg event: WatchEvent.Kind<*>, function: (File) -> Unit): ConfigurateWatcherRegistry { + event.forEach { this.events[it] = function } + return this + } + + /** + * Adds a requirement for the event watcher + * @param function the requirement + */ + fun withWatcherRequirements(function: (Path) -> Boolean): ConfigurateWatcherRegistry { + this.watcherRequirements = function + return this + } + + /** + * Registers a new [java.nio.file.WatchService] for a path + * @param path to register the watcher + */ + fun register(path: Path): Job { + val watchService = FileSystems.getDefault().newWatchService() + + path.parent.register( + watchService, + *this.events.keys.toTypedArray() + ) + + return CoroutineScope(Dispatchers.IO).launch { + while (isActive) { + val watchKey = watchService.take() + watchKey.pollEvents().forEach { watchEvent(path, it) } + watchKey.reset() + } + } + } + + private fun watchEvent(directoryPath: Path, event: WatchEvent<*>) { + val path = event.context() as? Path ?: return + if (!path.toString().endsWith(".yml")) + return + + val resolvedPath = directoryPath.resolve(path) + if (this.watcherRequirements(resolvedPath)) + return + + val kind = event.kind() + this.events[kind]?.invoke(resolvedPath.toFile()) + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt new file mode 100644 index 0000000..fe2cbf7 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt @@ -0,0 +1,51 @@ +package app.simplecloud.plugin.api.shared.config + +import java.io.File + +/** + * @author Niklas Nieberler + */ + +class ConfigurationFactory( + private val file: File, + javaClass: Class, +) { + + private val yamlFileConfigurator = YamlFileConfigurator(javaClass) + + private var config: E? = null + + /** + * Loads the config and if it does not exist, it creates a default config + * @param defaultConfig the default configuration + */ + fun loadOrCreate(defaultConfig: E): E { + if (this.file.exists()) { + return loadConfiguration() + ?: throw NullPointerException("failed to save config") + } + + this.yamlFileConfigurator.save(this.file, defaultConfig) + this.config = defaultConfig + return defaultConfig + } + + /** + * Gets the cached config file + */ + fun get(): E { + return this.config ?: throw NullPointerException("failed to find config") + } + + fun save(entry: E) { + this.yamlFileConfigurator.save(this.file, entry) + this.config = entry + } + + private fun loadConfiguration(): E? { + val configuration = this.yamlFileConfigurator.load(this.file) + this.config = configuration + return configuration + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt new file mode 100644 index 0000000..68e8cff --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt @@ -0,0 +1,96 @@ +package app.simplecloud.plugin.api.shared.config + +import java.io.File +import java.nio.file.* + +/** + * @author Niklas Nieberler + */ + +abstract class YamlDirectoryRepository( + private val directory: Path, + javaClass: Class +) { + + private val yamlFileConfigurator = YamlFileConfigurator(javaClass) + private val fileDirectory = directory.toFile() + + private val cachedEntities = mutableMapOf() + + /** + * Saves an element to the file directory + * @param entity to save + */ + abstract fun save(entity: E) + + abstract fun find(identifier: I): E? + + /** + * Loads all cached entities from a directory + */ + fun findAll(): List { + return this.cachedEntities.values.toList() + } + + /** + * Loads the yaml directory repository with all elements + * @return list of all file entities + */ + fun load(): List { + if (!this.fileDirectory.exists()) + this.fileDirectory.mkdirs() + + registerWatcher() + + return Files.walk(this.directory) + .toList() + .map { it.toFile() } + .filter { it.name.endsWith(".yml") || it.name.endsWith(".yaml") } + .mapNotNull { load(it) } + } + + /** + * Loads an entity from a file + * @param file to load + */ + fun load(file: File): E? { + val entity = this.yamlFileConfigurator.load(file) ?: return null + this.cachedEntities[file] = entity + return entity + } + + /** + * Saves an entity to the yaml formation + * @param name of the file + * @param entity to save + */ + protected fun save(name: String, entity: E) { + val file = this.directory.resolve(name).toFile() + this.yamlFileConfigurator.save(file, entity) + this.cachedEntities[file] = entity + } + + /** + * Deletes an entity file + * @param entity to delete + */ + fun delete(entity: E) { + val file = this.cachedEntities.keys + .find { this.cachedEntities[it] == entity } ?: return + delete(file) + } + + private fun delete(file: File) { + file.delete() + this.cachedEntities.remove(file) + } + + private fun registerWatcher() { + ConfigurateWatcherRegistry() + .withEvent(StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY) { load(it) } + .withEvent(StandardWatchEventKinds.ENTRY_DELETE) { delete(it) } + .withWatcherRequirements { Files.isDirectory(it) } + .register(this.directory) + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt new file mode 100644 index 0000000..a8d565d --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt @@ -0,0 +1,50 @@ +package app.simplecloud.plugin.api.shared.config + +import app.simplecloud.plugin.api.shared.config.serializer.GenericEnumSerializer +import org.spongepowered.configurate.ConfigurationOptions +import org.spongepowered.configurate.kotlin.objectMapperFactory +import org.spongepowered.configurate.yaml.NodeStyle +import org.spongepowered.configurate.yaml.YamlConfigurationLoader +import java.io.File + +/** + * @author Niklas Nieberler + */ + +class YamlFileConfigurator( + private val javaClass: Class +) { + + private val configurationLoaders = hashMapOf() + + private val defaultConfigurationBuilder = YamlConfigurationLoader.builder() + .nodeStyle(NodeStyle.BLOCK) + .defaultOptions { options -> + options.serializers { builder -> + builder.registerAnnotatedObjects(objectMapperFactory()) + builder.register(Enum::class.java, GenericEnumSerializer) + } + } + + fun save(file: File, entity: E) { + val configurationLoader = getOrCreateConfigurationLoader(file) + val node = configurationLoader.createNode(ConfigurationOptions.defaults()) + node.set(this.javaClass, entity) + configurationLoader.save(node) + } + + fun load(file: File): E? { + val configurationLoader = getOrCreateConfigurationLoader(file) + val node = configurationLoader.load(ConfigurationOptions.defaults()) + return node.get(this.javaClass) + } + + fun getOrCreateConfigurationLoader(file: File): YamlConfigurationLoader { + return this.configurationLoaders.getOrPut(file) { + this.defaultConfigurationBuilder + .path(file.toPath()) + .build() + } + } + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt deleted file mode 100644 index a3b7805..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/DirectoryRepository.kt +++ /dev/null @@ -1,362 +0,0 @@ -package app.simplecloud.plugin.api.shared.config.repository - -import app.simplecloud.plugin.api.shared.config.repository.handler.FileHandler -import app.simplecloud.plugin.api.shared.exception.RepositoryException -import kotlinx.coroutines.* -import org.slf4j.LoggerFactory -import java.io.File -import java.io.FileOutputStream -import java.net.URL -import java.nio.file.* -import java.util.concurrent.ConcurrentHashMap -import java.util.concurrent.atomic.AtomicReference -import java.util.jar.JarFile -import kotlin.coroutines.CoroutineContext -import kotlin.io.path.pathString - -/** - * A directory repository that manages files of a specific type. - * Features: - * - Thread-safe entity handling - * - File watching with automatic reloading - * - Entity change callbacks - * - Validation support - * - Automatic resource cleanup - * - * @param I The type of the identifier - * @param T The type of the entity - */ -class DirectoryRepository constructor( - private val directory: Path, - private val fileHandler: FileHandler, - private val coroutineContext: CoroutineContext, - private val validator: ((T) -> Boolean)? = null -) : AutoCloseable { - - private val logger = LoggerFactory.getLogger(DirectoryRepository::class.java) - private val entities = ConcurrentHashMap>() - private val identifiers = ConcurrentHashMap() - private val changeListeners = mutableListOf Unit>() - private val errorHandlers = mutableListOf<(Exception) -> Unit>() - private val saveLock = Object() - private val scope = CoroutineScope(coroutineContext + SupervisorJob()) - private var watchJob: Job? = null - - init { - if (!directory.toFile().exists()) { - directory.toFile().mkdirs() - } - } - - /** - * Loads all entities from the directory or creates them using default values. - * @param defaultEntities Default entities to use if no existing files are found - * @throws RepositoryException if loading or creation fails - */ - @Throws(RepositoryException::class) - fun loadOrCreate(defaultEntities: Map = emptyMap()) { - try { - if (Files.newDirectoryStream(directory).use { it.none() }) { - loadFromResources(defaultEntities) - } - - load() - registerWatcher() - } catch (e: Exception) { - handleError(RepositoryException("Failed to load repository", e)) - } - } - - private fun loadFromResources( - defaultEntities: Map, - writeBom: Boolean = true - ) { - val targetDirectory = File(directory.toUri()).apply { mkdirs() } - val last = directory.pathString.split('/').last() - - val resourceUrl = DirectoryRepository::class.java.getResource("/$last") ?: run { - logger.warn("$last folder not found in resources") - return - } - - when (resourceUrl.protocol) { - "file" -> handleFileProtocol(resourceUrl, targetDirectory) - "jar" -> handleJarProtocol(resourceUrl, targetDirectory, writeBom) - else -> logger.error("Unsupported protocol: ${resourceUrl.protocol}") - } - - defaultEntities.forEach { (id, entity) -> save(id, entity) } - } - - private fun handleFileProtocol(resourceUrl: URL, targetDirectory: File) { - val resourceDir = File(resourceUrl.toURI()) - - if (resourceDir.exists()) { - resourceDir.copyRecursively(targetDirectory, overwrite = true) - } else { - logger.warn("Resource directory does not exist: ${resourceUrl.path}") - } - } - - private fun handleJarProtocol( - resourceUrl: URL, - targetDirectory: File, - writeBom: Boolean - ) { - val jarPath = resourceUrl.path.substringBefore("!").removePrefix("file:") - try { - JarFile(jarPath).use { jarFile -> - val last = directory.pathString.split('/').last() - var filesProcessed = 0 - var filesFailed = 0 - - jarFile.entries().asSequence() - .filter { it.name.startsWith("$last/") && !it.isDirectory } - .forEach { entry -> - val targetFile = File(targetDirectory, entry.name.removePrefix("$last/")) - targetFile.parentFile.mkdirs() - try { - jarFile.getInputStream(entry).use { inputStream -> - FileOutputStream(targetFile).use { fos -> - if (writeBom) { - fos.write(0xEF) - fos.write(0xBB) - fos.write(0xBF) - } - inputStream.copyTo(fos) - } - } - filesProcessed++ - logger.debug("Successfully extracted: ${entry.name}") - } catch (e: Exception) { - filesFailed++ - logger.error("Error copying file ${entry.name}") - } - } - - logger.debug("Processed $filesProcessed files from JAR ($filesFailed failed)") - } - } catch (e: Exception) { - logger.error("Error processing JAR file") - } - } - - private fun load() = - Files.walk(directory) - .filter { !it.toFile().isDirectory && it.toString().endsWith(fileHandler.fileExtension) } - .forEach { loadFile(it.toFile()) } - - private fun loadFile(file: File) { - try { - logger.info("Loading file ${file.name}") - fileHandler.load(file)?.let { entity -> - logger.info("Reached First ${file.name}") - if (validateEntity(entity)) { - logger.info("Reached ${file.name}") - entities[file] = AtomicReference(entity) - } - } - } catch (e: Exception) { - handleError(RepositoryException("Error loading file ${file.name}", e)) - } - } - - /** - * Saves an entity to the repository - * @throws RepositoryException if saving fails or validation fails - */ - @Throws(RepositoryException::class) - fun save(identifier: I, entity: T) { - if (!validateEntity(entity)) { - throw RepositoryException("Entity validation failed") - } - - synchronized(saveLock) { - try { - val file = getFile(identifier) - file.parentFile?.mkdirs() - - fileHandler.save(file, entity) - val oldEntity = entities[file]?.get() - entities[file] = AtomicReference(entity) - identifiers[file] = identifier - - scope.launch { - notifyChangeListeners(identifier, oldEntity, entity) - } - } catch (e: Exception) { - handleError(RepositoryException("Failed to save entity", e)) - throw e - } - } - } - - /** - * Deletes an entity from the repository - */ - fun delete(identifier: I): Boolean { - val file = getFile(identifier) - if (!file.exists()) return false - - synchronized(saveLock) { - return try { - val deleted = file.delete() - - if (deleted) { - val oldEntity = entities.remove(file)?.get() - identifiers.remove(file) - if (oldEntity != null) { - scope.launch { - notifyChangeListeners(identifier, oldEntity, null) - } - } - } - - deleted - } catch (e: Exception) { - handleError(RepositoryException("Failed to delete entity", e)) - false - } - } - } - - /** - * Finds an entity by identifier - */ - fun find(identifier: I): T? = - entities[getFile(identifier)]?.get() - - - /** - * Gets all entities in the repository - */ - fun getAll(): List = entities.values.mapNotNull { it.get() } - - /** - * Gets all identifiers in the repository - */ - fun getAllIdentifiers(): Set = identifiers.values.toSet() - - /** - * Adds a listener for entity changes - */ - fun onEntityChanged(listener: suspend (I, T?, T?) -> Unit) { - synchronized(changeListeners) { - changeListeners.add(listener) - } - } - - /** - * Adds an error handler - */ - fun onError(handler: (Exception) -> Unit) { - synchronized(errorHandlers) { - errorHandlers.add(handler) - } - } - - private fun validateEntity(entity: T): Boolean { - return validator?.invoke(entity) ?: fileHandler.validate(entity) - } - - private fun handleError(error: Exception) { - logger.error(error.message, error) - synchronized(errorHandlers) { - errorHandlers.forEach { it(error) } - } - } - - private suspend fun notifyChangeListeners(identifier: I, oldEntity: T?, newEntity: T?) { - val listeners = synchronized(changeListeners) { changeListeners.toList() } - - listeners.forEach { listener -> - try { - withContext(coroutineContext) { - if (oldEntity != newEntity) { - listener(identifier, oldEntity, newEntity) - } - } - } catch (e: Exception) { - handleError(RepositoryException("Error in change listener", e)) - } - } - } - - private fun getFile(identifier: I): File = - directory.resolve("$identifier${fileHandler.fileExtension}").toFile() - - - private fun registerWatcher(): Job { - val watchService = FileSystems.getDefault().newWatchService() - directory.register( - watchService, - StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_MODIFY, - StandardWatchEventKinds.ENTRY_DELETE - ) - - return scope.launch { - watchService.use { service -> - while (isActive) { - val key = service.take() - - key.pollEvents().forEach { event -> - handleWatchEvent(event) - } - - if (!key.reset()) break - } - } - }.also { watchJob = it } - } - - private suspend fun handleWatchEvent(event: WatchEvent<*>) { - val path = event.context() as? Path ?: return - if (!path.toString().endsWith(fileHandler.fileExtension)) return - - val resolvedPath = directory.resolve(path) - if (Files.isDirectory(resolvedPath)) return - - when (event.kind()) { - StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_MODIFY -> { - delay(100) - loadFile(resolvedPath.toFile()) - } - - StandardWatchEventKinds.ENTRY_DELETE -> { - val file = resolvedPath.toFile() - val identifier = identifiers[file] - val oldEntity = entities.remove(file)?.get() - - if (identifier != null && oldEntity != null) { - notifyChangeListeners(identifier, oldEntity, null) - } - } - - else -> {} - } - } - - override fun close() { - scope.cancel() - watchJob?.cancel() - } - - companion object { - /** - * Creates a new DirectoryRepository instance - */ - inline fun create( - directory: Path, - fileHandler: FileHandler, - noinline validator: ((T) -> Boolean)? = null, - coroutineContext: CoroutineContext = Dispatchers.IO - ): DirectoryRepository = DirectoryRepository( - directory = directory, - fileHandler = fileHandler, - validator = validator, - coroutineContext = coroutineContext - ) - } -} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/FileHandler.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/FileHandler.kt deleted file mode 100644 index a144ba6..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/FileHandler.kt +++ /dev/null @@ -1,15 +0,0 @@ -package app.simplecloud.plugin.api.shared.config.repository.handler - -import java.io.File - -interface FileHandler { - - val fileExtension: String - - fun load(file: File): T? - - fun save(file: File, entity: T) - - fun validate(entity: T): Boolean = true - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/PNGFileHandler.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/PNGFileHandler.kt deleted file mode 100644 index 2135c4e..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/PNGFileHandler.kt +++ /dev/null @@ -1,22 +0,0 @@ -package app.simplecloud.plugin.api.shared.config.repository.handler - -import java.awt.image.BufferedImage -import java.io.File -import javax.imageio.ImageIO - -class PNGFileHandler : FileHandler { - - override val fileExtension: String = ".png" - - override fun load(file: File): BufferedImage? = - runCatching { ImageIO.read(file) }.getOrNull() - - - override fun save(file: File, entity: BufferedImage) { - ImageIO.write(entity, "png", file) - } - - override fun validate(entity: BufferedImage): Boolean = - entity.width > 0 && entity.height > 0 - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt deleted file mode 100644 index 4a7b4bc..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/repository/handler/YamlFileHandler.kt +++ /dev/null @@ -1,50 +0,0 @@ -package app.simplecloud.plugin.api.shared.config.repository.handler - -import app.simplecloud.plugin.api.shared.repository.GenericEnumSerializer -import org.spongepowered.configurate.kotlin.objectMapperFactory -import org.spongepowered.configurate.yaml.NodeStyle -import org.spongepowered.configurate.yaml.YamlConfigurationLoader -import java.io.File - -class YamlFileHandler( - private val clazz: Class -) : FileHandler { - - override val fileExtension: String = ".yml" - - private val loaders = mutableMapOf() - - private fun getOrCreateLoader(file: File): YamlConfigurationLoader { - return loaders.getOrPut(file) { - YamlConfigurationLoader.builder() - .path(file.toPath()) - .nodeStyle(NodeStyle.BLOCK) - .defaultOptions { options -> - options.serializers { builder -> - builder.registerAnnotatedObjects(objectMapperFactory()) - builder.register(Enum::class.java, GenericEnumSerializer) - } - } - .build() - } - } - - override fun load(file: File): T? { - return try { - val loader = getOrCreateLoader(file) - val node = loader.load() - node.get(clazz) - } catch (e: Exception) { - println("Error loading file ${file.name}: ${e.message}") - e.printStackTrace() - null - } - } - - override fun save(file: File, entity: T) { - val loader = getOrCreateLoader(file) - val node = loader.createNode() - node.set(clazz, entity) - loader.save(node) - } -} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/GenericEnumSerializer.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/serializer/GenericEnumSerializer.kt similarity index 81% rename from plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/GenericEnumSerializer.kt rename to plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/serializer/GenericEnumSerializer.kt index 26b4da9..59deb61 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/GenericEnumSerializer.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/serializer/GenericEnumSerializer.kt @@ -1,23 +1,26 @@ -package app.simplecloud.plugin.api.shared.repository +package app.simplecloud.plugin.api.shared.config.serializer import org.spongepowered.configurate.ConfigurationNode import org.spongepowered.configurate.serialize.SerializationException import org.spongepowered.configurate.serialize.TypeSerializer import java.lang.reflect.Type +/** + * @author Niklas Nieberler + */ + object GenericEnumSerializer : TypeSerializer> { @Suppress("UNCHECKED_CAST") override fun deserialize(type: Type, node: ConfigurationNode): Enum<*> { val value = node.string ?: throw SerializationException("No value present in node") - if (type !is Class<*> || !type.isEnum) { + if (type !is Class<*> || !type.isEnum) throw SerializationException("Type is not an enum class") - } return try { java.lang.Enum.valueOf(type as Class>, value) - } catch (e: IllegalArgumentException) { + } catch (_: IllegalArgumentException) { throw SerializationException("Invalid enum constant") } } diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/ConfigurationException.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/ConfigurationException.kt deleted file mode 100644 index b22ab88..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/ConfigurationException.kt +++ /dev/null @@ -1,4 +0,0 @@ -package app.simplecloud.plugin.api.shared.exception - -class ConfigurationException(message: String, cause: Throwable? = null) : - Exception(message, cause) \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/RepositoryException.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/RepositoryException.kt deleted file mode 100644 index a698774..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/exception/RepositoryException.kt +++ /dev/null @@ -1,3 +0,0 @@ -package app.simplecloud.plugin.api.shared.exception - -class RepositoryException(message: String, cause: Throwable? = null) : Exception(message, cause) \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt deleted file mode 100644 index 822a537..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/LoadableRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package app.simplecloud.plugin.api.shared.repository - -interface LoadableRepository : Repository { - - fun load(): List - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/Repository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/Repository.kt deleted file mode 100644 index 7bd8177..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/Repository.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.simplecloud.plugin.api.shared.repository - -interface Repository { - - fun delete(element: E): Boolean - - fun save(element: E) - - fun find(identifier: I): E? - - fun getAll(): List - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/ResourcedYamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/ResourcedYamlDirectoryRepository.kt deleted file mode 100644 index 8436502..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/ResourcedYamlDirectoryRepository.kt +++ /dev/null @@ -1,91 +0,0 @@ -package app.simplecloud.plugin.api.shared.repository - -import java.io.File -import java.io.FileOutputStream -import java.net.URL -import java.nio.file.Path -import java.util.jar.JarFile -import kotlin.io.path.exists -import kotlin.io.path.pathString - -/** - * An extension of [YamlDirectoryRepository] that adds resource loading capabilities - * - * Key differences from [YamlDirectoryRepository] - * - Automatically load default yml configuration files from resources if the target directory doesn't exist - * - Supports both file and jar protocols for loading resources - * - Handles both standalone file system resources and jar-packed resources - * - * Use this implementation of [YamlDirectoryRepository] when you need to - * - Ship default configurations with your plugin - * - Ensure configuration files exist on first run - * - Handle both development (file) and production (jar) environments - */ -abstract class ResourcedYamlDirectoryRepository( - private val directory: Path, - private val clazz: Class, -) : YamlDirectoryRepository(directory, clazz) { - - override fun load(): List { - if (!directory.exists()) loadDefaults() - - return super.load() - } - - private fun loadDefaults() { - val targetDirectory = File(directory.toUri()).apply { mkdirs() } - - val last = directory.pathString.split('/').last() - - val resourceUrl = YamlDirectoryRepository::class.java.getResource("/$last") ?: run { - println("$last folder not found in resources") - return - } - - when (resourceUrl.protocol) { - "file" -> handleFileProtocol(resourceUrl, targetDirectory) - "jar" -> handleJarProtocol(resourceUrl, targetDirectory) - else -> println("Unsupported protocol: ${resourceUrl.protocol}") - } - } - - private fun handleFileProtocol(resourceUrl: URL, targetDirectory: File) { - val resourceDir = File(resourceUrl.toURI()) - if (resourceDir.exists()) { - resourceDir.copyRecursively(targetDirectory, overwrite = true) - } else { - println("Resource directory does not exist: ${resourceUrl.path}") - } - } - - private fun handleJarProtocol(resourceUrl: URL, targetDirectory: File) { - val jarPath = resourceUrl.path.substringBefore("!").removePrefix("file:") - try { - JarFile(jarPath).use { jarFile -> - val last = directory.pathString.split('/').last() - jarFile.entries().asSequence() - .filter { it.name.startsWith("$last/") && !it.isDirectory } - .forEach { entry -> - val targetFile = File(targetDirectory, entry.name.removePrefix("$last/")) - targetFile.parentFile.mkdirs() - try { - jarFile.getInputStream(entry).use { inputStream -> - FileOutputStream(targetFile).use { fos -> - fos.write(0xEF) - fos.write(0xBB) - fos.write(0xBF) - - inputStream.copyTo(fos) - } - } - } catch (e: Exception) { - println("Error copying file ${entry.name}: ${e.message}") - } - } - } - } catch (e: Exception) { - println("Error processing JAR file: ${e.message}") - e.printStackTrace() - } - } -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt deleted file mode 100644 index 732bd7b..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/repository/YamlDirectoryRepository.kt +++ /dev/null @@ -1,137 +0,0 @@ -package app.simplecloud.plugin.api.shared.repository - -import kotlinx.coroutines.* -import org.spongepowered.configurate.ConfigurationOptions -import org.spongepowered.configurate.kotlin.objectMapperFactory -import org.spongepowered.configurate.loader.ParsingException -import org.spongepowered.configurate.serialize.TypeSerializerCollection -import org.spongepowered.configurate.yaml.NodeStyle -import org.spongepowered.configurate.yaml.YamlConfigurationLoader -import java.io.File -import java.nio.file.FileSystems -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.StandardWatchEventKinds - -abstract class YamlDirectoryRepository( - private val directory: Path, - private val clazz: Class, -) : LoadableRepository { - - private val watchService = FileSystems.getDefault().newWatchService() - private val loaders = mutableMapOf() - private val entities = mutableMapOf() - - abstract fun getFileName(identifier: I): String - - override fun delete(element: E): Boolean { - val file = entities.keys.find { entities[it] == element } ?: return false - return deleteFile(file) - } - - override fun getAll(): List { - return entities.values.toList() - } - - override fun load(): List { - if (!directory.toFile().exists()) { - directory.toFile().mkdirs() - } - - registerWatcher() - - return Files.walk(directory) - .toList() - .filter { !it.toFile().isDirectory && it.toString().endsWith(".yml") } - .mapNotNull { load(it.toFile()) } - } - - private fun load(file: File): E? { - try { - val loader = getOrCreateLoader(file) - val node = loader.load(ConfigurationOptions.defaults()) - val entity = node.get(clazz) ?: return null - entities[file] = entity - return entity - } catch (ex: ParsingException) { - val existedBefore = entities.containsKey(file) - if (existedBefore) { - return null - } - - return null - } - } - - private fun deleteFile(file: File): Boolean { - val deletedSuccessfully = file.delete() - val removedSuccessfully = entities.remove(file) != null - return deletedSuccessfully && removedSuccessfully - } - - protected fun save(fileName: String, entity: E) { - val file = directory.resolve(fileName).toFile() - val loader = getOrCreateLoader(file) - val node = loader.createNode(ConfigurationOptions.defaults()) - node.set(clazz, entity) - loader.save(node) - entities[file] = entity - } - - open fun watchUpdateEvent(file: File) {} - - protected open fun addSerializers(builder: TypeSerializerCollection.Builder) {} - - private fun getOrCreateLoader(file: File): YamlConfigurationLoader { - return loaders.getOrPut(file) { - YamlConfigurationLoader.builder() - .path(file.toPath()) - .nodeStyle(NodeStyle.BLOCK) - .defaultOptions { options -> - options.serializers { builder -> - builder.registerAnnotatedObjects(objectMapperFactory()) - builder.register(Enum::class.java, GenericEnumSerializer) - addSerializers(builder) - } - }.build() - } - } - - private fun registerWatcher(): Job { - directory.register( - watchService, - StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_DELETE, - StandardWatchEventKinds.ENTRY_MODIFY - ) - - return CoroutineScope(Dispatchers.IO).launch { - while (isActive) { - val key = watchService.take() - - key.pollEvents().forEach { event -> - val path = event.context() as? Path ?: return@forEach - if (!path.toString().endsWith(".yml")) return@forEach - - val resolvedPath = directory.resolve(path) - if (Files.isDirectory(resolvedPath)) return@forEach - - when (event.kind()) { - StandardWatchEventKinds.ENTRY_CREATE, - StandardWatchEventKinds.ENTRY_MODIFY -> { - delay(100) - load(resolvedPath.toFile()) - watchUpdateEvent(resolvedPath.toFile()) - } - - StandardWatchEventKinds.ENTRY_DELETE -> { - deleteFile(resolvedPath.toFile()) - } - } - } - - key.reset() - } - } - } -} \ No newline at end of file From 636c5a4732a2863a243615b4ae2af1ba5c943b4e Mon Sep 17 00:00:00 2001 From: "niklas.nieberler" Date: Mon, 6 Apr 2026 17:35:56 +0200 Subject: [PATCH 38/61] feat: add watchUpdateEvent in YamlDirectoryRepository --- .../plugin/api/shared/config/YamlDirectoryRepository.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt index 68e8cff..c3ca904 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt @@ -80,6 +80,8 @@ abstract class YamlDirectoryRepository( delete(file) } + open fun watchUpdateEvent(file: File) {} + private fun delete(file: File) { file.delete() this.cachedEntities.remove(file) @@ -89,6 +91,7 @@ abstract class YamlDirectoryRepository( ConfigurateWatcherRegistry() .withEvent(StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY) { load(it) } .withEvent(StandardWatchEventKinds.ENTRY_DELETE) { delete(it) } + .withEvent(StandardWatchEventKinds.ENTRY_MODIFY) { watchUpdateEvent(it) } .withWatcherRequirements { Files.isDirectory(it) } .register(this.directory) } From b364849c1e27fc2349b9a45632e60574e4895e54 Mon Sep 17 00:00:00 2001 From: "niklas.nieberler" Date: Mon, 6 Apr 2026 17:53:45 +0200 Subject: [PATCH 39/61] fix: enum serializer in YamlFileConfigurator --- .../simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt index a8d565d..225a463 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt @@ -23,6 +23,7 @@ class YamlFileConfigurator( options.serializers { builder -> builder.registerAnnotatedObjects(objectMapperFactory()) builder.register(Enum::class.java, GenericEnumSerializer) + builder.register({ type -> type is Class<*> && type.isEnum }, GenericEnumSerializer) } } From 76f81abc8db8e6ed09440bd07eeb4f1f6d06e239 Mon Sep 17 00:00:00 2001 From: "niklas.nieberler" Date: Thu, 9 Apr 2026 22:30:37 +0200 Subject: [PATCH 40/61] feat: add support for more values in AbstractPlaceholderProvide --- .../provider/AbstractPlaceholderProvider.kt | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt index d8b9427..4a971de 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt @@ -30,21 +30,21 @@ abstract class AbstractPlaceholderProvider( /** * Gets the sum of all [TagResolver] - * @param value for the placeholder + * @param values for the placeholder * @param prefix of the placeholder key */ suspend fun getTagResolver( - value: T, + values: List, prefix: String? = null, vararg argumentsResolver: ArgumentsResolver, ): TagResolver { - val availableArgumentsResolver = listOf( - *getArgumentsResolvers(this.cloudApi, value).toTypedArray(), - *argumentsResolver - ) - val singleTagResolver = this.executor.getTagResolver(this.cloudApi, value, prefix) + val availableArgumentsResolver = buildList { + addAll(values.flatMap { getArgumentsResolvers(cloudApi, it) }) + addAll(argumentsResolver) + } + val singleTagResolver = values.map { this.executor.getTagResolver(this.cloudApi, it, prefix) } return TagResolver.resolver( - singleTagResolver, + *singleTagResolver.toTypedArray(), *availableArgumentsResolver .map { convertArgumentsResolverToTagResolver(it, prefix) } .toTypedArray() @@ -65,7 +65,25 @@ abstract class AbstractPlaceholderProvider( ): Component { return text( string, - getTagResolver(value, prefix, *argumentsResolver), + getTagResolver(listOf(value), prefix, *argumentsResolver), + ) + } + + /** + * Serializes the string to a [Component] + * @param values for the placeholder + * @param string the message + * @param prefix of the placeholder key + */ + suspend fun append( + values: List, + string: String, + prefix: String? = null, + vararg argumentsResolver: ArgumentsResolver, + ): Component { + return text( + string, + getTagResolver(values, prefix, *argumentsResolver), ) } From 70e1581abca08d53c3b18cfc65de2ba520a9635f Mon Sep 17 00:00:00 2001 From: Janis Date: Sat, 11 Apr 2026 18:37:50 +0200 Subject: [PATCH 41/61] fix: use loader options in YamlFileConfigurator --- .../plugin/api/shared/config/YamlFileConfigurator.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt index 225a463..c4e609e 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt @@ -1,7 +1,6 @@ package app.simplecloud.plugin.api.shared.config import app.simplecloud.plugin.api.shared.config.serializer.GenericEnumSerializer -import org.spongepowered.configurate.ConfigurationOptions import org.spongepowered.configurate.kotlin.objectMapperFactory import org.spongepowered.configurate.yaml.NodeStyle import org.spongepowered.configurate.yaml.YamlConfigurationLoader @@ -29,14 +28,14 @@ class YamlFileConfigurator( fun save(file: File, entity: E) { val configurationLoader = getOrCreateConfigurationLoader(file) - val node = configurationLoader.createNode(ConfigurationOptions.defaults()) + val node = configurationLoader.createNode() node.set(this.javaClass, entity) configurationLoader.save(node) } fun load(file: File): E? { val configurationLoader = getOrCreateConfigurationLoader(file) - val node = configurationLoader.load(ConfigurationOptions.defaults()) + val node = configurationLoader.load() return node.get(this.javaClass) } @@ -48,4 +47,4 @@ class YamlFileConfigurator( } } -} \ No newline at end of file +} From 486e8e793cc7ed38787f28177b0caa7c92c797b5 Mon Sep 17 00:00:00 2001 From: xXJanisXx Date: Sun, 12 Apr 2026 00:08:18 +0200 Subject: [PATCH 42/61] chore: bump dependencies and move velocity api in the version catalog --- .idea/.gitignore | 10 ++++++++++ gradle/libs.versions.toml | 15 +++++++++++---- gradle/wrapper/gradle-wrapper.properties | 3 +-- plugin-velocity/build.gradle.kts | 4 ++-- 4 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fc805a0..1f8286b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,14 @@ [versions] -kotlin = "2.1.0" +kotlin = "2.2.20" kotlin-coroutines = "1.10.2" -simplecloud-api = "0.1.0-platform.22-dev.1774376168759-1e20f57" -sonatype-central-portal-publisher = "1.2.3" -adventure = "4.18.0" + +sonatype-central-portal-publisher = "1.2.4" + +simplecloud-api = "0.1.0-platform.23-dev.1775473227066-1c0c25a" + +velocity = "3.5.0-SNAPSHOT" +adventure = "4.26.1" + configurate = "4.2.0" slf4j = "2.0.17" @@ -14,6 +19,8 @@ kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", simplecloud-api = { module = "app.simplecloud.api:api", version.ref = "simplecloud-api" } +velocity-api = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" } + adventure = { module = "net.kyori:adventure-api", version.ref = "adventure" } adventure-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ed33eb3..221c4f9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sun Dec 29 18:17:48 CET 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/plugin-velocity/build.gradle.kts b/plugin-velocity/build.gradle.kts index 3daeb6c..7468d5f 100644 --- a/plugin-velocity/build.gradle.kts +++ b/plugin-velocity/build.gradle.kts @@ -4,6 +4,6 @@ plugins { dependencies { compileOnly(project(":plugin-shared")) - compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") - kapt("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") + compileOnly(libs.velocity.api) + kapt(libs.velocity.api) } \ No newline at end of file From f45d1bc48f8b4cac6ec2909cccc333340c411cef Mon Sep 17 00:00:00 2001 From: xXJanisXx Date: Sun, 12 Apr 2026 00:19:33 +0200 Subject: [PATCH 43/61] feat: support comments in configs --- .../api/shared/config/YamlFileConfigurator.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt index c4e609e..7dddd82 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt @@ -1,6 +1,7 @@ package app.simplecloud.plugin.api.shared.config import app.simplecloud.plugin.api.shared.config.serializer.GenericEnumSerializer +import org.spongepowered.configurate.CommentedConfigurationNode import org.spongepowered.configurate.kotlin.objectMapperFactory import org.spongepowered.configurate.yaml.NodeStyle import org.spongepowered.configurate.yaml.YamlConfigurationLoader @@ -27,18 +28,21 @@ class YamlFileConfigurator( } fun save(file: File, entity: E) { - val configurationLoader = getOrCreateConfigurationLoader(file) - val node = configurationLoader.createNode() + val (node, loader) = buildNode(file) node.set(this.javaClass, entity) - configurationLoader.save(node) + loader.save(node) } fun load(file: File): E? { - val configurationLoader = getOrCreateConfigurationLoader(file) - val node = configurationLoader.load() + val (node, _) = buildNode(file) return node.get(this.javaClass) } + fun buildNode(file: File): Pair { + val loader = getOrCreateConfigurationLoader(file) + return Pair(loader.load(), loader) + } + fun getOrCreateConfigurationLoader(file: File): YamlConfigurationLoader { return this.configurationLoaders.getOrPut(file) { this.defaultConfigurationBuilder From c1a4ac98b9d8843c615e2ed254dce4b14032e6c5 Mon Sep 17 00:00:00 2001 From: Jannis <0limitdev@gmail.com> Date: Mon, 13 Apr 2026 21:43:14 +0200 Subject: [PATCH 44/61] remove watcher --- .gitignore | 5 +- .../config/ConfigurateWatcherRegistry.kt | 75 ------------------- .../shared/config/YamlDirectoryRepository.kt | 15 ---- 3 files changed, 1 insertion(+), 94 deletions(-) delete mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurateWatcherRegistry.kt diff --git a/.gitignore b/.gitignore index b1dff0d..108d567 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,7 @@ build/ !**/src/test/**/build/ ### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ +.idea/ *.iws *.iml *.ipr diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurateWatcherRegistry.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurateWatcherRegistry.kt deleted file mode 100644 index 8cc2660..0000000 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurateWatcherRegistry.kt +++ /dev/null @@ -1,75 +0,0 @@ -package app.simplecloud.plugin.api.shared.config - -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.Job -import kotlinx.coroutines.isActive -import kotlinx.coroutines.launch -import java.io.File -import java.nio.file.FileSystems -import java.nio.file.Path -import java.nio.file.WatchEvent - -/** - * @author Niklas Nieberler - */ - -class ConfigurateWatcherRegistry { - - private val events = hashMapOf, (File) -> Unit>() - private var watcherRequirements: (Path) -> Boolean = { false } - - /** - * Adds an event for the watcher - * @param event to register - * @param function to handle - */ - fun withEvent(vararg event: WatchEvent.Kind<*>, function: (File) -> Unit): ConfigurateWatcherRegistry { - event.forEach { this.events[it] = function } - return this - } - - /** - * Adds a requirement for the event watcher - * @param function the requirement - */ - fun withWatcherRequirements(function: (Path) -> Boolean): ConfigurateWatcherRegistry { - this.watcherRequirements = function - return this - } - - /** - * Registers a new [java.nio.file.WatchService] for a path - * @param path to register the watcher - */ - fun register(path: Path): Job { - val watchService = FileSystems.getDefault().newWatchService() - - path.parent.register( - watchService, - *this.events.keys.toTypedArray() - ) - - return CoroutineScope(Dispatchers.IO).launch { - while (isActive) { - val watchKey = watchService.take() - watchKey.pollEvents().forEach { watchEvent(path, it) } - watchKey.reset() - } - } - } - - private fun watchEvent(directoryPath: Path, event: WatchEvent<*>) { - val path = event.context() as? Path ?: return - if (!path.toString().endsWith(".yml")) - return - - val resolvedPath = directoryPath.resolve(path) - if (this.watcherRequirements(resolvedPath)) - return - - val kind = event.kind() - this.events[kind]?.invoke(resolvedPath.toFile()) - } - -} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt index c3ca904..cd6d162 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt @@ -6,7 +6,6 @@ import java.nio.file.* /** * @author Niklas Nieberler */ - abstract class YamlDirectoryRepository( private val directory: Path, javaClass: Class @@ -40,8 +39,6 @@ abstract class YamlDirectoryRepository( if (!this.fileDirectory.exists()) this.fileDirectory.mkdirs() - registerWatcher() - return Files.walk(this.directory) .toList() .map { it.toFile() } @@ -80,20 +77,8 @@ abstract class YamlDirectoryRepository( delete(file) } - open fun watchUpdateEvent(file: File) {} - private fun delete(file: File) { file.delete() this.cachedEntities.remove(file) } - - private fun registerWatcher() { - ConfigurateWatcherRegistry() - .withEvent(StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY) { load(it) } - .withEvent(StandardWatchEventKinds.ENTRY_DELETE) { delete(it) } - .withEvent(StandardWatchEventKinds.ENTRY_MODIFY) { watchUpdateEvent(it) } - .withWatcherRequirements { Files.isDirectory(it) } - .register(this.directory) - } - } \ No newline at end of file From 382b07e9b535311a0be1866b150c66fa6775e7be Mon Sep 17 00:00:00 2001 From: Jannis <0limitdev@gmail.com> Date: Mon, 13 Apr 2026 21:44:03 +0200 Subject: [PATCH 45/61] feat: basic message config abstraction --- .../shared/config/AbstractMessageConfig.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt new file mode 100644 index 0000000..8bddd1c --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt @@ -0,0 +1,28 @@ +package app.simplecloud.plugin.api.shared.config + +import app.simplecloud.plugin.api.shared.extension.miniMessage +import net.kyori.adventure.text.Component +import net.kyori.adventure.text.minimessage.tag.Tag +import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver + +abstract class AbstractMessageConfig { + protected abstract val variables: Map + + private val resolver: TagResolver by lazy { + TagResolver.resolver( + variables.map { (key, value) -> + TagResolver.resolver( + key, + Tag.selfClosingInserting(miniMessage.deserialize(value)) + ) + } + ) + } + + fun msg(message: String, vararg extra: TagResolver): Component { + return miniMessage.deserialize( + message, + TagResolver.resolver(resolver, *extra) + ) + } +} \ No newline at end of file From 1462ebd2e92064855ea78da4c7444a5aaa430441 Mon Sep 17 00:00:00 2001 From: Janis Date: Tue, 28 Apr 2026 15:45:00 +0200 Subject: [PATCH 46/61] fix: protected variables (#30) --- .idea/.gitignore | 10 ---------- .../plugin/api/shared/config/AbstractMessageConfig.kt | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 30cf57e..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Ignored default folder with query files -/queries/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt index 8bddd1c..ea32644 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt @@ -6,7 +6,7 @@ import net.kyori.adventure.text.minimessage.tag.Tag import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver abstract class AbstractMessageConfig { - protected abstract val variables: Map + abstract val variables: Map private val resolver: TagResolver by lazy { TagResolver.resolver( From b1e45e2d1520aa0e8dab2bb4fe334f0c52346252 Mon Sep 17 00:00:00 2001 From: Jannis <0limitdev@gmail.com> Date: Thu, 14 May 2026 20:49:11 +0200 Subject: [PATCH 47/61] add migration system --- plugin-shared/build.gradle.kts | 3 + .../api/shared/config/ConfigMigrator.kt | 108 ++++++++++++++++++ .../api/shared/config/ConfigurationFactory.kt | 12 +- .../api/shared/config/VersionedConfig.kt | 8 ++ .../shared/config/YamlDirectoryRepository.kt | 7 +- .../api/shared/config/YamlFileConfigurator.kt | 21 +++- .../config/ConfigurationMigrationTest.kt | 108 ++++++++++++++++++ 7 files changed, 256 insertions(+), 11 deletions(-) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigMigrator.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/VersionedConfig.kt create mode 100644 plugin-shared/src/test/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationMigrationTest.kt diff --git a/plugin-shared/build.gradle.kts b/plugin-shared/build.gradle.kts index e69de29..69b904b 100644 --- a/plugin-shared/build.gradle.kts +++ b/plugin-shared/build.gradle.kts @@ -0,0 +1,3 @@ +dependencies { + testImplementation(rootProject.libs.bundles.configurate) +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigMigrator.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigMigrator.kt new file mode 100644 index 0000000..a06be79 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigMigrator.kt @@ -0,0 +1,108 @@ +package app.simplecloud.plugin.api.shared.config + +import org.spongepowered.configurate.CommentedConfigurationNode + +/** + * Applies sequential migrations to bring a yaml config node to the current version. + */ +fun interface ConfigMigration { + fun migrate(node: CommentedConfigurationNode) +} + +class ConfigMigrator private constructor( + private val currentVersion: Int, + private val fallbackVersion: Int, + private val migrationsByFromVersion: Map, +) { + + init { + require(currentVersion >= fallbackVersion) { + "The current config version must be greater than or equal to the fallback version" + } + } + + fun migrate(node: CommentedConfigurationNode): Boolean { + var version = node.node(VERSION_NODE).getInt(this.fallbackVersion) + + require(version <= this.currentVersion) { + "The config version $version is newer than the supported version ${this.currentVersion}" + } + + var migrated = false + while (version < this.currentVersion) { + val migration = this.migrationsByFromVersion[version] + ?: throw IllegalStateException( + "Missing config migration from version $version to ${this.currentVersion}" + ) + + migration.action.migrate(node) + version = migration.toVersion + node.node(VERSION_NODE).set(version) + migrated = true + } + + return migrated + } + + class Builder internal constructor( + private val currentVersion: Int, + ) { + + private var fallbackVersion: Int = 0 + private val migrations = mutableMapOf() + + fun fallbackVersion(version: Int): Builder { + require(version >= 0) { + "The fallback version must be greater than or equal to 0" + } + this.fallbackVersion = version + return this + } + + fun migrate( + fromVersion: Int, + toVersion: Int, + action: ConfigMigration, + ): Builder { + require(fromVersion >= 0) { + "The source config version must be greater than or equal to 0" + } + require(toVersion > fromVersion) { + "The target config version must be greater than the source config version" + } + require(toVersion <= this.currentVersion) { + "The target config version must not exceed the current config version" + } + require(fromVersion !in this.migrations) { + "A migration from version $fromVersion is already registered" + } + + this.migrations[fromVersion] = MigrationStep(toVersion, action) + return this + } + + fun build(): ConfigMigrator { + return ConfigMigrator( + currentVersion = this.currentVersion, + fallbackVersion = this.fallbackVersion, + migrationsByFromVersion = this.migrations.toMap(), + ) + } + } + + private data class MigrationStep( + val toVersion: Int, + val action: ConfigMigration, + ) + + companion object { + const val VERSION_NODE = "version" + + fun builder(currentVersion: Int): Builder { + require(currentVersion >= 0) { + "The current config version must be greater than or equal to 0" + } + return Builder(currentVersion) + } + } +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt index fe2cbf7..f9f1a17 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt @@ -6,12 +6,13 @@ import java.io.File * @author Niklas Nieberler */ -class ConfigurationFactory( +class ConfigurationFactory @JvmOverloads constructor( private val file: File, javaClass: Class, + configMigrator: ConfigMigrator? = null, ) { - private val yamlFileConfigurator = YamlFileConfigurator(javaClass) + private val yamlFileConfigurator = YamlFileConfigurator(javaClass, configMigrator) private var config: E? = null @@ -22,7 +23,7 @@ class ConfigurationFactory( fun loadOrCreate(defaultConfig: E): E { if (this.file.exists()) { return loadConfiguration() - ?: throw NullPointerException("failed to save config") + ?: throw NullPointerException("failed to load config") } this.yamlFileConfigurator.save(this.file, defaultConfig) @@ -48,4 +49,7 @@ class ConfigurationFactory( return configuration } -} \ No newline at end of file + fun reload() { + loadConfiguration() + } +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/VersionedConfig.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/VersionedConfig.kt new file mode 100644 index 0000000..e38f8a6 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/VersionedConfig.kt @@ -0,0 +1,8 @@ +package app.simplecloud.plugin.api.shared.config + +/** + * Marks a configuration as versioned so it can participate in yaml migrations. + */ +interface VersionedConfig { + val version: Int +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt index cd6d162..68de866 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt @@ -6,12 +6,13 @@ import java.nio.file.* /** * @author Niklas Nieberler */ -abstract class YamlDirectoryRepository( +abstract class YamlDirectoryRepository @JvmOverloads constructor( private val directory: Path, - javaClass: Class + javaClass: Class, + configMigrator: ConfigMigrator? = null, ) { - private val yamlFileConfigurator = YamlFileConfigurator(javaClass) + private val yamlFileConfigurator = YamlFileConfigurator(javaClass, configMigrator) private val fileDirectory = directory.toFile() private val cachedEntities = mutableMapOf() diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt index 7dddd82..2ed62e5 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt @@ -10,11 +10,17 @@ import java.io.File /** * @author Niklas Nieberler */ - -class YamlFileConfigurator( - private val javaClass: Class +class YamlFileConfigurator @JvmOverloads constructor( + private val javaClass: Class, + private val configMigrator: ConfigMigrator? = null, ) { + init { + require(this.configMigrator == null || VersionedConfig::class.java.isAssignableFrom(this.javaClass)) { + "Config migrations can only be used with VersionedConfig types" + } + } + private val configurationLoaders = hashMapOf() private val defaultConfigurationBuilder = YamlConfigurationLoader.builder() @@ -34,7 +40,10 @@ class YamlFileConfigurator( } fun load(file: File): E? { - val (node, _) = buildNode(file) + val (node, loader) = buildNode(file) + if (migrate(node)) { + loader.save(node) + } return node.get(this.javaClass) } @@ -51,4 +60,8 @@ class YamlFileConfigurator( } } + private fun migrate(node: CommentedConfigurationNode): Boolean { + return this.configMigrator?.migrate(node) ?: false + } + } diff --git a/plugin-shared/src/test/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationMigrationTest.kt b/plugin-shared/src/test/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationMigrationTest.kt new file mode 100644 index 0000000..1afbab7 --- /dev/null +++ b/plugin-shared/src/test/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationMigrationTest.kt @@ -0,0 +1,108 @@ +package app.simplecloud.plugin.api.shared.config + +import java.nio.file.Files +import java.nio.file.Path +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFalse +import kotlin.test.assertTrue +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +class ConfigurationMigrationTest { + + @Test + fun `factory migrates outdated configs and rewrites yaml`() { + val tempDirectory = Files.createTempDirectory("config-migration-factory") + val file = tempDirectory.resolve("config.yml").toFile() + file.writeText( + """ + name: legacy-value + """.trimIndent() + ) + + val configurationFactory = ConfigurationFactory( + file = file, + javaClass = TestVersionedConfig::class.java, + configMigrator = testMigrator(), + ) + + val config = configurationFactory.loadOrCreate(TestVersionedConfig()) + + assertEquals(2, config.version) + assertEquals("legacy-value", config.message) + assertTrue(config.enabled) + + val migratedYaml = file.readText() + assertTrue(migratedYaml.contains("version: 2")) + assertTrue(migratedYaml.contains("message: legacy-value")) + assertTrue(migratedYaml.contains("enabled: true")) + assertFalse(migratedYaml.contains("name:")) + } + + @Test + fun `directory repository migrates loaded entries`() { + val tempDirectory = Files.createTempDirectory("config-migration-repository") + val file = tempDirectory.resolve("entry.yml").toFile() + file.writeText( + """ + version: 1 + message: repository-value + """.trimIndent() + ) + + val repository = TestYamlDirectoryRepository( + directory = tempDirectory, + configMigrator = testMigrator(), + ) + + val loadedEntries = repository.load() + + assertEquals(1, loadedEntries.size) + val config = loadedEntries.first() + assertEquals(2, config.version) + assertEquals("repository-value", config.message) + assertTrue(config.enabled) + + val migratedYaml = file.readText() + assertTrue(migratedYaml.contains("version: 2")) + assertTrue(migratedYaml.contains("enabled: true")) + } + + private fun testMigrator(): ConfigMigrator { + return ConfigMigrator.builder(currentVersion = 2) + .migrate(fromVersion = 0, toVersion = 1) { node -> + val legacyName = node.node("name").string ?: return@migrate + node.node("message").set(legacyName) + node.node("name").set(null) + } + .migrate(fromVersion = 1, toVersion = 2) { node -> + node.node("enabled").set(true) + } + .build() + } + + @ConfigSerializable + private class TestVersionedConfig : VersionedConfig { + override var version: Int = 2 + var message: String = "default-message" + var enabled: Boolean = true + } + + private class TestYamlDirectoryRepository( + directory: Path, + configMigrator: ConfigMigrator, + ) : YamlDirectoryRepository( + directory = directory, + javaClass = TestVersionedConfig::class.java, + configMigrator = configMigrator, + ) { + + override fun save(entity: TestVersionedConfig) { + save("${entity.message}.yml", entity) + } + + override fun find(identifier: String): TestVersionedConfig? { + return findAll().firstOrNull { it.message == identifier } + } + } +} From b9079e6491dc0b6dcc30a70f6a7f17a4cba50e68 Mon Sep 17 00:00:00 2001 From: Jannis <0limitdev@gmail.com> Date: Mon, 18 May 2026 17:16:15 +0200 Subject: [PATCH 48/61] add docs to cloud api --- docs/config-migration-system.md | 152 +++++++++++++++++++++++++ docs/config-system.md | 158 ++++++++++++++++++++++++++ docs/matcher-system.md | 113 +++++++++++++++++++ docs/placeholder-system.md | 191 ++++++++++++++++++++++++++++++++ 4 files changed, 614 insertions(+) create mode 100644 docs/config-migration-system.md create mode 100644 docs/config-system.md create mode 100644 docs/matcher-system.md create mode 100644 docs/placeholder-system.md diff --git a/docs/config-migration-system.md b/docs/config-migration-system.md new file mode 100644 index 0000000..5bb953a --- /dev/null +++ b/docs/config-migration-system.md @@ -0,0 +1,152 @@ +# Config Migration System + +The migration system lets you upgrade old YAML configs to the current structure before they are deserialized. +It is designed to plug directly into `ConfigurationFactory`, `YamlDirectoryRepository`, and `YamlFileConfigurator`. + +## Main pieces + +- `VersionedConfig`: marks a config as migration-capable +- `ConfigMigrator`: defines the current version and the upgrade steps +- root YAML key `version`: stores the config version on disk + +## Defining a versioned config + +Your config should implement `VersionedConfig` and expose the current version. + +```kotlin +import app.simplecloud.plugin.api.shared.config.VersionedConfig +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +@ConfigSerializable +class WarpConfig : VersionedConfig { + override var version: Int = 2 + + var name: String = "" + var world: String = "world" + var enabled: Boolean = true +} +``` + +## Creating a migrator + +`ConfigMigrator` upgrades a YAML node step by step. +Each migration receives the raw Configurate node, so you can rename fields, move sections, or add defaults. + +```kotlin +import app.simplecloud.plugin.api.shared.config.ConfigMigrator + +val warpMigrator = ConfigMigrator.builder(currentVersion = 2) + .migrate(fromVersion = 0, toVersion = 1) { node -> + val oldWorldName = node.node("location", "worldName").string ?: return@migrate + node.node("world").set(oldWorldName) + node.node("location").set(null) + } + .migrate(fromVersion = 1, toVersion = 2) { node -> + if (node.node("enabled").virtual()) { + node.node("enabled").set(true) + } + } + .build() +``` + +## Using migrations with a single config + +```kotlin +import app.simplecloud.plugin.api.shared.config.ConfigurationFactory + +val factory = ConfigurationFactory( + file = dataDirectory.resolve("config.yml").toFile(), + javaClass = WarpConfig::class.java, + configMigrator = warpMigrator, +) + +val config = factory.loadOrCreate(WarpConfig()) +``` + +When an older file is loaded: + +1. the YAML is parsed +2. the migrator checks the stored `version` +3. all missing migration steps are applied in order +4. the updated YAML is written back to disk +5. the final structure is deserialized into your config class + +## Using migrations with a directory repository + +```kotlin +import app.simplecloud.plugin.api.shared.config.YamlDirectoryRepository +import java.nio.file.Path + +class WarpRepository( + directory: Path, +) : YamlDirectoryRepository( + directory = directory, + javaClass = WarpConfig::class.java, + configMigrator = warpMigrator, +) { + + override fun save(entity: WarpConfig) { + save("${entity.name}.yml", entity) + } + + override fun find(identifier: String): WarpConfig? { + return findAll().firstOrNull { it.name == identifier } + } +} +``` + +Calling `load()` will migrate each YAML file as it is read. + +## Legacy files without a version + +Files that do not have a `version` key are treated as version `0` by default. +That makes it easy to introduce migrations for older configs that existed before versioning. + +Example legacy file: + +```yaml +name: spawn +location: + worldName: lobby +``` + +After migration: + +```yaml +version: 2 +name: spawn +world: lobby +enabled: true +``` + +## Changing the fallback version + +If your oldest supported files should be treated as something other than version `0`, set a fallback version: + +```kotlin +val migrator = ConfigMigrator.builder(currentVersion = 3) + .fallbackVersion(1) + .migrate(fromVersion = 1, toVersion = 2) { node -> + node.node("newField").set("default") + } + .migrate(fromVersion = 2, toVersion = 3) { node -> + node.node("anotherField").set(true) + } + .build() +``` + +## Important behavior + +- migrations only work for configs that implement `VersionedConfig` +- the migration chain must be complete from the file version to `currentVersion` +- if a file version is newer than the library supports, loading fails +- if a migration step is missing, loading fails +- migrated files are persisted automatically after a successful load + +## Best practices + +- increase `version` only when the YAML structure changes +- keep each migration small and focused +- prefer additive migrations where possible +- remove old fields explicitly with `node.node("oldField").set(null)` when renaming +- test migrations with real old YAML examples diff --git a/docs/config-system.md b/docs/config-system.md new file mode 100644 index 0000000..5a53053 --- /dev/null +++ b/docs/config-system.md @@ -0,0 +1,158 @@ +# Config System + +The config system in `plugin-shared` is built around Configurate YAML serialization. +Most configs should be regular Kotlin classes annotated with `@ConfigSerializable`. + +## Main pieces + +- `ConfigurationFactory`: loads or creates one config file +- `YamlDirectoryRepository`: manages many YAML files in one directory +- `YamlFileConfigurator`: low-level file serializer if you need direct access +- `AbstractMessageConfig`: optional base class for MiniMessage-based message configs + +## Single config file + +Use `ConfigurationFactory` when you have one config file such as `config.yml`. + +```kotlin +import app.simplecloud.plugin.api.shared.config.ConfigurationFactory +import org.spongepowered.configurate.objectmapping.ConfigSerializable +import java.io.File + +@ConfigSerializable +class PluginConfig { + var prefix: String = "[Example]" + var enabled: Boolean = true +} + +val factory = ConfigurationFactory( + File(dataDirectory.toFile(), "config.yml"), + PluginConfig::class.java, +) + +val config = factory.loadOrCreate(PluginConfig()) + +if (config.enabled) { + println(config.prefix) +} + +config.enabled = false +factory.save(config) +``` + +### Useful methods + +- `loadOrCreate(defaultConfig)`: loads the file, or creates it from the default object +- `get()`: returns the cached config after it has been loaded +- `save(entry)`: writes the config back to disk +- `reload()`: reloads the file into the cache + +## Directory-based configs + +Use `YamlDirectoryRepository` when each entity should live in its own YAML file. +This works well for things like warps, templates, arenas, or message profiles. + +```kotlin +import app.simplecloud.plugin.api.shared.config.YamlDirectoryRepository +import org.spongepowered.configurate.objectmapping.ConfigSerializable +import java.nio.file.Path + +@ConfigSerializable +class WarpConfig { + var name: String = "" + var world: String = "world" + var x: Double = 0.0 + var y: Double = 64.0 + var z: Double = 0.0 +} + +class WarpRepository( + directory: Path, +) : YamlDirectoryRepository( + directory = directory, + javaClass = WarpConfig::class.java, +) { + + override fun save(entity: WarpConfig) { + save("${entity.name}.yml", entity) + } + + override fun find(identifier: String): WarpConfig? { + return findAll().firstOrNull { it.name.equals(identifier, ignoreCase = true) } + } +} +``` + +Usage: + +```kotlin +val repository = WarpRepository(dataDirectory.resolve("warps")) + +repository.load() + +val lobby = WarpConfig().apply { + name = "lobby" + world = "world" + x = 10.0 + y = 65.0 + z = -5.0 +} + +repository.save(lobby) + +val loadedLobby = repository.find("lobby") +val allWarps = repository.findAll() +``` + +### Repository flow + +- implement your own repository class +- extend `YamlDirectoryRepository` +- decide how files are named in `save(entity)` +- decide how lookups work in `find(identifier)` +- call `load()` during startup to populate the cache + +## Direct YAML access + +`YamlFileConfigurator` is the lower-level serializer used by both higher abstractions. +Use it if you want YAML serialization without repository or factory behavior. + +```kotlin +import app.simplecloud.plugin.api.shared.config.YamlFileConfigurator + +val configurator = YamlFileConfigurator(PluginConfig::class.java) +val file = dataDirectory.resolve("config.yml").toFile() + +configurator.save(file, PluginConfig()) +val loaded = configurator.load(file) +``` + +## Message configs + +`AbstractMessageConfig` is helpful when your config stores MiniMessage strings and shared variables. + +```kotlin +import app.simplecloud.plugin.api.shared.config.AbstractMessageConfig + +class MessagesConfig : AbstractMessageConfig() { + override val variables = mapOf( + "prefix" to "[Example]" + ) + + val noPermission = " You do not have permission." +} +``` + +Then render a message with: + +```kotlin +val component = messagesConfig.msg(messagesConfig.noPermission) +``` + +## Best practices + +- annotate config classes with `@ConfigSerializable` +- prefer mutable `var` fields with default values for YAML-backed classes +- use `ConfigurationFactory` for one file and `YamlDirectoryRepository` for many files +- load repositories during startup so `findAll()` and `find()` work from cache +- keep config classes simple and serialization-friendly diff --git a/docs/matcher-system.md b/docs/matcher-system.md new file mode 100644 index 0000000..15e4a49 --- /dev/null +++ b/docs/matcher-system.md @@ -0,0 +1,113 @@ +# Matcher System + +The matcher system is a small utility for checking whether names or values match a configured rule. +The main user-facing type is `ServerMatcherConfiguration`. + +## Main pieces + +- `ServerMatcherConfiguration`: a serializable matcher config +- `OperationType`: the available match operations +- operation matcher implementations: the low-level matching logic + +## Basic usage + +`ServerMatcherConfiguration` is a YAML-friendly wrapper around an operation, a comparison value, and an optional negation flag. + +```kotlin +import app.simplecloud.plugin.api.shared.matcher.OperationType +import app.simplecloud.plugin.api.shared.matcher.ServerMatcherConfiguration + +val matcher = ServerMatcherConfiguration( + operation = OperationType.STARTS_WITH, + value = "Lobby-", + negate = false, +) + +val matches = matcher.matches("Lobby-1") +``` + +## Matching multiple names + +```kotlin +val matcher = ServerMatcherConfiguration( + operation = OperationType.CONTAINS, + value = "event", +) + +val names = listOf("lobby", "event-1", "event-2") + +val anyMatches = matcher.anyMatches(names) +val allMatch = matcher.allMatches(names) +``` + +## Available operations + +These operations are available through `OperationType`: + +- `REGEX` +- `PATTERN` +- `EQUALS` +- `CONTAINS` +- `STARTS_WITH` +- `ENDS_WITH` +- `GREATER_THAN` + +## YAML example + +Because `ServerMatcherConfiguration` is `@ConfigSerializable`, it can be used directly inside your config classes. + +```kotlin +import app.simplecloud.plugin.api.shared.matcher.ServerMatcherConfiguration +import org.spongepowered.configurate.objectmapping.ConfigSerializable + +@ConfigSerializable +class ExampleConfig { + var targetMatcher: ServerMatcherConfiguration = ServerMatcherConfiguration() +} +``` + +Example YAML: + +```yaml +targetMatcher: + operation: STARTS_WITH + value: Lobby- + negate: false +``` + +## Negation + +Use `negate = true` to invert the result. + +```kotlin +val matcher = ServerMatcherConfiguration( + operation = OperationType.ENDS_WITH, + value = "-dev", + negate = true, +) + +matcher.matches("proxy-1") +``` + +This returns `true` because `"proxy-1"` does not end with `"-dev"`. + +## Choosing an operation + +- use `EQUALS` for exact names +- use `STARTS_WITH` or `ENDS_WITH` for prefixes and suffixes +- use `CONTAINS` for simple substring checks +- use `REGEX` when you need explicit regular expressions +- use `PATTERN` only if you specifically want the alternate Java `Pattern`-based matcher behavior in this library + +## Important limitation + +`ServerMatcherConfiguration` currently stores its comparison `value` as a `String`. +That means it is mainly intended for string-based matching. + +`GREATER_THAN` exists in the lower-level `OperationType` API for integer comparisons, but it is not a natural fit for `ServerMatcherConfiguration` because that wrapper does not store numeric values. + +## Best practices + +- use `ServerMatcherConfiguration` inside other config classes when you want user-configurable filters +- prefer simple operations like `EQUALS` or `STARTS_WITH` unless you really need regex +- document the expected input format when exposing `REGEX` or `PATTERN` to end users diff --git a/docs/placeholder-system.md b/docs/placeholder-system.md new file mode 100644 index 0000000..a058fb2 --- /dev/null +++ b/docs/placeholder-system.md @@ -0,0 +1,191 @@ +# Placeholder System + +The placeholder system builds MiniMessage `TagResolver`s for SimpleCloud objects such as servers, groups, and persistent servers. +It is designed to turn strings like `` or `` into rendered Adventure components. + +## Main pieces + +- `PlaceholderProvider`: entry point for the built-in providers +- `ServerPlaceholderProvider` +- `GroupPlaceholderProvider` +- `PersistentServerPlaceholderProvider` +- `ArgumentsResolver`: dynamic placeholders with arguments such as `` +- `String.appendToComponent(...)`: convenience extensions for rendering messages + +## Quick start + +If you already have a `Server`, `Group`, or `PersistentServer`, the easiest API is the extension function on `String`. + +```kotlin +import app.simplecloud.plugin.api.shared.extension.appendToComponent + +val component = " is online on :".appendToComponent(server) +``` + +This returns an Adventure `Component`. + +## Built-in entry points + +The shared object exposes three built-in providers: + +```kotlin +import app.simplecloud.plugin.api.shared.placeholder.PlaceholderProvider + +val serverProvider = PlaceholderProvider.serverPlaceholderProvider +val groupProvider = PlaceholderProvider.groupPlaceholderProvider +val persistentServerProvider = PlaceholderProvider.persistentServerPlaceholderProvider +``` + +You can use the providers directly if you want a `TagResolver` or if you want to append placeholders to a string manually. + +## Server placeholders + +Server placeholders are backed by `SingleServerPlaceholderExecutor`. +Available keys include: + +- `` +- `` +- `` +- `` +- `` +- `` +- `` +- `` +- `` +- `` +- `` +- `` +- `` + +Example: + +```kotlin +val component = " (/)".appendToComponent(server) +``` + +## Group placeholders + +Group placeholders are backed by `SingleGroupPlaceholderExecutor`. +Available keys include: + +- `` +- `` +- `` +- `` +- `` +- `` + +Example: + +```kotlin +val component = " has players online".appendToComponent(group) +``` + +## Persistent server placeholders + +Persistent server placeholders are backed by `SinglePersistentServerPlaceholderExecutor`. +Available keys include: + +- `` +- `` +- `` +- `` +- `` +- `` +- `` +- `` +- `` + +Example: + +```kotlin +val component = " is running on type ".appendToComponent(persistentServer) +``` + +## Argument-based placeholders + +Some placeholders accept arguments. +These are powered by `ArgumentsResolver`. + +Built-in resolvers include: + +- `PropertiesArgumentsResolver`: `` +- `EnvironmentArgumentsResolver`: `` + +Examples: + +```kotlin +val component = "".appendToComponent(server) +val component2 = "".appendToComponent(server) +``` + +For groups, additional resolvers are registered automatically: + +- `` or `` +- `` or `` + +## Prefixing placeholders + +You can prefix all generated keys to avoid collisions when combining multiple resolver sets. + +```kotlin +val component = PlaceholderProvider.serverPlaceholderProvider.append( + server, + " -> :", + prefix = "source", +) +``` + +With `prefix = "source"`, `` becomes `` and `` becomes ``. + +## Working with multiple values + +The providers can also build a resolver from multiple values. +That is mostly useful when you want argument resolvers aggregated from several objects. + +```kotlin +val resolver = PlaceholderProvider.groupPlaceholderProvider.getTagResolver(listOf(groupA, groupB)) +``` + +You can then pass that resolver into your own MiniMessage rendering flow. + +## Direct provider usage + +```kotlin +val resolver = PlaceholderProvider.serverPlaceholderProvider.getTagResolver(listOf(server)) +val component = PlaceholderProvider.serverPlaceholderProvider.append( + server, + " - players" +) +``` + +## Custom argument resolvers + +You can contribute additional resolvers when rendering: + +```kotlin +import app.simplecloud.plugin.api.shared.placeholder.argument.ArgumentsResolver +import net.kyori.adventure.text.minimessage.tag.Tag +import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue + +class RankResolver : ArgumentsResolver { + override fun getKey() = "rank" + + override suspend fun resolve(arguments: ArgumentQueue): Tag? { + val playerName = arguments.popOr("player expected").value() + return Tag.preProcessParsed(fetchRank(playerName)) + } +} + +val component = " - rank: ".appendToComponent( + server, + RankResolver(), +) +``` + +## Best practices + +- use the `String.appendToComponent(...)` extensions for the most concise API +- use prefixes when combining resolvers from different domains +- keep custom argument resolvers fast and predictable +- supply sensible defaults for property- and environment-based placeholders From 62007fb01fa1393e0591a1ca715650a6be98aefa Mon Sep 17 00:00:00 2001 From: Janis Date: Tue, 13 Oct 2026 22:22:06 +0200 Subject: [PATCH 49/61] chore: update gradle wrapper --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 221c4f9..566107b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 5a0a64455ea21a5514079763d99f578f60f1935c Mon Sep 17 00:00:00 2001 From: Janis Date: Tue, 13 Oct 2026 22:26:13 +0200 Subject: [PATCH 50/61] chore: bump dependencies --- gradle/libs.versions.toml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1f8286b..7081746 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,21 +1,21 @@ [versions] -kotlin = "2.2.20" -kotlin-coroutines = "1.10.2" +kotlin = "2.4.21" +kotlinx-coroutines = "1.11.0" sonatype-central-portal-publisher = "1.2.4" -simplecloud-api = "0.1.0-platform.23-dev.1775473227066-1c0c25a" +simplecloud-api = "0.1.0-platform.58-dev.5.1-fe01ce5" -velocity = "3.5.0-SNAPSHOT" -adventure = "4.26.1" +velocity = "4.1.0-SNAPSHOT" +adventure = "5.2.0" configurate = "4.2.0" -slf4j = "2.0.17" +slf4j = "2.0.20" [libraries] kotlin-jvm = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } -kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines" } +kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" } simplecloud-api = { module = "app.simplecloud.api:api", version.ref = "simplecloud-api" } @@ -36,4 +36,4 @@ configurate = ["configurate-yaml", "configurate-gson", "configurate-extra-kotlin [plugins] kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -sonatype-central-portal-publisher = { id = "net.thebugmc.gradle.sonatype-central-portal-publisher", version.ref = "sonatype-central-portal-publisher" } \ No newline at end of file +sonatype-central-portal-publisher = { id = "net.thebugmc.gradle.sonatype-central-portal-publisher", version.ref = "sonatype-central-portal-publisher" } From ec2494fb3a2f688b9eb43ecd9f4fd572f425c79c Mon Sep 17 00:00:00 2001 From: Janis Date: Tue, 13 Oct 2026 23:00:55 +0200 Subject: [PATCH 51/61] feat: add DefaultConfigInstaller --- .../{release-dev.yml => release.yml} | 12 ++--- build.gradle.kts | 46 ++++++++++--------- .../shared/config/DefaultConfigInstaller.kt | 19 ++++++++ settings.gradle.kts | 9 ++-- 4 files changed, 54 insertions(+), 32 deletions(-) rename .github/workflows/{release-dev.yml => release.yml} (90%) create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/DefaultConfigInstaller.kt diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release.yml similarity index 90% rename from .github/workflows/release-dev.yml rename to .github/workflows/release.yml index ce42184..be70136 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Create Release +name: Release and Publish on: workflow_dispatch: @@ -14,20 +14,20 @@ on: jobs: build: - name: Build ShadowJars and Create Release + name: Build and Publish runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v7 with: ref: ${{ inputs.branch }} - - name: Set up JDK 21 - uses: actions/setup-java@v3 + - name: Set up JDK + uses: actions/setup-java@v6 with: distribution: 'adopt' - java-version: '21' + java-version: '25' - name: Cache Gradle packages uses: actions/cache@v3 diff --git a/build.gradle.kts b/build.gradle.kts index 54a111e..ce00bee 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,22 +1,18 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion + plugins { + id("maven-publish") alias(libs.plugins.kotlin) - alias(libs.plugins.sonatype.central.portal.publisher) - `maven-publish` } -val baseVersion = "0.0.1" -val commitHash = System.getenv("COMMIT_HASH") -val timestamp = System.currentTimeMillis() // Temporary to be able to build and publish directly out of fix branch with same commit hash -val snapshotVersion = "${baseVersion}-platform.${timestamp}-${commitHash}" - allprojects { group = "app.simplecloud.plugin" - version = if (commitHash != null) snapshotVersion else baseVersion + version = "1.0.0" repositories { mavenCentral() mavenLocal() - maven("https://libraries.minecraft.net") maven("https://buf.build/gen/maven") maven("https://repo.simplecloud.app/snapshots") maven("https://repo.papermc.io/repository/maven-public") @@ -24,8 +20,9 @@ allprojects { } subprojects { - apply(plugin = "org.jetbrains.kotlin.jvm") - apply(plugin = "net.thebugmc.gradle.sonatype-central-portal-publisher") + apply { + plugin("org.jetbrains.kotlin.jvm") + } dependencies { testImplementation(rootProject.libs.kotlin.test) @@ -38,7 +35,20 @@ subprojects { } kotlin { - jvmToolchain(21) + jvmToolchain(25) + compilerOptions { + jvmTarget = JvmTarget.JVM_25 + languageVersion = KotlinVersion.KOTLIN_2_4 + apiVersion = KotlinVersion.KOTLIN_2_4 + } + } + + java { + toolchain.languageVersion.set(JavaLanguageVersion.of(25)) + } + + tasks.test { + useJUnitPlatform() } publishing { @@ -47,8 +57,8 @@ subprojects { name = "simplecloud" url = uri("https://repo.simplecloud.app/snapshots/") credentials { - username = System.getenv("SIMPLECLOUD_USERNAME")?: (project.findProperty("simplecloudUsername") as? String) - password = System.getenv("SIMPLECLOUD_PASSWORD")?: (project.findProperty("simplecloudPassword") as? String) + username = System.getenv("SIMPLECLOUD_USERNAME") ?: (project.findProperty("simplecloudUsername") as? String) + password = System.getenv("SIMPLECLOUD_PASSWORD") ?: (project.findProperty("simplecloudPassword") as? String) } authentication { create("basic") @@ -63,12 +73,4 @@ subprojects { } } - signing { - if (commitHash != null) { - return@signing - } - - sign(publishing.publications) - useGpgCmd() - } } \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/DefaultConfigInstaller.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/DefaultConfigInstaller.kt new file mode 100644 index 0000000..c2c6025 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/DefaultConfigInstaller.kt @@ -0,0 +1,19 @@ +package app.simplecloud.plugin.api.shared.config + +import java.nio.file.Files +import java.nio.file.Path + +object DefaultConfigInstaller { + + fun install(target: Path, classLoader: ClassLoader) { + if (Files.exists(target)) return + + val name = target.fileName.toString() + val resource = checkNotNull(classLoader.getResourceAsStream(name)) { + "Missing bundled $name" + } + + Files.createDirectories(target.parent) + resource.use { stream -> Files.copy(stream, target) } + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 9f48b5b..5f8122a 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,7 @@ plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" } -rootProject.name = "plugin-api" -include("plugin-shared") -include("plugin-velocity") + +include("plugin-shared", "plugin-velocity") + +rootProject.name = "plugin-api" \ No newline at end of file From 2ab75e1635c84c8e9cfee8c8b688f5873f15058a Mon Sep 17 00:00:00 2001 From: Janis Date: Tue, 13 Oct 2026 23:44:31 +0200 Subject: [PATCH 52/61] feat: add common command classes --- build.gradle.kts | 23 +- gradle/libs.versions.toml | 26 +- plugin-bungeecord/build.gradle.kts | 6 + .../bungeecord/command/BungeeCloudSender.kt | 31 +++ .../command/BungeeCloudSenderMapper.kt | 19 ++ plugin-paper/build.gradle.kts | 5 + .../api/paper/command/PaperCloudSender.kt | 32 +++ .../paper/command/PaperCloudSenderMapper.kt | 16 ++ .../plugin/api/shared/command/CloudSender.kt | 14 ++ .../api/shared/command/CloudSuggestions.kt | 236 ++++++++++++++++++ plugin-velocity/build.gradle.kts | 1 + .../velocity/command/VelocityCloudSender.kt | 27 ++ .../command/VelocityCloudSenderMapper.kt | 16 ++ settings.gradle.kts | 7 +- 14 files changed, 440 insertions(+), 19 deletions(-) create mode 100644 plugin-bungeecord/build.gradle.kts create mode 100644 plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSender.kt create mode 100644 plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSenderMapper.kt create mode 100644 plugin-paper/build.gradle.kts create mode 100644 plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/command/PaperCloudSender.kt create mode 100644 plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/command/PaperCloudSenderMapper.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSender.kt create mode 100644 plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSuggestions.kt create mode 100644 plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSender.kt create mode 100644 plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSenderMapper.kt diff --git a/build.gradle.kts b/build.gradle.kts index ce00bee..cf71863 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,6 +21,7 @@ allprojects { subprojects { apply { + plugin("maven-publish") plugin("org.jetbrains.kotlin.jvm") } @@ -29,6 +30,7 @@ subprojects { compileOnly(rootProject.libs.kotlin.jvm) compileOnly(rootProject.libs.kotlin.coroutines) compileOnly(rootProject.libs.simplecloud.api) + compileOnly(rootProject.libs.bundles.cloud) compileOnly(rootProject.libs.bundles.adventure) compileOnly(rootProject.libs.bundles.configurate) compileOnly(rootProject.libs.slf4j.api) @@ -52,25 +54,22 @@ subprojects { } publishing { + publications { + create("maven") { + from(components["java"]) + } + } + repositories { maven { name = "simplecloud" - url = uri("https://repo.simplecloud.app/snapshots/") + url = uri("https://repo.simplecloud.app/snapshots") credentials { - username = System.getenv("SIMPLECLOUD_USERNAME") ?: (project.findProperty("simplecloudUsername") as? String) - password = System.getenv("SIMPLECLOUD_PASSWORD") ?: (project.findProperty("simplecloudPassword") as? String) - } - authentication { - create("basic") + username = System.getenv("SIMPLECLOUD_USERNAME") + password = System.getenv("SIMPLECLOUD_PASSWORD") } } } - - publications { - create("mavenJava") { - from(components["java"]) - } - } } } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7081746..bd9cc54 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,16 +2,21 @@ kotlin = "2.4.21" kotlinx-coroutines = "1.11.0" -sonatype-central-portal-publisher = "1.2.4" - simplecloud-api = "0.1.0-platform.58-dev.5.1-fe01ce5" velocity = "4.1.0-SNAPSHOT" +bungeecord = "1.21-R0.4" +paper = "26.3.build.+" + adventure = "5.2.0" +adventure-platform-bungeecord = "4.4.1" configurate = "4.2.0" slf4j = "2.0.20" +cloud = "2.1.0" +cloud-platform = "2.0.0" + [libraries] kotlin-jvm = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" } @@ -20,9 +25,12 @@ kotlin-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", simplecloud-api = { module = "app.simplecloud.api:api", version.ref = "simplecloud-api" } velocity-api = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" } +bungeecord-api = { module = "net.md-5:bungeecord-api", version.ref = "bungeecord" } +paper-api = { module = "io.papermc.paper:paper-api", version.ref = "paper" } adventure = { module = "net.kyori:adventure-api", version.ref = "adventure" } -adventure-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } +adventure-text-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } +adventure-platform-bungeecord = { module = "net.kyori:adventure-platform-bungeecord", version.ref = "adventure-platform-bungeecord" } configurate-yaml = { module = "org.spongepowered:configurate-yaml", version.ref = "configurate" } configurate-gson = { module = "org.spongepowered:configurate-gson", version.ref = "configurate" } @@ -30,10 +38,16 @@ configurate-extra-kotlin = { module = "org.spongepowered:configurate-extra-kotli slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } +cloud-core = { module = "org.incendo:cloud-core", version.ref = "cloud" } +cloud-coroutines = { module = "org.incendo:cloud-kotlin-coroutines", version.ref = "cloud" } +cloud-velocity = { module = "org.incendo:cloud-velocity", version.ref = "cloud-platform" } +cloud-bungee = { module = "org.incendo:cloud-bungee", version.ref = "cloud-platform" } +cloud-paper = { module = "org.incendo:cloud-paper", version.ref = "cloud-platform" } + [bundles] -adventure = ["adventure", "adventure-minimessage"] +adventure = ["adventure", "adventure-text-minimessage"] configurate = ["configurate-yaml", "configurate-gson", "configurate-extra-kotlin"] +cloud = ["cloud-core", "cloud-coroutines"] [plugins] -kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -sonatype-central-portal-publisher = { id = "net.thebugmc.gradle.sonatype-central-portal-publisher", version.ref = "sonatype-central-portal-publisher" } +kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } \ No newline at end of file diff --git a/plugin-bungeecord/build.gradle.kts b/plugin-bungeecord/build.gradle.kts new file mode 100644 index 0000000..ea875ac --- /dev/null +++ b/plugin-bungeecord/build.gradle.kts @@ -0,0 +1,6 @@ +dependencies { + compileOnly(project(":plugin-shared")) + compileOnly(libs.cloud.bungee) + compileOnly(libs.bungeecord.api) + compileOnly(libs.adventure.platform.bungeecord) +} diff --git a/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSender.kt b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSender.kt new file mode 100644 index 0000000..16a769c --- /dev/null +++ b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSender.kt @@ -0,0 +1,31 @@ +package app.simplecloud.plugin.api.bungeecord.command + +import app.simplecloud.plugin.api.shared.command.CloudSender +import net.kyori.adventure.platform.bungeecord.BungeeAudiences +import net.kyori.adventure.text.Component +import net.md_5.bungee.api.CommandSender +import net.md_5.bungee.api.connection.ProxiedPlayer +import java.util.UUID + +class BungeeCloudSender( + private val commandSender: CommandSender, + private val audiences: BungeeAudiences +) : CloudSender { + + fun getCommandSender(): CommandSender { + return commandSender + } + + override fun getUniqueId(): UUID { + return (commandSender as? ProxiedPlayer)?.uniqueId ?: UUID(0L, 0L) + } + + override fun hasPermission(permission: String): Boolean { + return commandSender.hasPermission(permission) + } + + override fun sendMessage(message: Component) { + audiences.sender(commandSender).sendMessage(message) + } + +} diff --git a/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSenderMapper.kt b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSenderMapper.kt new file mode 100644 index 0000000..35a77a6 --- /dev/null +++ b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSenderMapper.kt @@ -0,0 +1,19 @@ +package app.simplecloud.plugin.api.bungeecord.command + +import net.kyori.adventure.platform.bungeecord.BungeeAudiences +import net.md_5.bungee.api.CommandSender +import org.incendo.cloud.SenderMapper + +class BungeeCloudSenderMapper( + private val audiences: BungeeAudiences +) : SenderMapper { + + override fun map(base: CommandSender): BungeeCloudSender { + return BungeeCloudSender(base, audiences) + } + + override fun reverse(mapped: BungeeCloudSender): CommandSender { + return mapped.getCommandSender() + } + +} diff --git a/plugin-paper/build.gradle.kts b/plugin-paper/build.gradle.kts new file mode 100644 index 0000000..cad79ca --- /dev/null +++ b/plugin-paper/build.gradle.kts @@ -0,0 +1,5 @@ +dependencies { + compileOnly(project(":plugin-shared")) + compileOnly(libs.paper.api) + compileOnly(libs.cloud.paper) +} diff --git a/plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/command/PaperCloudSender.kt b/plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/command/PaperCloudSender.kt new file mode 100644 index 0000000..30db3c8 --- /dev/null +++ b/plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/command/PaperCloudSender.kt @@ -0,0 +1,32 @@ +package app.simplecloud.plugin.api.paper.command + +import app.simplecloud.plugin.api.shared.command.CloudSender +import io.papermc.paper.command.brigadier.CommandSourceStack +import net.kyori.adventure.text.Component +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player +import java.util.UUID + +class PaperCloudSender(private val sourceStack: CommandSourceStack) : CloudSender { + + fun getSourceStack(): CommandSourceStack { + return sourceStack + } + + fun getCommandSender(): CommandSender { + return sourceStack.sender + } + + override fun getUniqueId(): UUID { + return (sourceStack.sender as? Player)?.uniqueId ?: UUID(0L, 0L) + } + + override fun hasPermission(permission: String): Boolean { + return sourceStack.sender.hasPermission(permission) + } + + override fun sendMessage(message: Component) { + sourceStack.sender.sendMessage(message) + } + +} diff --git a/plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/command/PaperCloudSenderMapper.kt b/plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/command/PaperCloudSenderMapper.kt new file mode 100644 index 0000000..7ce54d3 --- /dev/null +++ b/plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/command/PaperCloudSenderMapper.kt @@ -0,0 +1,16 @@ +package app.simplecloud.plugin.api.paper.command + +import io.papermc.paper.command.brigadier.CommandSourceStack +import org.incendo.cloud.SenderMapper + +object PaperCloudSenderMapper : SenderMapper { + + override fun map(base: CommandSourceStack): PaperCloudSender { + return PaperCloudSender(base) + } + + override fun reverse(mapped: PaperCloudSender): CommandSourceStack { + return mapped.getSourceStack() + } + +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSender.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSender.kt new file mode 100644 index 0000000..961d5c9 --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSender.kt @@ -0,0 +1,14 @@ +package app.simplecloud.plugin.api.shared.command + +import net.kyori.adventure.text.Component +import java.util.UUID + +interface CloudSender { + + fun getUniqueId(): UUID + + fun hasPermission(permission: String): Boolean + + fun sendMessage(message: Component) + +} \ No newline at end of file diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSuggestions.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSuggestions.kt new file mode 100644 index 0000000..93901fe --- /dev/null +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSuggestions.kt @@ -0,0 +1,236 @@ +package app.simplecloud.plugin.api.shared.command + +import app.simplecloud.api.CloudApi +import app.simplecloud.api.group.GroupServerType +import app.simplecloud.api.server.Server +import app.simplecloud.api.server.ServerState +import kotlinx.coroutines.future.await +import org.incendo.cloud.kotlin.coroutines.SuspendingSuggestionProvider +import org.incendo.cloud.suggestion.Suggestion +import org.incendo.cloud.suggestion.SuggestionProvider + +/** + * Commonly used suggestion providers for commands. + */ +object CloudSuggestions { + + const val TARGET_TYPE_GROUP = "group" + const val TARGET_TYPE_PERSISTENT_SERVER = "ps" + + /** + * Suggests the names of all groups. + */ + fun groups(api: CloudApi): SuggestionProvider = + SuspendingSuggestionProvider { _, _ -> + try { + api.group().allGroups.await().map { Suggestion.suggestion(it.name) } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + + /** + * Suggests the names of all groups of the given [type]. + */ + fun groups(api: CloudApi, type: GroupServerType): SuggestionProvider = + SuspendingSuggestionProvider { _, _ -> + try { + api.group().allGroups.await() + .filter { it.type == type } + .map { Suggestion.suggestion(it.name) } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + + /** + * Suggests the names of all proxy groups. + */ + fun proxyGroups(api: CloudApi): SuggestionProvider = + groups(api, GroupServerType.PROXY) + + /** + * Suggests the names of all server groups. + */ + fun serverGroups(api: CloudApi): SuggestionProvider = + groups(api, GroupServerType.SERVER) + + /** + * Suggests the numerical ids of the servers of the group stored in the argument [groupArgument]. + */ + fun serverIds(api: CloudApi, groupArgument: String = "group"): SuggestionProvider = + SuspendingSuggestionProvider { context, _ -> + try { + val group = context.get(groupArgument) + api.server().getServersByGroup(group).await() + .sortedBy { it.numericalId } + .map { Suggestion.suggestion(it.numericalId.toString()) } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + + /** + * Suggests the names of all running servers. + */ + fun servers(api: CloudApi): SuggestionProvider = + SuspendingSuggestionProvider { _, _ -> + try { + api.server().allServers.await() + .mapNotNull { serverName(it) } + .map { Suggestion.suggestion(it) } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + + /** + * Suggests the names of all running servers in one of the given [states]. + */ + fun servers(api: CloudApi, vararg states: ServerState): SuggestionProvider { + val stateSet = states.toSet() + return SuspendingSuggestionProvider { _, _ -> + try { + api.server().allServers.await() + .filter { it.state in stateSet } + .mapNotNull { serverName(it) } + .map { Suggestion.suggestion(it) } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + } + + /** + * Suggests the names of all running servers that players can join. + */ + fun availableServers(api: CloudApi): SuggestionProvider = + servers(api, ServerState.AVAILABLE, ServerState.INGAME) + + /** + * Suggests the names of all persistent servers. + */ + fun persistentServers(api: CloudApi): SuggestionProvider = + SuspendingSuggestionProvider { _, _ -> + try { + api.persistentServer().allPersistentServers.await().map { Suggestion.suggestion(it.name) } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + + /** + * Suggests the names of all online players. + */ + fun onlinePlayers(api: CloudApi): SuggestionProvider = + SuspendingSuggestionProvider { _, _ -> + try { + api.player().onlinePlayers.await().map { Suggestion.suggestion(it.name) } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + + /** + * Suggests the names of all online players except the command sender. + */ + fun otherOnlinePlayers(api: CloudApi): SuggestionProvider = + SuspendingSuggestionProvider { context, _ -> + try { + val uniqueId = context.sender().getUniqueId() + api.player().onlinePlayers.await() + .filter { it.uniqueId != uniqueId } + .map { Suggestion.suggestion(it.name) } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + + /** + * Suggests the names of all players connected to the server stored in the argument [serverArgument]. + */ + //fun playersOnServer(api: CloudApi, serverArgument: String = "server"): SuggestionProvider = + // SuspendingSuggestionProvider { context, _ -> + // try { + // val server = context.get(serverArgument) + // api.player().getOnlinePlayers(server).await().map { Suggestion.suggestion(it.name) } + // } catch (_: Exception) { + // emptyList() + // } + // }.asSuggestionProvider() + + /** + * Suggests the names of all players connected to the proxy stored in the argument [proxyArgument]. + */ + fun playersOnProxy(api: CloudApi, proxyArgument: String = "proxy"): SuggestionProvider = + SuspendingSuggestionProvider { context, _ -> + try { + val proxy = context.get(proxyArgument) + api.player().onlinePlayers.await() + .filter { it.connectedProxyName.equals(proxy, true) } + .map { Suggestion.suggestion(it.name) } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + + /** + * Suggests the target types [TARGET_TYPE_GROUP] and [TARGET_TYPE_PERSISTENT_SERVER]. + */ + fun targetTypes(): SuggestionProvider = + of(TARGET_TYPE_GROUP, TARGET_TYPE_PERSISTENT_SERVER) + + /** + * Suggests group or persistent server names, depending on the target type stored in the argument [targetTypeArgument]. + */ + fun targets(api: CloudApi, targetTypeArgument: String = "targetType"): SuggestionProvider = + SuspendingSuggestionProvider { context, _ -> + try { + val targetType = context.get(targetTypeArgument) + when { + targetType.equals(TARGET_TYPE_GROUP, true) -> api.group().allGroups.await().map { Suggestion.suggestion(it.name) } + targetType.equals(TARGET_TYPE_PERSISTENT_SERVER, true) -> api.persistentServer().allPersistentServers.await().map { Suggestion.suggestion(it.name) } + else -> emptyList() + } + } catch (_: Exception) { + emptyList() + } + }.asSuggestionProvider() + + /** + * Suggests all known [ServerState]s. + */ + fun serverStates(): SuggestionProvider = + of(ServerState.entries.filter { it != ServerState.UNKNOWN_STATE }.map { it.name.lowercase() }) + + //fun selectionModes(): SuggestionProvider = + // of(ServerSelectionMode.entries.map { it.name.lowercase() }) + + /** + * Suggests all known [GroupServerType]s. + */ + fun serverTypes(): SuggestionProvider = + of(GroupServerType.entries.filter { it != GroupServerType.UNKNOWN_SERVER }.map { it.name.lowercase() }) + + /** + * Suggests the given fixed [values]. + */ + fun of(vararg values: String): SuggestionProvider = + of(values.toList()) + + /** + * Suggests the given fixed [values]. + */ + fun of(values: Collection): SuggestionProvider { + val suggestions = values.map { Suggestion.suggestion(it) } + return SuggestionProvider.blocking { _, _ -> suggestions } + } + + private fun serverName(server: Server): String? { + val persistentServer = server.persistentServer + if (persistentServer != null) return persistentServer.name + val group = server.group ?: return null + return "${group.name}-${server.numericalId}" + } + +} diff --git a/plugin-velocity/build.gradle.kts b/plugin-velocity/build.gradle.kts index 7468d5f..12b0664 100644 --- a/plugin-velocity/build.gradle.kts +++ b/plugin-velocity/build.gradle.kts @@ -4,6 +4,7 @@ plugins { dependencies { compileOnly(project(":plugin-shared")) + compileOnly(libs.cloud.velocity) compileOnly(libs.velocity.api) kapt(libs.velocity.api) } \ No newline at end of file diff --git a/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSender.kt b/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSender.kt new file mode 100644 index 0000000..32ca7d9 --- /dev/null +++ b/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSender.kt @@ -0,0 +1,27 @@ +package app.simplecloud.plugin.api.velocity.command + +import app.simplecloud.plugin.api.shared.command.CloudSender +import com.velocitypowered.api.command.CommandSource +import com.velocitypowered.api.proxy.Player +import net.kyori.adventure.text.Component +import java.util.UUID + +class VelocityCloudSender(private val commandSource: CommandSource) : CloudSender { + + fun getCommandSource(): CommandSource { + return commandSource + } + + override fun getUniqueId(): UUID { + return (commandSource as? Player)?.uniqueId ?: UUID(0L, 0L) + } + + override fun hasPermission(permission: String): Boolean { + return commandSource.hasPermission(permission) + } + + override fun sendMessage(message: Component) { + commandSource.sendMessage(message) + } + +} diff --git a/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSenderMapper.kt b/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSenderMapper.kt new file mode 100644 index 0000000..e8ef1e8 --- /dev/null +++ b/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSenderMapper.kt @@ -0,0 +1,16 @@ +package app.simplecloud.plugin.api.velocity.command + +import com.velocitypowered.api.command.CommandSource +import org.incendo.cloud.SenderMapper + +object VelocityCloudSenderMapper : SenderMapper { + + override fun map(base: CommandSource): VelocityCloudSender { + return VelocityCloudSender(base) + } + + override fun reverse(mapped: VelocityCloudSender): CommandSource { + return mapped.getCommandSource() + } + +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 5f8122a..73d7004 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,6 +2,11 @@ plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" } -include("plugin-shared", "plugin-velocity") +include( + "plugin-bungeecord", + "plugin-paper", + "plugin-shared", + "plugin-velocity" +) rootProject.name = "plugin-api" \ No newline at end of file From 4cb65112b053d1d00291367e10fa74c230ee4132 Mon Sep 17 00:00:00 2001 From: Janis Date: Tue, 13 Oct 2026 23:47:40 +0200 Subject: [PATCH 53/61] ci: update release workflow --- .github/workflows/release.yml | 51 +++++++++++++++++------------------ LICENSE | 2 +- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index be70136..e3b3a73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,22 +26,26 @@ jobs: - name: Set up JDK uses: actions/setup-java@v6 with: - distribution: 'adopt' + distribution: 'temurin' java-version: '25' - - name: Cache Gradle packages - uses: actions/cache@v3 + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v6 with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - gradle-${{ runner.os }} + cache-disabled: true - name: Make gradlew executable run: chmod +x ./gradlew + - name: Build + run: ./gradlew clean build + + - name: Publish to SimpleCloud Repository + run: ./gradlew publish + env: + SIMPLECLOUD_USERNAME: ${{ secrets.SIMPLECLOUD_USERNAME }} + SIMPLECLOUD_PASSWORD: ${{ secrets.SIMPLECLOUD_PASSWORD }} + - name: Get Gradle Version id: gradle_version run: echo "GRADLE_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_ENV @@ -50,23 +54,18 @@ jobs: id: commit_hash run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - name: Publish to SimpleCloud Repository - run: ./gradlew publishMavenJavaPublicationToSimplecloudRepository - env: - COMMIT_HASH: ${{ env.COMMIT_HASH }} - SIMPLECLOUD_USERNAME: ${{ secrets.SIMPLECLOUD_USERNAME }} - SIMPLECLOUD_PASSWORD: ${{ secrets.SIMPLECLOUD_PASSWORD }} - - name: Create Release - id: create_release - uses: actions/create-release@v1 - with: - tag_name: v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }} - release_name: v${{ env.GRADLE_VERSION }}-dev.${{ env.COMMIT_HASH }} - draft: false - prerelease: true - commitish: ${{ inputs.branch }} - body: | - This release contains dev builds for all Gradle modules. + run: | + jars=() + for jar in $(find . -type f -name "*.jar" -path "*/build/libs/*.jar" -not -path "./build/libs/*"); do + echo "Uploading $jar" + jars+=("$jar") + done + gh release create "v${GRADLE_VERSION}-dev.${COMMIT_HASH}" \ + --target "${{ inputs.branch }}" \ + --title "v${GRADLE_VERSION}-dev.${COMMIT_HASH}" \ + --notes "This release contains dev builds for all Gradle modules." \ + --prerelease \ + "${jars[@]}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/LICENSE b/LICENSE index 2cd34d3..019b392 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2025] [SimpleCloud] + Copyright 2025-2026 SimpleCloud Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From f3257dcbfae81aa794d4da4835feea437aa410dc Mon Sep 17 00:00:00 2001 From: Janis Date: Wed, 14 Oct 2026 00:25:47 +0200 Subject: [PATCH 54/61] feat: minestom --- build.gradle.kts | 1 + gradle/libs.versions.toml | 4 +++ .../permission/BungeeCordPermissionChecker.kt | 12 +++++++ plugin-minestom/build.gradle.kts | 5 +++ .../minestom/command/MinestomCloudSender.kt | 31 +++++++++++++++++++ .../command/MinestomCloudSenderMapper.kt | 19 ++++++++++++ .../permission/MinestomPermissionChecker.kt | 12 +++++++ .../permission/MinestomPermissions.kt | 29 +++++++++++++++++ .../permission/PaperPermissionChecker.kt | 12 +++++++ settings.gradle.kts | 1 + 10 files changed, 126 insertions(+) create mode 100644 plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/permission/BungeeCordPermissionChecker.kt create mode 100644 plugin-minestom/build.gradle.kts create mode 100644 plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/command/MinestomCloudSender.kt create mode 100644 plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/command/MinestomCloudSenderMapper.kt create mode 100644 plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/permission/MinestomPermissionChecker.kt create mode 100644 plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/permission/MinestomPermissions.kt create mode 100644 plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/permission/PaperPermissionChecker.kt diff --git a/build.gradle.kts b/build.gradle.kts index cf71863..ee24864 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,6 +14,7 @@ allprojects { mavenCentral() mavenLocal() maven("https://buf.build/gen/maven") + maven("https://repo.spectr.is/snapshots") maven("https://repo.simplecloud.app/snapshots") maven("https://repo.papermc.io/repository/maven-public") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bd9cc54..36fffd0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ simplecloud-api = "0.1.0-platform.58-dev.5.1-fe01ce5" velocity = "4.1.0-SNAPSHOT" bungeecord = "1.21-R0.4" paper = "26.3.build.+" +minestom = "26_3-SNAPSHOT" adventure = "5.2.0" adventure-platform-bungeecord = "4.4.1" @@ -16,6 +17,7 @@ slf4j = "2.0.20" cloud = "2.1.0" cloud-platform = "2.0.0" +cloud-minestom = "2.2.0-SNAPSHOT" [libraries] kotlin-jvm = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" } @@ -27,6 +29,7 @@ simplecloud-api = { module = "app.simplecloud.api:api", version.ref = "simpleclo velocity-api = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" } bungeecord-api = { module = "net.md-5:bungeecord-api", version.ref = "bungeecord" } paper-api = { module = "io.papermc.paper:paper-api", version.ref = "paper" } +minestom = { module = "net.minestom:minestom", version.ref = "minestom" } adventure = { module = "net.kyori:adventure-api", version.ref = "adventure" } adventure-text-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } @@ -43,6 +46,7 @@ cloud-coroutines = { module = "org.incendo:cloud-kotlin-coroutines", version.ref cloud-velocity = { module = "org.incendo:cloud-velocity", version.ref = "cloud-platform" } cloud-bungee = { module = "org.incendo:cloud-bungee", version.ref = "cloud-platform" } cloud-paper = { module = "org.incendo:cloud-paper", version.ref = "cloud-platform" } +cloud-minestom = { module = "org.incendo:cloud-minestom", version.ref = "cloud-minestom" } [bundles] adventure = ["adventure", "adventure-text-minimessage"] diff --git a/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/permission/BungeeCordPermissionChecker.kt b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/permission/BungeeCordPermissionChecker.kt new file mode 100644 index 0000000..9753dfb --- /dev/null +++ b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/permission/BungeeCordPermissionChecker.kt @@ -0,0 +1,12 @@ +package app.simplecloud.plugin.api.bungeecord.permission + +import app.simplecloud.plugin.api.shared.permission.PermissionChecker +import net.md_5.bungee.api.connection.ProxiedPlayer + +class BungeeCordPermissionChecker : PermissionChecker { + + override fun checkPermission(player: ProxiedPlayer, name: String): Boolean { + return player.hasPermission(name) + } + +} diff --git a/plugin-minestom/build.gradle.kts b/plugin-minestom/build.gradle.kts new file mode 100644 index 0000000..32e39cb --- /dev/null +++ b/plugin-minestom/build.gradle.kts @@ -0,0 +1,5 @@ +dependencies { + compileOnly(project(":plugin-shared")) + compileOnly(libs.minestom) + compileOnly(libs.cloud.minestom) +} diff --git a/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/command/MinestomCloudSender.kt b/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/command/MinestomCloudSender.kt new file mode 100644 index 0000000..0a7e014 --- /dev/null +++ b/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/command/MinestomCloudSender.kt @@ -0,0 +1,31 @@ +package app.simplecloud.plugin.api.minestom.command + +import app.simplecloud.plugin.api.minestom.permission.MinestomPermissions +import app.simplecloud.plugin.api.shared.command.CloudSender +import net.kyori.adventure.text.Component +import net.minestom.server.command.CommandSender +import net.minestom.server.entity.Player +import java.util.UUID + +class MinestomCloudSender( + private val commandSender: CommandSender, + private val permissions: MinestomPermissions +) : CloudSender { + + fun getCommandSender(): CommandSender { + return commandSender + } + + override fun getUniqueId(): UUID { + return (commandSender as? Player)?.uuid ?: UUID(0L, 0L) + } + + override fun hasPermission(permission: String): Boolean { + return permissions.hasPermission(commandSender, permission) + } + + override fun sendMessage(message: Component) { + commandSender.sendMessage(message) + } + +} diff --git a/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/command/MinestomCloudSenderMapper.kt b/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/command/MinestomCloudSenderMapper.kt new file mode 100644 index 0000000..6ca2b6a --- /dev/null +++ b/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/command/MinestomCloudSenderMapper.kt @@ -0,0 +1,19 @@ +package app.simplecloud.plugin.api.minestom.command + +import app.simplecloud.plugin.api.minestom.permission.MinestomPermissions +import net.minestom.server.command.CommandSender +import org.incendo.cloud.SenderMapper + +class MinestomCloudSenderMapper( + private val permissions: MinestomPermissions +) : SenderMapper { + + override fun map(base: CommandSender): MinestomCloudSender { + return MinestomCloudSender(base, permissions) + } + + override fun reverse(mapped: MinestomCloudSender): CommandSender { + return mapped.getCommandSender() + } + +} diff --git a/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/permission/MinestomPermissionChecker.kt b/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/permission/MinestomPermissionChecker.kt new file mode 100644 index 0000000..63ed96c --- /dev/null +++ b/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/permission/MinestomPermissionChecker.kt @@ -0,0 +1,12 @@ +package app.simplecloud.plugin.api.minestom.permission + +import app.simplecloud.plugin.api.shared.permission.PermissionChecker +import net.minestom.server.entity.Player + +class MinestomPermissionChecker(private val permissions: MinestomPermissions) : PermissionChecker { + + override fun checkPermission(player: Player, name: String): Boolean { + return permissions.hasPermission(player, name) + } + +} diff --git a/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/permission/MinestomPermissions.kt b/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/permission/MinestomPermissions.kt new file mode 100644 index 0000000..7bd91ef --- /dev/null +++ b/plugin-minestom/src/main/kotlin/app/simplecloud/plugin/api/minestom/permission/MinestomPermissions.kt @@ -0,0 +1,29 @@ +package app.simplecloud.plugin.api.minestom.permission + +import net.minestom.server.command.CommandSender +import net.minestom.server.command.ConsoleSender +import net.minestom.server.entity.Player +import java.util.function.BiPredicate + +/** + * Utility for checking permissions on a Minestom server. + * Without a [check], only players with permission level 4 have permissions. + */ +class MinestomPermissions(private val check: BiPredicate?) { + + val hasCheck: Boolean = check != null + + fun hasPermission(sender: CommandSender, permission: String): Boolean { + if (permission.isEmpty()) return true + if (sender is ConsoleSender) return true + if (sender !is Player) return false + + if (check != null) return check.test(sender, permission) + return sender.permissionLevel >= 4 + } + + fun getChecker(): MinestomPermissionChecker { + return MinestomPermissionChecker(this) + } + +} diff --git a/plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/permission/PaperPermissionChecker.kt b/plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/permission/PaperPermissionChecker.kt new file mode 100644 index 0000000..f3bda7b --- /dev/null +++ b/plugin-paper/src/main/kotlin/app/simplecloud/plugin/api/paper/permission/PaperPermissionChecker.kt @@ -0,0 +1,12 @@ +package app.simplecloud.plugin.api.paper.permission + +import app.simplecloud.plugin.api.shared.permission.PermissionChecker +import org.bukkit.entity.Player + +class PaperPermissionChecker : PermissionChecker { + + override fun checkPermission(player: Player, name: String): Boolean { + return player.hasPermission(name) + } + +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 73d7004..7cabdca 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,6 +4,7 @@ plugins { include( "plugin-bungeecord", + "plugin-minestom", "plugin-paper", "plugin-shared", "plugin-velocity" From cc3612c5247685b26c4d13797feef9a93fc40395 Mon Sep 17 00:00:00 2001 From: Janis Date: Wed, 14 Oct 2026 00:28:31 +0200 Subject: [PATCH 55/61] chore: bump version --- .github/workflows/release.yml | 8 ++------ build.gradle.kts | 7 ++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e3b3a73..fbe1943 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,10 +50,6 @@ jobs: id: gradle_version run: echo "GRADLE_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_ENV - - name: Get Commit Hash - id: commit_hash - run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - name: Create Release run: | jars=() @@ -61,9 +57,9 @@ jobs: echo "Uploading $jar" jars+=("$jar") done - gh release create "v${GRADLE_VERSION}-dev.${COMMIT_HASH}" \ + gh release create "v${GRADLE_VERSION}" \ --target "${{ inputs.branch }}" \ - --title "v${GRADLE_VERSION}-dev.${COMMIT_HASH}" \ + --title "v${GRADLE_VERSION}" \ --notes "This release contains dev builds for all Gradle modules." \ --prerelease \ "${jars[@]}" diff --git a/build.gradle.kts b/build.gradle.kts index ee24864..90f16fb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,9 +6,14 @@ plugins { alias(libs.plugins.kotlin) } +val baseVersion = "1.0.0" +val commitHash = providers.exec { + commandLine("git", "rev-parse", "--short", "HEAD") +}.standardOutput.asText.get().trim() + allprojects { group = "app.simplecloud.plugin" - version = "1.0.0" + version = "$baseVersion-dev.$commitHash" repositories { mavenCentral() From 69b9a60cb5b9b2f76e9956d8d5a6b9f0b63b6829 Mon Sep 17 00:00:00 2001 From: Janis Date: Wed, 14 Oct 2026 00:35:51 +0200 Subject: [PATCH 56/61] ci: rename workflow --- .github/workflows/{release.yml => release-dev.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{release.yml => release-dev.yml} (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release-dev.yml similarity index 100% rename from .github/workflows/release.yml rename to .github/workflows/release-dev.yml From 1dbc20651ffb1a24dd71e8d728627424959f2d81 Mon Sep 17 00:00:00 2001 From: Janis Date: Wed, 14 Oct 2026 00:41:32 +0200 Subject: [PATCH 57/61] fix: issues with adventure 5.2.0 --- .../shared/placeholder/provider/AbstractPlaceholderProvider.kt | 3 ++- .../single/SinglePersistentServerPlaceholderExecutor.kt | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt index 4a971de..1ce97bb 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt @@ -6,6 +6,7 @@ import app.simplecloud.plugin.api.shared.placeholder.argument.ArgumentsResolver import app.simplecloud.plugin.api.shared.placeholder.single.SinglePlaceholderExecutor import kotlinx.coroutines.runBlocking import net.kyori.adventure.text.Component +import net.kyori.adventure.text.minimessage.tag.Tag import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver /** @@ -91,7 +92,7 @@ abstract class AbstractPlaceholderProvider( val key = resolver.getKey() val resolvedKey = prefix?.let { "${it}_$key" } ?: key return TagResolver.resolver(resolvedKey) { arguments, _ -> - return@resolver runBlocking { resolver.resolve(arguments) } + return@resolver runBlocking { resolver.resolve(arguments) as Tag } } } diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePersistentServerPlaceholderExecutor.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePersistentServerPlaceholderExecutor.kt index 2e99d5c..f0cb0ed 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePersistentServerPlaceholderExecutor.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/single/SinglePersistentServerPlaceholderExecutor.kt @@ -2,7 +2,6 @@ package app.simplecloud.plugin.api.shared.placeholder.single import app.simplecloud.api.CloudApi import app.simplecloud.api.persistentserver.PersistentServer -import app.simplecloud.api.server.Server import app.simplecloud.plugin.api.shared.placeholder.async.AsyncPlaceholder import app.simplecloud.plugin.api.shared.pretty.StringPrettifier From c40fdd8c4f1e458ce43a8bb856a157509ef61a06 Mon Sep 17 00:00:00 2001 From: Janis Date: Thu, 15 Oct 2026 00:24:32 +0200 Subject: [PATCH 58/61] feat: add BungeeComponentConverter --- gradle/libs.versions.toml | 4 +-- plugin-bungeecord/build.gradle.kts | 2 +- .../bungeecord/command/BungeeCloudSender.kt | 7 +++-- .../command/BungeeCloudSenderMapper.kt | 7 ++--- .../text/BungeeComponentConverter.kt | 26 +++++++++++++++++++ 5 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/text/BungeeComponentConverter.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 36fffd0..e2bf57a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ paper = "26.3.build.+" minestom = "26_3-SNAPSHOT" adventure = "5.2.0" -adventure-platform-bungeecord = "4.4.1" + configurate = "4.2.0" slf4j = "2.0.20" @@ -33,7 +33,7 @@ minestom = { module = "net.minestom:minestom", version.ref = "minestom" } adventure = { module = "net.kyori:adventure-api", version.ref = "adventure" } adventure-text-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } -adventure-platform-bungeecord = { module = "net.kyori:adventure-platform-bungeecord", version.ref = "adventure-platform-bungeecord" } +adventure-text-serializer-gson = { module = "net.kyori:adventure-text-serializer-gson", version.ref = "adventure" } configurate-yaml = { module = "org.spongepowered:configurate-yaml", version.ref = "configurate" } configurate-gson = { module = "org.spongepowered:configurate-gson", version.ref = "configurate" } diff --git a/plugin-bungeecord/build.gradle.kts b/plugin-bungeecord/build.gradle.kts index ea875ac..a733652 100644 --- a/plugin-bungeecord/build.gradle.kts +++ b/plugin-bungeecord/build.gradle.kts @@ -2,5 +2,5 @@ dependencies { compileOnly(project(":plugin-shared")) compileOnly(libs.cloud.bungee) compileOnly(libs.bungeecord.api) - compileOnly(libs.adventure.platform.bungeecord) + compileOnly(libs.adventure.text.serializer.gson) } diff --git a/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSender.kt b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSender.kt index 16a769c..5301722 100644 --- a/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSender.kt +++ b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSender.kt @@ -1,15 +1,14 @@ package app.simplecloud.plugin.api.bungeecord.command +import app.simplecloud.plugin.api.bungeecord.text.BungeeComponentConverter import app.simplecloud.plugin.api.shared.command.CloudSender -import net.kyori.adventure.platform.bungeecord.BungeeAudiences import net.kyori.adventure.text.Component import net.md_5.bungee.api.CommandSender import net.md_5.bungee.api.connection.ProxiedPlayer import java.util.UUID class BungeeCloudSender( - private val commandSender: CommandSender, - private val audiences: BungeeAudiences + private val commandSender: CommandSender ) : CloudSender { fun getCommandSender(): CommandSender { @@ -25,7 +24,7 @@ class BungeeCloudSender( } override fun sendMessage(message: Component) { - audiences.sender(commandSender).sendMessage(message) + commandSender.sendMessage(BungeeComponentConverter.toBungee(message)) } } diff --git a/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSenderMapper.kt b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSenderMapper.kt index 35a77a6..698ddee 100644 --- a/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSenderMapper.kt +++ b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/command/BungeeCloudSenderMapper.kt @@ -1,15 +1,12 @@ package app.simplecloud.plugin.api.bungeecord.command -import net.kyori.adventure.platform.bungeecord.BungeeAudiences import net.md_5.bungee.api.CommandSender import org.incendo.cloud.SenderMapper -class BungeeCloudSenderMapper( - private val audiences: BungeeAudiences -) : SenderMapper { +class BungeeCloudSenderMapper : SenderMapper { override fun map(base: CommandSender): BungeeCloudSender { - return BungeeCloudSender(base, audiences) + return BungeeCloudSender(base) } override fun reverse(mapped: BungeeCloudSender): CommandSender { diff --git a/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/text/BungeeComponentConverter.kt b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/text/BungeeComponentConverter.kt new file mode 100644 index 0000000..9d85dc2 --- /dev/null +++ b/plugin-bungeecord/src/main/kotlin/app/simplecloud/plugin/api/bungeecord/text/BungeeComponentConverter.kt @@ -0,0 +1,26 @@ +package app.simplecloud.plugin.api.bungeecord.text + +import net.kyori.adventure.text.Component +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer +import net.md_5.bungee.api.chat.BaseComponent +import net.md_5.bungee.chat.ComponentSerializer + +/** + * Converts between Adventure and BungeeCord components. + */ +object BungeeComponentConverter { + + private val serializer = GsonComponentSerializer.gson() + + /** + * Converts the given [component] into a [BaseComponent]. + */ + fun toBungee(component: Component): BaseComponent = + ComponentSerializer.deserialize(serializer.serialize(component)) + + /** + * Converts the given [component] into an Adventure [Component]. + */ + fun fromBungee(component: BaseComponent): Component = + serializer.deserialize(ComponentSerializer.toString(component)) +} From 65ae6b7d444fa36471d7e24500f0bdfdc5a19c71 Mon Sep 17 00:00:00 2001 From: Janis Date: Sun, 18 Oct 2026 06:17:36 +0200 Subject: [PATCH 59/61] feat: more config utilities and some cleanup --- gradle/libs.versions.toml | 1 - gradle/wrapper/gradle-wrapper.jar | Bin 60756 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 2 + gradlew | 2 +- gradlew.bat | 2 +- .../bungeecord/command/BungeeCloudSender.kt | 4 +- .../minestom/command/MinestomCloudSender.kt | 4 +- .../api/paper/command/PaperCloudSender.kt | 4 +- .../AdventureExt.kt} | 18 +++-- .../plugin/api/shared/command/CloudSender.kt | 21 ++++- .../shared/config/AbstractMessageConfig.kt | 21 ++--- .../api/shared/config/ConfigMigrator.kt | 67 +++++++++------- .../api/shared/config/ConfigurationFactory.kt | 74 +++++++++++++----- .../shared/config/DefaultConfigInstaller.kt | 27 ++++++- .../api/shared/config/VersionedConfig.kt | 2 +- .../shared/config/YamlDirectoryRepository.kt | 66 +++++++--------- .../api/shared/config/YamlFileConfigurator.kt | 34 ++++---- .../serializer/GenericEnumSerializer.kt | 6 +- .../provider/AbstractPlaceholderProvider.kt | 2 +- .../velocity/command/VelocityCloudSender.kt | 4 +- 20 files changed, 224 insertions(+), 137 deletions(-) rename plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/{extension/Extension.kt => adventure/AdventureExt.kt} (73%) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e2bf57a..adaa298 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,6 @@ minestom = "26_3-SNAPSHOT" adventure = "5.2.0" - configurate = "4.2.0" slf4j = "2.0.20" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832f090a2944b7473328c07c9755baa3196..a4b76b9530d66f5e68d973ea569d8e19de379189 100644 GIT binary patch literal 43583 zcma&N1CXTcmMvW9vTb(Rwr$&4wr$(C?dmSu>@vG-+vuvg^_??!{yS%8zW-#zn-LkA z5&1^$^{lnmUON?}LBF8_K|(?T0Ra(xUH{($5eN!MR#ZihR#HxkUPe+_R8Cn`RRs(P z_^*#_XlXmGv7!4;*Y%p4nw?{bNp@UZHv1?Um8r6)Fei3p@ClJn0ECfg1hkeuUU@Or zDaPa;U3fE=3L}DooL;8f;P0ipPt0Z~9P0)lbStMS)ag54=uL9ia-Lm3nh|@(Y?B`; zx_#arJIpXH!U{fbCbI^17}6Ri*H<>OLR%c|^mh8+)*h~K8Z!9)DPf zR2h?lbDZQ`p9P;&DQ4F0sur@TMa!Y}S8irn(%d-gi0*WxxCSk*A?3lGh=gcYN?FGl z7D=Js!i~0=u3rox^eO3i@$0=n{K1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kN|yamn1uyl2*N-lnqRI1cvs_JxLTeahEK=THV$Sz*gQhKNb*p0fNoda#-&F zB-qJgW^g}!TtM|0bS2QZekW7_tKu%GcJ!4?lObt0z_$mZ4rbQ0o=^curCs3bJK6sq z9fu-aW-l#>z~ca(B;4yv;2RZ?tGYAU)^)Kz{L|4oPj zdOf_?de|#yS)p2v8-N||+XL=O*%3+y)oI(HbM)Ds?q8~HPzIP(vs*G`iddbWq}! z(2!VjP&{Z1w+%eUq^:'"\\\s]{1,32}$""") + fun text(message: String, vararg tagResolver: TagResolver): Component { return miniMessage.deserialize(message, *tagResolver) } +fun tags(vararg entries: Pair): TagResolver { + return TagResolver.resolver( + entries.map { (key, value) -> + val text = value?.toString() ?: "" + if (key == "playername" && playerNameRegex.matches(text)) Placeholder.parsed(key, text) else Placeholder.unparsed(key, text) + } + ) +} + suspend fun String.appendToComponent( server: Server, prefix: String? = null, diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSender.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSender.kt index 961d5c9..d53c292 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSender.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/command/CloudSender.kt @@ -3,12 +3,29 @@ package app.simplecloud.plugin.api.shared.command import net.kyori.adventure.text.Component import java.util.UUID +/** + * A command sender, e.g. a player or the console. + */ interface CloudSender { - fun getUniqueId(): UUID + /** + * The unique id of the player, or `null` if the sender is not a player. + */ + fun getUniqueId(): UUID? + /** + * Whether the sender has the given [permission]. + */ fun hasPermission(permission: String): Boolean + /** + * Sends the [message] to the sender. + */ fun sendMessage(message: Component) -} \ No newline at end of file + /** + * Whether the sender is a player. + */ + fun isPlayer(): Boolean = getUniqueId() != null + +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt index ea32644..3bc8505 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/AbstractMessageConfig.kt @@ -1,28 +1,29 @@ package app.simplecloud.plugin.api.shared.config -import app.simplecloud.plugin.api.shared.extension.miniMessage +import app.simplecloud.plugin.api.shared.adventure.miniMessage import net.kyori.adventure.text.Component import net.kyori.adventure.text.minimessage.tag.Tag import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver +/** + * Base class for a message configuration with variables. + */ abstract class AbstractMessageConfig { + abstract val variables: Map private val resolver: TagResolver by lazy { TagResolver.resolver( variables.map { (key, value) -> - TagResolver.resolver( - key, - Tag.selfClosingInserting(miniMessage.deserialize(value)) - ) + TagResolver.resolver(key, Tag.selfClosingInserting(miniMessage.deserialize(value))) } ) } + /** + * Parses the [message] with the [variables] and the [extra] resolvers. + */ fun msg(message: String, vararg extra: TagResolver): Component { - return miniMessage.deserialize( - message, - TagResolver.resolver(resolver, *extra) - ) + return miniMessage.deserialize(message, TagResolver.resolver(resolver, *extra)) } -} \ No newline at end of file +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigMigrator.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigMigrator.kt index a06be79..e3e4350 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigMigrator.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigMigrator.kt @@ -3,12 +3,21 @@ package app.simplecloud.plugin.api.shared.config import org.spongepowered.configurate.CommentedConfigurationNode /** - * Applies sequential migrations to bring a yaml config node to the current version. + * A single migration step that modifies a yaml node in place. */ fun interface ConfigMigration { fun migrate(node: CommentedConfigurationNode) } +/** + * Applies sequential migrations to bring a yaml config node to the current version. + * + * ``` + * ConfigMigrator.builder(currentVersion = 2) + * .migrate(1, 2) { node -> ... } + * .build() + * ``` + */ class ConfigMigrator private constructor( private val currentVersion: Int, private val fallbackVersion: Int, @@ -21,19 +30,21 @@ class ConfigMigrator private constructor( } } + /** + * Migrates the [node] to the current version and returns whether anything was migrated. + */ fun migrate(node: CommentedConfigurationNode): Boolean { - var version = node.node(VERSION_NODE).getInt(this.fallbackVersion) + var version = node.node(VERSION_NODE).getInt(fallbackVersion) - require(version <= this.currentVersion) { - "The config version $version is newer than the supported version ${this.currentVersion}" + require(version <= currentVersion) { + "The config version $version is newer than the supported version $currentVersion" } var migrated = false - while (version < this.currentVersion) { - val migration = this.migrationsByFromVersion[version] - ?: throw IllegalStateException( - "Missing config migration from version $version to ${this.currentVersion}" - ) + while (version < currentVersion) { + val migration = checkNotNull(migrationsByFromVersion[version]) { + "Missing config migration from version $version to $currentVersion" + } migration.action.migrate(node) version = migration.toVersion @@ -48,46 +59,44 @@ class ConfigMigrator private constructor( private val currentVersion: Int, ) { - private var fallbackVersion: Int = 0 + private var fallbackVersion = 0 private val migrations = mutableMapOf() - fun fallbackVersion(version: Int): Builder { + /** + * The version that is assumed if the config has no version node yet. Defaults to `0`. + */ + fun fallbackVersion(version: Int): Builder = apply { require(version >= 0) { "The fallback version must be greater than or equal to 0" } - this.fallbackVersion = version - return this + fallbackVersion = version } - fun migrate( - fromVersion: Int, - toVersion: Int, - action: ConfigMigration, - ): Builder { + /** + * Registers a migration from [fromVersion] to [toVersion]. + */ + fun migrate(fromVersion: Int, toVersion: Int, action: ConfigMigration): Builder = apply { require(fromVersion >= 0) { "The source config version must be greater than or equal to 0" } require(toVersion > fromVersion) { "The target config version must be greater than the source config version" } - require(toVersion <= this.currentVersion) { + require(toVersion <= currentVersion) { "The target config version must not exceed the current config version" } - require(fromVersion !in this.migrations) { + require(fromVersion !in migrations) { "A migration from version $fromVersion is already registered" } - this.migrations[fromVersion] = MigrationStep(toVersion, action) - return this + migrations[fromVersion] = MigrationStep(toVersion, action) } - fun build(): ConfigMigrator { - return ConfigMigrator( - currentVersion = this.currentVersion, - fallbackVersion = this.fallbackVersion, - migrationsByFromVersion = this.migrations.toMap(), - ) - } + fun build(): ConfigMigrator = ConfigMigrator( + currentVersion = currentVersion, + fallbackVersion = fallbackVersion, + migrationsByFromVersion = migrations.toMap(), + ) } private data class MigrationStep( diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt index f9f1a17..d8e9a8e 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/ConfigurationFactory.kt @@ -1,55 +1,89 @@ package app.simplecloud.plugin.api.shared.config import java.io.File +import java.nio.file.Path /** * @author Niklas Nieberler */ - -class ConfigurationFactory @JvmOverloads constructor( +class ConfigurationFactory( private val file: File, javaClass: Class, configMigrator: ConfigMigrator? = null, ) { - private val yamlFileConfigurator = YamlFileConfigurator(javaClass, configMigrator) + private val configurator = YamlFileConfigurator(javaClass, configMigrator) private var config: E? = null /** - * Loads the config and if it does not exist, it creates a default config - * @param defaultConfig the default configuration + * Loads the config, or creates the file from [defaultConfig] if it does not exist. */ fun loadOrCreate(defaultConfig: E): E { - if (this.file.exists()) { - return loadConfiguration() - ?: throw NullPointerException("failed to load config") + if (file.exists()) { + return load() ?: throw NullPointerException("failed to load config") } - this.yamlFileConfigurator.save(this.file, defaultConfig) - this.config = defaultConfig + save(defaultConfig) return defaultConfig } /** - * Gets the cached config file + * The cached config. Throws if it has not been loaded yet. */ fun get(): E { - return this.config ?: throw NullPointerException("failed to find config") + return config ?: throw NullPointerException("failed to find config") } + /** + * Writes the [entry] to the file and caches it. + */ fun save(entry: E) { - this.yamlFileConfigurator.save(this.file, entry) - this.config = entry + configurator.save(file, entry) + config = entry } - private fun loadConfiguration(): E? { - val configuration = this.yamlFileConfigurator.load(this.file) - this.config = configuration - return configuration + /** + * Reloads the file into the cache. + */ + fun reload() { + load() } - fun reload() { - loadConfiguration() + private fun load(): E? { + return configurator.load(file).also { config = it } + } + + companion object { + + /** + * Installs the bundled default file if missing, creates the factory and loads the config. + * + * The bundled file is looked up by [fileName] with the class loader of the config class. + */ + inline fun create( + dataDirectory: File, + fileName: String, + default: E, + migrator: ConfigMigrator? = null, + classLoader: ClassLoader = E::class.java.classLoader, + ): ConfigurationFactory { + val file = File(dataDirectory, fileName) + DefaultConfigInstaller.install(file.toPath(), classLoader) + return ConfigurationFactory(file, E::class.java, migrator).also { it.loadOrCreate(default) } + } + + /** + * Same as [create] but with a [Path] as data directory. + */ + inline fun create( + dataDirectory: Path, + fileName: String, + default: E, + migrator: ConfigMigrator? = null, + classLoader: ClassLoader = E::class.java.classLoader, + ): ConfigurationFactory { + return create(dataDirectory.toFile(), fileName, default, migrator, classLoader) + } } } diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/DefaultConfigInstaller.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/DefaultConfigInstaller.kt index c2c6025..166da06 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/DefaultConfigInstaller.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/DefaultConfigInstaller.kt @@ -3,17 +3,36 @@ package app.simplecloud.plugin.api.shared.config import java.nio.file.Files import java.nio.file.Path +/** + * Copies bundled default files from the jar into the data directory. + */ object DefaultConfigInstaller { + /** + * Copies the bundled resource with the same file name as [target] if [target] does not exist yet. + */ fun install(target: Path, classLoader: ClassLoader) { + copy(target, target.fileName.toString(), classLoader) + } + + /** + * Copies all [resources] into [dataDirectory]. Paths may contain sub directories, e.g. `layout/public.yml`. + */ + fun installAll(dataDirectory: Path, resources: List, classLoader: ClassLoader, resourcePrefix: String = "") { + val prefix = if (resourcePrefix.isEmpty() || resourcePrefix.endsWith("/")) resourcePrefix else "$resourcePrefix/" + resources.forEach { resource -> + copy(dataDirectory.resolve(resource), prefix + resource, classLoader) + } + } + + private fun copy(target: Path, resourceName: String, classLoader: ClassLoader) { if (Files.exists(target)) return - val name = target.fileName.toString() - val resource = checkNotNull(classLoader.getResourceAsStream(name)) { - "Missing bundled $name" + val resource = checkNotNull(classLoader.getResourceAsStream(resourceName)) { + "Missing bundled $resourceName" } Files.createDirectories(target.parent) resource.use { stream -> Files.copy(stream, target) } } -} \ No newline at end of file +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/VersionedConfig.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/VersionedConfig.kt index e38f8a6..7bf1324 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/VersionedConfig.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/VersionedConfig.kt @@ -1,7 +1,7 @@ package app.simplecloud.plugin.api.shared.config /** - * Marks a configuration as versioned so it can participate in yaml migrations. + * Marks a config as versioned, so it can be used with a [ConfigMigrator]. */ interface VersionedConfig { val version: Int diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt index 68de866..e1f9bc4 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlDirectoryRepository.kt @@ -1,85 +1,77 @@ package app.simplecloud.plugin.api.shared.config import java.io.File -import java.nio.file.* +import java.nio.file.Files +import java.nio.file.Path /** * @author Niklas Nieberler */ -abstract class YamlDirectoryRepository @JvmOverloads constructor( +abstract class YamlDirectoryRepository( private val directory: Path, javaClass: Class, configMigrator: ConfigMigrator? = null, ) { - private val yamlFileConfigurator = YamlFileConfigurator(javaClass, configMigrator) - private val fileDirectory = directory.toFile() + private val configurator = YamlFileConfigurator(javaClass, configMigrator) private val cachedEntities = mutableMapOf() /** - * Saves an element to the file directory - * @param entity to save + * Saves the [entity] to the directory. */ abstract fun save(entity: E) + /** + * Finds a cached entity by its [identifier]. + */ abstract fun find(identifier: I): E? /** - * Loads all cached entities from a directory + * All cached entities. */ fun findAll(): List { - return this.cachedEntities.values.toList() + return cachedEntities.values.toList() } /** - * Loads the yaml directory repository with all elements - * @return list of all file entities + * Loads all `.yml` and `.yaml` files of the directory and creates it if missing. */ fun load(): List { - if (!this.fileDirectory.exists()) - this.fileDirectory.mkdirs() + Files.createDirectories(directory) - return Files.walk(this.directory) - .toList() - .map { it.toFile() } - .filter { it.name.endsWith(".yml") || it.name.endsWith(".yaml") } - .mapNotNull { load(it) } + return Files.walk(directory).use { paths -> + paths.toList() + .map { it.toFile() } + .filter { it.extension == "yml" || it.extension == "yaml" } + .mapNotNull { load(it) } + } } /** - * Loads an entity from a file - * @param file to load + * Loads and caches the entity of a single [file]. */ fun load(file: File): E? { - val entity = this.yamlFileConfigurator.load(file) ?: return null - this.cachedEntities[file] = entity + val entity = configurator.load(file) ?: return null + cachedEntities[file] = entity return entity } /** - * Saves an entity to the yaml formation - * @param name of the file - * @param entity to save + * Saves the [entity] to the file [name] inside the directory. */ protected fun save(name: String, entity: E) { - val file = this.directory.resolve(name).toFile() - this.yamlFileConfigurator.save(file, entity) - this.cachedEntities[file] = entity + val file = directory.resolve(name).toFile() + configurator.save(file, entity) + cachedEntities[file] = entity } /** - * Deletes an entity file - * @param entity to delete + * Deletes the file of the [entity]. */ fun delete(entity: E) { - val file = this.cachedEntities.keys - .find { this.cachedEntities[it] == entity } ?: return - delete(file) - } - - private fun delete(file: File) { + val file = cachedEntities.entries.find { it.value == entity }?.key ?: return file.delete() - this.cachedEntities.remove(file) + cachedEntities.remove(file) } -} \ No newline at end of file +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt index 2ed62e5..ed405c2 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/YamlFileConfigurator.kt @@ -10,13 +10,13 @@ import java.io.File /** * @author Niklas Nieberler */ -class YamlFileConfigurator @JvmOverloads constructor( +class YamlFileConfigurator( private val javaClass: Class, private val configMigrator: ConfigMigrator? = null, ) { init { - require(this.configMigrator == null || VersionedConfig::class.java.isAssignableFrom(this.javaClass)) { + require(configMigrator == null || VersionedConfig::class.java.isAssignableFrom(javaClass)) { "Config migrations can only be used with VersionedConfig types" } } @@ -33,35 +33,41 @@ class YamlFileConfigurator @JvmOverloads constructor( } } + /** + * Writes the [entity] to the [file]. + */ fun save(file: File, entity: E) { val (node, loader) = buildNode(file) - node.set(this.javaClass, entity) + node.set(javaClass, entity) loader.save(node) } + /** + * Reads the [file], migrates it if needed and saves the migrated result. + */ fun load(file: File): E? { val (node, loader) = buildNode(file) - if (migrate(node)) { + if (configMigrator?.migrate(node) == true) { loader.save(node) } - return node.get(this.javaClass) + return node.get(javaClass) } + /** + * Loads the raw node of the [file] together with its loader. + */ fun buildNode(file: File): Pair { val loader = getOrCreateConfigurationLoader(file) - return Pair(loader.load(), loader) + return loader.load() to loader } + /** + * The cached loader of the [file]. + */ fun getOrCreateConfigurationLoader(file: File): YamlConfigurationLoader { - return this.configurationLoaders.getOrPut(file) { - this.defaultConfigurationBuilder - .path(file.toPath()) - .build() + return configurationLoaders.getOrPut(file) { + defaultConfigurationBuilder.path(file.toPath()).build() } } - private fun migrate(node: CommentedConfigurationNode): Boolean { - return this.configMigrator?.migrate(node) ?: false - } - } diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/serializer/GenericEnumSerializer.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/serializer/GenericEnumSerializer.kt index 59deb61..4a1bf63 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/serializer/GenericEnumSerializer.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/config/serializer/GenericEnumSerializer.kt @@ -8,15 +8,15 @@ import java.lang.reflect.Type /** * @author Niklas Nieberler */ - object GenericEnumSerializer : TypeSerializer> { @Suppress("UNCHECKED_CAST") override fun deserialize(type: Type, node: ConfigurationNode): Enum<*> { val value = node.string ?: throw SerializationException("No value present in node") - if (type !is Class<*> || !type.isEnum) + if (type !is Class<*> || !type.isEnum) { throw SerializationException("Type is not an enum class") + } return try { java.lang.Enum.valueOf(type as Class>, value) @@ -29,4 +29,4 @@ object GenericEnumSerializer : TypeSerializer> { node.set(obj?.name) } -} \ No newline at end of file +} diff --git a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt index 1ce97bb..a540a71 100644 --- a/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt +++ b/plugin-shared/src/main/kotlin/app/simplecloud/plugin/api/shared/placeholder/provider/AbstractPlaceholderProvider.kt @@ -1,7 +1,7 @@ package app.simplecloud.plugin.api.shared.placeholder.provider import app.simplecloud.api.CloudApi -import app.simplecloud.plugin.api.shared.extension.text +import app.simplecloud.plugin.api.shared.adventure.text import app.simplecloud.plugin.api.shared.placeholder.argument.ArgumentsResolver import app.simplecloud.plugin.api.shared.placeholder.single.SinglePlaceholderExecutor import kotlinx.coroutines.runBlocking diff --git a/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSender.kt b/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSender.kt index 32ca7d9..9527ac2 100644 --- a/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSender.kt +++ b/plugin-velocity/src/main/kotlin/app/simplecloud/plugin/api/velocity/command/VelocityCloudSender.kt @@ -12,8 +12,8 @@ class VelocityCloudSender(private val commandSource: CommandSource) : CloudSende return commandSource } - override fun getUniqueId(): UUID { - return (commandSource as? Player)?.uniqueId ?: UUID(0L, 0L) + override fun getUniqueId(): UUID? { + return (commandSource as? Player)?.uniqueId } override fun hasPermission(permission: String): Boolean { From 539d8340b4b7517a07fd931d9fcaa50195b75586 Mon Sep 17 00:00:00 2001 From: Janis Date: Sun, 18 Oct 2026 06:24:16 +0200 Subject: [PATCH 60/61] ci: publish release and dev builds and test prs --- .github/workflows/build.yml | 38 +++++++++++++ .../{release-dev.yml => release.yml} | 54 +++++++++++-------- build.gradle.kts | 3 +- 3 files changed, 73 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/build.yml rename .github/workflows/{release-dev.yml => release.yml} (57%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..12b3274 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +name: Build Pull Request + +on: + pull_request: + branches: + - main + types: [opened, synchronize, reopened, ready_for_review] + +concurrency: + group: build-${{ github.event.pull_request.number }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + build: + name: build + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - name: Set up JDK + uses: actions/setup-java@v6 + with: + distribution: 'temurin' + java-version: '25' + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v6 + + - name: Make gradlew executable + run: chmod +x ./gradlew + + - name: Build and test + run: ./gradlew clean build diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release.yml similarity index 57% rename from .github/workflows/release-dev.yml rename to .github/workflows/release.yml index fbe1943..a0d17b9 100644 --- a/.github/workflows/release-dev.yml +++ b/.github/workflows/release.yml @@ -1,27 +1,31 @@ name: Release and Publish on: + push: + branches: + - main + - develop workflow_dispatch: - inputs: - branch: - description: 'Branch to build and publish' - required: true - default: 'develop' - type: choice - options: - - develop - - feat/platform + +concurrency: + group: release-${{ github.ref }} + cancel-in-progress: false + +permissions: + contents: write jobs: - build: + release: name: Build and Publish runs-on: ubuntu-latest + env: + GRADLE_ARGS: ${{ github.ref_name == 'main' && '-Prelease' || '' }} + IS_RELEASE: ${{ github.ref_name == 'main' }} + steps: - name: Checkout repository uses: actions/checkout@v7 - with: - ref: ${{ inputs.branch }} - name: Set up JDK uses: actions/setup-java@v6 @@ -37,19 +41,18 @@ jobs: - name: Make gradlew executable run: chmod +x ./gradlew + - name: Get Gradle Version + run: echo "GRADLE_VERSION=$(./gradlew properties -q $GRADLE_ARGS | awk '/^version:/ {print $2}')" >> $GITHUB_ENV + - name: Build - run: ./gradlew clean build + run: ./gradlew clean build $GRADLE_ARGS - name: Publish to SimpleCloud Repository - run: ./gradlew publish + run: ./gradlew publish $GRADLE_ARGS env: SIMPLECLOUD_USERNAME: ${{ secrets.SIMPLECLOUD_USERNAME }} SIMPLECLOUD_PASSWORD: ${{ secrets.SIMPLECLOUD_PASSWORD }} - - name: Get Gradle Version - id: gradle_version - run: echo "GRADLE_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_ENV - - name: Create Release run: | jars=() @@ -57,11 +60,20 @@ jobs: echo "Uploading $jar" jars+=("$jar") done + + if [ "$IS_RELEASE" = "true" ]; then + flags=() + notes="This release contains release builds for all Gradle modules." + else + flags=(--prerelease) + notes="This release contains dev builds for all Gradle modules." + fi + gh release create "v${GRADLE_VERSION}" \ - --target "${{ inputs.branch }}" \ + --target "${{ github.sha }}" \ --title "v${GRADLE_VERSION}" \ - --notes "This release contains dev builds for all Gradle modules." \ - --prerelease \ + --notes "$notes" \ + "${flags[@]}" \ "${jars[@]}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index 90f16fb..53464ea 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,13 +7,14 @@ plugins { } val baseVersion = "1.0.0" +val isRelease = providers.gradleProperty("release").isPresent val commitHash = providers.exec { commandLine("git", "rev-parse", "--short", "HEAD") }.standardOutput.asText.get().trim() allprojects { group = "app.simplecloud.plugin" - version = "$baseVersion-dev.$commitHash" + version = if (isRelease) baseVersion else "$baseVersion-dev.$commitHash" repositories { mavenCentral() From 8313c1cc51960b750a81425bc37fccc7ab287331 Mon Sep 17 00:00:00 2001 From: Janis Date: Sun, 18 Oct 2026 06:25:54 +0200 Subject: [PATCH 61/61] ci: add workflow dispatch --- .github/workflows/release.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a0d17b9..47b038d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,6 +6,15 @@ on: - main - develop workflow_dispatch: + inputs: + type: + description: 'Release type' + required: true + default: 'dev' + type: choice + options: + - dev + - release concurrency: group: release-${{ github.ref }} @@ -20,10 +29,16 @@ jobs: runs-on: ubuntu-latest env: - GRADLE_ARGS: ${{ github.ref_name == 'main' && '-Prelease' || '' }} - IS_RELEASE: ${{ github.ref_name == 'main' }} + GRADLE_ARGS: ${{ ((github.event_name == 'push' && github.ref_name == 'main') || inputs.type == 'release') && '-Prelease' || '' }} + IS_RELEASE: ${{ (github.event_name == 'push' && github.ref_name == 'main') || inputs.type == 'release' }} steps: + - name: Check branch + if: env.IS_RELEASE == 'true' && github.ref_name != 'main' + run: | + echo "::error::Releases can only be created from main" + exit 1 + - name: Checkout repository uses: actions/checkout@v7