Add a way to hook into Baritone's post-init stage

This commit is contained in:
Brady 2018-08-27 17:45:31 -05:00
parent 8f8bedb1b0
commit 423087cc12
No known key found for this signature in database
GPG Key ID: 73A788379A197567

View File

@ -54,11 +54,20 @@ public enum Baritone {
private List<Behavior> behaviors;
private File dir;
/**
* List of runnables to be called after Baritone has initialized
*/
private List<Runnable> 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);
}
}