add say command, make chatappend compatible with chatcrypt

This commit is contained in:
Daniella / Tove 2024-05-27 22:45:45 +02:00
parent b1e1586f51
commit e910229940
3 changed files with 29 additions and 18 deletions

View file

@ -4,6 +4,7 @@ import com.baseband.client.module.Feature;
import com.baseband.client.module.chat.*;
import com.baseband.client.module.client.*;
import com.baseband.client.module.combat.AutoTotem;
import com.baseband.client.module.command.Say;
import com.baseband.client.module.command.Set;
import com.baseband.client.module.command.Test;
import com.baseband.client.module.movement.ElytraBot;
@ -54,6 +55,7 @@ public class Setup {
new Nametags(),
new NoSlowDown(),
new Ping(),
new Say(),
new Set(),
new Selection(),
new Test(),

View file

@ -2,14 +2,11 @@ package com.baseband.client.module.chat;
import com.baseband.client.configuration.annotation.Config;
import com.baseband.client.configuration.annotation.Gate;
import com.baseband.client.event.events.PacketEvent;
import com.baseband.client.BaseBand;
import com.baseband.client.mixins.ICPacketChat;
import com.baseband.client.module.Feature;
import com.baseband.client.module.category.Chat;
import com.baseband.client.util.misc.Marker;
import com.baseband.client.util.interact.ChatUtil;
import net.minecraft.network.play.client.CPacketChatMessage;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Chat
public class ChatAppend extends Feature {
@ -37,21 +34,14 @@ public class ChatAppend extends Feature {
@Gate(0)
public boolean customUnicodeToggle;
public void packetWrite(PacketEvent.Send event) {
if(event.getPacket() instanceof CPacketChatMessage) {
if (BaseBand.isFeatureEnabled(ChatCrypt.class)) {
ChatUtil.print("ChatAppend toggled, As using it simultaneously with ChatCrypt is not supported.");
toggle();
return;
}
@SubscribeEvent
public void onChatSend(ClientChatEvent event) {
String message = event.getMessage();
String message = ((CPacketChatMessage) event.getPacket()).getMessage();
if(message.matches("\\W.*"))
return;
if(message.startsWith("/"))
return;
((ICPacketChat) event.getPacket()).setMessage(applyWatermark((custom ? (customUnicodeToggle ? toUnicode(customWatermark) : customWatermark) : toUnicode("baseband")), message));
}
event.setMessage(applyWatermark((custom ? (customUnicodeToggle ? toUnicode(customWatermark) : customWatermark) : toUnicode("baseband")), message));
}
private String applyWatermark(String watermark, String text) {

View file

@ -0,0 +1,19 @@
package com.baseband.client.module.command;
import com.baseband.client.module.Feature;
import com.baseband.client.module.category.Command;
import net.minecraft.network.play.client.CPacketChatMessage;
@Command
public class Say extends Feature {
@Override
public void onCommand(String[] args) {
mc.player.connection.sendPacket(new CPacketChatMessage(String.join(" ", args)));
}
@Override
public String toString() {
return "Say";
}
}