aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/woverflow
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-14 13:45:51 -0500
committerWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-14 13:45:51 -0500
commite574e54a53b87ef4bbb33404b6fdb6b97c72dd81 (patch)
tree62bc726b1f0eb4727b6ddf10696f1fa69c519806 /src/main/java/cc/woverflow
parent27aa4095270f943ddab2a4e4d370e225766c7ff7 (diff)
downloadChatting-e574e54a53b87ef4bbb33404b6fdb6b97c72dd81.tar.gz
Chatting-e574e54a53b87ef4bbb33404b6fdb6b97c72dd81.tar.bz2
Chatting-e574e54a53b87ef4bbb33404b6fdb6b97c72dd81.zip
allow selecting multiple chat tabs at the same time
Diffstat (limited to 'src/main/java/cc/woverflow')
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java b/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java
index 2c19b0f..1316aba 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/EntityPlayerSPMixin.java
@@ -1,21 +1,36 @@
package cc.woverflow.chatting.mixin;
+import cc.woverflow.chatting.chat.ChatTab;
import cc.woverflow.chatting.chat.ChatTabs;
import cc.woverflow.chatting.config.ChattingConfig;
import net.minecraft.client.entity.EntityPlayerSP;
+import net.minecraft.client.network.NetHandlerPlayClient;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.client.C01PacketChatMessage;
+import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.ModifyVariable;
+import org.spongepowered.asm.mixin.injection.Redirect;
-@Mixin(EntityPlayerSP.class)
+@Mixin(value = EntityPlayerSP.class, priority = 0)
public class EntityPlayerSPMixin {
- @ModifyVariable(method = "sendChatMessage", at = @At("HEAD"), ordinal = 0, argsOnly = true)
- private String handleSentMessages(String value) {
- if (value.startsWith("/")) return value;
- if (ChattingConfig.INSTANCE.getChatTabs() && ChatTabs.INSTANCE.getCurrentTab() != null && ChatTabs.INSTANCE.getCurrentTab().getPrefix() != null && !ChatTabs.INSTANCE.getCurrentTab().getPrefix().isEmpty()) {
- return ChatTabs.INSTANCE.getCurrentTab().getPrefix() + value;
+ @Shadow @Final public NetHandlerPlayClient sendQueue;
+
+ @Redirect(method = "sendChatMessage", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/NetHandlerPlayClient;addToSendQueue(Lnet/minecraft/network/Packet;)V"))
+ private void handleSentMessages(NetHandlerPlayClient instance, Packet<?> packet, String value) {
+ if (value.startsWith("/")) {
+ sendQueue.addToSendQueue(packet);
+ return;
+ }
+ if (ChattingConfig.INSTANCE.getChatTabs() && !ChatTabs.INSTANCE.getCurrentTabs().isEmpty()) {
+ for (ChatTab tab : ChatTabs.INSTANCE.getTabs()) {
+ if (tab.getPrefix() != null && !tab.getPrefix().isEmpty()) {
+ sendQueue.addToSendQueue(new C01PacketChatMessage(tab.getPrefix() + value));
+ }
+ }
} else {
- return value;
+ sendQueue.addToSendQueue(packet);
}
}
} \ No newline at end of file