fix chat history with chatappend

This commit is contained in:
Daniella / Tove 2024-06-02 20:01:59 +02:00
parent 1cafa1dd38
commit b5a34bd2f6
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
2 changed files with 7 additions and 1 deletions

View file

@ -5,6 +5,7 @@ import com.baseband.client.feature.category.Chat;
import com.baseband.client.registry.annotation.Config;
import com.baseband.client.registry.annotation.Gate;
import com.baseband.client.util.adapt.Marker;
import com.baseband.client.util.interact.ChatUtil;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@ -41,7 +42,9 @@ public class ChatAppend extends Feature {
if(message.matches("\\W.*"))
return;
event.setMessage(applyWatermark((custom ? (customUnicodeToggle ? toUnicode(customWatermark) : customWatermark) : toUnicode("baseband")), message));
ChatUtil.history(message);
ChatUtil.send(applyWatermark((custom ? (customUnicodeToggle ? toUnicode(customWatermark) : customWatermark) : toUnicode("baseband")), message), false);
event.setCanceled(true);
}
private String applyWatermark(String watermark, String text) {

View file

@ -51,6 +51,9 @@ public class ChatUtil {
public static void simulateSend(String msg, boolean addToHistory) {
msg = net.minecraftforge.event.ForgeEventFactory.onClientSendMessage(msg);
send(msg, addToHistory);
}
public static void send(String msg, boolean addToHistory) {
if (msg.isEmpty()) return;
if (addToHistory) {
Minecraft.getMinecraft().ingameGUI.getChatGUI().addToSentMessages(msg);