mirror of https://github.com/cabaletta/baritone
commit
944405e4df
|
@ -17,10 +17,12 @@
|
|||
|
||||
package baritone.api;
|
||||
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.NotificationHelper;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import baritone.api.utils.TypeUtils;
|
||||
import baritone.api.utils.gui.BaritoneToast;
|
||||
import net.minecraft.client.GuiMessageTag;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -772,6 +774,11 @@ public final class Settings {
|
|||
*/
|
||||
public final Setting<Boolean> shortBaritonePrefix = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Use a modern message tag instead of a prefix when logging to chat
|
||||
*/
|
||||
public final Setting<Boolean> useMessageTag = new Setting<>(false);
|
||||
|
||||
/**
|
||||
* Echo commands to chat when they are run
|
||||
*/
|
||||
|
@ -1141,7 +1148,10 @@ public final class Settings {
|
|||
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
|
||||
* {@link Setting#value};
|
||||
*/
|
||||
public final Setting<Consumer<Component>> logger = new Setting<>(msg -> Minecraft.getInstance().gui.getChat().addMessage(msg));
|
||||
public final Setting<Consumer<Component>> logger = new Setting<>((msg) -> {
|
||||
final GuiMessageTag tag = useMessageTag.value ? Helper.MESSAGE_TAG : null;
|
||||
Minecraft.getInstance().gui.getChat().addMessage(msg, null, tag);
|
||||
});
|
||||
|
||||
/**
|
||||
* The function that is called when Baritone will send a desktop notification. This function can be added to
|
||||
|
|
|
@ -18,8 +18,10 @@
|
|||
package baritone.api.utils;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import baritone.api.utils.gui.BaritoneToast;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.GuiMessageTag;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
@ -48,6 +50,11 @@ public interface Helper {
|
|||
*/
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
/**
|
||||
* The tag to assign to chat messages when {@link Settings#useMessageTag} is {@code true}.
|
||||
*/
|
||||
GuiMessageTag MESSAGE_TAG = new GuiMessageTag(0xFF55FF, null, Component.literal("Baritone message."), "Baritone");
|
||||
|
||||
static Component getPrefix() {
|
||||
// Inner text component
|
||||
final Calendar now = Calendar.getInstance();
|
||||
|
@ -160,8 +167,10 @@ public interface Helper {
|
|||
*/
|
||||
default void logDirect(boolean logAsToast, Component... components) {
|
||||
MutableComponent component = Component.literal("");
|
||||
component.append(getPrefix());
|
||||
component.append(Component.literal(" "));
|
||||
if (!logAsToast && !BaritoneAPI.getSettings().useMessageTag.value) {
|
||||
component.append(getPrefix());
|
||||
component.append(Component.literal(" "));
|
||||
}
|
||||
Arrays.asList(components).forEach(component::append);
|
||||
if (logAsToast) {
|
||||
logToast(getPrefix(), component);
|
||||
|
|
Loading…
Reference in New Issue