Skip to content

Commit 2e6d9df

Browse files
committed
Flip script terminate/enable order when reloading
1 parent 28085e5 commit 2e6d9df

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/me/lucko/scriptcontroller/internal/ScriptLoaderImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,19 @@ private void reload() {
289289
// handle init of new scripts & cleanup of old ones
290290
Executor runExecutor = this.environment.getSettings().getRunExecutor();
291291
runExecutor.execute(() -> {
292+
// terminate old scripts
293+
CompositeAutoClosable.create()
294+
.bindAll(toTerminate)
295+
.closeAndReportExceptions();
296+
297+
// init new/reloaded scripts
292298
for (ScriptImpl script : toRun) {
293299
try {
294300
script.run();
295301
} catch (Exception e) {
296302
e.printStackTrace();
297303
}
298304
}
299-
300-
CompositeAutoClosable.create()
301-
.bindAll(toTerminate)
302-
.closeAndReportExceptions();
303305
});
304306
}
305307

0 commit comments

Comments
 (0)