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

View File

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