feat(binding): add AsyncPlugin as entry point for Async library

Introduces AsyncPlugin to serve as a standalone library-plugin entry point for the Async library. This allows other plugins to depend on Async without bundling it directly. The plugin installs a disconnect hook on start and ensures proper shutdown of tracked scopes.
This commit is contained in:
2026-04-28 18:25:22 +02:00
parent 15e6b9692b
commit a0ad12b208
2 changed files with 39 additions and 0 deletions
@@ -0,0 +1,23 @@
package com.mythlane.async.binding
import com.hypixel.hytale.server.core.plugin.JavaPlugin
import com.hypixel.hytale.server.core.plugin.JavaPluginInit
import com.mythlane.async.Async
/**
* Standalone library-plugin entry point. Drop the shaded jar in `mods/` and
* other plugins can depend on Async without bundling it themselves.
*
* Installs the disconnect hook on start and drains every tracked scope on
* shutdown. Plugins that bundle Async directly should keep calling
* [installAsync] and [Async.shutdown] themselves and not rely on this class.
*/
class AsyncPlugin(init: JavaPluginInit) : JavaPlugin(init) {
override fun start() {
installAsync()
}
override fun shutdown() {
Async.shutdown()
}
}