Skip to content

Commit bd97261

Browse files
committed
Fixed bugs.
1 parent d308636 commit bd97261

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+166
-83
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class FastScript(val plugin: ScriptPlugin) {
6767
}
6868

6969
fun reloadLanguage() {
70-
languages.current = languages.languages[settings.getString("Options.Language")] ?: languages.defaultLanguage.also {
70+
languages.current = languages.languages[settings.getString("Options.Language")]?.reload() ?: languages.defaultLanguage.reload().also {
7171
plugin.server.console.sendMessage(FormatHeader.ERROR, "Language loading failed. The file may not exist. The default language will be used: ${it.name}")
7272
}
7373
}

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/api/config/Config.kt renamed to common/src/main/kotlin/me/scoretwo/fastscript/api/config/Config.kt

File renamed without changes.

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/api/exception/ProcessException.kt renamed to common/src/main/kotlin/me/scoretwo/fastscript/api/exception/ProcessException.kt

File renamed without changes.

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/api/exception/ScriptException.kt renamed to common/src/main/kotlin/me/scoretwo/fastscript/api/exception/ScriptException.kt

File renamed without changes.

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/api/exception/ScriptNotFound.kt renamed to common/src/main/kotlin/me/scoretwo/fastscript/api/exception/ScriptNotFound.kt

File renamed without changes.

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/api/expansion/ExpansionDescription.kt renamed to common/src/main/kotlin/me/scoretwo/fastscript/api/expansion/ExpansionDescription.kt

File renamed without changes.

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

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

3-
import me.scoretwo.fastscript.FastScript
3+
import me.scoretwo.fastscript.*
44
import me.scoretwo.fastscript.api.format.FormatHeader
55
import me.scoretwo.fastscript.api.plugin.ScriptPluginState
66
import me.scoretwo.fastscript.api.utils.ExecType
77
import me.scoretwo.fastscript.api.utils.process.ProcessResult
88
import me.scoretwo.fastscript.api.utils.process.ProcessResultType
99
import me.scoretwo.fastscript.expansion.javascript.JavaScriptExpansion
10-
import me.scoretwo.fastscript.plugin
11-
import me.scoretwo.fastscript.sendMessage
1210
import me.scoretwo.utils.bukkit.configuration.yaml.file.YamlConfiguration
1311
import java.io.File
1412
import java.net.URL
@@ -74,14 +72,24 @@ class ExpansionManager {
7472
try {
7573
expansions.add(rawExpansion.second!!.reload())
7674
success++
77-
} catch (e: Exception) {
75+
} catch (e: Throwable) {
7876
fail++
79-
plugin.server.console.sendMessage(FormatHeader.ERROR, "An exception occurred when loading extended ${file.name}, reason:\n§8${e.stackTraceToString()}")
77+
// plugin.server.console.sendMessage(FormatHeader.ERROR, "An exception occurred while loading expansion ${file.name}, reason:\n§8${e.stackTraceToString()}")
8078
}
8179
}
8280
val format = if (FastScript.stats == ScriptPluginState.RUNNING) FormatHeader.INFO else FormatHeader.TREE
8381

84-
plugin.server.console.sendMessage(format, "Loaded §b$total §7expansions, §a$success §7successes${if (fail == 0) "" else ", §c$fail §7failures"}.§8(${System.currentTimeMillis() - startTime}ms)")
82+
val placeholders = mapOf(
83+
"id" to "expansions",
84+
"total" to "$total",
85+
"success" to "$success",
86+
"fail" to "$fail",
87+
"millisecond" to "${System.currentTimeMillis() - startTime}"
88+
)
89+
if (fail == 0)
90+
plugin.server.console.sendMessage(format, languages["LOADED-COUNTS-PROCESS-SUCCESS"].setPlaceholder(placeholders))
91+
else
92+
plugin.server.console.sendMessage(format, languages["LOADED-COUNTS-PROCESS-HAS-FAILED"].setPlaceholder(placeholders))
8593
}
8694

8795
private fun fromFileExpansion(file: File): Pair<ProcessResult, FastScriptExpansion?> {
@@ -95,32 +103,59 @@ class ExpansionManager {
95103
val jarFile = JarFile(file)
96104
description = try {
97105
ExpansionDescription.readConfig(YamlConfiguration().also { it.load(jarFile.getInputStream(jarFile.getJarEntry("expansion.yml")).reader()) })
98-
} catch (e: Exception) {
99-
plugin.server.console.sendMessage(FormatHeader.ERROR, "An error occurred while loading the expansion '${file.name}' description file, reason:\n§8${e.stackTraceToString()}")
106+
} catch (e: Throwable) {
107+
plugin.server.console.sendMessage(FormatHeader.ERROR, languages["EXPANSION.ERROR-BY-CAUSE.LOAD-DESCRIPTION-FILE-ERROR"].setPlaceholder(
108+
mapOf(
109+
"file_name" to file.name,
110+
"reason" to e.stackTraceToString()
111+
)
112+
))
100113
return Pair(ProcessResult(ProcessResultType.FAILED), null)
101114
}
102115
val clazz = try {
103116
Class.forName(description.main)
104-
} catch (e: Exception) {
105-
plugin.server.console.sendMessage(FormatHeader.ERROR, "An error occurred while loading the main class ${description.main} of expansion '${file.name}', reason:\n§8${e.stackTraceToString()}")
117+
} catch (e: Throwable) {
118+
plugin.server.console.sendMessage(FormatHeader.ERROR, languages["EXPANSION.ERROR-BY-CAUSE.LOAD-MAIN-CLASS-ERROR"].setPlaceholder(
119+
mapOf(
120+
"file_name" to file.name,
121+
"description_main" to description.main,
122+
"reason" to e.stackTraceToString()
123+
)
124+
))
106125
return Pair(ProcessResult(ProcessResultType.FAILED), null)
107126
}
108127

109128
val instance = try {
110129
clazz.newInstance()
111-
} catch (e: Exception) {
112-
plugin.server.console.sendMessage(FormatHeader.ERROR, "An error occurred while loading the main class ${description.main} of expansion '${file.name}', reason:\n§8${e.stackTraceToString()}")
130+
} catch (e: Throwable) {
131+
plugin.server.console.sendMessage(FormatHeader.ERROR, languages["EXPANSION.ERROR-BY-CAUSE.LOAD-MAIN-CLASS-ERROR"].setPlaceholder(
132+
mapOf(
133+
"file_name" to file.name,
134+
"description_main" to description.main,
135+
"reason" to e.stackTraceToString()
136+
)
137+
))
113138
return Pair(ProcessResult(ProcessResultType.FAILED), null)
114139
}
115140

116141
if (instance !is FastScriptExpansion) {
117-
plugin.server.console.sendMessage(FormatHeader.ERROR, "An error occurred while loading the main class ${description.main} of expansion '${file.name}', reason: §cThe main class does not depend on FastScriptExpansion.")
142+
plugin.server.console.sendMessage(FormatHeader.ERROR, languages["EXPANSION.ERROR-BY-CAUSE.LOAD-MAIN-CLASS-MAIN-NOT-DEPEND"].setPlaceholder(
143+
mapOf(
144+
"file_name" to file.name,
145+
"description_main" to description.main
146+
)
147+
))
118148
return Pair(ProcessResult(ProcessResultType.FAILED), null)
119149
}
120150

121151
clazz.asSubclass(FastScriptExpansion::class.java)
122-
} catch (e: Exception) {
123-
plugin.server.console.sendMessage(FormatHeader.ERROR, "An exception occurred when loading extended '${file.name}', reason:\n§8${e.stackTraceToString()}")
152+
} catch (e: Throwable) {
153+
plugin.server.console.sendMessage(FormatHeader.ERROR, languages["EXPANSION.ERROR-BY-CAUSE.LOAD-ERROR"].setPlaceholder(
154+
mapOf(
155+
"file_name" to file.name,
156+
"reason" to e.stackTraceToString()
157+
)
158+
))
124159
return Pair(ProcessResult(ProcessResultType.FAILED), null)
125160
}
126161

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/api/expansion/FastScriptExpansion.kt renamed to common/src/main/kotlin/me/scoretwo/fastscript/api/expansion/FastScriptExpansion.kt

File renamed without changes.

FastScript-common/src/main/kotlin/me/scoretwo/fastscript/api/format/FormatHeader.kt renamed to common/src/main/kotlin/me/scoretwo/fastscript/api/format/FormatHeader.kt

File renamed without changes.

0 commit comments

Comments
 (0)