From e9d6a8aa983ac8e3eca7984a774af592b59cc33d Mon Sep 17 00:00:00 2001 From: hackthetime Date: Mon, 16 Oct 2023 10:37:12 +0200 Subject: added meme actionbar normal chat switcher. --- .../fabric/BBsentialsConfigScreemFactory.java | 23 ++++++++++++++++++++ .../java/de/hype/bbsentials/fabric/FabricChat.java | 25 ++++++++++++++++------ 2 files changed, 41 insertions(+), 7 deletions(-) (limited to 'fabric/src/main') diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java b/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java index a723284..5cfcbe3 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/BBsentialsConfigScreemFactory.java @@ -133,6 +133,29 @@ public class BBsentialsConfigScreemFactory { .setTooltip(Text.of("Do you want that whenever someone sends you a msg ending with 'bb:party me' to send them a party invite automatically?")) .setSaveConsumer(newValue -> BBsentials.config.allowBBinviteMe = newValue) .build()); + SubCategoryBuilder trolls = entryBuilder.startSubCategory(Text.of("Trolls")).setExpanded(false); + BooleanListEntry swapActionBarAndChat = (entryBuilder.startBooleanToggle(Text.of("Actionbar-Chat switch"), BBsentials.config.swapActionBarChat) + .setDefaultValue(false) + .setTooltip(Text.of("Swap that chat messages are shown in actionbar and reverse")) + .setSaveConsumer(newValue -> BBsentials.config.swapActionBarChat = newValue) + .build()); + Requirement trollSwapEnabled = swapActionBarAndChat::getValue; + BooleanListEntry swapActionBarAndChatOnlyNormal = (entryBuilder.startBooleanToggle(Text.of("Only normal messages"), BBsentials.config.swapOnlyNormal) + .setDefaultValue(false) + .setRequirement(trollSwapEnabled) + .setTooltip(Text.of("Swap only the default messages (→ everything not from BBsentials)")) + .setSaveConsumer(newValue -> BBsentials.config.swapOnlyNormal = newValue) + .build()); + BooleanListEntry swapActionBarAndChatOnlyBB = (entryBuilder.startBooleanToggle(Text.of("Only BBsentials messages"), BBsentials.config.swapOnlyBBsentials) + .setDefaultValue(false) + .setRequirement(trollSwapEnabled) + .setTooltip(Text.of("Swap only the messages from BBsentials")) + .setSaveConsumer(newValue -> BBsentials.config.swapOnlyBBsentials = newValue) + .build()); + trolls.add(swapActionBarAndChat); + trolls.add(swapActionBarAndChatOnlyNormal); + trolls.add(swapActionBarAndChatOnlyBB); + other.addEntry(trolls.build()); ConfigCategory chChestItems = builder.getOrCreateCategory(Text.of("Ch Chest Items")); { BooleanListEntry allItems = entryBuilder.startBooleanToggle(Text.of("All Chest Items"), BBsentials.config.toDisplayConfig.allChChestItem) diff --git a/fabric/src/main/java/de/hype/bbsentials/fabric/FabricChat.java b/fabric/src/main/java/de/hype/bbsentials/fabric/FabricChat.java index d4fefd3..e78df68 100644 --- a/fabric/src/main/java/de/hype/bbsentials/fabric/FabricChat.java +++ b/fabric/src/main/java/de/hype/bbsentials/fabric/FabricChat.java @@ -2,6 +2,7 @@ package de.hype.bbsentials.fabric; import de.hype.bbsentials.common.chat.Chat; import de.hype.bbsentials.common.chat.Message; +import de.hype.bbsentials.common.client.BBsentials; import de.hype.bbsentials.common.mclibraries.MCChat; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; import net.fabricmc.fabric.api.client.message.v1.ClientSendMessageEvents; @@ -21,10 +22,7 @@ public class FabricChat implements MCChat { chat.onEvent(new Message(Text.Serializer.toJson(message), message.getString())); }); ClientReceiveMessageEvents.MODIFY_GAME.register((message, actionbar) -> { - if (!actionbar) { - return prepareOnEvent(message, actionbar); - } - return message; + return prepareOnEvent(message, actionbar); }); ClientSendMessageEvents.CHAT.register(message -> { if (message.startsWith("/")) { @@ -36,8 +34,19 @@ public class FabricChat implements MCChat { public Text prepareOnEvent(Text text, boolean actionbar) { String json = Text.Serializer.toJson(text); Message message = new Message(json, text.getString(), actionbar); - Message returned = chat.onEvent(message); - Text toReturn = Text.Serializer.fromJson(returned.getJson()); + if (!actionbar) { + message = chat.onEvent(message); + } + Text toReturn = Text.Serializer.fromJson(message.getJson()); + if (BBsentials.config.swapActionBarChat && !BBsentials.config.swapOnlyBBsentials) { + if (!actionbar) { + showActionBar(message); + } + else { + sendClientSideMessage(message); + } + return null; + } return toReturn; } @@ -49,6 +58,9 @@ public class FabricChat implements MCChat { } public void sendClientSideMessage(Message message, boolean actionbar) { + if (BBsentials.config.swapActionBarChat && !BBsentials.config.swapOnlyNormal) { + actionbar = !actionbar; + } if (actionbar) { showActionBar(message); } @@ -56,7 +68,6 @@ public class FabricChat implements MCChat { sendClientSideMessage(message); } } - public void showActionBar(Message message) { MinecraftClient client = MinecraftClient.getInstance(); if (client.player != null) { -- cgit