Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
06f531fe
Commit
06f531fe
authored
May 08, 2022
by
Melledy
Browse files
Merge branch 'stable' into development
parents
5d1f4957
d43f4315
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
LICENSE
View file @
06f531fe
This diff is collapsed.
Click to expand it.
src/main/java/emu/grasscutter/Config.java
View file @
06f531fe
...
...
@@ -16,7 +16,6 @@ public final class Config {
public
String
KEY_FOLDER
=
"./keys/"
;
public
String
SCRIPTS_FOLDER
=
"./resources/Scripts/"
;
public
String
PLUGINS_FOLDER
=
"./plugins/"
;
public
String
LANGUAGE_FOLDER
=
"./languages/"
;
public
ServerDebugMode
DebugMode
=
ServerDebugMode
.
NONE
;
// ALL, MISSING, NONE
public
ServerRunMode
RunMode
=
ServerRunMode
.
HYBRID
;
// HYBRID, DISPATCH_ONLY, GAME_ONLY
...
...
src/main/java/emu/grasscutter/utils/Language.java
View file @
06f531fe
...
...
@@ -19,7 +19,7 @@ public final class Language {
* @return A language instance.
*/
public
static
Language
getLanguage
(
String
langCode
)
{
return
new
Language
(
langCode
+
".json"
,
Grasscutter
.
getConfig
().
DefaultLanguage
.
toLanguageTag
());
return
new
Language
(
langCode
+
".json"
,
Grasscutter
.
getConfig
().
DefaultLanguage
.
toLanguageTag
()
+
".json"
);
}
/**
...
...
@@ -46,15 +46,20 @@ public final class Language {
private
Language
(
String
fileName
,
String
fallback
)
{
@Nullable
JsonObject
languageData
=
null
;
InputStream
file
=
Grasscutter
.
class
.
getResourceAsStream
(
"/languages/"
+
fileName
);
if
(
file
==
null
)
{
// Provided fallback language.
file
=
Grasscutter
.
class
.
getResourceAsStream
(
"/languages/"
+
fallback
);
Grasscutter
.
getLogger
().
warn
(
"Failed to load language file: "
+
fileName
+
", falling back to: "
+
fallback
);
}
if
(
file
==
null
)
{
// Fallback the fallback language.
file
=
Grasscutter
.
class
.
getResourceAsStream
(
"/languages/en-US.json"
);
Grasscutter
.
getLogger
().
warn
(
"Failed to load language file: "
+
fallback
+
", falling back to: en-US.json"
);
}
if
(
file
==
null
)
throw
new
RuntimeException
(
"Unable to load the primary, fallback, and 'en-US' language files."
);
try
{
InputStream
file
=
Grasscutter
.
class
.
getResourceAsStream
(
"/languages/"
+
fileName
);
String
translationContents
=
Utils
.
readFromInputStream
(
file
);
if
(
translationContents
.
equals
(
"empty"
))
{
file
=
Grasscutter
.
class
.
getResourceAsStream
(
"/languages/"
+
fallback
);
translationContents
=
Utils
.
readFromInputStream
(
file
);
}
languageData
=
Grasscutter
.
getGsonFactory
().
fromJson
(
translationContents
,
JsonObject
.
class
);
languageData
=
Grasscutter
.
getGsonFactory
().
fromJson
(
Utils
.
readFromInputStream
(
file
),
JsonObject
.
class
);
}
catch
(
Exception
exception
)
{
Grasscutter
.
getLogger
().
warn
(
"Failed to load language file: "
+
fileName
,
exception
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment