-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} | ||
} | ||
} | ||
} |