Skip to content

Commit

Permalink
external api for adding scripts upgrade: buildAdditionalScripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 5, 2023
1 parent 3667d16 commit 7bbf90e
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
public class ScriptHelper {
public static volatile ArrayList<YamlConfiguration> _yamlScripts;

@Deprecated
public static ArrayList<YamlConfiguration> additionalScripts = new ArrayList<>();

/**
* Add additional script file references here as wanted/needed. Use like:
*
* ScriptHelper.additionalScripts.add(YamlConfiguration.load(ScriptHelper.clearComments(MY_FILENAME, MY_FILE_TEXT, true)));
* (scripts) -> scripts.add(YamlConfiguration.load(ScriptHelper.clearComments(MY_FILENAME, MY_FILE_TEXT, true)));
*/
public static ArrayList<YamlConfiguration> additionalScripts = new ArrayList<>();
public static List<Consumer<List<YamlConfiguration>>> buildAdditionalScripts = new ArrayList<>();

private static void reloadFailed(Throwable ex) {
hadError = true;
Expand Down Expand Up @@ -207,6 +210,16 @@ private static ArrayList<YamlConfiguration> buildScriptList() { // Note: can be
Debug.echoError(e);
}
}
for (Consumer<List<YamlConfiguration>> additional : buildAdditionalScripts) {
try {
additional.accept(outList);
}
catch (Exception ex) {
Debug.echoError("Error parsing additional script!");
hadError = true;
Debug.echoError(ex);
}
}
if (CoreConfiguration.debugLoadingInfo) {
Debug.echoApproval("All scripts loaded!");
}
Expand Down

0 comments on commit 7bbf90e

Please sign in to comment.