Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grasscutter
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
ziqian zhang
Grasscutter
Commits
1282e138
Commit
1282e138
authored
3 years ago
by
Melledy
Browse files
Options
Downloads
Patches
Plain Diff
Add error message in case data files in resources could not be found
parent
86dee4ba
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/emu/grasscutter/data/DataLoader.java
+5
-1
5 additions, 1 deletion
src/main/java/emu/grasscutter/data/DataLoader.java
src/main/java/emu/grasscutter/utils/FileUtils.java
+6
-0
6 additions, 0 deletions
src/main/java/emu/grasscutter/utils/FileUtils.java
with
11 additions
and
1 deletion
src/main/java/emu/grasscutter/data/DataLoader.java
+
5
−
1
View file @
1282e138
...
@@ -50,6 +50,10 @@ public class DataLoader {
...
@@ -50,6 +50,10 @@ public class DataLoader {
public
static
void
CheckAllFiles
()
{
public
static
void
CheckAllFiles
()
{
try
{
try
{
List
<
Path
>
filenames
=
FileUtils
.
getPathsFromResource
(
"/defaults/data/"
);
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
)
{
for
(
Path
file
:
filenames
)
{
String
relativePath
=
String
.
valueOf
(
file
).
split
(
"defaults[\\\\\\/]data[\\\\\\/]"
)[
1
];
String
relativePath
=
String
.
valueOf
(
file
).
split
(
"defaults[\\\\\\/]data[\\\\\\/]"
)[
1
];
...
@@ -57,7 +61,7 @@ public class DataLoader {
...
@@ -57,7 +61,7 @@ public class DataLoader {
CheckAndCopyData
(
relativePath
);
CheckAndCopyData
(
relativePath
);
}
}
}
catch
(
Exception
e
)
{
}
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
();
GenerateGachaMappings
();
...
...
This diff is collapsed.
Click to expand it.
src/main/java/emu/grasscutter/utils/FileUtils.java
+
6
−
0
View file @
1282e138
...
@@ -9,6 +9,7 @@ import java.net.URI;
...
@@ -9,6 +9,7 @@ import java.net.URI;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.*
;
import
java.nio.file.*
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
...
@@ -97,6 +98,11 @@ public final class FileUtils {
...
@@ -97,6 +98,11 @@ public final class FileUtils {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// Eclipse puts resources in its bin folder
// Eclipse puts resources in its bin folder
File
f
=
new
File
(
jarPath
+
"defaults/data/"
);
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
();
result
=
Arrays
.
stream
(
f
.
listFiles
()).
map
(
File:
:
toPath
).
toList
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment