Make Baritone initialization listeners consumers
This commit is contained in:
		@@ -28,6 +28,7 @@ import java.io.IOException;
 | 
			
		||||
import java.nio.file.Files;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.function.Consumer;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Brady
 | 
			
		||||
@@ -52,9 +53,9 @@ public enum Baritone {
 | 
			
		||||
    private File dir;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * List of runnables to be called after Baritone has initialized
 | 
			
		||||
     * List of consumers to be called after Baritone has initialized
 | 
			
		||||
     */
 | 
			
		||||
    private List<Runnable> onInitRunnables;
 | 
			
		||||
    private List<Consumer<Baritone>> onInitConsumers;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Whether or not Baritone is active
 | 
			
		||||
@@ -62,7 +63,7 @@ public enum Baritone {
 | 
			
		||||
    private boolean active;
 | 
			
		||||
 | 
			
		||||
    Baritone() {
 | 
			
		||||
        this.onInitRunnables = new ArrayList<>();
 | 
			
		||||
        this.onInitConsumers = new ArrayList<>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public synchronized void init() {
 | 
			
		||||
@@ -91,7 +92,7 @@ public enum Baritone {
 | 
			
		||||
        this.active = true;
 | 
			
		||||
        this.initialized = true;
 | 
			
		||||
 | 
			
		||||
        this.onInitRunnables.forEach(Runnable::run);
 | 
			
		||||
        this.onInitConsumers.forEach(consumer -> consumer.accept(this));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public final boolean isInitialized() {
 | 
			
		||||
@@ -131,7 +132,7 @@ public enum Baritone {
 | 
			
		||||
        return this.dir;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public final void registerInitListener(Runnable runnable) {
 | 
			
		||||
        this.onInitRunnables.add(runnable);
 | 
			
		||||
    public final void registerInitListener(Consumer<Baritone> runnable) {
 | 
			
		||||
        this.onInitConsumers.add(runnable);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user