aboutsummaryrefslogtreecommitdiff
path: root/forge
diff options
context:
space:
mode:
authorhackthetime <l4bg0jb7@duck.com>2023-10-16 10:37:12 +0200
committerhackthetime <l4bg0jb7@duck.com>2023-10-16 10:37:12 +0200
commite9d6a8aa983ac8e3eca7984a774af592b59cc33d (patch)
treeb20231cac0d4ab1f8bcfc225733c0abdb7e87bab /forge
parent6dd18970edf93c6e9bb5315194e0accd81810fb1 (diff)
downloadBBsentials-e9d6a8aa983ac8e3eca7984a774af592b59cc33d.tar.gz
BBsentials-e9d6a8aa983ac8e3eca7984a774af592b59cc33d.tar.bz2
BBsentials-e9d6a8aa983ac8e3eca7984a774af592b59cc33d.zip
added meme actionbar normal chat switcher.
Diffstat (limited to 'forge')
-rw-r--r--forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java33
1 files changed, 30 insertions, 3 deletions
diff --git a/forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java b/forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java
index f84d760..7764d7b 100644
--- a/forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java
+++ b/forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java
@@ -2,9 +2,11 @@ package de.hype.bbsentials.forge;
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.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.util.ChatStyle;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.common.MinecraftForge;
@@ -26,10 +28,11 @@ public class ForgeChat implements MCChat {
if (!(event.type == 2)) {
//2 means action bar
// Chat.sendPrivateMessageToSelfDebug(String.valueOf(((int) event.type)));
- Message newMessage = chat.onEvent(new Message(IChatComponent.Serializer.componentToJson(event.message), event.message.getUnformattedText()));
- if (!newMessage.equals(event.message)) {
+ Message message = new Message(IChatComponent.Serializer.componentToJson(event.message), event.message.getUnformattedText());
+ Message newMessage = chat.onEvent(message);
+ if (!newMessage.equals(message)) {
event.setCanceled(true);
- Chat.sendPrivateMessageToSelfText(newMessage);
+ sendClientSideMessage(newMessage);
}
}
}
@@ -43,7 +46,31 @@ public class ForgeChat implements MCChat {
}
}
+
+ public void sendClientSideMessage(Message message, boolean actionbar) {
+ if (BBsentials.config.swapActionBarChat && !BBsentials.config.swapOnlyNormal) {
+ actionbar = !actionbar;
+ }
+ if (actionbar) {
+ showActionBar(message);
+ }
+ else {
+ sendClientSideMessage(message);
+ }
+ }
+
public void sendChatMessage(String message) {
Minecraft.getMinecraft().thePlayer.sendChatMessage(message);
}
+
+ public void showActionBar(Message message) {
+ EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ if (player != null) {
+ String json = message.getJson();
+ IChatComponent text = IChatComponent.Serializer.jsonToComponent(json);
+ // Display the text in the action bar
+ Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(text);
+ }
+ }
+
}