From 903b1b16a4aed39889a5833bcb3c36bce852f487 Mon Sep 17 00:00:00 2001 From: Brady Date: Sun, 11 Nov 2018 17:45:01 -0600 Subject: [PATCH] static --- src/main/java/baritone/Baritone.java | 53 ++++++++++++---------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 6df47147..f4546012 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -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 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; } }