Skip to content

Commit

Permalink
Fix shutdown issue when server is reloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
vjh0107 committed Feb 5, 2024
1 parent 617112c commit 9cfb018
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kotlin.code.style=official

project.group=kr.summitsystems
project.version=0.0.9-beta1
project.version=0.0.9-beta2
project.name=spring-bukkit
project.url=https://github.com/summit-systems/spring-bukkit
project.url.scm=https://github.com/summit-systems/spring-bukkit.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ abstract class SpringBukkitPlugin : JavaPlugin(), ApplicationContextInitializer<
final override fun onDisable() {
disposables.forEach { it.dispose() }

applicationContext?.registerShutdownHook()
applicationContext?.close()
}

final override fun dispose() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,61 @@ package kr.summitsystems.springbukkit.core.support.config
import kr.summitsystems.springbukkit.core.support.SpringBukkitConversionService
import org.bukkit.Bukkit
import org.bukkit.Server
import org.bukkit.configuration.file.FileConfiguration
import org.bukkit.configuration.file.YamlConfiguration
import org.bukkit.plugin.Plugin
import org.bukkit.plugin.PluginDescriptionFile
import org.bukkit.plugin.PluginManager
import org.bukkit.plugin.ServicesManager
import org.springframework.beans.factory.config.BeanDefinition
import org.springframework.beans.factory.support.AbstractBeanDefinition
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Role
import org.springframework.core.convert.ConversionService

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Role(BeanDefinition.ROLE_SUPPORT)
@Configuration
class BukkitConfiguration {
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Bean
@Role(BeanDefinition.ROLE_SUPPORT)
@Bean(destroyMethod = "")
fun bukkitServer(): Server {
return Bukkit.getServer()
}

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Role(BeanDefinition.ROLE_SUPPORT)
@Bean
fun bukkitPluginManager(server: Server): PluginManager {
return server.pluginManager
}

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Role(BeanDefinition.ROLE_SUPPORT)
@Bean
fun bukkitServicesManager(server: Server): ServicesManager {
return server.servicesManager
}

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Role(BeanDefinition.ROLE_SUPPORT)
@Bean
fun pluginDescriptionFile(plugin: Plugin): PluginDescriptionFile {
return plugin.description
}

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Role(BeanDefinition.ROLE_SUPPORT)
@Bean
fun pluginFileConfiguration(plugin: Plugin): FileConfiguration {
return plugin.config
}

@Role(BeanDefinition.ROLE_SUPPORT)
@ConditionalOnMissingBean(Plugin::class)
@Bean
fun plugin(): Plugin {
throw NotImplementedError()
throw IllegalStateException()
}

@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@Role(BeanDefinition.ROLE_SUPPORT)
@Bean
fun conversionService(): ConversionService {
return SpringBukkitConversionService()
Expand Down

0 comments on commit 9cfb018

Please sign in to comment.