diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 5642323b..333a9fdb 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -54,11 +54,20 @@ public enum Baritone { private List behaviors; private File dir; + /** + * List of runnables to be called after Baritone has initialized + */ + private List onInitRunnables; + /** * Whether or not Baritone is active */ private boolean active; + Baritone() { + this.onInitRunnables = new ArrayList<>(); + } + public synchronized void init() { if (initialized) { return; @@ -82,6 +91,8 @@ public enum Baritone { this.active = true; this.initialized = true; + + this.onInitRunnables.forEach(Runnable::run); } public final boolean isInitialized() { @@ -120,4 +131,8 @@ public enum Baritone { public final File getDir() { return this.dir; } + + public final void registerInitListener(Runnable runnable) { + this.onInitRunnables.add(runnable); + } }