2018-08-07 22:16:53 -05:00
|
|
|
/*
|
|
|
|
|
* This file is part of Baritone.
|
|
|
|
|
*
|
|
|
|
|
* Baritone is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
2018-08-07 23:15:22 -05:00
|
|
|
* Baritone is distributed in the hope that it will be useful,
|
2018-08-07 22:16:53 -05:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-08-01 13:10:48 -04:00
|
|
|
package baritone.bot;
|
|
|
|
|
|
2018-08-01 20:10:19 -07:00
|
|
|
import baritone.bot.behavior.Behavior;
|
2018-08-05 21:52:55 -04:00
|
|
|
import baritone.bot.behavior.impl.LookBehavior;
|
2018-08-08 03:35:29 -05:00
|
|
|
import baritone.bot.behavior.impl.MemoryBehavior;
|
2018-08-05 17:48:10 -04:00
|
|
|
import baritone.bot.behavior.impl.PathingBehavior;
|
2018-08-11 00:03:16 -05:00
|
|
|
import baritone.bot.event.GameEventHandler;
|
2018-08-14 15:04:41 -07:00
|
|
|
import baritone.bot.utils.InputOverrideHandler;
|
2018-08-01 20:10:19 -07:00
|
|
|
|
2018-08-01 21:41:36 -07:00
|
|
|
import java.util.ArrayList;
|
2018-08-01 20:10:19 -07:00
|
|
|
import java.util.List;
|
|
|
|
|
|
2018-08-01 13:10:48 -04:00
|
|
|
/**
|
|
|
|
|
* @author Brady
|
|
|
|
|
* @since 7/31/2018 10:50 PM
|
|
|
|
|
*/
|
|
|
|
|
public enum Baritone {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Singleton instance of this class
|
|
|
|
|
*/
|
|
|
|
|
INSTANCE;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether or not {@link Baritone#init()} has been called yet
|
|
|
|
|
*/
|
|
|
|
|
private boolean initialized;
|
|
|
|
|
|
|
|
|
|
private GameEventHandler gameEventHandler;
|
|
|
|
|
private InputOverrideHandler inputOverrideHandler;
|
2018-08-13 20:57:29 -07:00
|
|
|
private Settings settings;
|
2018-08-01 20:10:19 -07:00
|
|
|
private List<Behavior> behaviors;
|
2018-08-01 13:10:48 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Whether or not Baritone is active
|
|
|
|
|
*/
|
|
|
|
|
private boolean active;
|
|
|
|
|
|
2018-08-13 20:57:29 -07:00
|
|
|
public synchronized void init() {
|
|
|
|
|
if (initialized) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-08-01 13:10:48 -04:00
|
|
|
this.gameEventHandler = new GameEventHandler();
|
|
|
|
|
this.inputOverrideHandler = new InputOverrideHandler();
|
2018-08-13 20:57:29 -07:00
|
|
|
this.settings = new Settings();
|
2018-08-01 21:41:36 -07:00
|
|
|
this.behaviors = new ArrayList<>();
|
2018-08-20 20:32:18 -05:00
|
|
|
{
|
|
|
|
|
registerBehavior(PathingBehavior.INSTANCE);
|
|
|
|
|
registerBehavior(LookBehavior.INSTANCE);
|
|
|
|
|
registerBehavior(MemoryBehavior.INSTANCE);
|
|
|
|
|
}
|
2018-08-01 13:10:48 -04:00
|
|
|
|
|
|
|
|
this.active = true;
|
|
|
|
|
this.initialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public final boolean isInitialized() {
|
|
|
|
|
return this.initialized;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public final GameEventHandler getGameEventHandler() {
|
|
|
|
|
return this.gameEventHandler;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public final InputOverrideHandler getInputOverrideHandler() {
|
|
|
|
|
return this.inputOverrideHandler;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-01 20:10:19 -07:00
|
|
|
public final List<Behavior> getBehaviors() {
|
|
|
|
|
return this.behaviors;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-13 20:57:29 -07:00
|
|
|
public void registerBehavior(Behavior behavior) {
|
|
|
|
|
this.behaviors.add(behavior);
|
2018-08-20 20:32:18 -05:00
|
|
|
this.gameEventHandler.registerEventListener(behavior);
|
2018-08-13 20:57:29 -07:00
|
|
|
}
|
|
|
|
|
|
2018-08-01 13:10:48 -04:00
|
|
|
public final boolean isActive() {
|
|
|
|
|
return this.active;
|
|
|
|
|
}
|
2018-08-13 17:15:59 -07:00
|
|
|
|
|
|
|
|
public final Settings getSettings() {
|
|
|
|
|
return this.settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Settings settings() {
|
|
|
|
|
return Baritone.INSTANCE.settings; // yolo
|
|
|
|
|
}
|
2018-08-01 13:10:48 -04:00
|
|
|
}
|