diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoRespawn.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoRespawn.java index 2a66effd44..84fa0a643f 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoRespawn.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/AutoRespawn.java @@ -6,15 +6,52 @@ package meteordevelopment.meteorclient.systems.modules.misc; import meteordevelopment.meteorclient.events.game.OpenScreenEvent; +import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.settings.BoolSetting; +import meteordevelopment.meteorclient.settings.IntSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.meteorclient.settings.StringSetting; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.render.WaypointsModule; +import meteordevelopment.meteorclient.utils.player.ChatUtils; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; import net.minecraft.client.gui.screen.DeathScreen; public class AutoRespawn extends Module { + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + public final Setting sendRespawnMessage = sgGeneral.add(new BoolSetting.Builder() + .name("respawn-message") + .description("Sends a message or command upon respawning.") + .defaultValue(false) + .build() + ); + + private final Setting respawnMessage = sgGeneral.add(new StringSetting.Builder() + .name("message") + .description("The message/command to send.") + .defaultValue("Meteor on Crack!") + .visible(sendRespawnMessage::get) + .build() + ); + + private final Setting respawnMessageDelay = sgGeneral.add(new IntSetting.Builder() + .name("message-delay") + .description("The delay before sending respawn message in ticks.") + .defaultValue(1) + .sliderMax(100) + .visible(sendRespawnMessage::get) + .build() + ); + + // Fields + private int respawnTimer; + private boolean respawning = false; + public AutoRespawn() { super(Categories.Player, "auto-respawn", "Automatically respawns after death."); } @@ -26,5 +63,21 @@ private void onOpenScreenEvent(OpenScreenEvent event) { Modules.get().get(WaypointsModule.class).addDeath(mc.player.getPos()); mc.player.requestRespawn(); event.cancel(); + + if (!sendRespawnMessage.get()) return; + respawnTimer = 0; + respawning = true; + } + + @EventHandler + private void onTick(TickEvent.Post event) { + if (!respawning) return; + respawnTimer++; + + if (respawnTimer <= respawnMessageDelay.get()) return; + respawning = false; + + info("Sending message '"+respawnMessage.get()+"'"); + ChatUtils.sendPlayerMsg(respawnMessage.get()); } }