walkmc.annotation.Module.kt Maven / Gradle / Ivy
package walkmc.annotation
import com.google.devtools.ksp.symbol.*
import org.bukkit.plugin.*
import walkmc.processor.*
/**
* A module annotation represents a plugin settings.
*
* All settings configured by this module will be inserted in the `plugin.yml`.
* Note that this will be processed in compile-time, using the [ModuleProcessor]
*/
@Target(AnnotationTarget.CLASS)
annotation class Module(
val name: String = "",
val version: String = "1.0.0",
val author: String = "",
val description: String = "",
val website: String = "",
val load: PluginLoadOrder = PluginLoadOrder.POSTWORLD,
val authors: Array = [],
val depend: Array = [],
val softDepend: Array = [],
val loadBefore: Array = [],
)
/**
* A module prototype for serializing plugin.yml with [Module].
*/
class ModuleInfo(
val main: String = "",
val name: String = "",
val version: String = "1.0.0",
val author: String = "",
val description: String = "",
val website: String = "",
val load: PluginLoadOrder = PluginLoadOrder.POSTWORLD,
val authors: Array = emptyArray(),
val depend: Array = emptyArray(),
val softDepend: Array = emptyArray(),
val loadBefore: Array = emptyArray(),
) {
constructor(template: KSClassDeclaration, plugin: Module) : this(
template.qualifiedName!!.asString(),
plugin.name.ifBlank { template.simpleName.asString() },
plugin.version,
plugin.author,
plugin.description,
plugin.website,
plugin.load,
plugin.authors,
plugin.depend,
plugin.softDepend,
plugin.loadBefore
)
fun toMap(): Map = LinkedHashMap().apply {
put("main", main)
put("name", name)
put("version", version)
put("author", author)
put("description", description)
put("website", website)
put("load", load.name)
put("authors", authors)
put("depend", arrayOf(*depend, "WalkResources"))
put("softdepend", softDepend)
put("loadbefore", loadBefore)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy