From 1880810c923cfb2b5b4896862ba5dab275930d14 Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Thu, 9 Oct 2025 17:06:03 +0200 Subject: [PATCH 01/39] refactor: rename to surf-settings --- .gitignore | 167 +++++------------- README.md | 3 +- build.gradle.kts | 4 +- gradle.properties | 2 +- gradle/libs.versions.toml | 2 - gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 18 +- .../build.gradle.kts | 11 -- .../slne/surf/template/api/client/.gitkeep | 0 .../build.gradle.kts | 11 -- .../surf/template/api/client/paper/.gitkeep | 0 .../build.gradle.kts | 11 -- .../template/api/client/velocity/.gitkeep | 0 .../surf/template/api/common/player/.gitkeep | 0 .../build.gradle.kts | 11 -- .../build.gradle.kts | 12 -- .../slne/surf/template/core/client/.gitkeep | 0 .../template/core/netty/protocol/.gitkeep | 0 .../build.gradle.kts | 14 -- .../build.gradle.kts | 12 -- .../src/main/resources/db/migration/.gitkeep | 0 .../src/main/resources/standalone-plugin.yml | 10 -- .../build.gradle.kts | 12 -- .../build.gradle.kts | 0 .../api/common/InternalContextHolder.kt | 4 +- .../settings}/api/common/util/InternalApi.kt | 2 +- .../build.gradle.kts | 2 +- .../surf/settings/SurfSettingsApplication.kt | 4 +- .../surf/settings}/core/ContextHolderImpl.kt | 6 +- surf-settings-paper/build.gradle.kts | 14 ++ .../surf/settings}/paper/PaperBootstrap.kt | 8 +- .../slne/surf/settings}/paper/PaperMain.kt | 2 +- surf-settings-server/build.gradle.kts | 12 ++ .../surf/settings}/server/PluginBootstrap.kt | 8 +- .../slne/surf/settings}/server/PluginMain.kt | 2 +- .../src/main/resources/standalone-plugin.yml | 7 + surf-settings-velocity/build.gradle.kts | 12 ++ .../surf/settings}/velocity/VelocityMain.kt | 8 +- 38 files changed, 120 insertions(+), 273 deletions(-) delete mode 100644 surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-common-api/build.gradle.kts delete mode 100644 surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-common-api/src/main/kotlin/dev/slne/surf/template/api/client/.gitkeep delete mode 100644 surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-paper-api/build.gradle.kts delete mode 100644 surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-paper-api/src/main/kotlin/dev/slne/surf/template/api/client/paper/.gitkeep delete mode 100644 surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-velocity-api/build.gradle.kts delete mode 100644 surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-velocity-api/src/main/kotlin/dev/slne/surf/template/api/client/velocity/.gitkeep delete mode 100644 surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template/api/common/player/.gitkeep delete mode 100644 surf-cloud-plugin-template-api/surf-cloud-plugin-template-server-api/build.gradle.kts delete mode 100644 surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-client/build.gradle.kts delete mode 100644 surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-client/src/main/kotlin/dev/slne/surf/template/core/client/.gitkeep delete mode 100644 surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/core/netty/protocol/.gitkeep delete mode 100644 surf-cloud-plugin-template-paper/build.gradle.kts delete mode 100644 surf-cloud-plugin-template-server/build.gradle.kts delete mode 100644 surf-cloud-plugin-template-server/src/main/resources/db/migration/.gitkeep delete mode 100644 surf-cloud-plugin-template-server/src/main/resources/standalone-plugin.yml delete mode 100644 surf-cloud-plugin-template-velocity/build.gradle.kts rename {surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api => surf-settings-api/surf-settings-api-common}/build.gradle.kts (100%) rename {surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template => surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings}/api/common/InternalContextHolder.kt (74%) rename {surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template => surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings}/api/common/util/InternalApi.kt (92%) rename {surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common => surf-settings-core/surf-settings-core-common}/build.gradle.kts (55%) rename surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/SurfCloudPluginTemplateApplication.kt => surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/SurfSettingsApplication.kt (53%) rename {surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template => surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings}/core/ContextHolderImpl.kt (70%) create mode 100644 surf-settings-paper/build.gradle.kts rename {surf-cloud-plugin-template-paper/src/main/kotlin/dev/slne/surf/template => surf-settings-paper/src/main/kotlin/dev/slne/surf/settings}/paper/PaperBootstrap.kt (62%) rename {surf-cloud-plugin-template-paper/src/main/kotlin/dev/slne/surf/template => surf-settings-paper/src/main/kotlin/dev/slne/surf/settings}/paper/PaperMain.kt (85%) create mode 100644 surf-settings-server/build.gradle.kts rename {surf-cloud-plugin-template-server/src/main/kotlin/dev/slne/surf/template => surf-settings-server/src/main/kotlin/dev/slne/surf/settings}/server/PluginBootstrap.kt (63%) rename {surf-cloud-plugin-template-server/src/main/kotlin/dev/slne/surf/template => surf-settings-server/src/main/kotlin/dev/slne/surf/settings}/server/PluginMain.kt (85%) create mode 100644 surf-settings-server/src/main/resources/standalone-plugin.yml create mode 100644 surf-settings-velocity/build.gradle.kts rename {surf-cloud-plugin-template-velocity/src/main/kotlin/dev/slne/surf/template => surf-settings-velocity/src/main/kotlin/dev/slne/surf/settings}/velocity/VelocityMain.kt (76%) diff --git a/.gitignore b/.gitignore index 9cbe271..b7c785d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,131 +1,46 @@ -### Intellij template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# AWS User-specific -.idea/**/aws.xml - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. - .idea/artifacts - .idea/compiler.xml - .idea/jarRepositories.xml - .idea/modules.xml - .idea/*.iml - .idea/modules - *.iml - *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format +.gradle +build/ +!gradle/wrapper/gradle-wrapper.jar +!**/src/main/**/build/ +!**/src/test/**/build/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +.idea/ *.iws - -# IntelliJ +*.iml +*.ipr out/ +!**/src/main/**/out/ +!**/src/test/**/out/ -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# SonarLint plugin -.idea/sonarlint/ - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser +### Kotlin ### +.kotlin -### Gradle template -.gradle -**/build/ -!src/**/build/ - -# Ignore Gradle GUI config -gradle-app.setting - -# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) -!gradle-wrapper.jar - -# Avoid ignore Gradle wrappper properties -!gradle-wrapper.properties - -# Cache of project -.gradletasknamecache - -# Eclipse Gradle plugin generated files -# Eclipse Core -.project -# JDT-specific (Eclipse Java Development Tools) +### Eclipse ### +.apt_generated .classpath - -### Kotlin template -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* -replay_pid* - - -# Ignore Gradle build output directory -build +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index d747b29..13bd9e8 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# surf-cloud-plugin-template -Template for surf-cloud applications +# surf-settings diff --git a/build.gradle.kts b/build.gradle.kts index 22a3acb..82d3302 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,11 +4,11 @@ buildscript { maven("https://repo.slne.dev/repository/maven-public/") { name = "maven-public" } } dependencies { - classpath("dev.slne.surf:surf-api-gradle-plugin:1.21.7+") + classpath("dev.slne.surf:surf-api-gradle-plugin:1.21.10+") } } allprojects { - group = "dev.slne.surf.template" + group = "dev.slne.surf.settings" version = findProperty("version") as String } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 804a362..add4d96 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ org.gradle.parallel=true org.gradle.caching=true kotlin.code.style=official kotlin.stdlib.default.dependency=false -version=1.21.7-1.0.0 \ No newline at end of file +version=1.21.10-1.0.0 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4ac3234..e69de29 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,2 +0,0 @@ -# This file was generated by the Gradle 'init' task. -# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index cea7a79..d4081da 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index 2c0bd8e..603c19b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,13 +1,7 @@ -rootProject.name = "surf-cloud-plugin-template" +rootProject.name = "surf-settings" -include("surf-cloud-plugin-template-api:surf-cloud-plugin-template-common-api") -include("surf-cloud-plugin-template-api:surf-cloud-plugin-template-client-api:surf-cloud-plugin-template-client-common-api") -include("surf-cloud-plugin-template-api:surf-cloud-plugin-template-client-api:surf-cloud-plugin-template-client-paper-api") -include("surf-cloud-plugin-template-api:surf-cloud-plugin-template-client-api:surf-cloud-plugin-template-client-velocity-api") -include("surf-cloud-plugin-template-api:surf-cloud-plugin-template-server-api") - -include("surf-cloud-plugin-template-core:surf-cloud-plugin-template-core-common") -include("surf-cloud-plugin-template-core:surf-cloud-plugin-template-core-client") -include("surf-cloud-plugin-template-paper") -include("surf-cloud-plugin-template-velocity") -include("surf-cloud-plugin-template-server") \ No newline at end of file +include("surf-settings-api:surf-settings-api-common") +include("surf-settings-core:surf-settings-core-common") +include("surf-settings-paper") +include("surf-settings-velocity") +include("surf-settings-server") \ No newline at end of file diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-common-api/build.gradle.kts b/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-common-api/build.gradle.kts deleted file mode 100644 index c5d6dab..0000000 --- a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-common-api/build.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - id("dev.slne.surf.surfapi.gradle.core") -} - -surfCoreApi { - withCloudClientCommon() -} - -dependencies { - api(project(":surf-cloud-plugin-template-api:surf-cloud-plugin-template-common-api")) -} \ No newline at end of file diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-common-api/src/main/kotlin/dev/slne/surf/template/api/client/.gitkeep b/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-common-api/src/main/kotlin/dev/slne/surf/template/api/client/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-paper-api/build.gradle.kts b/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-paper-api/build.gradle.kts deleted file mode 100644 index 72388b1..0000000 --- a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-paper-api/build.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - id("dev.slne.surf.surfapi.gradle.paper-raw") -} - -surfRawPaperApi { - withCloudClientPaper() -} - -dependencies { - api(project(":surf-cloud-plugin-template-api:surf-cloud-plugin-template-client-api:surf-cloud-plugin-template-client-common-api")) -} \ No newline at end of file diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-paper-api/src/main/kotlin/dev/slne/surf/template/api/client/paper/.gitkeep b/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-paper-api/src/main/kotlin/dev/slne/surf/template/api/client/paper/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-velocity-api/build.gradle.kts b/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-velocity-api/build.gradle.kts deleted file mode 100644 index 982fd35..0000000 --- a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-velocity-api/build.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - id("dev.slne.surf.surfapi.gradle.velocity") -} - -surfVelocityApi { - withCloudClientVelocity() -} - -dependencies { - api(project(":surf-cloud-plugin-template-api:surf-cloud-plugin-template-client-api:surf-cloud-plugin-template-client-common-api")) -} \ No newline at end of file diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-velocity-api/src/main/kotlin/dev/slne/surf/template/api/client/velocity/.gitkeep b/surf-cloud-plugin-template-api/surf-cloud-plugin-template-client-api/surf-cloud-plugin-template-client-velocity-api/src/main/kotlin/dev/slne/surf/template/api/client/velocity/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template/api/common/player/.gitkeep b/surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template/api/common/player/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-server-api/build.gradle.kts b/surf-cloud-plugin-template-api/surf-cloud-plugin-template-server-api/build.gradle.kts deleted file mode 100644 index 0c45c34..0000000 --- a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-server-api/build.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - id("dev.slne.surf.surfapi.gradle.core") -} - -surfCoreApi { - withCloudServer() -} - -dependencies { - api(project(":surf-cloud-plugin-template-api:surf-cloud-plugin-template-common-api")) -} \ No newline at end of file diff --git a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-client/build.gradle.kts b/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-client/build.gradle.kts deleted file mode 100644 index af70e24..0000000 --- a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-client/build.gradle.kts +++ /dev/null @@ -1,12 +0,0 @@ -plugins { - id("dev.slne.surf.surfapi.gradle.core") -} - -surfCoreApi { - withCloudClientCommon() -} - -dependencies { - api(project(":surf-cloud-plugin-template-api:surf-cloud-plugin-template-client-api:surf-cloud-plugin-template-client-common-api")) - api(project(":surf-cloud-plugin-template-core:surf-cloud-plugin-template-core-common")) -} \ No newline at end of file diff --git a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-client/src/main/kotlin/dev/slne/surf/template/core/client/.gitkeep b/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-client/src/main/kotlin/dev/slne/surf/template/core/client/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/core/netty/protocol/.gitkeep b/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/core/netty/protocol/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/surf-cloud-plugin-template-paper/build.gradle.kts b/surf-cloud-plugin-template-paper/build.gradle.kts deleted file mode 100644 index f4ff0bc..0000000 --- a/surf-cloud-plugin-template-paper/build.gradle.kts +++ /dev/null @@ -1,14 +0,0 @@ -plugins { - id("dev.slne.surf.surfapi.gradle.paper-plugin") -} - -surfPaperPluginApi { - withCloudClientPaper() - mainClass("dev.slne.surf.template.paper.PaperMain") - bootstrapper("dev.slne.surf.template.paper.PaperBootstrap") -} - -dependencies { - api(project(":surf-cloud-plugin-template-core:surf-cloud-plugin-template-core-client")) - api(project(":surf-cloud-plugin-template-api:surf-cloud-plugin-template-client-api:surf-cloud-plugin-template-client-paper-api")) -} \ No newline at end of file diff --git a/surf-cloud-plugin-template-server/build.gradle.kts b/surf-cloud-plugin-template-server/build.gradle.kts deleted file mode 100644 index 89257bb..0000000 --- a/surf-cloud-plugin-template-server/build.gradle.kts +++ /dev/null @@ -1,12 +0,0 @@ -plugins { - id("dev.slne.surf.surfapi.gradle.core") -} - -surfCoreApi { - withCloudServer() -} - -dependencies { - api(project(":surf-cloud-plugin-template-core:surf-cloud-plugin-template-core-common")) - api(project(":surf-cloud-plugin-template-api:surf-cloud-plugin-template-server-api")) -} \ No newline at end of file diff --git a/surf-cloud-plugin-template-server/src/main/resources/db/migration/.gitkeep b/surf-cloud-plugin-template-server/src/main/resources/db/migration/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/surf-cloud-plugin-template-server/src/main/resources/standalone-plugin.yml b/surf-cloud-plugin-template-server/src/main/resources/standalone-plugin.yml deleted file mode 100644 index 7a7248e..0000000 --- a/surf-cloud-plugin-template-server/src/main/resources/standalone-plugin.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: surf-cloud-plugin-template-server -main: 'dev.slne.surf.template.server.PluginMain' -bootstrapper: 'dev.slne.surf.template.server.PluginBootstrap' -#loader: 'dev.slne.surf.template.server.PluginLoader' -version: 1.21.7-1.0.0 -description: 'Template plugin' -#authors: -# - 'slne' -#contributors: -# - 'slne2' \ No newline at end of file diff --git a/surf-cloud-plugin-template-velocity/build.gradle.kts b/surf-cloud-plugin-template-velocity/build.gradle.kts deleted file mode 100644 index 5edaa0a..0000000 --- a/surf-cloud-plugin-template-velocity/build.gradle.kts +++ /dev/null @@ -1,12 +0,0 @@ -plugins { - id("dev.slne.surf.surfapi.gradle.velocity") -} - -surfVelocityApi { - withCloudClientVelocity() -} - -dependencies { - api(project(":surf-cloud-plugin-template-core:surf-cloud-plugin-template-core-client")) - api(project(":surf-cloud-plugin-template-api:surf-cloud-plugin-template-client-api:surf-cloud-plugin-template-client-velocity-api")) -} \ No newline at end of file diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/build.gradle.kts b/surf-settings-api/surf-settings-api-common/build.gradle.kts similarity index 100% rename from surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/build.gradle.kts rename to surf-settings-api/surf-settings-api-common/build.gradle.kts diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template/api/common/InternalContextHolder.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/InternalContextHolder.kt similarity index 74% rename from surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template/api/common/InternalContextHolder.kt rename to surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/InternalContextHolder.kt index 5e84c1e..c701f20 100644 --- a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template/api/common/InternalContextHolder.kt +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/InternalContextHolder.kt @@ -1,7 +1,7 @@ -package dev.slne.surf.template.api.common +package dev.slne.surf.settings.api.common import dev.slne.surf.surfapi.core.api.util.requiredService -import dev.slne.surf.template.api.common.util.InternalApi +import dev.slne.surf.settings.api.common.util.InternalApi import org.springframework.context.ApplicationContext @InternalApi diff --git a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template/api/common/util/InternalApi.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/InternalApi.kt similarity index 92% rename from surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template/api/common/util/InternalApi.kt rename to surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/InternalApi.kt index 9fb6f13..0ba8be2 100644 --- a/surf-cloud-plugin-template-api/surf-cloud-plugin-template-common-api/src/main/kotlin/dev/slne/surf/template/api/common/util/InternalApi.kt +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/InternalApi.kt @@ -1,4 +1,4 @@ -package dev.slne.surf.template.api.common.util +package dev.slne.surf.settings.api.common.util @RequiresOptIn( level = RequiresOptIn.Level.ERROR, diff --git a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/build.gradle.kts b/surf-settings-core/surf-settings-core-common/build.gradle.kts similarity index 55% rename from surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/build.gradle.kts rename to surf-settings-core/surf-settings-core-common/build.gradle.kts index 92be4ae..271be88 100644 --- a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/build.gradle.kts +++ b/surf-settings-core/surf-settings-core-common/build.gradle.kts @@ -7,5 +7,5 @@ surfCoreApi { } dependencies { - api(project(":surf-cloud-plugin-template-api:surf-cloud-plugin-template-common-api")) + api(project(":surf-settings-api:surf-settings-api-common")) } diff --git a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/SurfCloudPluginTemplateApplication.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/SurfSettingsApplication.kt similarity index 53% rename from surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/SurfCloudPluginTemplateApplication.kt rename to surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/SurfSettingsApplication.kt index 03d8480..b1811bc 100644 --- a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/SurfCloudPluginTemplateApplication.kt +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/SurfSettingsApplication.kt @@ -1,7 +1,7 @@ -package dev.slne.surf.template +package dev.slne.surf.settings import dev.slne.surf.cloud.api.common.SurfCloudApplication @SurfCloudApplication -class SurfCloudPluginTemplateApplication { +class SurfSettingsApplication { } \ No newline at end of file diff --git a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/core/ContextHolderImpl.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/ContextHolderImpl.kt similarity index 70% rename from surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/core/ContextHolderImpl.kt rename to surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/ContextHolderImpl.kt index 024c3da..8bd2c4f 100644 --- a/surf-cloud-plugin-template-core/surf-cloud-plugin-template-core-common/src/main/kotlin/dev/slne/surf/template/core/ContextHolderImpl.kt +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/ContextHolderImpl.kt @@ -1,8 +1,8 @@ -package dev.slne.surf.template.core +package dev.slne.surf.settings.core import com.google.auto.service.AutoService -import dev.slne.surf.template.api.common.InternalContextHolder -import dev.slne.surf.template.api.common.util.InternalApi +import dev.slne.surf.settings.api.common.InternalContextHolder +import dev.slne.surf.settings.api.common.util.InternalApi import org.springframework.context.ApplicationContext @OptIn(InternalApi::class) diff --git a/surf-settings-paper/build.gradle.kts b/surf-settings-paper/build.gradle.kts new file mode 100644 index 0000000..b609bb4 --- /dev/null +++ b/surf-settings-paper/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("dev.slne.surf.surfapi.gradle.paper-plugin") +} + +surfPaperPluginApi { + withCloudClientPaper() + mainClass("dev.slne.surf.settings.paper.PaperMain") + bootstrapper("dev.slne.surf.settings.paper.PaperBootstrap") +} + +dependencies { + api(project(":surf-settings-core:surf-settings-core-common")) + api(project(":surf-settings-api:surf-settings-api-common")) +} \ No newline at end of file diff --git a/surf-cloud-plugin-template-paper/src/main/kotlin/dev/slne/surf/template/paper/PaperBootstrap.kt b/surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperBootstrap.kt similarity index 62% rename from surf-cloud-plugin-template-paper/src/main/kotlin/dev/slne/surf/template/paper/PaperBootstrap.kt rename to surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperBootstrap.kt index 3049b7b..a63238b 100644 --- a/surf-cloud-plugin-template-paper/src/main/kotlin/dev/slne/surf/template/paper/PaperBootstrap.kt +++ b/surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperBootstrap.kt @@ -1,9 +1,9 @@ -package dev.slne.surf.template.paper +package dev.slne.surf.settings.paper import dev.slne.surf.cloud.api.common.CloudInstance import dev.slne.surf.cloud.api.common.startSpringApplication -import dev.slne.surf.template.SurfCloudPluginTemplateApplication -import dev.slne.surf.template.core.ContextHolderImpl +import dev.slne.surf.settings.SurfSettingsApplication +import dev.slne.surf.settings.core.ContextHolderImpl import io.papermc.paper.plugin.bootstrap.BootstrapContext import io.papermc.paper.plugin.bootstrap.PluginBootstrap @@ -11,6 +11,6 @@ import io.papermc.paper.plugin.bootstrap.PluginBootstrap class PaperBootstrap : PluginBootstrap { override fun bootstrap(context: BootstrapContext) { ContextHolderImpl.instance.context = - CloudInstance.startSpringApplication(SurfCloudPluginTemplateApplication::class) + CloudInstance.startSpringApplication(SurfSettingsApplication::class) } } \ No newline at end of file diff --git a/surf-cloud-plugin-template-paper/src/main/kotlin/dev/slne/surf/template/paper/PaperMain.kt b/surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperMain.kt similarity index 85% rename from surf-cloud-plugin-template-paper/src/main/kotlin/dev/slne/surf/template/paper/PaperMain.kt rename to surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperMain.kt index c04dea2..3b07b90 100644 --- a/surf-cloud-plugin-template-paper/src/main/kotlin/dev/slne/surf/template/paper/PaperMain.kt +++ b/surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperMain.kt @@ -1,4 +1,4 @@ -package dev.slne.surf.template.paper +package dev.slne.surf.settings.paper import com.github.shynixn.mccoroutine.folia.SuspendingJavaPlugin import org.bukkit.plugin.java.JavaPlugin diff --git a/surf-settings-server/build.gradle.kts b/surf-settings-server/build.gradle.kts new file mode 100644 index 0000000..a7eb659 --- /dev/null +++ b/surf-settings-server/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + id("dev.slne.surf.surfapi.gradle.core") +} + +surfCoreApi { + withCloudServer() +} + +dependencies { + api(project(":surf-settings-core:surf-settings-core-common")) + api(project(":surf-settings-api:surf-settings-api-common")) +} \ No newline at end of file diff --git a/surf-cloud-plugin-template-server/src/main/kotlin/dev/slne/surf/template/server/PluginBootstrap.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginBootstrap.kt similarity index 63% rename from surf-cloud-plugin-template-server/src/main/kotlin/dev/slne/surf/template/server/PluginBootstrap.kt rename to surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginBootstrap.kt index 0a8464f..a6d1d79 100644 --- a/surf-cloud-plugin-template-server/src/main/kotlin/dev/slne/surf/template/server/PluginBootstrap.kt +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginBootstrap.kt @@ -1,15 +1,15 @@ -package dev.slne.surf.template.server +package dev.slne.surf.settings.server import dev.slne.surf.cloud.api.common.CloudInstance import dev.slne.surf.cloud.api.common.startSpringApplication import dev.slne.surf.cloud.api.server.plugin.bootstrap.BootstrapContext import dev.slne.surf.cloud.api.server.plugin.bootstrap.StandalonePluginBootstrap -import dev.slne.surf.template.SurfCloudPluginTemplateApplication -import dev.slne.surf.template.core.ContextHolderImpl +import dev.slne.surf.settings.SurfSettingsApplication +import dev.slne.surf.settings.core.ContextHolderImpl class PluginBootstrap : StandalonePluginBootstrap { override suspend fun bootstrap(context: BootstrapContext) { ContextHolderImpl.instance.context = - CloudInstance.startSpringApplication(SurfCloudPluginTemplateApplication::class) + CloudInstance.startSpringApplication(SurfSettingsApplication::class) } } \ No newline at end of file diff --git a/surf-cloud-plugin-template-server/src/main/kotlin/dev/slne/surf/template/server/PluginMain.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginMain.kt similarity index 85% rename from surf-cloud-plugin-template-server/src/main/kotlin/dev/slne/surf/template/server/PluginMain.kt rename to surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginMain.kt index 8700720..eab84df 100644 --- a/surf-cloud-plugin-template-server/src/main/kotlin/dev/slne/surf/template/server/PluginMain.kt +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginMain.kt @@ -1,4 +1,4 @@ -package dev.slne.surf.template.server +package dev.slne.surf.settings.server import dev.slne.surf.cloud.api.server.plugin.StandalonePlugin diff --git a/surf-settings-server/src/main/resources/standalone-plugin.yml b/surf-settings-server/src/main/resources/standalone-plugin.yml new file mode 100644 index 0000000..a808b07 --- /dev/null +++ b/surf-settings-server/src/main/resources/standalone-plugin.yml @@ -0,0 +1,7 @@ +name: surf-settings-server +main: 'dev.slne.surf.settings.server.PluginMain' +bootstrapper: 'dev.slne.surf.settings.server.PluginBootstrap' +version: 1.21.10-1.0.0 +description: 'Settings Plugin' +authors: + - 'red' \ No newline at end of file diff --git a/surf-settings-velocity/build.gradle.kts b/surf-settings-velocity/build.gradle.kts new file mode 100644 index 0000000..17877b0 --- /dev/null +++ b/surf-settings-velocity/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + id("dev.slne.surf.surfapi.gradle.velocity") +} + +surfVelocityApi { + withCloudClientVelocity() +} + +dependencies { + api(project(":surf-settings-core:surf-settings-core-common")) + api(project(":surf-settings-api:surf-settings-api-common")) +} \ No newline at end of file diff --git a/surf-cloud-plugin-template-velocity/src/main/kotlin/dev/slne/surf/template/velocity/VelocityMain.kt b/surf-settings-velocity/src/main/kotlin/dev/slne/surf/settings/velocity/VelocityMain.kt similarity index 76% rename from surf-cloud-plugin-template-velocity/src/main/kotlin/dev/slne/surf/template/velocity/VelocityMain.kt rename to surf-settings-velocity/src/main/kotlin/dev/slne/surf/settings/velocity/VelocityMain.kt index 6f4b8cb..20e2303 100644 --- a/surf-cloud-plugin-template-velocity/src/main/kotlin/dev/slne/surf/template/velocity/VelocityMain.kt +++ b/surf-settings-velocity/src/main/kotlin/dev/slne/surf/settings/velocity/VelocityMain.kt @@ -1,4 +1,4 @@ -package dev.slne.surf.template.velocity +package dev.slne.surf.settings.velocity import com.google.inject.Inject import com.velocitypowered.api.event.EventManager @@ -7,8 +7,8 @@ import com.velocitypowered.api.plugin.annotation.DataDirectory import com.velocitypowered.api.proxy.ProxyServer import dev.slne.surf.cloud.api.common.CloudInstance import dev.slne.surf.cloud.api.common.startSpringApplication -import dev.slne.surf.template.SurfCloudPluginTemplateApplication -import dev.slne.surf.template.core.ContextHolderImpl +import dev.slne.surf.settings.SurfSettingsApplication +import dev.slne.surf.settings.core.ContextHolderImpl import java.nio.file.Path class VelocityMain @Inject constructor( @@ -21,7 +21,7 @@ class VelocityMain @Inject constructor( init { instance = this ContextHolderImpl.instance.context = - CloudInstance.startSpringApplication(SurfCloudPluginTemplateApplication::class) + CloudInstance.startSpringApplication(SurfSettingsApplication::class) } companion object { From f94164f875e87fe43cd2d43f64e0b4b3effcc66d Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Thu, 9 Oct 2025 20:11:02 +0200 Subject: [PATCH 02/39] refactor: rename ContextHolderImpl to SettingsContextHolderImpl and related classes --- ...older.kt => InternalSettingsContextHolder.kt} | 8 ++++---- .../{InternalApi.kt => InternalSettingsApi.kt} | 2 +- .../slne/surf/settings/core/ContextHolderImpl.kt | 16 ---------------- .../settings/core/SettingsContextHolderImpl.kt | 16 ++++++++++++++++ .../serverbound/ServerboundSettingQueryPacket.kt | 15 +++++++++++++++ .../slne/surf/settings/paper/PaperBootstrap.kt | 4 ++-- .../slne/surf/settings/server/PluginBootstrap.kt | 4 ++-- .../slne/surf/settings/velocity/VelocityMain.kt | 4 ++-- 8 files changed, 42 insertions(+), 27 deletions(-) rename surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/{InternalContextHolder.kt => InternalSettingsContextHolder.kt} (52%) rename surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/{InternalApi.kt => InternalSettingsApi.kt} (94%) delete mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/ContextHolderImpl.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/SettingsContextHolderImpl.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingQueryPacket.kt diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/InternalContextHolder.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/InternalSettingsContextHolder.kt similarity index 52% rename from surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/InternalContextHolder.kt rename to surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/InternalSettingsContextHolder.kt index c701f20..0377d3c 100644 --- a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/InternalContextHolder.kt +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/InternalSettingsContextHolder.kt @@ -1,14 +1,14 @@ package dev.slne.surf.settings.api.common import dev.slne.surf.surfapi.core.api.util.requiredService -import dev.slne.surf.settings.api.common.util.InternalApi +import dev.slne.surf.settings.api.common.util.InternalSettingsApi import org.springframework.context.ApplicationContext -@InternalApi -interface InternalContextHolder { +@InternalSettingsApi +interface InternalSettingsContextHolder { val context: ApplicationContext companion object { - val instance = requiredService() + val instance = requiredService() } } \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/InternalApi.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/InternalSettingsApi.kt similarity index 94% rename from surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/InternalApi.kt rename to surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/InternalSettingsApi.kt index 0ba8be2..87c4fec 100644 --- a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/InternalApi.kt +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/util/InternalSettingsApi.kt @@ -14,4 +14,4 @@ package dev.slne.surf.settings.api.common.util AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FIELD ) -annotation class InternalApi \ No newline at end of file +annotation class InternalSettingsApi \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/ContextHolderImpl.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/ContextHolderImpl.kt deleted file mode 100644 index 8bd2c4f..0000000 --- a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/ContextHolderImpl.kt +++ /dev/null @@ -1,16 +0,0 @@ -package dev.slne.surf.settings.core - -import com.google.auto.service.AutoService -import dev.slne.surf.settings.api.common.InternalContextHolder -import dev.slne.surf.settings.api.common.util.InternalApi -import org.springframework.context.ApplicationContext - -@OptIn(InternalApi::class) -@AutoService(InternalContextHolder::class) -class ContextHolderImpl : InternalContextHolder { - override lateinit var context: ApplicationContext - - companion object { - val instance = InternalContextHolder.instance as ContextHolderImpl - } -} \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/SettingsContextHolderImpl.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/SettingsContextHolderImpl.kt new file mode 100644 index 0000000..a70cf79 --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/SettingsContextHolderImpl.kt @@ -0,0 +1,16 @@ +package dev.slne.surf.settings.core + +import com.google.auto.service.AutoService +import dev.slne.surf.settings.api.common.InternalSettingsContextHolder +import dev.slne.surf.settings.api.common.util.InternalSettingsApi +import org.springframework.context.ApplicationContext + +@OptIn(InternalSettingsApi::class) +@AutoService(InternalSettingsContextHolder::class) +class SettingsContextHolderImpl : InternalSettingsContextHolder { + override lateinit var context: ApplicationContext + + companion object { + val instance = InternalSettingsContextHolder.instance as SettingsContextHolderImpl + } +} \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingQueryPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingQueryPacket.kt new file mode 100644 index 0000000..d6b782b --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingQueryPacket.kt @@ -0,0 +1,15 @@ +package dev.slne.surf.settings.core.netty.protocol.serverbound + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.RespondingNettyPacket +import dev.slne.surf.cloud.api.common.player.CloudPlayer +import dev.slne.surf.settings.core.netty.protocol.clientbound.ClientboundSettingQueryResultPacket +import kotlinx.serialization.Serializable + +@Serializable +@SurfNettyPacket("setting:serverbound:setting_query", PacketFlow.SERVERBOUND) +class ServerboundSettingQueryPacket( + val player: CloudPlayer, + val identifier: String +) : RespondingNettyPacket() \ No newline at end of file diff --git a/surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperBootstrap.kt b/surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperBootstrap.kt index a63238b..4b9d551 100644 --- a/surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperBootstrap.kt +++ b/surf-settings-paper/src/main/kotlin/dev/slne/surf/settings/paper/PaperBootstrap.kt @@ -3,14 +3,14 @@ package dev.slne.surf.settings.paper import dev.slne.surf.cloud.api.common.CloudInstance import dev.slne.surf.cloud.api.common.startSpringApplication import dev.slne.surf.settings.SurfSettingsApplication -import dev.slne.surf.settings.core.ContextHolderImpl +import dev.slne.surf.settings.core.SettingsContextHolderImpl import io.papermc.paper.plugin.bootstrap.BootstrapContext import io.papermc.paper.plugin.bootstrap.PluginBootstrap @Suppress("UnstableApiUsage") class PaperBootstrap : PluginBootstrap { override fun bootstrap(context: BootstrapContext) { - ContextHolderImpl.instance.context = + SettingsContextHolderImpl.instance.context = CloudInstance.startSpringApplication(SurfSettingsApplication::class) } } \ No newline at end of file diff --git a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginBootstrap.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginBootstrap.kt index a6d1d79..5915bbd 100644 --- a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginBootstrap.kt +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/PluginBootstrap.kt @@ -5,11 +5,11 @@ import dev.slne.surf.cloud.api.common.startSpringApplication import dev.slne.surf.cloud.api.server.plugin.bootstrap.BootstrapContext import dev.slne.surf.cloud.api.server.plugin.bootstrap.StandalonePluginBootstrap import dev.slne.surf.settings.SurfSettingsApplication -import dev.slne.surf.settings.core.ContextHolderImpl +import dev.slne.surf.settings.core.SettingsContextHolderImpl class PluginBootstrap : StandalonePluginBootstrap { override suspend fun bootstrap(context: BootstrapContext) { - ContextHolderImpl.instance.context = + SettingsContextHolderImpl.instance.context = CloudInstance.startSpringApplication(SurfSettingsApplication::class) } } \ No newline at end of file diff --git a/surf-settings-velocity/src/main/kotlin/dev/slne/surf/settings/velocity/VelocityMain.kt b/surf-settings-velocity/src/main/kotlin/dev/slne/surf/settings/velocity/VelocityMain.kt index 20e2303..f810b73 100644 --- a/surf-settings-velocity/src/main/kotlin/dev/slne/surf/settings/velocity/VelocityMain.kt +++ b/surf-settings-velocity/src/main/kotlin/dev/slne/surf/settings/velocity/VelocityMain.kt @@ -8,7 +8,7 @@ import com.velocitypowered.api.proxy.ProxyServer import dev.slne.surf.cloud.api.common.CloudInstance import dev.slne.surf.cloud.api.common.startSpringApplication import dev.slne.surf.settings.SurfSettingsApplication -import dev.slne.surf.settings.core.ContextHolderImpl +import dev.slne.surf.settings.core.SettingsContextHolderImpl import java.nio.file.Path class VelocityMain @Inject constructor( @@ -20,7 +20,7 @@ class VelocityMain @Inject constructor( init { instance = this - ContextHolderImpl.instance.context = + SettingsContextHolderImpl.instance.context = CloudInstance.startSpringApplication(SurfSettingsApplication::class) } From cbad078c3144cd66d8cc27e22a4cb4bd72abf4df Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Thu, 9 Oct 2025 20:11:07 +0200 Subject: [PATCH 03/39] feat: add clientbound and serverbound packets for setting query and modification results --- .../api/common/result/SettingModifyResult.kt | 15 +++++++++++++++ .../api/common/result/SettingQueryResult.kt | 14 ++++++++++++++ .../api/common/setting/ConfiguredSetting.kt | 11 +++++++++++ .../ClientboundSettingModifyResultPacket.kt | 13 +++++++++++++ .../ClientboundSettingQueryResultPacket.kt | 13 +++++++++++++ .../ServerboundSettingModifyPacket.kt | 16 ++++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingModifyResult.kt create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingQueryResult.kt create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/ConfiguredSetting.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingModifyResultPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingQueryResultPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingModifyPacket.kt diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingModifyResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingModifyResult.kt new file mode 100644 index 0000000..a51c323 --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingModifyResult.kt @@ -0,0 +1,15 @@ +package dev.slne.surf.settings.api.common.result + +import dev.slne.surf.settings.api.common.setting.ConfiguredSetting +import kotlinx.serialization.Serializable + +@Serializable +sealed class SettingModifyResult { + data class Success(val setting: ConfiguredSetting) : SettingModifyResult() + data class Failure(val failureReason: SettingModifyResultFailure) : SettingModifyResult() + + enum class SettingModifyResultFailure { + SETTING_NOT_FOUND, + ALREADY_UP_TO_DATE + } +} \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingQueryResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingQueryResult.kt new file mode 100644 index 0000000..e5a8d3a --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingQueryResult.kt @@ -0,0 +1,14 @@ +package dev.slne.surf.settings.api.common.result + +import dev.slne.surf.settings.api.common.setting.ConfiguredSetting +import kotlinx.serialization.Serializable + +@Serializable +sealed class SettingQueryResult { + data class Success(val setting: ConfiguredSetting) : SettingQueryResult() + data class Failure(val failureReason: SettingQueryFailureReason) : SettingQueryResult() + + enum class SettingQueryFailureReason { + SETTING_NOT_FOUND + } +} \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/ConfiguredSetting.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/ConfiguredSetting.kt new file mode 100644 index 0000000..9d15ab1 --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/ConfiguredSetting.kt @@ -0,0 +1,11 @@ +package dev.slne.surf.settings.api.common.setting + +import net.kyori.adventure.text.Component + +interface ConfiguredSetting { + val identifier: String + val displayName: Component + val description: String + val value: String + val updatedAt: Long +} \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingModifyResultPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingModifyResultPacket.kt new file mode 100644 index 0000000..4aa229a --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingModifyResultPacket.kt @@ -0,0 +1,13 @@ +package dev.slne.surf.settings.core.netty.protocol.clientbound + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.ResponseNettyPacket +import dev.slne.surf.settings.api.common.result.SettingModifyResult +import kotlinx.serialization.Serializable + +@Serializable +@SurfNettyPacket("setting:clientbound:setting_modify_result", PacketFlow.CLIENTBOUND) +data class ClientboundSettingModifyResultPacket( + val result: SettingModifyResult +) : ResponseNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingQueryResultPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingQueryResultPacket.kt new file mode 100644 index 0000000..30b2844 --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingQueryResultPacket.kt @@ -0,0 +1,13 @@ +package dev.slne.surf.settings.core.netty.protocol.clientbound + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.ResponseNettyPacket +import dev.slne.surf.settings.api.common.result.SettingQueryResult +import kotlinx.serialization.Serializable + +@Serializable +@SurfNettyPacket("setting:clientbound:setting_query_result", PacketFlow.CLIENTBOUND) +data class ClientboundSettingQueryResultPacket( + val result: SettingQueryResult +) : ResponseNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingModifyPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingModifyPacket.kt new file mode 100644 index 0000000..69c3010 --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingModifyPacket.kt @@ -0,0 +1,16 @@ +package dev.slne.surf.settings.core.netty.protocol.serverbound + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.RespondingNettyPacket +import dev.slne.surf.cloud.api.common.player.CloudPlayer +import dev.slne.surf.settings.api.common.setting.ConfiguredSetting +import dev.slne.surf.settings.core.netty.protocol.clientbound.ClientboundSettingModifyResultPacket +import kotlinx.serialization.Serializable + +@Serializable +@SurfNettyPacket("setting:serverbound:setting_modify", PacketFlow.SERVERBOUND) +class ServerboundSettingModifyPacket( + val player: CloudPlayer, + val configuredSetting: ConfiguredSetting +) : RespondingNettyPacket() \ No newline at end of file From 06cad0efecfffaebd3844fd733623fd9bed01535 Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Fri, 10 Oct 2025 16:38:14 +0200 Subject: [PATCH 04/39] feat: implement core and API structures for settings and setting entries --- .../api/common/setting/ConfiguredSetting.kt | 11 ----------- .../surf/settings/api/common/setting/Setting.kt | 9 +++++++++ .../settings/api/common/setting/SettingEntry.kt | 12 ++++++++++++ .../settings/core/setting/SettingEntryImpl.kt | 16 ++++++++++++++++ .../surf/settings/core/setting/SettingImpl.kt | 13 +++++++++++++ 5 files changed, 50 insertions(+), 11 deletions(-) delete mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/ConfiguredSetting.kt create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/Setting.kt create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/SettingEntry.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/setting/SettingEntryImpl.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/setting/SettingImpl.kt diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/ConfiguredSetting.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/ConfiguredSetting.kt deleted file mode 100644 index 9d15ab1..0000000 --- a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/ConfiguredSetting.kt +++ /dev/null @@ -1,11 +0,0 @@ -package dev.slne.surf.settings.api.common.setting - -import net.kyori.adventure.text.Component - -interface ConfiguredSetting { - val identifier: String - val displayName: Component - val description: String - val value: String - val updatedAt: Long -} \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/Setting.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/Setting.kt new file mode 100644 index 0000000..81efb2e --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/Setting.kt @@ -0,0 +1,9 @@ +package dev.slne.surf.settings.api.common.setting + +interface Setting { + val id: Long + val identifier: String + val displayName: String + val description: String + val defaultValue: String +} \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/SettingEntry.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/SettingEntry.kt new file mode 100644 index 0000000..773219a --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/setting/SettingEntry.kt @@ -0,0 +1,12 @@ +package dev.slne.surf.settings.api.common.setting + +import dev.slne.surf.cloud.api.common.player.OfflineCloudPlayer + +interface SettingEntry { + val id: Long + val player: OfflineCloudPlayer + val setting: Setting + val value: String + val addedAt: Long + val updatedAt: Long +} \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/setting/SettingEntryImpl.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/setting/SettingEntryImpl.kt new file mode 100644 index 0000000..82cdd97 --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/setting/SettingEntryImpl.kt @@ -0,0 +1,16 @@ +package dev.slne.surf.settings.core.setting + +import dev.slne.surf.cloud.api.common.player.OfflineCloudPlayer +import dev.slne.surf.settings.api.common.setting.Setting +import dev.slne.surf.settings.api.common.setting.SettingEntry +import kotlinx.serialization.Serializable + +@Serializable +class SettingEntryImpl( + override val id: Long, + override val player: OfflineCloudPlayer, + override val setting: Setting, + override val value: String, + override val addedAt: Long, + override val updatedAt: Long +) : SettingEntry \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/setting/SettingImpl.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/setting/SettingImpl.kt new file mode 100644 index 0000000..204bec1 --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/setting/SettingImpl.kt @@ -0,0 +1,13 @@ +package dev.slne.surf.settings.core.setting + +import dev.slne.surf.settings.api.common.setting.Setting +import kotlinx.serialization.Serializable + +@Serializable +class SettingImpl( + override val id: Long, + override val identifier: String, + override val displayName: String, + override val description: String, + override val defaultValue: String +) : Setting \ No newline at end of file From 51b0ed4f79285cc3094f957bee68b6ce3a9fedbb Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Fri, 10 Oct 2025 16:38:39 +0200 Subject: [PATCH 05/39] feat: add result models for setting and setting entry operations --- .../api/common/result/SettingCreateResult.kt | 17 +++++++++++++++++ .../api/common/result/SettingDeleteResult.kt | 16 ++++++++++++++++ .../api/common/result/SettingQueryResult.kt | 7 +++++-- .../result/entry/SettingEntryModifyResult.kt | 17 +++++++++++++++++ .../result/entry/SettingEntryQueryResult.kt | 18 ++++++++++++++++++ .../result/entry/SettingEntryResetResult.kt | 18 ++++++++++++++++++ 6 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingCreateResult.kt create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingDeleteResult.kt create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryModifyResult.kt create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryQueryResult.kt create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryResetResult.kt diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingCreateResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingCreateResult.kt new file mode 100644 index 0000000..5cf3caf --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingCreateResult.kt @@ -0,0 +1,17 @@ +package dev.slne.surf.settings.api.common.result + +import dev.slne.surf.settings.api.common.setting.Setting +import kotlinx.serialization.Serializable + +@Serializable +sealed class SettingCreateResult { + data class Success(val setting: Setting) : SettingCreateResult() + data class Failure(val failureReason: SettingCreateFailureReason) : SettingCreateResult() + + enum class SettingCreateFailureReason { + SETTING_ALREADY_EXISTS + } + + fun isFailure() = this is Failure + fun isSuccess() = this is Success +} \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingDeleteResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingDeleteResult.kt new file mode 100644 index 0000000..b0d8339 --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingDeleteResult.kt @@ -0,0 +1,16 @@ +package dev.slne.surf.settings.api.common.result + +import kotlinx.serialization.Serializable + +@Serializable +sealed class SettingDeleteResult { + class Success : SettingDeleteResult() + data class Failure(val failureReason: SettingDeleteFailureReason) : SettingDeleteResult() + + enum class SettingDeleteFailureReason { + SETTING_NOT_FOUND + } + + fun isFailure() = this is Failure + fun isSuccess() = this is Success +} \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingQueryResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingQueryResult.kt index e5a8d3a..670d395 100644 --- a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingQueryResult.kt +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingQueryResult.kt @@ -1,14 +1,17 @@ package dev.slne.surf.settings.api.common.result -import dev.slne.surf.settings.api.common.setting.ConfiguredSetting +import dev.slne.surf.settings.api.common.setting.Setting import kotlinx.serialization.Serializable @Serializable sealed class SettingQueryResult { - data class Success(val setting: ConfiguredSetting) : SettingQueryResult() + data class Success(val setting: Setting) : SettingQueryResult() data class Failure(val failureReason: SettingQueryFailureReason) : SettingQueryResult() enum class SettingQueryFailureReason { SETTING_NOT_FOUND } + + fun isFailure() = this is Failure + fun isSuccess() = this is Success } \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryModifyResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryModifyResult.kt new file mode 100644 index 0000000..eadd1cd --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryModifyResult.kt @@ -0,0 +1,17 @@ +package dev.slne.surf.settings.api.common.result.entry + +import dev.slne.surf.settings.api.common.setting.SettingEntry +import kotlinx.serialization.Serializable + +@Serializable +sealed class SettingEntryModifyResult { + data class Success(val setting: SettingEntry) : SettingEntryModifyResult() + data class Failure(val failureReason: SettingModifyResultFailure) : SettingEntryModifyResult() + + enum class SettingModifyResultFailure { + SETTING_NOT_FOUND + } + + fun isFailure() = this is Failure + fun isSuccess() = this is Success +} \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryQueryResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryQueryResult.kt new file mode 100644 index 0000000..fb0a84b --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryQueryResult.kt @@ -0,0 +1,18 @@ +package dev.slne.surf.settings.api.common.result.entry + +import dev.slne.surf.settings.api.common.setting.SettingEntry +import kotlinx.serialization.Serializable + +@Serializable +sealed class SettingEntryQueryResult { + data class Success(val setting: SettingEntry) : SettingEntryQueryResult() + data class Failure(val failureReason: SettingEntryQueryFailureReason) : + SettingEntryQueryResult() + + enum class SettingEntryQueryFailureReason { + SETTING_NOT_FOUND + } + + fun isFailure() = this is Failure + fun isSuccess() = this is Success +} \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryResetResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryResetResult.kt new file mode 100644 index 0000000..531c64b --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/entry/SettingEntryResetResult.kt @@ -0,0 +1,18 @@ +package dev.slne.surf.settings.api.common.result.entry + +import dev.slne.surf.settings.api.common.setting.SettingEntry +import kotlinx.serialization.Serializable + +@Serializable +sealed class SettingEntryResetResult { + data class Success(val setting: SettingEntry) : SettingEntryResetResult() + data class Failure(val failureReason: SettingEntryResetFailureReason) : + SettingEntryResetResult() + + enum class SettingEntryResetFailureReason { + SETTING_NOT_FOUND + } + + fun isFailure() = this is Failure + fun isSuccess() = this is Success +} \ No newline at end of file From c0a8c4394dd50c2ee32ab726dc5cea68c73cb3d0 Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Fri, 10 Oct 2025 16:38:47 +0200 Subject: [PATCH 06/39] feat: add clientbound packets for setting entry operations - Added `ClientboundSettingEntryQueryResultPacket`, `ClientboundSettingEntryQueryManyPacket`, `ClientboundSettingEntryModifyResultPacket`, and `ClientboundSettingEntryResetResultPacket`. - Updated packages and renamed existing packets to align with setting entry operations. --- .../ClientboundSettingModifyResultPacket.kt | 13 ------------- .../ClientboundSettingQueryResultPacket.kt | 13 ------------- .../ClientboundSettingEntryModifyResultPacket.kt | 13 +++++++++++++ .../ClientboundSettingEntryQueryManyPacket.kt | 14 ++++++++++++++ .../ClientboundSettingEntryQueryResultPacket.kt | 13 +++++++++++++ .../ClientboundSettingEntryResetResultPacket.kt | 13 +++++++++++++ 6 files changed, 53 insertions(+), 26 deletions(-) delete mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingModifyResultPacket.kt delete mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingQueryResultPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryModifyResultPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryQueryManyPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryQueryResultPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryResetResultPacket.kt diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingModifyResultPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingModifyResultPacket.kt deleted file mode 100644 index 4aa229a..0000000 --- a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingModifyResultPacket.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.slne.surf.settings.core.netty.protocol.clientbound - -import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket -import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow -import dev.slne.surf.cloud.api.common.netty.packet.ResponseNettyPacket -import dev.slne.surf.settings.api.common.result.SettingModifyResult -import kotlinx.serialization.Serializable - -@Serializable -@SurfNettyPacket("setting:clientbound:setting_modify_result", PacketFlow.CLIENTBOUND) -data class ClientboundSettingModifyResultPacket( - val result: SettingModifyResult -) : ResponseNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingQueryResultPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingQueryResultPacket.kt deleted file mode 100644 index 30b2844..0000000 --- a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/ClientboundSettingQueryResultPacket.kt +++ /dev/null @@ -1,13 +0,0 @@ -package dev.slne.surf.settings.core.netty.protocol.clientbound - -import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket -import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow -import dev.slne.surf.cloud.api.common.netty.packet.ResponseNettyPacket -import dev.slne.surf.settings.api.common.result.SettingQueryResult -import kotlinx.serialization.Serializable - -@Serializable -@SurfNettyPacket("setting:clientbound:setting_query_result", PacketFlow.CLIENTBOUND) -data class ClientboundSettingQueryResultPacket( - val result: SettingQueryResult -) : ResponseNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryModifyResultPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryModifyResultPacket.kt new file mode 100644 index 0000000..bc4cb20 --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryModifyResultPacket.kt @@ -0,0 +1,13 @@ +package dev.slne.surf.settings.core.netty.protocol.clientbound.entry + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.ResponseNettyPacket +import dev.slne.surf.settings.api.common.result.entry.SettingEntryModifyResult +import kotlinx.serialization.Serializable + +@Serializable +@SurfNettyPacket("setting:clientbound:setting_entry_modify_result", PacketFlow.CLIENTBOUND) +data class ClientboundSettingEntryModifyResultPacket( + val result: SettingEntryModifyResult +) : ResponseNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryQueryManyPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryQueryManyPacket.kt new file mode 100644 index 0000000..cff9aee --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryQueryManyPacket.kt @@ -0,0 +1,14 @@ +package dev.slne.surf.settings.core.netty.protocol.clientbound.entry + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.ResponseNettyPacket +import dev.slne.surf.settings.api.common.setting.SettingEntry +import it.unimi.dsi.fastutil.objects.ObjectSet +import kotlinx.serialization.Serializable + +@Serializable +@SurfNettyPacket("setting:clientbound:setting_entry_query_many_result", PacketFlow.CLIENTBOUND) +data class ClientboundSettingEntryQueryManyPacket( + val queries: ObjectSet +) : ResponseNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryQueryResultPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryQueryResultPacket.kt new file mode 100644 index 0000000..b8367d5 --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryQueryResultPacket.kt @@ -0,0 +1,13 @@ +package dev.slne.surf.settings.core.netty.protocol.clientbound.entry + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.ResponseNettyPacket +import dev.slne.surf.settings.api.common.result.entry.SettingEntryQueryResult +import kotlinx.serialization.Serializable + +@Serializable +@SurfNettyPacket("setting:clientbound:setting_entry_query_result", PacketFlow.CLIENTBOUND) +data class ClientboundSettingEntryQueryResultPacket( + val result: SettingEntryQueryResult +) : ResponseNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryResetResultPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryResetResultPacket.kt new file mode 100644 index 0000000..7a5e348 --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/clientbound/entry/ClientboundSettingEntryResetResultPacket.kt @@ -0,0 +1,13 @@ +package dev.slne.surf.settings.core.netty.protocol.clientbound.entry + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.ResponseNettyPacket +import dev.slne.surf.settings.api.common.result.entry.SettingEntryResetResult +import kotlinx.serialization.Serializable + +@Serializable +@SurfNettyPacket("setting:clientbound:setting_entry_reset_result", PacketFlow.CLIENTBOUND) +data class ClientboundSettingEntryResetResultPacket( + val result: SettingEntryResetResult +) : ResponseNettyPacket() \ No newline at end of file From a001ca74c38d9042f8b57b66c6e29d7c9d044b08 Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Fri, 10 Oct 2025 16:38:58 +0200 Subject: [PATCH 07/39] feat: add serverbound packets for setting entry operations - Introduced `ServerboundSettingEntryQueryAllPacket`, `ServerboundSettingEntryQueryAllByPlayerPacket`, `ServerboundSettingEntryResetPacket`, and `ServerboundSettingEntryModifyPacket`. - Updated and renamed existing serverbound packets to align with setting entry operations. --- .../ServerboundSettingModifyPacket.kt | 16 ---------------- .../ServerboundSettingQueryPacket.kt | 15 --------------- .../ServerboundSettingEntryModifyPacket.kt | 17 +++++++++++++++++ ...erboundSettingEntryQueryAllByPlayerPacket.kt | 15 +++++++++++++++ .../ServerboundSettingEntryQueryAllPacket.kt | 12 ++++++++++++ .../entry/ServerboundSettingEntryQueryPacket.kt | 17 +++++++++++++++++ .../entry/ServerboundSettingEntryResetPacket.kt | 17 +++++++++++++++++ 7 files changed, 78 insertions(+), 31 deletions(-) delete mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingModifyPacket.kt delete mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingQueryPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryModifyPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryAllByPlayerPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryAllPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryPacket.kt create mode 100644 surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryResetPacket.kt diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingModifyPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingModifyPacket.kt deleted file mode 100644 index 69c3010..0000000 --- a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingModifyPacket.kt +++ /dev/null @@ -1,16 +0,0 @@ -package dev.slne.surf.settings.core.netty.protocol.serverbound - -import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket -import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow -import dev.slne.surf.cloud.api.common.netty.packet.RespondingNettyPacket -import dev.slne.surf.cloud.api.common.player.CloudPlayer -import dev.slne.surf.settings.api.common.setting.ConfiguredSetting -import dev.slne.surf.settings.core.netty.protocol.clientbound.ClientboundSettingModifyResultPacket -import kotlinx.serialization.Serializable - -@Serializable -@SurfNettyPacket("setting:serverbound:setting_modify", PacketFlow.SERVERBOUND) -class ServerboundSettingModifyPacket( - val player: CloudPlayer, - val configuredSetting: ConfiguredSetting -) : RespondingNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingQueryPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingQueryPacket.kt deleted file mode 100644 index d6b782b..0000000 --- a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/ServerboundSettingQueryPacket.kt +++ /dev/null @@ -1,15 +0,0 @@ -package dev.slne.surf.settings.core.netty.protocol.serverbound - -import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket -import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow -import dev.slne.surf.cloud.api.common.netty.packet.RespondingNettyPacket -import dev.slne.surf.cloud.api.common.player.CloudPlayer -import dev.slne.surf.settings.core.netty.protocol.clientbound.ClientboundSettingQueryResultPacket -import kotlinx.serialization.Serializable - -@Serializable -@SurfNettyPacket("setting:serverbound:setting_query", PacketFlow.SERVERBOUND) -class ServerboundSettingQueryPacket( - val player: CloudPlayer, - val identifier: String -) : RespondingNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryModifyPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryModifyPacket.kt new file mode 100644 index 0000000..f6b53f5 --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryModifyPacket.kt @@ -0,0 +1,17 @@ +package dev.slne.surf.settings.core.netty.protocol.serverbound.entry + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.RespondingNettyPacket +import dev.slne.surf.settings.api.common.setting.SettingEntry +import dev.slne.surf.settings.core.netty.protocol.clientbound.entry.ClientboundSettingEntryModifyResultPacket +import kotlinx.serialization.Contextual +import kotlinx.serialization.Serializable +import java.util.* + +@Serializable +@SurfNettyPacket("setting:serverbound:setting_entry_modify", PacketFlow.SERVERBOUND) +class ServerboundSettingEntryModifyPacket( + val player: @Contextual UUID, + val setting: SettingEntry +) : RespondingNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryAllByPlayerPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryAllByPlayerPacket.kt new file mode 100644 index 0000000..a25f40f --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryAllByPlayerPacket.kt @@ -0,0 +1,15 @@ +package dev.slne.surf.settings.core.netty.protocol.serverbound.entry + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.RespondingNettyPacket +import dev.slne.surf.settings.core.netty.protocol.clientbound.entry.ClientboundSettingEntryQueryManyPacket +import kotlinx.serialization.Contextual +import kotlinx.serialization.Serializable +import java.util.* + +@Serializable +@SurfNettyPacket("setting:serverbound:setting_entry_query_all_player", PacketFlow.SERVERBOUND) +class ServerboundSettingEntryQueryAllByPlayerPacket( + val playerUuid: @Contextual UUID +) : RespondingNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryAllPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryAllPacket.kt new file mode 100644 index 0000000..ee53b7f --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryAllPacket.kt @@ -0,0 +1,12 @@ +package dev.slne.surf.settings.core.netty.protocol.serverbound.entry + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.RespondingNettyPacket +import dev.slne.surf.settings.core.netty.protocol.clientbound.entry.ClientboundSettingEntryQueryManyPacket +import kotlinx.serialization.Serializable + +@Serializable +@SurfNettyPacket("setting:serverbound:setting_entry_query_all", PacketFlow.SERVERBOUND) +class ServerboundSettingEntryQueryAllPacket() : + RespondingNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryPacket.kt new file mode 100644 index 0000000..57fe55a --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryQueryPacket.kt @@ -0,0 +1,17 @@ +package dev.slne.surf.settings.core.netty.protocol.serverbound.entry + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.RespondingNettyPacket +import dev.slne.surf.settings.api.common.setting.Setting +import dev.slne.surf.settings.core.netty.protocol.clientbound.entry.ClientboundSettingEntryQueryResultPacket +import kotlinx.serialization.Contextual +import kotlinx.serialization.Serializable +import java.util.* + +@Serializable +@SurfNettyPacket("setting:serverbound:setting_entry_query", PacketFlow.SERVERBOUND) +class ServerboundSettingEntryQueryPacket( + val player: @Contextual UUID, + val setting: Setting +) : RespondingNettyPacket() \ No newline at end of file diff --git a/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryResetPacket.kt b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryResetPacket.kt new file mode 100644 index 0000000..5607cfe --- /dev/null +++ b/surf-settings-core/surf-settings-core-common/src/main/kotlin/dev/slne/surf/settings/core/netty/protocol/serverbound/entry/ServerboundSettingEntryResetPacket.kt @@ -0,0 +1,17 @@ +package dev.slne.surf.settings.core.netty.protocol.serverbound.entry + +import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket +import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow +import dev.slne.surf.cloud.api.common.netty.packet.RespondingNettyPacket +import dev.slne.surf.settings.api.common.setting.Setting +import dev.slne.surf.settings.core.netty.protocol.clientbound.entry.ClientboundSettingEntryResetResultPacket +import kotlinx.serialization.Contextual +import kotlinx.serialization.Serializable +import java.util.* + +@Serializable +@SurfNettyPacket("setting:serverbound:setting_entry_reset", PacketFlow.SERVERBOUND) +class ServerboundSettingEntryResetPacket( + val player: @Contextual UUID, + val setting: Setting +) : RespondingNettyPacket() \ No newline at end of file From 4f6b2a001eb2b60bd5e3b235d9b534b007121c11 Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Fri, 10 Oct 2025 16:39:10 +0200 Subject: [PATCH 08/39] refactor: rename SettingModifyResult to SettingCreateIgnoringResult and update related types --- .../common/result/SettingCreateIgnoringResult.kt | 15 +++++++++++++++ .../api/common/result/SettingModifyResult.kt | 15 --------------- 2 files changed, 15 insertions(+), 15 deletions(-) create mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingCreateIgnoringResult.kt delete mode 100644 surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingModifyResult.kt diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingCreateIgnoringResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingCreateIgnoringResult.kt new file mode 100644 index 0000000..367b481 --- /dev/null +++ b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingCreateIgnoringResult.kt @@ -0,0 +1,15 @@ +package dev.slne.surf.settings.api.common.result + +import dev.slne.surf.settings.api.common.setting.Setting +import kotlinx.serialization.Serializable + +@Serializable +sealed class SettingCreateIgnoringResult { + data class Success(val setting: Setting) : SettingCreateIgnoringResult() + data class Failure(val failureReason: SettingCreateIgnoringFailureReason) : + SettingCreateIgnoringResult() + + enum class SettingCreateIgnoringFailureReason { + INTERNAL_ERROR + } +} \ No newline at end of file diff --git a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingModifyResult.kt b/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingModifyResult.kt deleted file mode 100644 index a51c323..0000000 --- a/surf-settings-api/surf-settings-api-common/src/main/kotlin/dev/slne/surf/settings/api/common/result/SettingModifyResult.kt +++ /dev/null @@ -1,15 +0,0 @@ -package dev.slne.surf.settings.api.common.result - -import dev.slne.surf.settings.api.common.setting.ConfiguredSetting -import kotlinx.serialization.Serializable - -@Serializable -sealed class SettingModifyResult { - data class Success(val setting: ConfiguredSetting) : SettingModifyResult() - data class Failure(val failureReason: SettingModifyResultFailure) : SettingModifyResult() - - enum class SettingModifyResultFailure { - SETTING_NOT_FOUND, - ALREADY_UP_TO_DATE - } -} \ No newline at end of file From 8c62c352a771a65466f93d055946af6923bf61b1 Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Fri, 10 Oct 2025 16:39:27 +0200 Subject: [PATCH 09/39] feat: implement database entities, tables, repositories, and services for settings and setting entries - Added `SettingEntity`, `SettingEntryEntity`, `SettingsTable`, and `SettingsEntryTable`. - Implemented `SettingRepository` and `SettingEntryRepository` for data access. - Introduced `SettingService` and `SettingEntryService` for business logic. --- .../server/database/entity/SettingEntity.kt | 24 ++++++++++ .../database/entity/SettingEntryEntity.kt | 25 ++++++++++ .../database/table/SettingsEntryTable.kt | 10 ++++ .../server/database/table/SettingsTable.kt | 10 ++++ .../repository/SettingEntryRepository.kt | 46 +++++++++++++++++++ .../server/repository/SettingRepository.kt | 36 +++++++++++++++ .../server/service/SettingEntryService.kt | 45 ++++++++++++++++++ .../settings/server/service/SettingService.kt | 46 +++++++++++++++++++ 8 files changed, 242 insertions(+) create mode 100644 surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/entity/SettingEntity.kt create mode 100644 surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/entity/SettingEntryEntity.kt create mode 100644 surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/table/SettingsEntryTable.kt create mode 100644 surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/table/SettingsTable.kt create mode 100644 surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/repository/SettingEntryRepository.kt create mode 100644 surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/repository/SettingRepository.kt create mode 100644 surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/service/SettingEntryService.kt create mode 100644 surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/service/SettingService.kt diff --git a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/entity/SettingEntity.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/entity/SettingEntity.kt new file mode 100644 index 0000000..a67fa7c --- /dev/null +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/entity/SettingEntity.kt @@ -0,0 +1,24 @@ +package dev.slne.surf.settings.server.database.entity + +import dev.slne.surf.settings.core.setting.SettingImpl +import dev.slne.surf.settings.server.database.table.SettingsTable +import org.jetbrains.exposed.dao.LongEntity +import org.jetbrains.exposed.dao.LongEntityClass +import org.jetbrains.exposed.dao.id.EntityID + +class SettingEntity(id: EntityID) : LongEntity(id) { + companion object : LongEntityClass(SettingsTable) + + var identifier by SettingsTable.identifier + var displayName by SettingsTable.displayName + var description by SettingsTable.description + var defaultValue by SettingsTable.defaultValue + + fun toDto() = SettingImpl( + id = id.value, + identifier = identifier, + displayName = displayName, + description = description, + defaultValue = defaultValue, + ) +} \ No newline at end of file diff --git a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/entity/SettingEntryEntity.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/entity/SettingEntryEntity.kt new file mode 100644 index 0000000..4e07918 --- /dev/null +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/entity/SettingEntryEntity.kt @@ -0,0 +1,25 @@ +package dev.slne.surf.settings.server.database.entity + +import dev.slne.surf.cloud.api.common.player.OfflineCloudPlayer +import dev.slne.surf.cloud.api.server.exposed.table.AuditableLongEntity +import dev.slne.surf.cloud.api.server.exposed.table.AuditableLongEntityClass +import dev.slne.surf.settings.core.setting.SettingEntryImpl +import dev.slne.surf.settings.server.database.table.SettingsEntryTable +import org.jetbrains.exposed.dao.id.EntityID + +class SettingEntryEntity(id: EntityID) : AuditableLongEntity(id, SettingsEntryTable) { + companion object : AuditableLongEntityClass(SettingsEntryTable) + + var player by SettingsEntryTable.player + var value by SettingsEntryTable.value + var setting by SettingEntity referencedOn SettingsEntryTable.setting + + fun toDto() = SettingEntryImpl( + id = id.value, + player = OfflineCloudPlayer[player], + setting = setting.toDto(), + value = value, + addedAt = createdAt.toEpochSecond() * 1_000, + updatedAt = updatedAt.toEpochSecond() + 1_000, + ) +} \ No newline at end of file diff --git a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/table/SettingsEntryTable.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/table/SettingsEntryTable.kt new file mode 100644 index 0000000..65b7011 --- /dev/null +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/table/SettingsEntryTable.kt @@ -0,0 +1,10 @@ +package dev.slne.surf.settings.server.database.table + +import dev.slne.surf.cloud.api.server.exposed.table.AuditableLongIdTable +import org.jetbrains.exposed.sql.ReferenceOption + +object SettingsEntryTable : AuditableLongIdTable("setting_entries") { + val player = uuid("player_uuid") + val value = varchar("value", 256) + val setting = reference("setting_id", SettingsTable, onDelete = ReferenceOption.CASCADE) +} \ No newline at end of file diff --git a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/table/SettingsTable.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/table/SettingsTable.kt new file mode 100644 index 0000000..20520a0 --- /dev/null +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/database/table/SettingsTable.kt @@ -0,0 +1,10 @@ +package dev.slne.surf.settings.server.database.table + +import org.jetbrains.exposed.dao.id.LongIdTable + +object SettingsTable : LongIdTable("setting_settings") { + val identifier = varchar("identifier", 255).uniqueIndex() + val displayName = varchar("display_name", 128) + val description = text("description") + val defaultValue = varchar("default_value", 256) +} \ No newline at end of file diff --git a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/repository/SettingEntryRepository.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/repository/SettingEntryRepository.kt new file mode 100644 index 0000000..5c23781 --- /dev/null +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/repository/SettingEntryRepository.kt @@ -0,0 +1,46 @@ +package dev.slne.surf.settings.server.repository + +import dev.slne.surf.cloud.api.common.util.toObjectSet +import dev.slne.surf.cloud.api.server.plugin.CoroutineTransactional +import dev.slne.surf.settings.api.common.setting.Setting +import dev.slne.surf.settings.api.common.setting.SettingEntry +import dev.slne.surf.settings.server.database.entity.SettingEntryEntity +import dev.slne.surf.settings.server.database.table.SettingsEntryTable +import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq +import org.jetbrains.exposed.sql.and +import org.springframework.stereotype.Repository +import java.util.* + +@Repository +@CoroutineTransactional +class SettingEntryRepository( + private val settingRepository: SettingRepository +) { + suspend fun all(playerUuid: UUID) = + SettingEntryEntity.find(SettingsEntryTable.player eq playerUuid).map { it.toDto() } + .toObjectSet() + + suspend fun query(playerUuid: UUID, setting: Setting) = SettingEntryEntity + .find((SettingsEntryTable.player eq playerUuid) and (SettingsEntryTable.setting eq setting.id)) + .firstOrNull() + + suspend fun modify(playerUUID: UUID, settingEntry: SettingEntry): SettingEntry? { + val setting = + settingRepository.queryInternal(settingEntry.setting.identifier) ?: return null + + val updated = query(playerUUID, settingEntry.setting)?.apply { + value = settingEntry.value + } ?: SettingEntryEntity.new { + player = playerUUID + value = settingEntry.value + this.setting = setting + } + + return updated.toDto() + } + + suspend fun all() = SettingEntryEntity.all().map { it.toDto() }.toObjectSet() + suspend fun reset(playerUuid: UUID, setting: Setting) = query(playerUuid, setting)?.apply { + value = setting.defaultValue + } +} \ No newline at end of file diff --git a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/repository/SettingRepository.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/repository/SettingRepository.kt new file mode 100644 index 0000000..e436bbb --- /dev/null +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/repository/SettingRepository.kt @@ -0,0 +1,36 @@ +package dev.slne.surf.settings.server.repository + +import dev.slne.surf.cloud.api.common.util.toObjectSet +import dev.slne.surf.cloud.api.server.plugin.CoroutineTransactional +import dev.slne.surf.settings.api.common.setting.Setting +import dev.slne.surf.settings.server.database.entity.SettingEntity +import dev.slne.surf.settings.server.database.table.SettingsTable +import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq +import org.springframework.stereotype.Repository + +@Repository +@CoroutineTransactional +class SettingRepository { + suspend fun query(identifier: String) = + SettingEntity.find(SettingsTable.identifier eq identifier).firstOrNull()?.toDto() + + suspend fun queryInternal(identifier: String) = + SettingEntity.find(SettingsTable.identifier eq identifier).firstOrNull() + + suspend fun all() = SettingEntity.all().map { it.toDto() }.toObjectSet() + suspend fun delete(identifier: String) = + SettingEntity.find(SettingsTable.identifier eq identifier).firstOrNull()?.delete() != null + + suspend fun delete(setting: Setting) = delete(setting.identifier) + + suspend fun create(setting: Setting) = + if (query(setting.identifier) == null) SettingEntity.new { + this.displayName = setting.displayName + this.identifier = setting.identifier + this.description = setting.description + this.defaultValue = setting.defaultValue + }.toDto() else null + + suspend fun createIfNotExists(setting: Setting) = + query(setting.identifier) ?: create(setting) +} \ No newline at end of file diff --git a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/service/SettingEntryService.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/service/SettingEntryService.kt new file mode 100644 index 0000000..54d1746 --- /dev/null +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/service/SettingEntryService.kt @@ -0,0 +1,45 @@ +package dev.slne.surf.settings.server.service + +import dev.slne.surf.settings.api.common.result.entry.SettingEntryModifyResult +import dev.slne.surf.settings.api.common.result.entry.SettingEntryQueryResult +import dev.slne.surf.settings.api.common.result.entry.SettingEntryResetResult +import dev.slne.surf.settings.api.common.setting.Setting +import dev.slne.surf.settings.api.common.setting.SettingEntry +import dev.slne.surf.settings.server.repository.SettingEntryRepository +import org.springframework.stereotype.Service +import java.util.* + +@Service +class SettingEntryService( + private val settingEntryRepository: SettingEntryRepository +) { + suspend fun modify(playerUuid: UUID, settingEntry: SettingEntry): SettingEntryModifyResult { + val entry = settingEntryRepository.modify(playerUuid, settingEntry) + return if (entry != null) { + SettingEntryModifyResult.Success(entry) + } else { + SettingEntryModifyResult.Failure(SettingEntryModifyResult.SettingModifyResultFailure.SETTING_NOT_FOUND) + } + } + + suspend fun reset(playerUUID: UUID, setting: Setting): SettingEntryResetResult { + val entry = settingEntryRepository.reset(playerUUID, setting)?.toDto() + return if (entry != null) { + SettingEntryResetResult.Success(entry) + } else { + SettingEntryResetResult.Failure(SettingEntryResetResult.SettingEntryResetFailureReason.SETTING_NOT_FOUND) + } + } + + suspend fun all(playerUuid: UUID) = settingEntryRepository.all(playerUuid) + suspend fun all() = settingEntryRepository.all() + + suspend fun query(playerUUID: UUID, setting: Setting): SettingEntryQueryResult { + val entry = settingEntryRepository.query(playerUUID, setting)?.toDto() + return if (entry != null) { + SettingEntryQueryResult.Success(entry) + } else { + SettingEntryQueryResult.Failure(SettingEntryQueryResult.SettingEntryQueryFailureReason.SETTING_NOT_FOUND) + } + } +} \ No newline at end of file diff --git a/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/service/SettingService.kt b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/service/SettingService.kt new file mode 100644 index 0000000..6c92db0 --- /dev/null +++ b/surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/service/SettingService.kt @@ -0,0 +1,46 @@ +package dev.slne.surf.settings.server.service + +import dev.slne.surf.settings.api.common.result.SettingCreateIgnoringResult +import dev.slne.surf.settings.api.common.result.SettingCreateResult +import dev.slne.surf.settings.api.common.result.SettingDeleteResult +import dev.slne.surf.settings.api.common.result.SettingQueryResult +import dev.slne.surf.settings.api.common.setting.Setting +import dev.slne.surf.settings.server.repository.SettingRepository +import org.springframework.stereotype.Service + +@Service +class SettingService( + private val settingRepository: SettingRepository +) { + suspend fun createSetting(setting: Setting): SettingCreateResult { + val create = settingRepository.create(setting) ?: return SettingCreateResult.Failure( + SettingCreateResult.SettingCreateFailureReason.SETTING_ALREADY_EXISTS + ) + + return SettingCreateResult.Success(create) + } + + suspend fun createIfNotExists(setting: Setting): SettingCreateIgnoringResult { + val create = settingRepository.createIfNotExists(setting) + ?: return SettingCreateIgnoringResult.Failure( + SettingCreateIgnoringResult.SettingCreateIgnoringFailureReason.INTERNAL_ERROR + ) + + return SettingCreateIgnoringResult.Success(create) + } + + suspend fun delete(identifier: String) = if (settingRepository.delete(identifier)) { + SettingDeleteResult.Success() + } else { + SettingDeleteResult.Failure(SettingDeleteResult.SettingDeleteFailureReason.SETTING_NOT_FOUND) + } + + suspend fun query(identifier: String): SettingQueryResult { + val query = settingRepository.query(identifier) + ?: return SettingQueryResult.Failure(SettingQueryResult.SettingQueryFailureReason.SETTING_NOT_FOUND) + + return SettingQueryResult.Success(query) + } + + suspend fun queryAll() = settingRepository.all() +} \ No newline at end of file From 27ddbaa32c2f19c2ada4763d584246af4e4ab478 Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Fri, 10 Oct 2025 17:08:15 +0200 Subject: [PATCH 10/39] feat: add SettingEntryPacketListener and enhance repository/service - Implemented `SettingEntryPacketListener` for handling setting entry packets. - Updated `SettingEntryRepository` and `SettingEntryService` to use `ObjectSet` for results. - Adjusted all relevant methods to return `ObjectSet` for consistency. - Minor XML configuration update for project settings. --- .idea/discord.xml | 2 +- .../surf/settings/SurfSettingsApplication.kt | 3 +- .../listener/SettingEntryPacketListener.kt | 61 +++++++++++++++++++ .../repository/SettingEntryRepository.kt | 7 ++- .../server/service/SettingEntryService.kt | 7 ++- 5 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 surf-settings-server/src/main/kotlin/dev/slne/surf/settings/server/protocol/listener/SettingEntryPacketListener.kt diff --git a/.idea/discord.xml b/.idea/discord.xml index 6b01108..912db82 100644 --- a/.idea/discord.xml +++ b/.idea/discord.xml @@ -1,7 +1,7 @@ -