Add a way to hook into Baritone's post-init stage
This commit is contained in:
parent
8f8bedb1b0
commit
423087cc12
@ -54,11 +54,20 @@ public enum Baritone {
|
|||||||
private List<Behavior> behaviors;
|
private List<Behavior> behaviors;
|
||||||
private File dir;
|
private File dir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of runnables to be called after Baritone has initialized
|
||||||
|
*/
|
||||||
|
private List<Runnable> onInitRunnables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not Baritone is active
|
* Whether or not Baritone is active
|
||||||
*/
|
*/
|
||||||
private boolean active;
|
private boolean active;
|
||||||
|
|
||||||
|
Baritone() {
|
||||||
|
this.onInitRunnables = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void init() {
|
public synchronized void init() {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
return;
|
return;
|
||||||
@ -82,6 +91,8 @@ public enum Baritone {
|
|||||||
|
|
||||||
this.active = true;
|
this.active = true;
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
||||||
|
this.onInitRunnables.forEach(Runnable::run);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isInitialized() {
|
public final boolean isInitialized() {
|
||||||
@ -120,4 +131,8 @@ public enum Baritone {
|
|||||||
public final File getDir() {
|
public final File getDir() {
|
||||||
return this.dir;
|
return this.dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void registerInitListener(Runnable runnable) {
|
||||||
|
this.onInitRunnables.add(runnable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user