Skip to content

Commit d308636

Browse files
committed
Update languages.
1 parent 3ab69b4 commit d308636

File tree

9 files changed

+245
-87
lines changed

9 files changed

+245
-87
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ fun GlobalSender.sendMessage(text: String, placeholders: Map<String, String>) {
157157

158158
fun String.setPlaceholder(player: GlobalPlayer) = FastScript.instance.setPlaceholder(player, this)
159159

160-
fun String.setPlaceholder(placeholders: Map<String, String>): String {
161-
var rawText = this
160+
fun String.setPlaceholder(placeholders: Map<String, String>, player: GlobalPlayer? = null): String {
161+
var rawText = if (player == null) this else setPlaceholder(player)
162162
placeholders.forEach {
163163
rawText = rawText.replace("{${it.key}}", it.value)
164164
}

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

Lines changed: 102 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Language {
2222
config.load(file)
2323
val version = config.getString(config.getLowerCaseNode("version"))
2424

25-
if (version == null || languages.version.toString() != version) {
25+
if (version == null || languages.version != version) {
2626
languages.defaultLanguage.config.getKeys(true).forEach { if (!config.contains(it)) { config.set(it, languages.defaultLanguage.config[it]) } }
2727
config.save(file)
2828
}
@@ -47,25 +47,121 @@ class Language {
4747
it.set("HOOKED", "&7[&3Fast&bScript&7] &6HOOKED &8| &7")
4848
it.set("DEBUG", "&7[&3Fast&bScript&7] &3DEBUG &8| &7")
4949
}
50+
it["SUBSTANTIVE"] = YamlConfiguration().also {
51+
it["ARGS"] = "args"
52+
it["USAGE"] = "usage"
53+
it["EVALUATED"] = "EVALUATED"
54+
}
5055
it["COMMAND-NEXUS"] = YamlConfiguration().also {
51-
it["SUBSTANTIVE"] = YamlConfiguration().also {
52-
it["ARGS"] = "args"
53-
}
5456
it["TIPS"] = YamlConfiguration().also {
5557
it["ONLY-CONSOLE"] = "This command can only be executed on the console."
5658
it["ONLY-PLAYER"] = "This command can only be executed by the player."
5759
it["NO-PERMISSION"] = "You do not have permission to execute the command."
58-
it["UNKNOWN-USAGE"] = "&cUsage &e{usage_error} &cis incorrect, you may want to use &e{usage_guess}"
60+
it["UNKNOWN-USAGE"] = "&cUsage &e{usage_error} &cis incorrect, you may want to use &e{usage_guess}&c."
5961
}
60-
it["HELP-GENERATION"] = YamlConfiguration().also {
62+
it["HELPER"] = YamlConfiguration().also {
6163
it["NOT-FOUND-COMMANDS"] = "&7No command data available."
6264
it["CLICK-INSERT-COMMAND"] = "&7Click insert command: &f/{command}"
6365
it["CLICK-TO-GO-URL"] = "&7Click to go to url: &f{url}"
6466
}
6567
it["COMMANDS"] = YamlConfiguration().also {
68+
it["EXPANSION"] = YamlConfiguration().also {
69+
it["NOT-FOUND-NAME-OR-SIGN"] = "Cannot find the extension name or sign §c{expansion_name}§7! Please check the name."
70+
it["LOADED-EXPANSIONS"] = "Currently available extensions: &6{expansions}"
71+
it["DESCRIPTION"] = "View all expansions or operations."
72+
it["SUB-EXPANSION-DESCRIPTION"] = "About {expansion_name} commands."
73+
74+
it["INFO"] = YamlConfiguration().also {
75+
it["DESCRIPTION"] = "View the information of this expansion."
76+
it["TITLE"] = "Expansion &6{expansion_name}&7's information."
77+
it["TEXTS"] = mutableListOf(
78+
" &3&l* &7Sign: &a{expansion_sign}",
79+
" &3&l* &7File suffix: &a{expansion_file_suffix}",
80+
" &3&l* &7Bind scripts: &f{expansion_bind_scripts}",
81+
"",
82+
" &7About expansions &6{expansion_name} &7more help, please enter:&8(Bad grammar)"
83+
84+
)
85+
}
86+
it["EVALUATE"] = YamlConfiguration().also {
87+
it["DESCRIPTION"] = "Evaluate the specified content to get the return value (':s' added at the end does not return a message)"
88+
it["EVALUATE-RESULT"] = "Use extension &6{expansion_name} &7to evaluate the result of the content: &b{result}"
89+
}
90+
}
91+
it["SCRIPT"] = YamlConfiguration().also {
92+
it["DESCRIPTION"] = "View the information of this script."
93+
it["NOT-FOUND-SCRIPT"] = "Not found script &b{script_name}&7! Please check the name."
94+
it["SUB-SCRIPT-DESCRIPTION"] = "About {script_name} commands."
95+
96+
it["EXECUTE"] = YamlConfiguration().also {
97+
it["DESCRIPTION"] = "Execute the specified content to get the return value (':s' added at the end does not return a message)"
98+
99+
it["EXECUTE-RESULT"] = "Execute script &b{script_name} &7used expansion &6{expansion_name} to return result: {result}"
100+
}
101+
it["EVALUATE"] = YamlConfiguration().also {
102+
it["DESCRIPTION"] = "Evaluate the specified content to get the return value (':s' added at the end does not return a message)"
103+
104+
it["EXECUTE-RESULT"] = "Evaluate script &b{script_name} &7used expansion &6{expansion_name} to return result: {result}"
105+
}
106+
it["RELOAD"] = YamlConfiguration().also {
107+
it["DESCRIPTION"] = "Reload this script."
108+
it["RELOADED-SCRIPT"] = "Reloaded script &b{script_name} &7successful!"
109+
}
110+
111+
it["INFO"] = YamlConfiguration().also {
112+
it["DESCRIPTION"] = "View the information of this expansion."
113+
it["TITLE"] = "Script &b{script_name}&7's information."
114+
it["TEXTS"] = mutableListOf(
115+
" &3&l* &7Version: &2{script_version}",
116+
" &3&l* &7Authors: &3{script_authors}",
117+
" &3&l* &7Description: &f{script_description}",
118+
" &3&l* &7Main: &f{script_main}",
119+
" &3&l* &7Bind expansions: &6{script_bind_expansions}",
120+
"",
121+
" &7About script &6{script_name} &7more help, please enter:&8(Bad grammar)"
66122

123+
)
124+
}
125+
126+
}
127+
it["RELOAD"] = YamlConfiguration().also {
128+
it["DESCRIPTION"] = "Reload configuration files or settings."
129+
it["MODE"] = YamlConfiguration().also {
130+
it["ALL"] = "Reload all."
131+
it["CONFIG"] = "Reload configuration file."
132+
it["SCRIPT"] = "Reload script file."
133+
it["PLUGIN"] = "Reload plugin settings."
134+
}
135+
it["LOADED-ALL"] = "Loaded all settings successful."
136+
it["LOADED-CONFIG"] = "Loaded configuration file successful."
137+
it["LOADED-SCRIPT"] = "Loaded script file successful."
138+
it["LOADED-PLUGIN"] = "Loaded plugin settings successful."
139+
}
140+
}
141+
142+
}
143+
it["EXPANSION"] = YamlConfiguration().also {
144+
it["TYPE-ENGINE"] = YamlConfiguration().also {
145+
it["EVALUATE-SCRIPT-ERROR"] = "An error occurred during script {script_name} evaluation, please check the script format."
146+
it["EVALUATE-TEMP-SCRIPT-ERROR"] = "An error occurred during temp script evaluation, please check the script format."
147+
it["EXECUTE-SCRIPT-ERROR"] = "An error occurred when the script {script_name} executes the function {execute_main}, please check the script format."
148+
it["EXECUTE-SCRIPT-FUNCTION-NOT-FOUND-ERROR"] = "An error occurred when the script {script_name} executes the function {execute_main}, this function not found!"
149+
it["EXECUTE-TEMP-SCRIPT-ERROR"] = "An error occurred when the temp script executes the function {execute_main}, please check the script format."
150+
it["EXECUTE-SCRIPT-FUNCTION-NOT-FOUND-ERROR"] = "An error occurred when the temp script executes the function {execute_main}, this function not found!"
67151
}
68152
}
153+
it["SCRIPT-MANAGER"] = YamlConfiguration().also {
154+
it["PROCESS-RESULT"] = YamlConfiguration().also {
155+
it["SCRIPT-OPTION-FILE-NOT-EXISTS"] = "Script option file exists!"
156+
it["SCRIPT-TYPE-NOT-SUPPORTED"] = "The script file extension is not supported!"
157+
it["SCRIPT-FILE-NAME-CANNOT-SPACES"] = "File name cannot contain spaces!"
158+
}
159+
it["SCRIPT-FAILED-LOAD-BY-PROCESS-RESULT"] = "An error occurred while loading script {file_name}, reason: &8{reason}"
160+
}
161+
it["LOADED-PROCESS-SUCCESS"] = "Loaded &b{total} &7{id}, &a{success} &7successes.&8({millisecond}ms)"
162+
it["LOADED-PROCESS-HAS-FAILED"] = "Loaded &b{total} &7{id}, &a{success} &7successes, &c{fail} &7failures.&8({millisecond}ms)"
163+
164+
it["VERSION"] = languages.version
69165

70166
}
71167

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package me.scoretwo.fastscript.api.language
33
import net.md_5.bungee.api.ChatColor
44

55
class LanguageManager {
6-
val version = 1
6+
val version = "1"
77
val defaultLanguage = Language()
88
val languages = mutableMapOf<String, Language>().also {
99
it["en_US"] = defaultLanguage

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
package me.scoretwo.fastscript.api.script
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.script.custom.ConfigScriptOption
66
import me.scoretwo.fastscript.api.script.custom.CustomScript
77
import me.scoretwo.fastscript.api.script.temp.TempScript
88
import me.scoretwo.fastscript.api.utils.ExecType
99
import me.scoretwo.fastscript.api.utils.process.ProcessResult
1010
import me.scoretwo.fastscript.api.utils.process.ProcessResultType
11-
import me.scoretwo.fastscript.plugin
12-
import me.scoretwo.fastscript.sendMessage
13-
import me.scoretwo.fastscript.settings
1411
import me.scoretwo.utils.bukkit.configuration.yaml.ConfigurationSection
1512
import me.scoretwo.utils.bukkit.configuration.yaml.patchs.getLowerCaseNode
1613
import me.scoretwo.utils.sender.GlobalSender
@@ -50,7 +47,7 @@ class ScriptManager {
5047
val scriptName = scriptFile.name.substringBeforeLast(".")
5148
scriptFile.parentFile.listFiles()?.forEach {
5249
if (it.name == "$scriptName.yml") {
53-
return Pair(null, ProcessResult(ProcessResultType.OTHER, "script option file exists!"))
50+
return Pair(null, ProcessResult(ProcessResultType.OTHER, languages["SCRIPT-MANAGER.PROCESS-RESULT.SCRIPT-OPTION-FILE-NOT-EXISTS"]))
5451
}
5552
}
5653

@@ -61,7 +58,7 @@ class ScriptManager {
6158

6259
return@let scriptFile
6360
}
64-
return Pair(null, ProcessResult(ProcessResultType.FAILED, "The script file extension is not supported!"))
61+
return Pair(null, ProcessResult(ProcessResultType.FAILED, languages["SCRIPT-MANAGER.PROCESS-RESULT.SCRIPT-TYPE-NOT-SUPPORTED"]))
6562
}
6663
val script = CustomScript(
6764
object : ScriptDescription {
@@ -84,7 +81,7 @@ class ScriptManager {
8481
* 仅接受文件后缀为yml的文件或者可用的脚本文件夹才能被处理
8582
*/
8683
private fun loadScript(file: File): Pair<CustomScript?, ProcessResult> {
87-
if (file.name.contains(" ")) return Pair(null, ProcessResult(ProcessResultType.FAILED, "File name cannot contain spaces!"))
84+
if (file.name.contains(" ")) return Pair(null, ProcessResult(ProcessResultType.FAILED, languages["SCRIPT-MANAGER.PROCESS-RESULT.SCRIPT-FILE-NAME-CANNOT-SPACES"]))
8885
if (file.isDirectory) {
8986
return loadFromFolderScript(file)
9087
}
@@ -173,7 +170,9 @@ class ScriptManager {
173170
total++
174171
if (it.second.type == ProcessResultType.FAILED || it.first == null) {
175172
fail++
176-
plugin.server.console.sendMessage(FormatHeader.ERROR, "An error occurred while loading script ${file.name}, reason: §8${it.second.message}")
173+
plugin.server.console.sendMessage(FormatHeader.ERROR, languages["SCRIPT-MANAGER.SCRIPT-FAILED-LOAD-BY-PROCESS-RESULT"].setPlaceholder(
174+
mapOf("file_name" to file.name, "reason" to it.second.message)
175+
))
177176
}
178177
else if (it.second.type == ProcessResultType.SUCCESS)
179178
success++

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ class FSCommandNexus: CommandNexus(FastScript.instance.plugin, arrayOf("FastScri
5353

5454
val displayArgs =
5555
if (subCommand.subCommands.isEmpty() && subCommand.customCommands.isNotEmpty())
56-
"§7<${languages["COMMAND-NEXUS.SUBSTANTIVE.ARGS"]}...> "
56+
"§7<${languages["SUBSTANTIVE.ARGS"]}...> "
5757
else if (subCommand.subCommands.isNotEmpty()) {
5858
subCommand.subCommands.joinToString("/", "§7<", "§7> ", 5, "§8...") { it.alias[0] }
5959
} else
6060
""
6161

6262
texts.add(arrayOf(TextComponent("§7/$displayParents §f$displayAlia$displayAlias §7$displayArgs§8§l- §7${subCommand.description}").also {
63-
it.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text(languages["COMMAND-NEXUS.HELP-GENERATION.CLICK-INSERT-COMMAND"].setPlaceholder(
63+
it.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text(languages["COMMAND-NEXUS.HELPER.CLICK-INSERT-COMMAND"].setPlaceholder(
6464
mapOf("command" to "$displayParents $displayAlia"))))
6565
it.clickEvent = ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/$displayParents $displayAlia ")
6666
}))
@@ -70,15 +70,15 @@ class FSCommandNexus: CommandNexus(FastScript.instance.plugin, arrayOf("FastScri
7070
val displayAlia = it.key
7171
val displayArgs = it.value.first?.joinToString("/", "§7<", "§7> ", 5, "§8...") ?: ""
7272
texts.add(arrayOf(TextComponent("§7/$displayParents §f$displayAlia §7$displayArgs§8§l- §7${it.value.second}").also {
73-
it.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text(languages["COMMAND-NEXUS.HELP-GENERATION.CLICK-INSERT-COMMAND"].setPlaceholder(
73+
it.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text(languages["COMMAND-NEXUS.HELPER.CLICK-INSERT-COMMAND"].setPlaceholder(
7474
mapOf("command" to "$displayParents $displayAlia"))))
7575
it.clickEvent = ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/$displayParents $displayAlia ")
7676
}))
7777
}
7878

7979
if (upperModule.size == texts.size) {
80-
texts.add(arrayOf(TextComponent(languages["COMMAND-NEXUS.HELP-GENERATION.NOT-FOUND-COMMANDS"]).also {
81-
it.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text(languages["COMMAND-NEXUS.HELP-GENERATION.NOT-FOUND-COMMANDS"]))
80+
texts.add(arrayOf(TextComponent(languages["COMMAND-NEXUS.HELPER.NOT-FOUND-COMMANDS"]).also {
81+
it.hoverEvent = HoverEvent(HoverEvent.Action.SHOW_TEXT, Text(languages["COMMAND-NEXUS.HELPER.NOT-FOUND-COMMANDS"]))
8282
}))
8383
}
8484

@@ -91,7 +91,7 @@ class FSCommandNexus: CommandNexus(FastScript.instance.plugin, arrayOf("FastScri
9191
arrayOf(
9292
TextComponent(" §3${plugin.description.name} §7v${plugin.description.version}").also {
9393
it.hoverEvent = HoverEvent(
94-
HoverEvent.Action.SHOW_TEXT, Text(languages["COMMAND-NEXUS.HELP-GENERATION.CLICK-TO-GO-URL"].setPlaceholder(
94+
HoverEvent.Action.SHOW_TEXT, Text(languages["COMMAND-NEXUS.HELPER.CLICK-TO-GO-URL"].setPlaceholder(
9595
mapOf("url" to "https://github.com/FastScriptModule/FastScript")))
9696
)
9797
it.clickEvent = ClickEvent(ClickEvent.Action.OPEN_URL, "https://github.com/FastScriptModule/FastScript")

0 commit comments

Comments
 (0)