Move Settings to api
This commit is contained in:
parent
4ac2ade7c6
commit
eeea07ed2b
@ -29,6 +29,10 @@ import baritone.api.behavior.*;
|
||||
*/
|
||||
public class BaritoneAPI {
|
||||
|
||||
// General
|
||||
private static final Settings settings = new Settings();
|
||||
|
||||
// Behaviors
|
||||
private static IFollowBehavior followBehavior;
|
||||
private static ILookBehavior lookBehavior;
|
||||
private static IMemoryBehavior memoryBehavior;
|
||||
@ -55,6 +59,10 @@ public class BaritoneAPI {
|
||||
return pathingBehavior;
|
||||
}
|
||||
|
||||
public static Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* FOR INTERNAL USE ONLY
|
||||
*/
|
||||
|
@ -15,9 +15,9 @@
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone;
|
||||
package baritone.api;
|
||||
|
||||
import baritone.utils.Helper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
@ -32,6 +32,7 @@ import java.util.function.Consumer;
|
||||
* @author leijurv
|
||||
*/
|
||||
public class Settings {
|
||||
|
||||
/**
|
||||
* Allow Baritone to break blocks
|
||||
*/
|
||||
@ -389,9 +390,11 @@ public class Settings {
|
||||
public Setting<Integer> followRadius = new Setting<>(3);
|
||||
|
||||
/**
|
||||
* Instead of Baritone logging to chat, set a custom consumer.
|
||||
* The function that is called when Baritone will log to chat. This function can be added to
|
||||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||
* {@link Setting#value};
|
||||
*/
|
||||
public Setting<Consumer<ITextComponent>> logger = new Setting<>(new Helper() {}::addToChat);
|
||||
public Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage);
|
||||
|
||||
public final Map<String, Setting<?>> byLowerName;
|
||||
public final List<Setting<?>> allSettings;
|
27
src/api/java/baritone/api/utils/Logger.java
Normal file
27
src/api/java/baritone/api/utils/Logger.java
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.api.utils;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 9/23/2018
|
||||
*/
|
||||
public class Logger {
|
||||
|
||||
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
package baritone;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import baritone.behavior.Behavior;
|
||||
import baritone.api.event.listener.IGameEventListener;
|
||||
import baritone.behavior.*;
|
||||
@ -81,7 +82,11 @@ public enum Baritone {
|
||||
this.threadPool = new ThreadPoolExecutor(4, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>());
|
||||
this.gameEventHandler = new GameEventHandler();
|
||||
this.inputOverrideHandler = new InputOverrideHandler();
|
||||
this.settings = new Settings();
|
||||
|
||||
// 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<>();
|
||||
{
|
||||
registerBehavior(PathingBehavior.INSTANCE);
|
||||
|
@ -18,7 +18,7 @@
|
||||
package baritone.behavior;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.Settings;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.behavior.ILookBehavior;
|
||||
import baritone.api.event.events.PlayerUpdateEvent;
|
||||
import baritone.api.event.events.RotationMoveEvent;
|
||||
|
@ -18,7 +18,7 @@
|
||||
package baritone.utils;
|
||||
|
||||
import baritone.Baritone;
|
||||
import baritone.Settings;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.behavior.Behavior;
|
||||
import baritone.api.event.events.ChatEvent;
|
||||
|
@ -99,9 +99,4 @@ public interface Helper {
|
||||
component.appendSibling(new TextComponentString(" " + message));
|
||||
Baritone.settings().logger.get().accept(component);
|
||||
}
|
||||
|
||||
default void addToChat(ITextComponent msg) {
|
||||
mc.ingameGUI.getChatGUI().printChatMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user