diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index ad0d487f..50b11580 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -17,8 +17,10 @@ package baritone.api; +import baritone.api.utils.NotificationHelper; import baritone.api.utils.SettingsUtil; import baritone.api.utils.TypeUtils; +import baritone.api.utils.gui.BaritoneToast; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.init.Blocks; @@ -33,6 +35,7 @@ import java.lang.reflect.Type; import java.util.List; import java.util.*; import java.util.function.Consumer; +import java.util.function.BiConsumer; /** * Baritone's settings. Settings apply to all Baritone instances. @@ -1058,6 +1061,20 @@ public final class Settings { */ public final Setting> logger = new Setting<>(Minecraft.getMinecraft().ingameGUI.getChatGUI()::printChatMessage); + /** + * The function that is called when Baritone will send a desktop notification. This function can be added to + * via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting + * {@link Setting#value}; + */ + public final Setting> notifier = new Setting<>(NotificationHelper::notify); + + /** + * The function that is called when Baritone will show a toast. This function can be added to + * via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting + * {@link Setting#value}; + */ + public final Setting> toaster = new Setting<>(BaritoneToast::addOrUpdate); + /** * The size of the box that is rendered when the current goal is a GoalYLevel */ diff --git a/src/api/java/baritone/api/utils/Helper.java b/src/api/java/baritone/api/utils/Helper.java index 336b410e..9bed3738 100755 --- a/src/api/java/baritone/api/utils/Helper.java +++ b/src/api/java/baritone/api/utils/Helper.java @@ -18,8 +18,6 @@ package baritone.api.utils; import baritone.api.BaritoneAPI; -import baritone.api.utils.gui.BaritoneToast; -import baritone.api.utils.NotificationHelper; import net.minecraft.client.Minecraft; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; @@ -72,7 +70,7 @@ public interface Helper { * @param message The message to display in the popup */ default void logToast(ITextComponent title, ITextComponent message) { - mc.addScheduledTask(() -> BaritoneToast.addOrUpdate(mc.getToastGui(), title, message, BaritoneAPI.getSettings().toastTimer.value)); + mc.addScheduledTask(() -> BaritoneAPI.getSettings().toaster.value.accept(title, message)); } /** @@ -133,7 +131,7 @@ public interface Helper { * @param error Whether to log as an error */ default void logNotificationDirect(String message, boolean error) { - NotificationHelper.notify(message, error); + mc.addScheduledTask(() -> BaritoneAPI.getSettings().notifier.value.accept(message, error)); } /** diff --git a/src/api/java/baritone/api/utils/gui/BaritoneToast.java b/src/api/java/baritone/api/utils/gui/BaritoneToast.java index 82df6741..eb636147 100644 --- a/src/api/java/baritone/api/utils/gui/BaritoneToast.java +++ b/src/api/java/baritone/api/utils/gui/BaritoneToast.java @@ -71,4 +71,8 @@ public class BaritoneToast implements IToast { baritonetoast.setDisplayedText(title, subtitle); } } + + public static void addOrUpdate(ITextComponent title, ITextComponent subtitle) { + addOrUpdate(net.minecraft.client.Minecraft.getMinecraft().getToastGui(), title, subtitle, baritone.api.BaritoneAPI.getSettings().toastTimer.value); + } }