<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[自动重载配置]]></title><description><![CDATA[<pre><code>
    lateinit var service: WatchService

    override fun onEnable() {
        DebugSetting.reload()

        service = configFolderPath.fileSystem.newWatchService()
        configFolderPath.register(
            service,
            arrayOf(StandardWatchEventKinds.ENTRY_MODIFY),
            SensitivityWatchEventModifier.LOW
        )

        launch {
            while (isActive) {
                val key = runInterruptible(Dispatchers.IO, service::take)
                for (event in key.pollEvents()) {
                    val path = event.context() as? Path ?: continue
                    if (path.extension != "yml") continue
                    when (val name = path.nameWithoutExtension) {
                        DebugSetting.saveName -&gt; launch {
                            logger.info { "$name reload for ${event.kind().name()} - ${event.count()}." }
                            try {
                                DebugSetting.reload()
                            } catch (cause: Throwable) {
                                logger.warning({ "$name reload failure." }, cause)
                            }
                        }
                        else -&gt; Unit
                    }
                }
                key.reset()
            }
        }
    }
    override fun onDisable() {
        service.close()
    }
</code></pre>
]]></description><link>https://mirai.mamoe.net/topic/1453/自动重载配置</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Mar 2026 11:35:44 GMT</lastBuildDate><atom:link href="https://mirai.mamoe.net/topic/1453.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Aug 2022 06:31:42 GMT</pubDate><ttl>60</ttl></channel></rss>