This commit is contained in:
Brady 2018-11-11 17:45:01 -06:00
parent e81d0a0b1b
commit 903b1b16a4
No known key found for this signature in database
GPG Key ID: 73A788379A197567

View File

@ -59,15 +59,26 @@ public enum Baritone implements IBaritone {
*/
INSTANCE;
private static ThreadPoolExecutor threadPool;
private static File dir;
static {
threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
if (!Files.exists(dir.toPath())) {
try {
Files.createDirectories(dir.toPath());
} catch (IOException ignored) {}
}
}
/**
* Whether or not {@link Baritone#init()} has been called yet
*/
private boolean initialized;
private GameEventHandler gameEventHandler;
private Settings settings;
private File dir;
private List<Behavior> behaviors;
private PathingBehavior pathingBehavior;
@ -84,8 +95,6 @@ public enum Baritone implements IBaritone {
private WorldProvider worldProvider;
private static ThreadPoolExecutor threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
Baritone() {
this.gameEventHandler = new GameEventHandler(this);
}
@ -95,10 +104,6 @@ public enum Baritone implements IBaritone {
return;
}
// Acquire the "singleton" instance of the settings directly from the API
// We might want to change this...
this.settings = BaritoneAPI.getSettings();
this.behaviors = new ArrayList<>();
{
// the Behavior constructor calls baritone.registerBehavior(this) so this populates the behaviors arraylist
@ -122,12 +127,6 @@ public enum Baritone implements IBaritone {
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
registerEventListener(BaritoneAutoTest.INSTANCE);
}
this.dir = new File(Minecraft.getMinecraft().gameDir, "baritone");
if (!Files.exists(dir.toPath())) {
try {
Files.createDirectories(dir.toPath());
} catch (IOException ignored) {}
}
this.initialized = true;
}
@ -136,10 +135,6 @@ public enum Baritone implements IBaritone {
return pathingControlManager;
}
public boolean isInitialized() {
return this.initialized;
}
public IGameEventListener getGameEventHandler() {
return this.gameEventHandler;
}
@ -152,22 +147,18 @@ public enum Baritone implements IBaritone {
return this.behaviors;
}
public static Executor getExecutor() {
return threadPool;
}
public void registerBehavior(Behavior behavior) {
this.behaviors.add(behavior);
this.registerEventListener(behavior);
}
@Override
public CustomGoalProcess getCustomGoalProcess() {
public CustomGoalProcess getCustomGoalProcess() { // Iffy
return customGoalProcess;
}
@Override
public GetToBlockProcess getGetToBlockProcess() { // very very high iq
public GetToBlockProcess getGetToBlockProcess() { // Iffy
return getToBlockProcess;
}
@ -211,15 +202,15 @@ public enum Baritone implements IBaritone {
this.gameEventHandler.registerEventListener(listener);
}
public Settings getSettings() {
return this.settings;
}
public static Settings settings() {
return Baritone.INSTANCE.settings; // yolo
return BaritoneAPI.getSettings();
}
public static File getDir() {
return Baritone.INSTANCE.dir; // should be static I guess
return dir;
}
public static Executor getExecutor() {
return threadPool;
}
}