From 3d0e4e05fe167dd64c57c3f008eecf3fd9e9bc77 Mon Sep 17 00:00:00 2001 From: DieZeitungsente Date: Tue, 14 May 2024 17:40:11 +0200 Subject: [PATCH] might work now actually --- .../java/spigey/asteroide/AsteroideAddon.java | 1 + .../asteroide/mixin/ChatMessageC2SMixin.java | 53 +++++++++++++++---- .../asteroide/modules/WordFilterModule.java | 8 +-- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/main/java/spigey/asteroide/AsteroideAddon.java b/src/main/java/spigey/asteroide/AsteroideAddon.java index 8440dd4..97feb2e 100644 --- a/src/main/java/spigey/asteroide/AsteroideAddon.java +++ b/src/main/java/spigey/asteroide/AsteroideAddon.java @@ -48,6 +48,7 @@ public void onInitialize() { addModule(new AutoLoginModule()); addModule(new InvCleanerModule()); addModule(new BorderNoclipModule()); + addModule(new WordFilterModule()); // Commands addCommand(new CrashAll()); diff --git a/src/main/java/spigey/asteroide/mixin/ChatMessageC2SMixin.java b/src/main/java/spigey/asteroide/mixin/ChatMessageC2SMixin.java index 5ef3509..9f4d51c 100644 --- a/src/main/java/spigey/asteroide/mixin/ChatMessageC2SMixin.java +++ b/src/main/java/spigey/asteroide/mixin/ChatMessageC2SMixin.java @@ -1,27 +1,60 @@ package spigey.asteroide.mixin; import meteordevelopment.meteorclient.systems.modules.Modules; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.message.LastSeenMessageList; +import net.minecraft.network.message.MessageSignatureData; import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket; import net.minecraft.world.border.WorldBorder; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import spigey.asteroide.modules.WordFilterModule; +import java.time.Instant; + import static meteordevelopment.meteorclient.utils.player.ChatUtils.info; @Mixin(ChatMessageC2SPacket.class) public abstract class ChatMessageC2SMixin { + @Mutable + @Shadow + @Final + private String chatMessage; + /** * @author Spigey * @reason Word Filter - * - @Overwrite - public String chatMessage(){ - if(Modules.get().get(WordFilterModule.class).isActive()) return "WOAH DUDE!!! IT WORKED!!!111"; - return "ermm what the sigma."; - } */ + */ + @Inject(method = "(Ljava/lang/String;Ljava/time/Instant;JLnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/network/message/LastSeenMessageList$Acknowledgment;)V", at = @At("RETURN")) + private void onChatMessageC2SPacket(String string, Instant timestamp, long salt, MessageSignatureData signature, LastSeenMessageList.Acknowledgment acknowledgment, CallbackInfo ci){ + if(!Modules.get().get(WordFilterModule.class).isActive()) return; + WordFilterModule filter = Modules.get().get(WordFilterModule.class); + String content = this.chatMessage; + String[] datshit = content.split(" "); + StringBuilder message = new StringBuilder(); + boolean pleasekillme = false; + for (int i = 0; i < datshit.length; i++) { + for (int j = 0; j < filter.messages.get().size(); j++) { + if (datshit[i].toLowerCase().contains(filter.messages.get().get(j).toLowerCase())) { + pleasekillme = true; + if (filter.woblox.get()) { + String temp = ""; + for (int k = 0; k < datshit[i].length(); k++) { + temp += filter.roblock.get(); + } + datshit[i] = temp; + } else { + datshit[i] = filter.replacement.get(); + } + } + } + } + for (int i = 0; i < datshit.length; i++) { + message.append(datshit[i]).append(" "); + } + if (pleasekillme && !content.trim().equalsIgnoreCase(message.toString().trim())) this.chatMessage = content; + } } diff --git a/src/main/java/spigey/asteroide/modules/WordFilterModule.java b/src/main/java/spigey/asteroide/modules/WordFilterModule.java index 85b7463..5655c63 100644 --- a/src/main/java/spigey/asteroide/modules/WordFilterModule.java +++ b/src/main/java/spigey/asteroide/modules/WordFilterModule.java @@ -20,26 +20,26 @@ public WordFilterModule() { } final SettingGroup sgGeneral = settings.getDefaultGroup(); - private final Setting> messages = sgGeneral.add(new StringListSetting.Builder() + public final Setting> messages = sgGeneral.add(new StringListSetting.Builder() .name("messages to filter") .description("Filter these messages") .defaultValue("cum", "sex", "dick", "nigga", "nigger", "retard", "hitler") .build() ); - private final Setting woblox = sgGeneral.add(new BoolSetting.Builder() + public final Setting woblox = sgGeneral.add(new BoolSetting.Builder() .name("Roblox-like Replacement") .description("Filters the message to look more like roblox filtering") .defaultValue(false) .build() ); - private final Setting replacement = sgGeneral.add(new StringSetting.Builder() + public final Setting replacement = sgGeneral.add(new StringSetting.Builder() .name("filter replacement") .description("String to replace filtered messages with") .defaultValue("@$#!?&") .visible(() -> !woblox.get()) .build() ); - private final Setting roblock = sgGeneral.add(new StringSetting.Builder() + public final Setting roblock = sgGeneral.add(new StringSetting.Builder() .name("roblox-like filter replacement") .description("String to replace filtered messages with") .defaultValue("#")