11package me.scoretwo.fastscript.api.script
22
3+ import me.scoretwo.utils.bukkit.configuration.yaml.ConfigurationSection
4+ import me.scoretwo.utils.bukkit.configuration.yaml.patchs.getLowerCaseNode
35import javax.security.auth.login.Configuration
46
57interface ScriptDescription {
@@ -14,6 +16,26 @@ interface ScriptDescription {
1416 val authors: Array <String >
1517
1618 companion object {
19+
20+ fun fromSection (section : ConfigurationSection ) = parseDescription(
21+ section.getString(section.getLowerCaseNode(" name" )),
22+ section.getString(section.getLowerCaseNode(" main" )),
23+ section.getString(section.getLowerCaseNode(" version" )),
24+ section.getString(section.getLowerCaseNode(" description" )),
25+ if (section.isList(section.getLowerCaseNode(" authors" )))
26+ section.getStringList(section.getLowerCaseNode(" authors" ))!!
27+ else
28+ mutableListOf (section[section.getLowerCaseNode(" authors" )])
29+ )
30+
31+ fun parseDescription (
32+ name : String ,
33+ main : String ,
34+ version : String? = null,
35+ description : String? = null,
36+ authors : MutableList <String > = mutableListOf()
37+ ) = parseDescription(name, main, version, description, * authors.toTypedArray())
38+
1739 fun parseDescription (
1840 name : String ,
1941 main : String ,
@@ -28,5 +50,7 @@ interface ScriptDescription {
2850 override val authors: Array <String > = arrayOf(* authors)
2951
3052 }
53+
54+
3155 }
3256}
0 commit comments