Skip to content

Commit 323ac35

Browse files
committed
Enter the first round of testing.
1 parent 11cdc32 commit 323ac35

File tree

14 files changed

+98
-73
lines changed

14 files changed

+98
-73
lines changed

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/FastScript.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class FastScript(val plugin: ScriptPlugin) {
2929

3030
printLogo()
3131

32-
plugin.server.console.sendMessage(FormatHeader.INFO, "Initializing...")
32+
plugin.server.console.sendMessage("§3FastScript initializing...")
3333

3434
if (!plugin.dataFolder.exists()) {
3535
plugin.dataFolder.mkdirs()
@@ -58,6 +58,7 @@ class FastScript(val plugin: ScriptPlugin) {
5858
plugin.dataFolder.mkdirs()
5959
}
6060
plugin.reload()
61+
expansionManager.reload()
6162
initInternalScripts()
6263
scriptManager.loadScripts()
6364
}

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
package me.scoretwo.fastscript.api.expansion
22

3+
import me.scoretwo.fastscript.FastScript
4+
import me.scoretwo.fastscript.api.format.FormatHeader
35
import me.scoretwo.fastscript.expansion.javascript.JavaScriptExpansion
6+
import me.scoretwo.fastscript.plugin
7+
import me.scoretwo.fastscript.sendMessage
8+
import me.scoretwo.utils.syntaxes.findClass
9+
import java.io.File
10+
import java.net.URL
11+
import java.net.URLClassLoader
412

513
class ExpansionManager {
614

15+
val expansionFolder = File(plugin.dataFolder, "expansions")
716
val expansions = mutableSetOf<FastScriptExpansion>()
817

918
init {
1019
register(JavaScriptExpansion())
20+
21+
if (!expansionFolder.exists()) expansionFolder.mkdirs()
1122
}
1223

1324
fun register(expansion: FastScriptExpansion) {
@@ -18,6 +29,40 @@ class ExpansionManager {
1829
expansions.remove(expansion)
1930
}
2031

32+
@Synchronized
33+
fun reload() {
34+
expansions.clear()
35+
36+
register(JavaScriptExpansion())
37+
38+
if (!expansionFolder.exists())
39+
expansionFolder.mkdirs()
40+
41+
for (file in expansionFolder.listFiles() ?: arrayOf()) {
42+
val expansionClass = try {
43+
file.findClass(FastScriptExpansion::class.java)
44+
} catch (e: Exception) {
45+
e.printStackTrace()
46+
plugin.server.console.sendMessage(FormatHeader.ERROR, "An exception occurred when loading extended ${file.name}, the reason:\n${e.message}")
47+
continue
48+
}
49+
50+
if (expansionClass == null) {
51+
plugin.server.console.sendMessage(FormatHeader.ERROR, "Unable to load the extension ${file.name} because it has no FastScriptExpansion class available!")
52+
continue
53+
}
54+
55+
try {
56+
expansions.add(expansionClass.newInstance())
57+
} catch (e: Exception) {
58+
e.printStackTrace()
59+
plugin.server.console.sendMessage(FormatHeader.ERROR, "An exception occurred when loading extended ${file.name}, the reason:\n${e.message}")
60+
}
61+
}
62+
63+
64+
}
65+
2166
fun unregister(name: String) = expansions.forEach {
2267
if (it.name == name) {
2368
expansions.remove(it)

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/api/language/LanguageManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package me.scoretwo.fastscript.api.language
22

33
class LanguageManager {
44

5+
val defaultLanguage = Language()
56
val languages = mutableMapOf<String, Language>().also {
6-
it["en_US"] = Language()
7+
it["en_US"] = defaultLanguage
78
}
89

9-
var current = languages["en_US"]!!
10-
10+
var current = defaultLanguage
1111

1212
operator fun set(node: String, any: Any?) = current.set(node, any)
1313

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/config/MessageConfig.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.

FastScript-plugin/build.gradle.kts

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
3535
include(dependency("org.jetbrains.kotlin:kotlin-stdlib"))
3636

3737
include(dependency(":FastScript-common"))
38-
include(dependency(":version-control:FastScript-bukkit"))
39-
include(dependency(":version-control:FastScript-bungee"))
40-
include(dependency(":version-control:FastScript-sponge"))
41-
include(dependency(":version-control:FastScript-velocity"))
38+
include(dependency(":FastScript-bukkit"))
39+
include(dependency(":FastScript-bungee"))
40+
include(dependency(":FastScript-sponge"))
41+
include(dependency(":FastScript-velocity"))
4242

4343
include(dependency("me.scoretwo:commons-velocity-plugin:${rootProject.extra.get("commonsVersion")}"))
4444
include(dependency("me.scoretwo:commons-sponge-plugin:${rootProject.extra.get("commonsVersion")}"))
@@ -59,4 +59,44 @@ tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
5959
relocate("org.bstats","me.scoretwo.utils.libs.org.bstats")
6060

6161
classifier = null
62+
}
63+
64+
tasks.processResources {
65+
from("src/main/resources") {
66+
include("plugin.yml")
67+
expand(mapOf(
68+
"name" to rootProject.name,
69+
"main" to "${rootProject.group}.${rootProject.name.toLowerCase()}.bukkit.BukkitBootStrap",
70+
"version" to rootProject.version,
71+
"description" to rootProject.description
72+
))
73+
}
74+
from("src/main/resources") {
75+
include("bungee.yml")
76+
expand(mapOf(
77+
"name" to project.name,
78+
"main" to "${rootProject.group}.${rootProject.name.toLowerCase()}.bungee.BungeeBootStrap",
79+
"version" to project.version,
80+
"description" to project.description
81+
))
82+
}
83+
from("src/main/resources") {
84+
include("mcmod.info")
85+
expand(mapOf(
86+
"id" to project.name.toLowerCase(),
87+
"name" to project.name,
88+
"version" to project.version,
89+
"description" to project.description
90+
))
91+
}
92+
from("src/main/resources") {
93+
include("velocity-plugin.json")
94+
expand(mapOf(
95+
"id" to project.name.toLowerCase(),
96+
"name" to project.name,
97+
"version" to project.version,
98+
"main" to "${rootProject.group}.${rootProject.name.toLowerCase()}.velocity.VelocityBootStrap",
99+
"description" to project.description
100+
))
101+
}
62102
}

version-control/FastScript-bungee/src/main/resources/bungee.yml renamed to FastScript-plugin/src/main/resources/bungee.yml

File renamed without changes.

version-control/FastScript-sponge/src/main/resources/mcmod.info renamed to FastScript-plugin/src/main/resources/mcmod.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"name": "${name}",
55
"version": "${version}",
66
"description": "${description}",
7-
"authorList": ["Score2"],
7+
"authorList": ["Score2"]
88
}
99
]

version-control/FastScript-bukkit/src/main/resources/plugin.yml renamed to FastScript-plugin/src/main/resources/plugin.yml

File renamed without changes.

version-control/FastScript-velocity/src/main/resources/velocity-plugin.json renamed to FastScript-plugin/src/main/resources/velocity-plugin.json

File renamed without changes.

settings.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ class MergeBuilder {
5151
return MergeBuilder(nodes, addNodes)
5252
}
5353
}
54-
5554
include("FastScript-common")
56-
include("FastScript-plugin")
5755

5856
MergeBuilder("version-control").also {
5957
it.add("FastScript-bukkit")
6058
it.add("FastScript-bungee")
6159
it.add("FastScript-sponge")
6260
it.add("FastScript-velocity")
63-
}
61+
}
62+
63+
include("FastScript-plugin")

0 commit comments

Comments
 (0)