Skip to content

Commit

Permalink
auto macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Spigey committed Apr 20, 2024
1 parent 603da33 commit 3ccb1ef
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/main/java/spigey/asteroide/modules/AutoMacro.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package spigey.asteroide.modules;

import meteordevelopment.meteorclient.events.packets.PacketEvent;
import meteordevelopment.meteorclient.settings.BoolSetting;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.SettingGroup;
import meteordevelopment.meteorclient.settings.StringListSetting;
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import meteordevelopment.orbit.EventHandler;
import meteordevelopment.orbit.EventPriority;
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
import spigey.asteroide.AsteroideAddon;
import meteordevelopment.meteorclient.systems.config.Config;

import java.util.List;

import static spigey.asteroide.util.msg;

public class AutoMacro extends Module {

private final SettingGroup sgGeneral = settings.getDefaultGroup();

private final Setting<List<String>> messages = sgGeneral.add(new StringListSetting.Builder()
.name("messages")
.description("Keywords to execute the macro")
.defaultValue("Hello world!")
.build()
);
private final Setting<List<String>> macro = sgGeneral.add(new StringListSetting.Builder()
.name("macro")
.description("macro to execute")
.defaultValue("testmacro")
.build()
);

public AutoMacro() {
super(AsteroideAddon.CATEGORY, "auto-macro", "Automatically runs a macro when a specified message is sent in the chat");
}

@EventHandler(priority = EventPriority.HIGHEST + 1)
private void PacketReceive(PacketEvent.Receive event){
if(!(event.packet instanceof GameMessageS2CPacket)){return;}
String content = String.valueOf(((GameMessageS2CPacket) event.packet).content().getString());
for(int i = 0; i < messages.get().size(); i++){
if(content.toLowerCase().contains(messages.get().get(i).toLowerCase())){
if(macro.get().get(i) != null){
msg(Config.get().prefix.get() + "macro " + macro.get().get(i));
} else{
error("Error: Macro " + macro.get().get(i) + " is null");
}
}
}
}
}

0 comments on commit 3ccb1ef

Please sign in to comment.