From dcdebc47ba915db85d0b573d7be7efc2819c29da Mon Sep 17 00:00:00 2001 From: Illyrius Date: Fri, 31 Oct 2025 10:59:57 +0100 Subject: [PATCH 1/4] init Signed-off-by: Illyrius --- ...ml_jackson_core_jackson_annotations_2_13_4.xml | 10 ++++++++++ ...rxml_jackson_core_jackson_annotations_2_20.xml | 12 ------------ ...asterxml_jackson_core_jackson_core_2_13_4.xml} | 6 +++--- ...ml_jackson_core_jackson_databind_2_13_4_2.xml} | 6 +++--- ...on_datatype_jackson_datatype_jsr310_2_20_1.xml | 10 ---------- ...ackson_module_jackson_module_kotlin_2_20_1.xml | 10 ---------- ...org_jetbrains_kotlin_kotlin_reflect_2_2_21.xml | 12 ------------ ...tlinx_kotlinx_serialization_core_jvm_1_9_0.xml | 12 ++++++++++++ ...tlinx_kotlinx_serialization_json_jvm_1_9_0.xml | 12 ++++++++++++ .idea/modules/VanillaPlus.main.iml | 11 +++++------ .idea/modules/VanillaPlus.test.iml | 15 +++++++-------- build.gradle.kts | 7 ++----- 12 files changed, 54 insertions(+), 69 deletions(-) create mode 100644 .idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_annotations_2_13_4.xml delete mode 100644 .idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_annotations_2_20.xml rename .idea/libraries/{Gradle__com_fasterxml_jackson_core_jackson_core_2_20_1.xml => Gradle__com_fasterxml_jackson_core_jackson_core_2_13_4.xml} (65%) rename .idea/libraries/{Gradle__com_fasterxml_jackson_core_jackson_databind_2_20_1.xml => Gradle__com_fasterxml_jackson_core_jackson_databind_2_13_4_2.xml} (63%) delete mode 100644 .idea/libraries/Gradle__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_20_1.xml delete mode 100644 .idea/libraries/Gradle__com_fasterxml_jackson_module_jackson_module_kotlin_2_20_1.xml delete mode 100644 .idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_reflect_2_2_21.xml create mode 100644 .idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_serialization_core_jvm_1_9_0.xml create mode 100644 .idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_serialization_json_jvm_1_9_0.xml diff --git a/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_annotations_2_13_4.xml b/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_annotations_2_13_4.xml new file mode 100644 index 000000000..82c363444 --- /dev/null +++ b/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_annotations_2_13_4.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_annotations_2_20.xml b/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_annotations_2_20.xml deleted file mode 100644 index 3024ac8ca..000000000 --- a/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_annotations_2_20.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_20_1.xml b/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_13_4.xml similarity index 65% rename from .idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_20_1.xml rename to .idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_13_4.xml index bd1118597..e2ea33654 100644 --- a/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_20_1.xml +++ b/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_13_4.xml @@ -1,11 +1,11 @@ - - + + - + diff --git a/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_databind_2_20_1.xml b/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_databind_2_13_4_2.xml similarity index 63% rename from .idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_databind_2_20_1.xml rename to .idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_databind_2_13_4_2.xml index af66a41e3..98f2b9160 100644 --- a/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_databind_2_20_1.xml +++ b/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_databind_2_13_4_2.xml @@ -1,11 +1,11 @@ - - + + - + diff --git a/.idea/libraries/Gradle__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_20_1.xml b/.idea/libraries/Gradle__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_20_1.xml deleted file mode 100644 index 8a28347e8..000000000 --- a/.idea/libraries/Gradle__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_20_1.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_fasterxml_jackson_module_jackson_module_kotlin_2_20_1.xml b/.idea/libraries/Gradle__com_fasterxml_jackson_module_jackson_module_kotlin_2_20_1.xml deleted file mode 100644 index bc7cd0444..000000000 --- a/.idea/libraries/Gradle__com_fasterxml_jackson_module_jackson_module_kotlin_2_20_1.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_reflect_2_2_21.xml b/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_reflect_2_2_21.xml deleted file mode 100644 index 62756740d..000000000 --- a/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_reflect_2_2_21.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_serialization_core_jvm_1_9_0.xml b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_serialization_core_jvm_1_9_0.xml new file mode 100644 index 000000000..263269de8 --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_serialization_core_jvm_1_9_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_serialization_json_jvm_1_9_0.xml b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_serialization_json_jvm_1_9_0.xml new file mode 100644 index 000000000..44e5dfbfd --- /dev/null +++ b/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_serialization_json_jvm_1_9_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/VanillaPlus.main.iml b/.idea/modules/VanillaPlus.main.iml index dde4fd273..21d091aa2 100644 --- a/.idea/modules/VanillaPlus.main.iml +++ b/.idea/modules/VanillaPlus.main.iml @@ -72,9 +72,6 @@ - - - @@ -117,9 +114,7 @@ - - - + @@ -129,6 +124,9 @@ + + + @@ -193,6 +191,7 @@ + \ No newline at end of file diff --git a/.idea/modules/VanillaPlus.test.iml b/.idea/modules/VanillaPlus.test.iml index 832085095..9ae85177a 100644 --- a/.idea/modules/VanillaPlus.test.iml +++ b/.idea/modules/VanillaPlus.test.iml @@ -69,15 +69,11 @@ - - - - - - + + @@ -98,7 +94,6 @@ - @@ -112,6 +107,9 @@ + + + @@ -159,6 +157,7 @@ + @@ -182,11 +181,11 @@ + - diff --git a/build.gradle.kts b/build.gradle.kts index c6523f886..404e68f8f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,9 +32,7 @@ dependencies { compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.3.17") // TODO("Move away from WorldEdit") implementation(kotlin("stdlib")) - implementation("org.jetbrains.kotlin:kotlin-reflect") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.20.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.20.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0") implementation("org.mariuszgromada.math:MathParser.org-mXparser:6.1.0") implementation("io.netty:netty-buffer:4.2.7.Final") } @@ -54,8 +52,7 @@ tasks { dependsOn(processResources) archiveClassifier.set("") destinationDirectory.set(layout.projectDirectory.dir("build/libs")) - relocate("com.fasterxml.jackson", "$group.jackson") - minimize { exclude(dependency("org.jetbrains.kotlin:kotlin-reflect:.*")) } + minimize() } jar { enabled = false } runServer { minecraftVersion(mcVersion) } From ea27b5fd730affd207d44eb849bca0332451e089 Mon Sep 17 00:00:00 2001 From: Illyrius Date: Fri, 31 Oct 2025 11:15:10 +0100 Subject: [PATCH 2/4] refactor Signed-off-by: Illyrius --- .../org/xodium/vanillaplus/data/SoundData.kt | 38 +++++++------- .../vanillaplus/interfaces/DataInterface.kt | 51 +++++++++---------- .../vanillaplus/interfaces/ModuleInterface.kt | 2 + .../vanillaplus/managers/ConfigManager.kt | 23 +++++++-- .../vanillaplus/modules/ArmorStandModule.kt | 2 + .../xodium/vanillaplus/modules/BooksModule.kt | 2 + .../vanillaplus/modules/CauldronModule.kt | 2 + .../xodium/vanillaplus/modules/ChatModule.kt | 3 ++ .../vanillaplus/modules/DimensionsModule.kt | 3 ++ .../vanillaplus/modules/EntityModule.kt | 3 ++ .../xodium/vanillaplus/modules/InvModule.kt | 3 ++ .../vanillaplus/modules/LocatorModule.kt | 2 + .../xodium/vanillaplus/modules/MotdModule.kt | 2 + .../vanillaplus/modules/OpenableModule.kt | 2 + .../xodium/vanillaplus/modules/PetModule.kt | 3 ++ .../vanillaplus/modules/PlayerModule.kt | 3 ++ .../vanillaplus/modules/RecipiesModule.kt | 2 + .../vanillaplus/modules/ScoreBoardModule.kt | 2 + .../xodium/vanillaplus/modules/SignModule.kt | 2 + .../vanillaplus/modules/SilkTouchModule.kt | 2 + .../xodium/vanillaplus/modules/SitModule.kt | 2 + .../vanillaplus/modules/TabListModule.kt | 3 ++ .../xodium/vanillaplus/modules/TreesModule.kt | 2 + 23 files changed, 109 insertions(+), 50 deletions(-) diff --git a/src/main/kotlin/org/xodium/vanillaplus/data/SoundData.kt b/src/main/kotlin/org/xodium/vanillaplus/data/SoundData.kt index c96f389af..3eae36e00 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/data/SoundData.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/data/SoundData.kt @@ -1,8 +1,12 @@ package org.xodium.vanillaplus.data -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.databind.util.StdConverter +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.descriptors.PrimitiveKind +import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder import net.kyori.adventure.key.Key import net.kyori.adventure.sound.Sound @@ -14,28 +18,26 @@ import net.kyori.adventure.sound.Sound * @property pitch The [pitch] of the sound. Defaults to 1.0f. */ internal data class SoundData( - @get:JsonSerialize(converter = SoundTypeToString::class) - @param:JsonDeserialize(converter = StringToSoundType::class) + @Serializable(with = SoundTypeSerializer::class) val name: Sound.Type, private val source: Sound.Source = Sound.Source.MASTER, private val volume: Float = 1.0f, private val pitch: Float = 1.0f, ) { - companion object { - /** - * Converts a [Sound.Type] to its string representation for JSON serialization. - * Converts a string back to a [Sound.Type] for JSON deserialization. - */ - private object SoundTypeToString : StdConverter() { - override fun convert(value: Sound.Type) = value.key().asString() + object SoundTypeSerializer : KSerializer { + override val descriptor: SerialDescriptor = + PrimitiveSerialDescriptor("Sound.Type", PrimitiveKind.STRING) + + override fun serialize( + encoder: Encoder, + value: Sound.Type, + ) { + encoder.encodeString(value.key().asString()) } - /** - * Converts a string to a [Sound.Type] for JSON deserialization. - * Converts a [Sound.Type] to its string representation for JSON serialization. - */ - private object StringToSoundType : StdConverter() { - override fun convert(value: String) = Sound.Type { Key.key(value) } + override fun deserialize(decoder: Decoder): Sound.Type { + val keyString = decoder.decodeString() + return Sound.Type { Key.key(keyString) } } } diff --git a/src/main/kotlin/org/xodium/vanillaplus/interfaces/DataInterface.kt b/src/main/kotlin/org/xodium/vanillaplus/interfaces/DataInterface.kt index 3c5fdc631..96411fd73 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/interfaces/DataInterface.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/interfaces/DataInterface.kt @@ -2,54 +2,48 @@ package org.xodium.vanillaplus.interfaces -import com.fasterxml.jackson.annotation.JsonAutoDetect -import com.fasterxml.jackson.annotation.PropertyAccessor -import com.fasterxml.jackson.databind.DeserializationFeature -import com.fasterxml.jackson.databind.MapperFeature -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.SerializationFeature -import com.fasterxml.jackson.databind.json.JsonMapper -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule -import com.fasterxml.jackson.module.kotlin.KotlinModule +import kotlinx.serialization.KSerializer +import kotlinx.serialization.builtins.MapSerializer +import kotlinx.serialization.json.Json import org.xodium.vanillaplus.VanillaPlus.Companion.instance import org.xodium.vanillaplus.utils.ExtUtils.toSnakeCase import java.io.IOException import java.nio.file.Path import kotlin.io.path.createDirectories +import kotlin.io.path.readText import kotlin.io.path.writeText -import kotlin.reflect.KClass /** Represents a contract for data within the system. */ interface DataInterface { - val dataClass: KClass + val serializer: KSerializer + val keySerializer: KSerializer + val dataClassName: String val cache: MutableMap val fileName: String - get() = "${dataClass.simpleName?.toSnakeCase()}.json" + get() = "${dataClassName.toSnakeCase()}.json" val filePath: Path get() = instance.dataFolder.toPath().resolve(fileName) - val jsonMapper: ObjectMapper + val json: Json get() = - JsonMapper - .builder() - .addModule(KotlinModule.Builder().build()) - .addModule(JavaTimeModule()) - .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS) - .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .configure(MapperFeature.PROPAGATE_TRANSIENT_MARKER, true) - .build() - .setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY) + Json { + prettyPrint = true + ignoreUnknownKeys = true + encodeDefaults = true + } /** Initializes the cache and loads existing data from the file. */ fun load() { if (filePath.toFile().exists()) { try { cache.clear() - val type = jsonMapper.typeFactory.constructMapType(cache::class.java, Any::class.java, dataClass.java) - val rawMap: Map = jsonMapper.readValue(filePath.toFile(), type) + val mapSerializer = MapSerializer(keySerializer, serializer) + val rawMap: Map = json.decodeFromString(mapSerializer, filePath.readText()) cache.putAll(rawMap) save() } catch (e: IOException) { - instance.logger.severe("Failed to load ${dataClass.simpleName}: ${e.message}") + instance.logger.severe("Failed to load $dataClassName: ${e.message}") + } catch (e: Exception) { + instance.logger.severe("Failed to deserialize $dataClassName: ${e.message}") } } } @@ -61,9 +55,12 @@ interface DataInterface { Runnable { try { filePath.parent.createDirectories() - filePath.writeText(jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(cache)) + val mapSerializer = MapSerializer(keySerializer, serializer) + filePath.writeText(json.encodeToString(mapSerializer, cache)) } catch (e: IOException) { - instance.logger.severe("Failed to write ${dataClass.simpleName} to file: ${e.message}") + instance.logger.severe("Failed to write $dataClassName to file: ${e.message}") + } catch (e: Exception) { + instance.logger.severe("Failed to serialize $dataClassName: ${e.message}") } }, ) diff --git a/src/main/kotlin/org/xodium/vanillaplus/interfaces/ModuleInterface.kt b/src/main/kotlin/org/xodium/vanillaplus/interfaces/ModuleInterface.kt index f758ffbac..ba4e21bb4 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/interfaces/ModuleInterface.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/interfaces/ModuleInterface.kt @@ -1,5 +1,6 @@ package org.xodium.vanillaplus.interfaces +import kotlinx.serialization.Serializable import org.bukkit.event.Listener import org.bukkit.permissions.Permission import org.xodium.vanillaplus.data.CommandData @@ -10,6 +11,7 @@ internal interface ModuleInterface : Listener { * Represents the configuration settings for a module. * @property enabled Indicates whether the module is enabled or not. */ + @Serializable interface Config { var enabled: Boolean } diff --git a/src/main/kotlin/org/xodium/vanillaplus/managers/ConfigManager.kt b/src/main/kotlin/org/xodium/vanillaplus/managers/ConfigManager.kt index 6025a2d84..9124bbd13 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/managers/ConfigManager.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/managers/ConfigManager.kt @@ -1,14 +1,21 @@ package org.xodium.vanillaplus.managers +import kotlinx.serialization.KSerializer +import kotlinx.serialization.builtins.serializer +import kotlinx.serialization.json.jsonObject +import kotlinx.serialization.serializer import org.xodium.vanillaplus.VanillaPlus.Companion.instance import org.xodium.vanillaplus.interfaces.DataInterface import org.xodium.vanillaplus.interfaces.ModuleInterface import org.xodium.vanillaplus.utils.ExtUtils.key -import kotlin.reflect.KClass +import kotlin.io.path.readText /** Manages module configs on disk and in-memory. */ internal object ConfigManager : DataInterface { - override val dataClass: KClass = ModuleInterface.Config::class + override val serializer: KSerializer + get() = throw UnsupportedOperationException("ConfigManager uses polymorphic serialization") + override val keySerializer: KSerializer = String.serializer() + override val dataClassName: String = "Config" override val cache: MutableMap = mutableMapOf() override val fileName: String = "config.json" @@ -21,7 +28,7 @@ internal object ConfigManager : DataInterface { modules.forEach { module -> val key = module.key() val fileConfig = readFileConfig(key, module) - val mergedConfig = fileConfig?.let { jsonMapper.updateValue(module.config, it) } ?: module.config + val mergedConfig = fileConfig ?: module.config set(key, mergedConfig) } if (modules.isNotEmpty()) instance.logger.info("Config updated successfully") @@ -40,8 +47,14 @@ internal object ConfigManager : DataInterface { ): ModuleInterface.Config? = try { if (filePath.toFile().exists()) { - jsonMapper.readTree(filePath.toFile())?.get(key)?.let { node -> - jsonMapper.treeToValue(node, module.config::class.java) + val jsonContent = filePath.readText() + val jsonElement = json.parseToJsonElement(jsonContent) + jsonElement.jsonObject[key]?.let { node -> + @Suppress("UNCHECKED_CAST") + json.decodeFromJsonElement( + serializer(module.config::class.java) as KSerializer, + node, + ) } } else { null diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/ArmorStandModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/ArmorStandModule.kt index 5e2a8488d..8a7829073 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/ArmorStandModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/ArmorStandModule.kt @@ -3,6 +3,7 @@ package org.xodium.vanillaplus.modules import com.google.common.io.ByteStreams +import kotlinx.serialization.Serializable import org.bukkit.entity.ArmorStand import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerInteractAtEntityEvent @@ -47,6 +48,7 @@ internal class ArmorStandModule : ModuleInterface { } } + @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/BooksModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/BooksModule.kt index 72c0556f6..af71c4cac 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/BooksModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/BooksModule.kt @@ -1,6 +1,7 @@ package org.xodium.vanillaplus.modules import io.papermc.paper.command.brigadier.Commands +import kotlinx.serialization.Serializable import org.bukkit.entity.Player import org.bukkit.permissions.Permission import org.bukkit.permissions.PermissionDefault @@ -43,6 +44,7 @@ internal class BooksModule : ModuleInterface { ) } + @Serializable data class Config( override var enabled: Boolean = true, var books: List = diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/CauldronModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/CauldronModule.kt index 90c839e70..c469809df 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/CauldronModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/CauldronModule.kt @@ -1,5 +1,6 @@ package org.xodium.vanillaplus.modules +import kotlinx.serialization.Serializable import org.bukkit.Material import org.bukkit.Tag import org.bukkit.block.Block @@ -105,6 +106,7 @@ internal class CauldronModule : ModuleInterface { } } + @Serializable data class Config( override var enabled: Boolean = true, var convertConcretePowder: Boolean = true, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/ChatModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/ChatModule.kt index 67e6ba915..30b8f3873 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/ChatModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/ChatModule.kt @@ -5,6 +5,7 @@ import com.mojang.brigadier.arguments.StringArgumentType import io.papermc.paper.chat.ChatRenderer import io.papermc.paper.command.brigadier.Commands import io.papermc.paper.event.player.AsyncChatEvent +import kotlinx.serialization.Serializable import net.kyori.adventure.text.Component import net.kyori.adventure.text.event.ClickEvent import net.kyori.adventure.text.event.HoverEvent @@ -212,6 +213,7 @@ internal class ChatModule : ModuleInterface { .hoverEvent(config.i18n.deleteMessage.mm()) .clickEvent(ClickEvent.callback { instance.server.deleteMessage(event.signedMessage()) }) + @Serializable data class Config( override var enabled: Boolean = true, var chatFormat: String = " ${"›".mangoFmt(true)} ", @@ -239,6 +241,7 @@ internal class ChatModule : ModuleInterface { var deleteCross: String = "[X]", var i18n: I18n = I18n(), ) : ModuleInterface.Config { + @Serializable data class I18n( var clickMe: String = "Click Me!".fireFmt(), var clickToWhisper: String = "Click to Whisper".fireFmt(), diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/DimensionsModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/DimensionsModule.kt index 5e84e128c..75c63b1bc 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/DimensionsModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/DimensionsModule.kt @@ -1,5 +1,6 @@ package org.xodium.vanillaplus.modules +import kotlinx.serialization.Serializable import org.bukkit.Location import org.bukkit.Material import org.bukkit.World @@ -134,11 +135,13 @@ internal class DimensionsModule : ModuleInterface { */ private fun getOverworld(): World = instance.server.getWorld("world") ?: error("Overworld (world) is not loaded.") + @Serializable data class Config( override var enabled: Boolean = true, var portalSearchRadius: Int = 128, var i18n: I18n = I18n(), ) : ModuleInterface.Config { + @Serializable data class I18n( var portalCreationDenied: String = "No corresponding active portal found in the Overworld!".fireFmt(), ) diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt index 011e3f7a2..9a267bd3f 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt @@ -2,6 +2,7 @@ package org.xodium.vanillaplus.modules +import kotlinx.serialization.Serializable import net.kyori.adventure.sound.Sound import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder import org.bukkit.Material @@ -125,6 +126,7 @@ internal class EntityModule : ModuleInterface { ).toInt() .coerceAtLeast(1) + @Serializable data class Config( override var enabled: Boolean = true, var disableBlazeGrief: Boolean = true, @@ -148,6 +150,7 @@ internal class EntityModule : ModuleInterface { ), var i18n: I18n = I18n(), ) : ModuleInterface.Config { + @Serializable data class I18n( var horseTradeSuccessfulMessage: String = "You traded your horse for: ", ) diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/InvModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/InvModule.kt index feb1f88a6..f42fb892b 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/InvModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/InvModule.kt @@ -7,6 +7,7 @@ import com.mojang.brigadier.arguments.StringArgumentType import com.mojang.brigadier.context.CommandContext import io.papermc.paper.command.brigadier.CommandSourceStack import io.papermc.paper.command.brigadier.Commands +import kotlinx.serialization.Serializable import net.kyori.adventure.sound.Sound import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder import org.bukkit.* @@ -515,6 +516,7 @@ internal class InvModule : ModuleInterface { return loc.add(0.5, 0.5, 0.5) } + @Serializable data class Config( override var enabled: Boolean = true, var searchRadius: Int = 25, @@ -529,6 +531,7 @@ internal class InvModule : ModuleInterface { var scheduleInitDelayInTicks: Long = 5, var i18n: I18n = I18n(), ) : ModuleInterface.Config { + @Serializable data class I18n( var noMaterialSpecified: String = "You must specify a valid material or hold something in your hand".fireFmt(), var noChestsFound: String = "No usable chests found for ${"".roseFmt()}".fireFmt(), diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/LocatorModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/LocatorModule.kt index 2ec849789..db1b6c3fd 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/LocatorModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/LocatorModule.kt @@ -4,6 +4,7 @@ package org.xodium.vanillaplus.modules import io.papermc.paper.command.brigadier.Commands import io.papermc.paper.command.brigadier.argument.ArgumentTypes +import kotlinx.serialization.Serializable import net.kyori.adventure.text.format.NamedTextColor import net.kyori.adventure.text.format.TextColor import org.bukkit.entity.Player @@ -105,6 +106,7 @@ internal class LocatorModule : ModuleInterface { } } + @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/MotdModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/MotdModule.kt index 328a8c5d0..4ca415b25 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/MotdModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/MotdModule.kt @@ -1,5 +1,6 @@ package org.xodium.vanillaplus.modules +import kotlinx.serialization.Serializable import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.server.ServerListPingEvent @@ -18,6 +19,7 @@ internal class MotdModule : ModuleInterface { event.motd(config.motd.joinToString("\n").mm()) } + @Serializable data class Config( override var enabled: Boolean = true, val motd: List = diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/OpenableModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/OpenableModule.kt index fccbc8ea6..c7b9d314b 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/OpenableModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/OpenableModule.kt @@ -2,6 +2,7 @@ package org.xodium.vanillaplus.modules +import kotlinx.serialization.Serializable import net.kyori.adventure.sound.Sound import org.bukkit.GameMode import org.bukkit.Material @@ -222,6 +223,7 @@ internal class OpenableModule : ModuleInterface { ?.getRelativeBlock(block) } + @Serializable data class Config( override var enabled: Boolean = true, var initDelayInTicks: Long = 1, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/PetModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/PetModule.kt index ac3cc3341..3630031a0 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/PetModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/PetModule.kt @@ -1,5 +1,6 @@ package org.xodium.vanillaplus.modules +import kotlinx.serialization.Serializable import net.kyori.adventure.text.Component import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder import org.bukkit.Material @@ -115,11 +116,13 @@ internal class PetModule : ModuleInterface { ) } + @Serializable data class Config( override var enabled: Boolean = true, var transferRadius: Int = 10, var i18n: I18n = I18n(), ) : ModuleInterface.Config { + @Serializable data class I18n( var sourceTransfer: String = "${"You have transferred".fireFmt()} ${"to".fireFmt()} ", var targetTransfer: String = " ${"has transferred".fireFmt()} ${"to you".fireFmt()}", diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt index 0b38b8468..460e7b904 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt @@ -5,6 +5,7 @@ import io.papermc.paper.command.brigadier.Commands import io.papermc.paper.datacomponent.DataComponentTypes import io.papermc.paper.datacomponent.item.ItemLore import io.papermc.paper.datacomponent.item.ResolvableProfile +import kotlinx.serialization.Serializable import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder import org.bukkit.Material import org.bukkit.entity.Player @@ -216,6 +217,7 @@ internal class PlayerModule( ) } + @Serializable data class Config( override var enabled: Boolean = true, var enderChestClickType: ClickType = ClickType.SHIFT_RIGHT, @@ -223,6 +225,7 @@ internal class PlayerModule( var xpCostToBottle: Int = 11, var i18n: I18n = I18n(), ) : ModuleInterface.Config { + @Serializable data class I18n( var playerHeadName: String = "’s Skull", var playerHeadLore: List = listOf(" killed by "), diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/RecipiesModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/RecipiesModule.kt index 591d30634..2d847db9d 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/RecipiesModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/RecipiesModule.kt @@ -1,5 +1,6 @@ package org.xodium.vanillaplus.modules +import kotlinx.serialization.Serializable import org.bukkit.Keyed import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -25,6 +26,7 @@ internal class RecipiesModule : ModuleInterface { ) } + @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/ScoreBoardModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/ScoreBoardModule.kt index 35906a214..ada8d12ac 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/ScoreBoardModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/ScoreBoardModule.kt @@ -1,6 +1,7 @@ package org.xodium.vanillaplus.modules import io.papermc.paper.command.brigadier.Commands +import kotlinx.serialization.Serializable import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerJoinEvent @@ -67,6 +68,7 @@ internal class ScoreBoardModule : ModuleInterface { } } + @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/SignModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/SignModule.kt index 9643615bf..5c0bcafad 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/SignModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/SignModule.kt @@ -3,6 +3,7 @@ package org.xodium.vanillaplus.modules import com.mojang.brigadier.arguments.IntegerArgumentType import com.mojang.brigadier.arguments.StringArgumentType import io.papermc.paper.command.brigadier.Commands +import kotlinx.serialization.Serializable import org.bukkit.block.Sign import org.bukkit.entity.Player import org.bukkit.permissions.Permission @@ -75,6 +76,7 @@ internal class SignModule : ModuleInterface { sign.update() } + @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/SilkTouchModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/SilkTouchModule.kt index 90116b48b..79b0da1c1 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/SilkTouchModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/SilkTouchModule.kt @@ -2,6 +2,7 @@ package org.xodium.vanillaplus.modules import io.papermc.paper.datacomponent.DataComponentTypes import io.papermc.paper.datacomponent.item.ItemLore +import kotlinx.serialization.Serializable import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder import org.bukkit.GameMode import org.bukkit.Material @@ -113,6 +114,7 @@ internal class SilkTouchModule : ModuleInterface { private fun isValidTool(item: ItemStack?): Boolean = item?.let { Tag.ITEMS_PICKAXES.isTagged(it.type) && it.containsEnchantment(Enchantment.SILK_TOUCH) } == true + @Serializable data class Config( override var enabled: Boolean = true, var allowSpawnerSilk: Boolean = true, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/SitModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/SitModule.kt index f06b773cf..40dac63bc 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/SitModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/SitModule.kt @@ -2,6 +2,7 @@ package org.xodium.vanillaplus.modules +import kotlinx.serialization.Serializable import org.bukkit.Location import org.bukkit.Material import org.bukkit.block.BlockFace @@ -98,6 +99,7 @@ internal class SitModule : ModuleInterface { sittingPlayers[player.uniqueId] = armorStand } + @Serializable data class Config( override var enabled: Boolean = true, var useStairs: Boolean = true, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/TabListModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/TabListModule.kt index fb58e26a2..42c0357d7 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/TabListModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/TabListModule.kt @@ -2,6 +2,7 @@ package org.xodium.vanillaplus.modules +import kotlinx.serialization.Serializable import net.kyori.adventure.audience.Audience import net.kyori.adventure.text.Component import net.kyori.adventure.text.JoinConfiguration @@ -129,6 +130,7 @@ internal class TabListModule : ModuleInterface { } } + @Serializable data class Config( override var enabled: Boolean = true, var initDelayInTicks: Long = 0, @@ -151,6 +153,7 @@ internal class TabListModule : ModuleInterface { ), var i18n: I18n = I18n(), ) : ModuleInterface.Config { + @Serializable data class I18n( var weatherThundering: String = "\uD83C\uDF29", var weatherStorm: String = "\uD83C\uDF26", diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/TreesModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/TreesModule.kt index b71db1c48..73e395fb1 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/TreesModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/TreesModule.kt @@ -9,6 +9,7 @@ import com.sk89q.worldedit.function.operation.Operations import com.sk89q.worldedit.math.BlockVector3 import com.sk89q.worldedit.math.transform.AffineTransform import com.sk89q.worldedit.session.ClipboardHolder +import kotlinx.serialization.Serializable import org.bukkit.Material import org.bukkit.Tag import org.bukkit.block.Block @@ -163,6 +164,7 @@ internal class TreesModule : ModuleInterface { return angle.random() } + @Serializable data class Config( override var enabled: Boolean = true, var copyBiomes: Boolean = false, From fc034c8516fbcd0ac853c1a940e0e5a2087d47f6 Mon Sep 17 00:00:00 2001 From: Illyrius Date: Fri, 31 Oct 2025 11:26:45 +0100 Subject: [PATCH 3/4] + Signed-off-by: Illyrius --- .../kotlin/org/xodium/vanillaplus/interfaces/DataInterface.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/org/xodium/vanillaplus/interfaces/DataInterface.kt b/src/main/kotlin/org/xodium/vanillaplus/interfaces/DataInterface.kt index 96411fd73..3e55c9df9 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/interfaces/DataInterface.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/interfaces/DataInterface.kt @@ -29,6 +29,7 @@ interface DataInterface { prettyPrint = true ignoreUnknownKeys = true encodeDefaults = true + classDiscriminator = "type" } /** Initializes the cache and loads existing data from the file. */ From 36a56ca14b23a24672d906471bbbf44e40f6e06f Mon Sep 17 00:00:00 2001 From: Illyrius Date: Fri, 31 Oct 2025 11:36:04 +0100 Subject: [PATCH 4/4] cleanup Signed-off-by: Illyrius --- .../kotlin/org/xodium/vanillaplus/interfaces/ModuleInterface.kt | 2 ++ .../kotlin/org/xodium/vanillaplus/modules/ArmorStandModule.kt | 2 -- src/main/kotlin/org/xodium/vanillaplus/modules/BooksModule.kt | 2 -- .../kotlin/org/xodium/vanillaplus/modules/CauldronModule.kt | 2 -- src/main/kotlin/org/xodium/vanillaplus/modules/ChatModule.kt | 1 - .../kotlin/org/xodium/vanillaplus/modules/DimensionsModule.kt | 1 - src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt | 1 - src/main/kotlin/org/xodium/vanillaplus/modules/InvModule.kt | 1 - src/main/kotlin/org/xodium/vanillaplus/modules/LocatorModule.kt | 2 -- src/main/kotlin/org/xodium/vanillaplus/modules/MotdModule.kt | 2 -- .../kotlin/org/xodium/vanillaplus/modules/OpenableModule.kt | 2 -- src/main/kotlin/org/xodium/vanillaplus/modules/PetModule.kt | 1 - src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt | 1 - .../kotlin/org/xodium/vanillaplus/modules/RecipiesModule.kt | 2 -- .../kotlin/org/xodium/vanillaplus/modules/ScoreBoardModule.kt | 2 -- src/main/kotlin/org/xodium/vanillaplus/modules/SignModule.kt | 2 -- .../kotlin/org/xodium/vanillaplus/modules/SilkTouchModule.kt | 2 -- src/main/kotlin/org/xodium/vanillaplus/modules/SitModule.kt | 2 -- src/main/kotlin/org/xodium/vanillaplus/modules/TabListModule.kt | 1 - src/main/kotlin/org/xodium/vanillaplus/modules/TreesModule.kt | 2 -- 20 files changed, 2 insertions(+), 31 deletions(-) diff --git a/src/main/kotlin/org/xodium/vanillaplus/interfaces/ModuleInterface.kt b/src/main/kotlin/org/xodium/vanillaplus/interfaces/ModuleInterface.kt index ba4e21bb4..00425ed2c 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/interfaces/ModuleInterface.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/interfaces/ModuleInterface.kt @@ -1,5 +1,6 @@ package org.xodium.vanillaplus.interfaces +import kotlinx.serialization.Polymorphic import kotlinx.serialization.Serializable import org.bukkit.event.Listener import org.bukkit.permissions.Permission @@ -11,6 +12,7 @@ internal interface ModuleInterface : Listener { * Represents the configuration settings for a module. * @property enabled Indicates whether the module is enabled or not. */ + @Polymorphic @Serializable interface Config { var enabled: Boolean diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/ArmorStandModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/ArmorStandModule.kt index 8a7829073..5e2a8488d 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/ArmorStandModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/ArmorStandModule.kt @@ -3,7 +3,6 @@ package org.xodium.vanillaplus.modules import com.google.common.io.ByteStreams -import kotlinx.serialization.Serializable import org.bukkit.entity.ArmorStand import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerInteractAtEntityEvent @@ -48,7 +47,6 @@ internal class ArmorStandModule : ModuleInterface { } } - @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/BooksModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/BooksModule.kt index af71c4cac..72c0556f6 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/BooksModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/BooksModule.kt @@ -1,7 +1,6 @@ package org.xodium.vanillaplus.modules import io.papermc.paper.command.brigadier.Commands -import kotlinx.serialization.Serializable import org.bukkit.entity.Player import org.bukkit.permissions.Permission import org.bukkit.permissions.PermissionDefault @@ -44,7 +43,6 @@ internal class BooksModule : ModuleInterface { ) } - @Serializable data class Config( override var enabled: Boolean = true, var books: List = diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/CauldronModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/CauldronModule.kt index c469809df..90c839e70 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/CauldronModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/CauldronModule.kt @@ -1,6 +1,5 @@ package org.xodium.vanillaplus.modules -import kotlinx.serialization.Serializable import org.bukkit.Material import org.bukkit.Tag import org.bukkit.block.Block @@ -106,7 +105,6 @@ internal class CauldronModule : ModuleInterface { } } - @Serializable data class Config( override var enabled: Boolean = true, var convertConcretePowder: Boolean = true, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/ChatModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/ChatModule.kt index 30b8f3873..2ea2fb23b 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/ChatModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/ChatModule.kt @@ -213,7 +213,6 @@ internal class ChatModule : ModuleInterface { .hoverEvent(config.i18n.deleteMessage.mm()) .clickEvent(ClickEvent.callback { instance.server.deleteMessage(event.signedMessage()) }) - @Serializable data class Config( override var enabled: Boolean = true, var chatFormat: String = " ${"›".mangoFmt(true)} ", diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/DimensionsModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/DimensionsModule.kt index 75c63b1bc..29920df35 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/DimensionsModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/DimensionsModule.kt @@ -135,7 +135,6 @@ internal class DimensionsModule : ModuleInterface { */ private fun getOverworld(): World = instance.server.getWorld("world") ?: error("Overworld (world) is not loaded.") - @Serializable data class Config( override var enabled: Boolean = true, var portalSearchRadius: Int = 128, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt index 9a267bd3f..2fae8db88 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/EntityModule.kt @@ -126,7 +126,6 @@ internal class EntityModule : ModuleInterface { ).toInt() .coerceAtLeast(1) - @Serializable data class Config( override var enabled: Boolean = true, var disableBlazeGrief: Boolean = true, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/InvModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/InvModule.kt index f42fb892b..b55638a92 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/InvModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/InvModule.kt @@ -516,7 +516,6 @@ internal class InvModule : ModuleInterface { return loc.add(0.5, 0.5, 0.5) } - @Serializable data class Config( override var enabled: Boolean = true, var searchRadius: Int = 25, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/LocatorModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/LocatorModule.kt index db1b6c3fd..2ec849789 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/LocatorModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/LocatorModule.kt @@ -4,7 +4,6 @@ package org.xodium.vanillaplus.modules import io.papermc.paper.command.brigadier.Commands import io.papermc.paper.command.brigadier.argument.ArgumentTypes -import kotlinx.serialization.Serializable import net.kyori.adventure.text.format.NamedTextColor import net.kyori.adventure.text.format.TextColor import org.bukkit.entity.Player @@ -106,7 +105,6 @@ internal class LocatorModule : ModuleInterface { } } - @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/MotdModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/MotdModule.kt index 4ca415b25..328a8c5d0 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/MotdModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/MotdModule.kt @@ -1,6 +1,5 @@ package org.xodium.vanillaplus.modules -import kotlinx.serialization.Serializable import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority import org.bukkit.event.server.ServerListPingEvent @@ -19,7 +18,6 @@ internal class MotdModule : ModuleInterface { event.motd(config.motd.joinToString("\n").mm()) } - @Serializable data class Config( override var enabled: Boolean = true, val motd: List = diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/OpenableModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/OpenableModule.kt index c7b9d314b..fccbc8ea6 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/OpenableModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/OpenableModule.kt @@ -2,7 +2,6 @@ package org.xodium.vanillaplus.modules -import kotlinx.serialization.Serializable import net.kyori.adventure.sound.Sound import org.bukkit.GameMode import org.bukkit.Material @@ -223,7 +222,6 @@ internal class OpenableModule : ModuleInterface { ?.getRelativeBlock(block) } - @Serializable data class Config( override var enabled: Boolean = true, var initDelayInTicks: Long = 1, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/PetModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/PetModule.kt index 3630031a0..4a77aca1b 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/PetModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/PetModule.kt @@ -116,7 +116,6 @@ internal class PetModule : ModuleInterface { ) } - @Serializable data class Config( override var enabled: Boolean = true, var transferRadius: Int = 10, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt index 460e7b904..5495d122d 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/PlayerModule.kt @@ -217,7 +217,6 @@ internal class PlayerModule( ) } - @Serializable data class Config( override var enabled: Boolean = true, var enderChestClickType: ClickType = ClickType.SHIFT_RIGHT, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/RecipiesModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/RecipiesModule.kt index 2d847db9d..591d30634 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/RecipiesModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/RecipiesModule.kt @@ -1,6 +1,5 @@ package org.xodium.vanillaplus.modules -import kotlinx.serialization.Serializable import org.bukkit.Keyed import org.bukkit.event.EventHandler import org.bukkit.event.EventPriority @@ -26,7 +25,6 @@ internal class RecipiesModule : ModuleInterface { ) } - @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/ScoreBoardModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/ScoreBoardModule.kt index ada8d12ac..35906a214 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/ScoreBoardModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/ScoreBoardModule.kt @@ -1,7 +1,6 @@ package org.xodium.vanillaplus.modules import io.papermc.paper.command.brigadier.Commands -import kotlinx.serialization.Serializable import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.player.PlayerJoinEvent @@ -68,7 +67,6 @@ internal class ScoreBoardModule : ModuleInterface { } } - @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/SignModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/SignModule.kt index 5c0bcafad..9643615bf 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/SignModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/SignModule.kt @@ -3,7 +3,6 @@ package org.xodium.vanillaplus.modules import com.mojang.brigadier.arguments.IntegerArgumentType import com.mojang.brigadier.arguments.StringArgumentType import io.papermc.paper.command.brigadier.Commands -import kotlinx.serialization.Serializable import org.bukkit.block.Sign import org.bukkit.entity.Player import org.bukkit.permissions.Permission @@ -76,7 +75,6 @@ internal class SignModule : ModuleInterface { sign.update() } - @Serializable data class Config( override var enabled: Boolean = true, ) : ModuleInterface.Config diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/SilkTouchModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/SilkTouchModule.kt index 79b0da1c1..90116b48b 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/SilkTouchModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/SilkTouchModule.kt @@ -2,7 +2,6 @@ package org.xodium.vanillaplus.modules import io.papermc.paper.datacomponent.DataComponentTypes import io.papermc.paper.datacomponent.item.ItemLore -import kotlinx.serialization.Serializable import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder import org.bukkit.GameMode import org.bukkit.Material @@ -114,7 +113,6 @@ internal class SilkTouchModule : ModuleInterface { private fun isValidTool(item: ItemStack?): Boolean = item?.let { Tag.ITEMS_PICKAXES.isTagged(it.type) && it.containsEnchantment(Enchantment.SILK_TOUCH) } == true - @Serializable data class Config( override var enabled: Boolean = true, var allowSpawnerSilk: Boolean = true, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/SitModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/SitModule.kt index 40dac63bc..f06b773cf 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/SitModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/SitModule.kt @@ -2,7 +2,6 @@ package org.xodium.vanillaplus.modules -import kotlinx.serialization.Serializable import org.bukkit.Location import org.bukkit.Material import org.bukkit.block.BlockFace @@ -99,7 +98,6 @@ internal class SitModule : ModuleInterface { sittingPlayers[player.uniqueId] = armorStand } - @Serializable data class Config( override var enabled: Boolean = true, var useStairs: Boolean = true, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/TabListModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/TabListModule.kt index 42c0357d7..db8417104 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/TabListModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/TabListModule.kt @@ -130,7 +130,6 @@ internal class TabListModule : ModuleInterface { } } - @Serializable data class Config( override var enabled: Boolean = true, var initDelayInTicks: Long = 0, diff --git a/src/main/kotlin/org/xodium/vanillaplus/modules/TreesModule.kt b/src/main/kotlin/org/xodium/vanillaplus/modules/TreesModule.kt index 73e395fb1..b71db1c48 100644 --- a/src/main/kotlin/org/xodium/vanillaplus/modules/TreesModule.kt +++ b/src/main/kotlin/org/xodium/vanillaplus/modules/TreesModule.kt @@ -9,7 +9,6 @@ import com.sk89q.worldedit.function.operation.Operations import com.sk89q.worldedit.math.BlockVector3 import com.sk89q.worldedit.math.transform.AffineTransform import com.sk89q.worldedit.session.ClipboardHolder -import kotlinx.serialization.Serializable import org.bukkit.Material import org.bukkit.Tag import org.bukkit.block.Block @@ -164,7 +163,6 @@ internal class TreesModule : ModuleInterface { return angle.random() } - @Serializable data class Config( override var enabled: Boolean = true, var copyBiomes: Boolean = false,