Skip to content

Commit 614318c

Browse files
committed
Fix bugs.
1 parent 25f2443 commit 614318c

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

common/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ dependencies {
1616
compileOnly("org.apache.commons:commons-lang3:3.10")
1717
compileOnly("com.google.code.gson:gson:2.8.6")
1818
compileOnly("org.slf4j:slf4j-log4j12:1.7.30")
19+
20+
implementation("org.jetbrains.kotlin:kotlin-script-util:${KotlinVersion.CURRENT}")
21+
implementation("org.jetbrains.kotlin:kotlin-compiler:${KotlinVersion.CURRENT}")
22+
implementation("commons-cli:commons-cli:1.4")
23+
1924
implementation("commons-io:commons-io:2.7")
2025
implementation("me.scoretwo:commons-syntaxes:${rootProject.extra.get("commonsVersion")}")
2126
implementation("me.scoretwo:commons-command:${rootProject.extra.get("commonsVersion")}")

common/src/main/kotlin/me/scoretwo/fastscript/api/expansion/ExpansionManager.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package me.scoretwo.fastscript.api.expansion
22

3+
import me.scoretwo.fastscript.expansion.javascript.JavaScriptExpansion
4+
import me.scoretwo.fastscript.expansion.kotlinscript.KotlinScriptExpansion
5+
36
class ExpansionManager {
47

58
val expansions = mutableSetOf<FastScriptExpansion>()
69

710
init {
8-
11+
register(KotlinScriptExpansion())
12+
register(JavaScriptExpansion())
913
}
1014

1115
fun register(expansion: FastScriptExpansion) {

common/src/main/kotlin/me/scoretwo/fastscript/api/script/ScriptDescription.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ interface ScriptDescription {
2323
section.getString(section.getLowerCaseNode("version")),
2424
section.getString(section.getLowerCaseNode("description")),
2525
if (section.isList(section.getLowerCaseNode("authors")))
26-
section.getStringList(section.getLowerCaseNode("authors"))!!
26+
section.getStringList(section.getLowerCaseNode("authors"))
2727
else
28-
mutableListOf(section[section.getLowerCaseNode("authors")])
28+
mutableListOf(section.getString(section.getLowerCaseNode("authors")))
2929
)
3030

3131
fun parseDescription(

common/src/main/kotlin/me/scoretwo/fastscript/api/script/ScriptManager.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package me.scoretwo.fastscript.api.script
33
import me.scoretwo.fastscript.FastScript
44
import me.scoretwo.fastscript.plugin
55
import me.scoretwo.fastscript.settings
6+
import me.scoretwo.utils.bukkit.configuration.yaml.ConfigurationSection
67
import me.scoretwo.utils.bukkit.configuration.yaml.patchs.getLowerCaseNode
78
import java.io.File
89

910
class ScriptManager {
1011

11-
val defaultScriptPath = File(plugin.dataFolder, "scripts")
12+
val folders = mutableListOf(File(plugin.dataFolder, "scripts"))
1213

1314
val scripts = mutableMapOf<String, Script>()
1415

@@ -43,12 +44,17 @@ class ScriptManager {
4344
}
4445
}
4546

47+
fun isConfigScriptOption(section: ConfigurationSection) =
48+
section.isString(section.getLowerCaseNode("name")) &&
49+
(section.isString(section.getLowerCaseNode("version")) || section.isInt(section.getLowerCaseNode("version"))) &&
50+
section.isString(section.getLowerCaseNode("main"))
51+
4652
fun selectScriptFiles(file: File): MutableList<File> = mutableListOf<File>().let { files ->
4753
if (file.isDirectory) {
4854
file.listFiles()?.forEach {
4955
files.addAll(selectScriptFiles(it))
5056
}
51-
} else if (file.name.endsWith(".js", true)) {
57+
} else if (file.name.endsWith(".yml", true)) {
5258
files.add(file)
5359
}
5460
files
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package me.scoretwo.fastscript.expansion.kotlinscript
2+
3+
import me.scoretwo.fastscript.expansion.typeengine.TypeEngineExpansion
4+
5+
class KotlinScriptExpansion: TypeEngineExpansion() {
6+
override val name = "KotlinScript"
7+
override val sign = "kts"
8+
override val fileSuffix = "kts"
9+
}

0 commit comments

Comments
 (0)