Initialize the script loader in ResourceLoader#loadAll

This commit is contained in:
KingRainbow44 2023-05-11 19:41:50 -04:00
parent 4eaaa507ae
commit 5cd9d3a26d
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
3 changed files with 27 additions and 21 deletions

View File

@ -1,8 +1,5 @@
package emu.grasscutter;
import static emu.grasscutter.config.Configuration.SERVER;
import static emu.grasscutter.utils.Language.translate;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import emu.grasscutter.auth.AuthenticationSystem;
@ -15,7 +12,6 @@ import emu.grasscutter.data.ResourceLoader;
import emu.grasscutter.database.DatabaseManager;
import emu.grasscutter.plugin.PluginManager;
import emu.grasscutter.plugin.api.ServerHook;
import emu.grasscutter.scripts.ScriptLoader;
import emu.grasscutter.server.game.GameServer;
import emu.grasscutter.server.http.HttpServer;
import emu.grasscutter.server.http.dispatch.DispatchHandler;
@ -28,12 +24,6 @@ import emu.grasscutter.server.http.handlers.GenericHandler;
import emu.grasscutter.server.http.handlers.LogHandler;
import emu.grasscutter.tools.Tools;
import emu.grasscutter.utils.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOError;
import java.io.IOException;
import java.util.Calendar;
import javax.annotation.Nullable;
import lombok.Getter;
import lombok.Setter;
import org.jline.reader.EndOfFileException;
@ -45,6 +35,16 @@ import org.jline.terminal.TerminalBuilder;
import org.reflections.Reflections;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FileWriter;
import java.io.IOError;
import java.io.IOException;
import java.util.Calendar;
import static emu.grasscutter.config.Configuration.SERVER;
import static emu.grasscutter.utils.Language.translate;
public final class Grasscutter {
public static final File configFile = new File("./config.json");
public static final Reflections reflector = new Reflections("emu.grasscutter");
@ -106,7 +106,6 @@ public final class Grasscutter {
// Load all resources.
Grasscutter.updateDayOfWeek();
ScriptLoader.init();
ResourceLoader.loadAll();
// Generate handbooks.

View File

@ -1,9 +1,5 @@
package emu.grasscutter.data;
import static emu.grasscutter.utils.FileUtils.getDataPath;
import static emu.grasscutter.utils.FileUtils.getResourcePath;
import static emu.grasscutter.utils.Language.translate;
import com.google.gson.annotations.SerializedName;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.binout.*;
@ -33,6 +29,12 @@ import it.unimi.dsi.fastutil.Pair;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntArraySet;
import lombok.SneakyThrows;
import lombok.val;
import org.reflections.Reflections;
import javax.script.Bindings;
import javax.script.CompiledScript;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
@ -44,10 +46,10 @@ import java.util.concurrent.CopyOnWriteArraySet;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.script.Bindings;
import javax.script.CompiledScript;
import lombok.val;
import org.reflections.Reflections;
import static emu.grasscutter.utils.FileUtils.getDataPath;
import static emu.grasscutter.utils.FileUtils.getResourcePath;
import static emu.grasscutter.utils.Language.translate;
public final class ResourceLoader {
@ -96,10 +98,14 @@ public final class ResourceLoader {
return List.copyOf(map.values());
}
@SneakyThrows
public static void loadAll() {
if (loadedAll) return;
Grasscutter.getLogger().info(translate("messages.status.resources.loading"));
// Initialize the script loader.
ScriptLoader.init();
loadConfigData();
// Load ability lists
loadAbilityEmbryos();

View File

@ -3,7 +3,6 @@ package io.grasscutter;
import com.mchange.util.AssertException;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.config.Configuration;
import java.io.IOException;
import lombok.Getter;
import okhttp3.OkHttpClient;
import okhttp3.Request;
@ -12,6 +11,8 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
/** Testing entrypoint for {@link Grasscutter}. */
public final class GrasscutterTest {
@Getter private static final OkHttpClient httpClient = new OkHttpClient();
@ -30,7 +31,7 @@ public final class GrasscutterTest {
}
@BeforeAll
public static void main() {
public static void entry() {
try {
// Start Grasscutter.
Grasscutter.main(new String[] {"-test"});