diff options
Diffstat (limited to 'forge')
-rw-r--r-- | forge/src/main/java/de/hype/bbsentials/forge/ForgeChat.java | 33 |
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); + } + } + } |