diff --git a/gradle.properties b/gradle.properties index 4a15058..c8a5f40 100755 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ kotlin.code.style=official project.group=kr.summitsystems -project.version=0.0.8-beta6 +project.version=0.0.8-beta7 project.name=spring-bukkit project.url=https://github.com/summit-systems/spring-bukkit project.url.scm=https://github.com/summit-systems/spring-bukkit.git @@ -18,7 +18,6 @@ project.developer.email=park@junhyung.kr # Spigot spigot.version=1.20.2-R0.1-SNAPSHOT mock.bukkit.version=3.58.0 -protocollib.version=5.1.0 # Jakarta EE jakarta.annotation.version=2.1.1 diff --git a/project-dependency-graph.png b/project-dependency-graph.png index bcc7849..9a9db82 100644 Binary files a/project-dependency-graph.png and b/project-dependency-graph.png differ diff --git a/settings.gradle.kts b/settings.gradle.kts index 8e77289..22506cf 100755 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -41,7 +41,6 @@ dependencyResolutionManagement { library("paper", "io.papermc.paper:paper-api:${extra["spigot.version"]}") library("folia", "dev.folia:folia-api:${extra["spigot.version"]}") library("mockbukkit", "com.github.seeseemelk:MockBukkit-v1.20:${extra["mock.bukkit.version"]}") - library("protocollib", "com.comphenix.protocol:ProtocolLib:${extra["protocollib.version"]}") library("kotlin-stdlib", "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${extra["kotlin.version"]}") library("kotlin-reflect", "org.jetbrains.kotlin:kotlin-reflect:${extra["kotlin.version"]}") diff --git a/spring-bukkit-kotlinx-coroutines/build.gradle.kts b/spring-bukkit-kotlinx-coroutines/build.gradle.kts index 1d01e7a..0e6618b 100755 --- a/spring-bukkit-kotlinx-coroutines/build.gradle.kts +++ b/spring-bukkit-kotlinx-coroutines/build.gradle.kts @@ -3,7 +3,7 @@ dependencies { api(libs.kotlinx.coroutines.core) api(projects.core) - implementation(projects.command) + compileOnly(projects.command) testImplementation(libs.spigot) testImplementation(libs.spring.test) diff --git a/spring-bukkit-kotlinx-coroutines/src/main/kotlin/kr/summitsystems/springbukkit/kotlinx/coroutines/command/CoroutinesCommandExecutor.kt b/spring-bukkit-kotlinx-coroutines/src/main/kotlin/kr/summitsystems/springbukkit/kotlinx/coroutines/command/CoroutinesCommandExecutor.kt index a02410c..bab696c 100644 --- a/spring-bukkit-kotlinx-coroutines/src/main/kotlin/kr/summitsystems/springbukkit/kotlinx/coroutines/command/CoroutinesCommandExecutor.kt +++ b/spring-bukkit-kotlinx-coroutines/src/main/kotlin/kr/summitsystems/springbukkit/kotlinx/coroutines/command/CoroutinesCommandExecutor.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.launch import kr.summitsystems.springbukkit.command.* import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.config.BeanDefinition -import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Primary import org.springframework.context.annotation.Role import org.springframework.core.KotlinDetector import org.springframework.core.convert.ConversionService @@ -13,6 +13,7 @@ import org.springframework.stereotype.Component import kotlin.reflect.full.callSuspend import kotlin.reflect.jvm.kotlinFunction +@Primary @Component @Role(BeanDefinition.ROLE_INFRASTRUCTURE) class CoroutinesCommandExecutor( diff --git a/spring-bukkit-kotlinx-coroutines/src/main/kotlin/kr/summitsystems/springbukkit/kotlinx/coroutines/listener/CoroutinesEventExecutorFactory.kt b/spring-bukkit-kotlinx-coroutines/src/main/kotlin/kr/summitsystems/springbukkit/kotlinx/coroutines/listener/CoroutinesEventExecutorFactory.kt index 1a9e3bb..e4b2833 100644 --- a/spring-bukkit-kotlinx-coroutines/src/main/kotlin/kr/summitsystems/springbukkit/kotlinx/coroutines/listener/CoroutinesEventExecutorFactory.kt +++ b/spring-bukkit-kotlinx-coroutines/src/main/kotlin/kr/summitsystems/springbukkit/kotlinx/coroutines/listener/CoroutinesEventExecutorFactory.kt @@ -4,10 +4,12 @@ import kotlinx.coroutines.CoroutineScope import kr.summitsystems.springbukkit.core.listener.EventExecutorFactory import org.bukkit.plugin.EventExecutor import org.springframework.beans.factory.config.BeanDefinition +import org.springframework.context.annotation.Primary import org.springframework.context.annotation.Role import org.springframework.stereotype.Component import java.lang.reflect.Method +@Primary @Component @Role(BeanDefinition.ROLE_INFRASTRUCTURE) class CoroutinesEventExecutorFactory(private val coroutineScope: CoroutineScope) : EventExecutorFactory { diff --git a/spring-bukkit-reactive/build.gradle.kts b/spring-bukkit-reactive/build.gradle.kts index 72e6ae1..cb00ebf 100755 --- a/spring-bukkit-reactive/build.gradle.kts +++ b/spring-bukkit-reactive/build.gradle.kts @@ -1,9 +1,9 @@ dependencies { compileOnly(libs.spigot) + api(libs.reactor) api(projects.core) - api(libs.reactor) - implementation(projects.view) + compileOnly(projects.view) testImplementation(libs.paper) testImplementation(libs.spring.test) diff --git a/spring-bukkit-starter/build.gradle.kts b/spring-bukkit-starter/build.gradle.kts index 833bfd2..6bed089 100755 --- a/spring-bukkit-starter/build.gradle.kts +++ b/spring-bukkit-starter/build.gradle.kts @@ -2,7 +2,7 @@ dependencies { api(projects.core) api(projects.command) api(projects.view) - runtimeOnly(projects.support) + api(projects.support) api(libs.jakarta.annotation) api(libs.spring.tx) diff --git a/spring-bukkit-support/build.gradle.kts b/spring-bukkit-support/build.gradle.kts index c6bea6f..0b755a9 100755 --- a/spring-bukkit-support/build.gradle.kts +++ b/spring-bukkit-support/build.gradle.kts @@ -1,12 +1,9 @@ dependencies { compileOnly(libs.paper) compileOnly(libs.folia) - compileOnly(libs.protocollib) api(projects.core) - implementation(projects.command) - implementation(projects.view) - implementation(projects.kotlinxCoroutines) + compileOnly(projects.kotlinxCoroutines) testImplementation(libs.spigot) testImplementation(libs.spring.test) diff --git a/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/ConditionalOnFolia.kt b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/ConditionalOnFolia.kt new file mode 100644 index 0000000..0fd7355 --- /dev/null +++ b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/ConditionalOnFolia.kt @@ -0,0 +1,8 @@ +package kr.summitsystems.springbukkit.support.folia + +import org.springframework.context.annotation.Conditional + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.RUNTIME) +@Conditional(FoliaCondition::class) +annotation class ConditionalOnFolia \ No newline at end of file diff --git a/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaCondition.kt b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaCondition.kt new file mode 100644 index 0000000..5e29121 --- /dev/null +++ b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaCondition.kt @@ -0,0 +1,11 @@ +package kr.summitsystems.springbukkit.support.folia + +import org.springframework.context.annotation.Condition +import org.springframework.context.annotation.ConditionContext +import org.springframework.core.type.AnnotatedTypeMetadata + +class FoliaCondition : Condition { + override fun matches(context: ConditionContext, metadata: AnnotatedTypeMetadata): Boolean { + return FoliaUtils.isUsingFolia() + } +} \ No newline at end of file diff --git a/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaConfiguration.kt b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaConfiguration.kt index 72dfe18..7c69069 100644 --- a/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaConfiguration.kt +++ b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaConfiguration.kt @@ -2,15 +2,18 @@ package kr.summitsystems.springbukkit.support.folia import kr.summitsystems.springbukkit.core.scheduler.BukkitTaskScheduler import org.bukkit.plugin.Plugin -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Primary @Configuration class FoliaConfiguration { - @ConditionalOnClass(name = ["io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler"]) + @Primary + @ConditionalOnFolia @Bean - fun foliaBukkitTaskScheduler(plugin: Plugin): BukkitTaskScheduler { + fun foliaBukkitTaskScheduler( + plugin: Plugin + ): BukkitTaskScheduler { return FoliaBukkitTaskScheduler(plugin) } } \ No newline at end of file diff --git a/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaUtils.kt b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaUtils.kt new file mode 100644 index 0000000..7691693 --- /dev/null +++ b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/FoliaUtils.kt @@ -0,0 +1,16 @@ +package kr.summitsystems.springbukkit.support.folia + +object FoliaUtils { + fun isUsingFolia(): Boolean { + return classExists("io.papermc.paper.threadedregions.RegionizedServer") + } + + private fun classExists(className: String): Boolean { + return try { + Class.forName(className) + true + } catch (ex: ClassNotFoundException) { + false + } + } +} \ No newline at end of file diff --git a/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/coroutines/FoliaMainDispatcherFactory.kt b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/coroutines/FoliaMainDispatcherFactory.kt index 1ce3d82..c06c43a 100644 --- a/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/coroutines/FoliaMainDispatcherFactory.kt +++ b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/folia/coroutines/FoliaMainDispatcherFactory.kt @@ -3,6 +3,7 @@ package kr.summitsystems.springbukkit.support.folia.coroutines import kotlinx.coroutines.InternalCoroutinesApi import kotlinx.coroutines.MainCoroutineDispatcher import kotlinx.coroutines.internal.MainDispatcherFactory +import kr.summitsystems.springbukkit.support.folia.FoliaUtils @OptIn(InternalCoroutinesApi::class) class FoliaMainDispatcherFactory : MainDispatcherFactory { @@ -10,7 +11,7 @@ class FoliaMainDispatcherFactory : MainDispatcherFactory { get() = -1 override fun createDispatcher(allFactories: List): MainCoroutineDispatcher { - return if (classExists("io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler")) { + return if (FoliaUtils.isUsingFolia()) { FoliaMainDispatcher() } else { allFactories @@ -18,13 +19,4 @@ class FoliaMainDispatcherFactory : MainDispatcherFactory { .createDispatcher(allFactories) } } - - private fun classExists(className: String): Boolean { - return try { - Class.forName(className) - true - } catch (ex: ClassNotFoundException) { - false - } - } } \ No newline at end of file diff --git a/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/protocollib/ProtocolLibConfiguration.kt b/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/protocollib/ProtocolLibConfiguration.kt deleted file mode 100644 index 986ea4e..0000000 --- a/spring-bukkit-support/src/main/kotlin/kr/summitsystems/springbukkit/support/protocollib/ProtocolLibConfiguration.kt +++ /dev/null @@ -1,16 +0,0 @@ -package kr.summitsystems.springbukkit.support.protocollib - -import com.comphenix.protocol.ProtocolLibrary -import com.comphenix.protocol.ProtocolManager -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.Configuration - -@Configuration -class ProtocolLibConfiguration { - @ConditionalOnClass(name = ["com.comphenix.protocol.ProtocolManager"]) - @Bean - fun protocolManager(): ProtocolManager { - return ProtocolLibrary.getProtocolManager() - } -} \ No newline at end of file