Add a way to hook into Baritone's post-init stage
This commit is contained in:
		@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user