mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-26 14:17:58 +00:00
Add error message in case data files in resources could not be found
This commit is contained in:
parent
01987279b5
commit
5429469852
@ -51,13 +51,17 @@ public class DataLoader {
|
|||||||
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];
|
||||||
|
|
||||||
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();
|
||||||
|
@ -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 {
|
|||||||
} 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user