Skip to content

Commit

Permalink
might work now actually
Browse files Browse the repository at this point in the history
  • Loading branch information
Spigey committed May 14, 2024
1 parent 403f702 commit 3d0e4e0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/main/java/spigey/asteroide/AsteroideAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void onInitialize() {
addModule(new AutoLoginModule());
addModule(new InvCleanerModule());
addModule(new BorderNoclipModule());
addModule(new WordFilterModule());

// Commands
addCommand(new CrashAll());
Expand Down
53 changes: 43 additions & 10 deletions src/main/java/spigey/asteroide/mixin/ChatMessageC2SMixin.java
Original file line number Diff line number Diff line change
@@ -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 = "<init>(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;
}
}
8 changes: 4 additions & 4 deletions src/main/java/spigey/asteroide/modules/WordFilterModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ public WordFilterModule() {
}

final SettingGroup sgGeneral = settings.getDefaultGroup();
private final Setting<List<String>> messages = sgGeneral.add(new StringListSetting.Builder()
public final Setting<List<String>> 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<Boolean> woblox = sgGeneral.add(new BoolSetting.Builder()
public final Setting<Boolean> 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<String> replacement = sgGeneral.add(new StringSetting.Builder()
public final Setting<String> replacement = sgGeneral.add(new StringSetting.Builder()
.name("filter replacement")
.description("String to replace filtered messages with")
.defaultValue("@$#!?&")
.visible(() -> !woblox.get())
.build()
);
private final Setting<String> roblock = sgGeneral.add(new StringSetting.Builder()
public final Setting<String> roblock = sgGeneral.add(new StringSetting.Builder()
.name("roblox-like filter replacement")
.description("String to replace filtered messages with")
.defaultValue("#")
Expand Down

0 comments on commit 3d0e4e0

Please sign in to comment.