Move gadget controller loaded message to debug

This commit is contained in:
KingRainbow44 2023-04-15 13:17:09 -04:00
parent d8f90b26cf
commit c672a2d9cb
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE

View File

@ -20,31 +20,27 @@ public class EntityControllerScriptManager {
}
private static void cacheGadgetControllers() {
try {
Files.newDirectoryStream(getScriptPath("Gadget/"), "*.lua")
.forEach(
path -> {
val fileName = path.getFileName().toString();
try (var stream = Files.newDirectoryStream(getScriptPath("Gadget/"), "*.lua")) {
stream.forEach(path -> {
val fileName = path.getFileName().toString();
if (!fileName.endsWith(".lua")) return;
if (!fileName.endsWith(".lua")) return;
val controllerName = fileName.substring(0, fileName.length() - 4);
var cs = ScriptLoader.getScript("Gadget/" + fileName);
var bindings = ScriptLoader.getEngine().createBindings();
if (cs == null) return;
val controllerName = fileName.substring(0, fileName.length() - 4);
CompiledScript cs = ScriptLoader.getScript("Gadget/" + fileName);
Bindings bindings = ScriptLoader.getEngine().createBindings();
if (cs == null) return;
try {
cs.eval(bindings);
gadgetController.put(controllerName, new EntityController(cs, bindings));
} catch (Throwable e) {
Grasscutter.getLogger()
.error("Error while loading gadget controller: {}", fileName);
}
});
Grasscutter.getLogger().info("Loaded {} gadget controllers", gadgetController.size());
try {
cs.eval(bindings);
gadgetController.put(controllerName, new EntityController(cs, bindings));
} catch (Throwable e) {
Grasscutter.getLogger()
.error("Error while loading gadget controller: {}.", fileName);
}
});
Grasscutter.getLogger().debug("Loaded {} gadget controllers", gadgetController.size());
} catch (IOException e) {
Grasscutter.getLogger().error("Error loading gadget controller luas");
Grasscutter.getLogger().error("Error loading gadget controller Lua scripts.");
}
}