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
54294698
Commit
54294698
authored
May 19, 2022
by
Melledy
Browse files
Add error message in case data files in resources could not be found
parent
01987279
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/data/DataLoader.java
View file @
54294698
...
...
@@ -51,13 +51,17 @@ public class DataLoader {
try
{
List
<
Path
>
filenames
=
FileUtils
.
getPathsFromResource
(
"/defaults/data/"
);
if
(
filenames
==
null
)
{
Grasscutter
.
getLogger
().
error
(
"We were unable to locate your default data files."
);
}
for
(
Path
file
:
filenames
)
{
String
relativePath
=
String
.
valueOf
(
file
).
split
(
"defaults[\\\\\\/]data[\\\\\\/]"
)[
1
];
CheckAndCopyData
(
relativePath
);
}
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"An error occurred while trying to check the data folder.
\n
"
,
e
);
Grasscutter
.
getLogger
().
error
(
"An error occurred while trying to check the data folder."
,
e
);
}
GenerateGachaMappings
();
...
...
src/main/java/emu/grasscutter/utils/FileUtils.java
View file @
54294698
...
...
@@ -9,6 +9,7 @@ import java.net.URI;
import
java.net.URISyntaxException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -97,6 +98,11 @@ public final class FileUtils {
}
catch
(
Exception
e
)
{
// Eclipse puts resources in its bin folder
File
f
=
new
File
(
jarPath
+
"defaults/data/"
);
if
(!
f
.
exists
()
||
f
.
listFiles
().
length
==
0
)
{
return
null
;
}
result
=
Arrays
.
stream
(
f
.
listFiles
()).
map
(
File:
:
toPath
).
toList
();
}
...
...
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