From c672a2d9cb2f7893d2602ce3632230d12936d406 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 15 Apr 2023 13:17:09 -0400 Subject: [PATCH] Move gadget controller loaded message to `debug` --- .../EntityControllerScriptManager.java | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/main/java/emu/grasscutter/scripts/EntityControllerScriptManager.java b/src/main/java/emu/grasscutter/scripts/EntityControllerScriptManager.java index fc6855eca..ee70af00b 100644 --- a/src/main/java/emu/grasscutter/scripts/EntityControllerScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/EntityControllerScriptManager.java @@ -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."); } }