spam module

spam: Minecraft 26.3 cheat module, full source for every implementation (2 clients: Meteor Client, OfflineClient).

2 implementationsMiscMISC

Clients with this module

Full module source: 2 implementations

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

Meteor ClientMiscsrc/main/java/meteordevelopment/meteorclient/systems/modules/misc/Spam.javaJava · 189 lines · 6.4 KB

Spams specified messages in chat.

Settingsmessagesdelaydisable-on-leavedisable-on-disconnectrandomiseauto-split-messagessplit-lengthsplit-delaybypassinclude-uppercase-characterslength
Spam.javaJava · Minecraft 26.2 · 189 lines · 6.4 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3
 * Copyright (c) Meteor Development.
4
 */
5
6
package meteordevelopment.meteorclient.systems.modules.misc;
7
8
import meteordevelopment.meteorclient.events.game.GameLeftEvent;
9
import meteordevelopment.meteorclient.events.game.OpenScreenEvent;
10
import meteordevelopment.meteorclient.events.world.TickEvent;
11
import meteordevelopment.meteorclient.settings.*;
12
import meteordevelopment.meteorclient.systems.modules.Categories;
13
import meteordevelopment.meteorclient.systems.modules.Module;
14
import meteordevelopment.meteorclient.utils.Utils;
15
import meteordevelopment.meteorclient.utils.player.ChatUtils;
16
import meteordevelopment.orbit.EventHandler;
17
import net.minecraft.client.gui.screens.DisconnectedScreen;
18
import org.apache.commons.lang3.RandomStringUtils;
19
20
import java.util.List;
21
22
public class Spam extends Module {
23
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
24
25
    private final Setting<List<String>> messages = sgGeneral.add(new StringListSetting.Builder()
26
        .name("messages")
27
        .description("Messages to use for spam.")
28
        .defaultValue(List.of("Meteor on Crack!"))
29
        .build()
30
    );
31
32
    private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
33
        .name("delay")
34
        .description("The delay between specified messages in ticks.")
35
        .defaultValue(20)
36
        .min(0)
37
        .sliderMax(200)
38
        .build()
39
    );
40
41
    private final Setting<Boolean> disableOnLeave = sgGeneral.add(new BoolSetting.Builder()
42
        .name("disable-on-leave")
43
        .description("Disables spam when you leave a server.")
44
        .defaultValue(true)
45
        .build()
46
    );
47
48
    private final Setting<Boolean> disableOnDisconnect = sgGeneral.add(new BoolSetting.Builder()
49
        .name("disable-on-disconnect")
50
        .description("Disables spam when you are disconnected from a server.")
51
        .defaultValue(true)
52
        .build()
53
    );
54
55
    private final Setting<Boolean> random = sgGeneral.add(new BoolSetting.Builder()
56
        .name("randomise")
57
        .description("Selects a random message from your spam message list.")
58
        .defaultValue(false)
59
        .build()
60
    );
61
62
    private final Setting<Boolean> autoSplitMessages = sgGeneral.add(new BoolSetting.Builder()
63
        .name("auto-split-messages")
64
        .description("Automatically split up large messages after a certain length")
65
        .defaultValue(false)
66
        .build()
67
    );
68
69
    private final Setting<Integer> splitLength = sgGeneral.add(new IntSetting.Builder()
70
        .name("split-length")
71
        .description("The length after which to split messages in chat")
72
        .visible(autoSplitMessages::get)
73
        .defaultValue(256)
74
        .min(1)
75
        .sliderMax(256)
76
        .build()
77
    );
78
79
    private final Setting<Integer> autoSplitDelay = sgGeneral.add(new IntSetting.Builder()
80
        .name("split-delay")
81
        .description("The delay between split messages in ticks.")
82
        .visible(autoSplitMessages::get)
83
        .defaultValue(20)
84
        .min(0)
85
        .sliderMax(200)
86
        .build()
87
    );
88
89
    private final Setting<Boolean> bypass = sgGeneral.add(new BoolSetting.Builder()
90
        .name("bypass")
91
        .description("Add random text at the end of the message to try to bypass anti spams.")
92
        .defaultValue(false)
93
        .build()
94
    );
95
96
    private final Setting<Boolean> uppercase = sgGeneral.add(new BoolSetting.Builder()
97
        .name("include-uppercase-characters")
98
        .description("Whether the bypass text should include uppercase characters.")
99
        .visible(bypass::get)
100
        .defaultValue(true)
101
        .build()
102
    );
103
104
    private final Setting<Integer> length = sgGeneral.add(new IntSetting.Builder()
105
        .name("length")
106
        .description("Number of characters used to bypass anti spam.")
107
        .visible(bypass::get)
108
        .defaultValue(16)
109
        .sliderRange(1, 256)
110
        .build()
111
    );
112
113
    private int messageI, timer, splitNum;
114
    private String text;
115
116
    public Spam() {
117
        super(Categories.Misc, "spam", "Spams specified messages in chat.");
118
    }
119
120
    @Override
121
    public void onActivate() {
122
        timer = delay.get();
123
        messageI = 0;
124
        splitNum = 0;
125
    }
126
127
    @EventHandler
128
    private void onScreenOpen(OpenScreenEvent event) {
129
        if (disableOnDisconnect.get() && event.screen instanceof DisconnectedScreen) {
130
            toggle();
131
        }
132
    }
133
134
    @EventHandler
135
    private void onGameLeft(GameLeftEvent event) {
136
        if (disableOnLeave.get()) toggle();
137
    }
138
139
    @EventHandler
140
    private void onTick(TickEvent.Post event) {
141
        if (messages.get().isEmpty()) return;
142
143
        if (timer <= 0) {
144
            if (text == null) {
145
                int i;
146
                if (random.get()) {
147
                    i = Utils.random(0, messages.get().size());
148
                } else {
149
                    if (messageI >= messages.get().size()) messageI = 0;
150
                    i = messageI++;
151
                }
152
153
                text = messages.get().get(i);
154
                if (bypass.get()) {
155
                    String bypass = RandomStringUtils.insecure().nextAlphabetic(length.get());
156
                    if (!uppercase.get()) bypass = bypass.toLowerCase();
157
158
                    text += " " + bypass;
159
                }
160
            }
161
162
            if (autoSplitMessages.get() && text.length() > splitLength.get()) {
163
                // the number of individual messages the whole text needs to be broken into
164
                double length = text.length();
165
                int splits = (int) Math.ceil(length / splitLength.get());
166
167
                // determine which chunk we need to send
168
                int start = splitNum * splitLength.get();
169
                int end = Math.min(start + splitLength.get(), text.length());
170
                ChatUtils.sendPlayerMsg(text.substring(start, end));
171
172
                splitNum = ++splitNum % splits;
173
                timer = autoSplitDelay.get();
174
                if (splitNum == 0) { // equals zero when all chunks are sent
175
                    timer = delay.get();
176
                    text = null;
177
                }
178
            } else {
179
                if (text.length() > 256) text = text.substring(0, 256); // prevent kick
180
                ChatUtils.sendPlayerMsg(text);
181
                timer = delay.get();
182
                text = null;
183
            }
184
        } else {
185
            timer--;
186
        }
187
    }
188
}
189
OfflineClientMISCsrc/main/java/com/jellypudding/offlineclient/modules/misc/Spam.javaJava · 190 lines · 7.4 KB

Sends chat messages on a timer.

SettingsDelayRandomiseSpreadVary textVariationSplit long linesSplit lengthSplit delayStop on leaveStop on disconnect
Spam.javaJava · Minecraft 26.2 · 190 lines · 7.4 KB · complete file, verbatimOriginal ↗
1
package com.jellypudding.offlineclient.modules.misc;
2
3
import com.jellypudding.offlineclient.event.Subscribe;
4
import com.jellypudding.offlineclient.event.events.ClientTickEvent;
5
import com.jellypudding.offlineclient.event.events.TickEvent;
6
import com.jellypudding.offlineclient.module.Category;
7
import com.jellypudding.offlineclient.module.Module;
8
import com.jellypudding.offlineclient.setting.BoolSetting;
9
import com.jellypudding.offlineclient.setting.NumberSetting;
10
import com.jellypudding.offlineclient.util.TextLines;
11
import net.minecraft.client.gui.screens.DisconnectedScreen;
12
13
import java.util.ArrayDeque;
14
import java.util.ArrayList;
15
import java.util.Deque;
16
import java.util.List;
17
import java.util.concurrent.ThreadLocalRandom;
18
19
// A message starting with a slash is sent as a command.
20
public final class Spam extends Module {
21
22
    // Servers cut a chat line off here.
23
    private static final int MAX_LENGTH = 256;
24
25
    // Tacked onto the end of a message when the variation calls for it.
26
    private static final String TAILS = "!.~";
27
28
    private final TextLines lines = new TextLines("Messages",
29
        "How many lines to rotate through.", "minecraftoffline.net is OK I guess");
30
    private final NumberSetting delay = new NumberSetting("Delay",
31
        "Seconds between messages.", 5, 0.1, 60, 0.1, "s").min(0.1).max(600);
32
    private final BoolSetting randomise = new BoolSetting("Randomise",
33
        "Shifts each delay by a random amount to look less robotic.", false);
34
    private final NumberSetting spread = new NumberSetting("Spread",
35
        "The most a delay is shifted either way. A delay of 5s with a spread of 2s waits anywhere from 3s to 7s.",
36
        1, 0.1, 10, 0.1, "s").min(0.1).max(300)
37
        .under(randomise);
38
    private final BoolSetting vary = new BoolSetting("Vary text",
39
        "Makes small random changes to each message to get repeats past a spam filter.", false);
40
    private final NumberSetting variation = new NumberSetting("Variation",
41
        "How many changes each message gets. A letter changes case or doubles or the line gains a tail.",
42
        1, 1, 10, 1).max(100)
43
        .under(vary);
44
    private final BoolSetting split = new BoolSetting("Split long lines",
45
        "Sends a long message in pieces instead of cutting it short.", false);
46
    private final NumberSetting splitLength = new NumberSetting("Split length",
47
        "How many characters each piece holds.", MAX_LENGTH, 1, MAX_LENGTH, 1)
48
        .min(1).max(MAX_LENGTH)
49
        .under(split);
50
    private final NumberSetting splitDelay = new NumberSetting("Split delay",
51
        "Ticks between one piece and the next.", 20, 0, 200, 1, " ticks").min(0).max(1000)
52
        .under(split);
53
    private final BoolSetting stopOnLeave = new BoolSetting("Stop on leave",
54
        "Turns itself off when you leave a world.", true);
55
    private final BoolSetting stopOnDisconnect = new BoolSetting("Stop on disconnect",
56
        "Turns itself off when the disconnected screen opens.", true);
57
58
    // Pieces of a split message still waiting to go out.
59
    private final Deque<String> pieces = new ArrayDeque<>();
60
    private int timer;
61
    private boolean wasInGame;
62
63
    public Spam() {
64
        super("Spam", "Sends chat messages on a timer.", Category.MISC);
65
        addSettings(lines.settings());
66
        addSettings(delay, randomise, spread, vary, variation, split, splitLength, splitDelay,
67
            stopOnLeave, stopOnDisconnect);
68
        searchTags("auto message", "advert", "chat spam");
69
    }
70
71
    @Override
72
    public String getSuffix() {
73
        return delay.getValueString();
74
    }
75
76
    @Override
77
    protected void onEnable() {
78
        // Enabling never fires instantly.
79
        timer = 20;
80
        pieces.clear();
81
        wasInGame = inGame();
82
        lines.restart();
83
    }
84
85
    // Leaving a world or landing on the disconnected screen can switch it off.
86
    @Subscribe
87
    private void onClientTick(ClientTickEvent event) {
88
        if (stopOnDisconnect.isOn() && mc.gui.screen() instanceof DisconnectedScreen) {
89
            setEnabled(false);
90
            return;
91
        }
92
        if (inGame()) {
93
            wasInGame = true;
94
            return;
95
        }
96
        if (wasInGame && stopOnLeave.isOn()) {
97
            setEnabled(false);
98
        }
99
    }
100
101
    @Subscribe
102
    private void onTick(TickEvent event) {
103
        if (!inGame() || mc.getConnection() == null) {
104
            return;
105
        }
106
        if (--timer > 0) {
107
            return;
108
        }
109
        // The rest of a split message goes out before the next line starts.
110
        if (!pieces.isEmpty()) {
111
            timer = Math.max(1, splitDelay.getInt());
112
            mc.getConnection().sendChat(pieces.removeFirst());
113
            return;
114
        }
115
        timer = nextDelay();
116
117
        String text = lines.pick();
118
        if (text == null) {
119
            return;
120
        }
121
        if (text.startsWith("/")) {
122
            mc.getConnection().sendCommand(text.substring(1));
123
            return;
124
        }
125
        if (vary.isOn()) {
126
            for (int i = 0; i < variation.getInt(); i++) {
127
                text = vary(text);
128
            }
129
        }
130
        if (split.isOn() && text.length() > splitLength.getInt()) {
131
            cutInto(text);
132
            timer = Math.max(1, splitDelay.getInt());
133
            mc.getConnection().sendChat(pieces.removeFirst());
134
            return;
135
        }
136
        if (text.length() > MAX_LENGTH) {
137
            text = text.substring(0, MAX_LENGTH);
138
        }
139
        mc.getConnection().sendChat(text);
140
    }
141
142
    private void cutInto(String text) {
143
        int size = splitLength.getInt();
144
        for (int start = 0; start < text.length(); start += size) {
145
            pieces.addLast(text.substring(start, Math.min(text.length(), start + size)));
146
        }
147
    }
148
149
    // The shift never takes the delay below the slider floor.
150
    private int nextDelay() {
151
        double seconds = delay.getValue();
152
        if (randomise.isOn()) {
153
            double reach = spread.getValue();
154
            seconds += ThreadLocalRandom.current().nextDouble(-reach, reach);
155
            seconds = Math.max(delay.getHardMin(), seconds);
156
        }
157
        return Math.max(1, (int) Math.round(seconds * 20));
158
    }
159
160
    // One small change to keep the message readable. A letter changes case or doubles up
161
    // or the message gains a tail. With no letters only a number or tail is added.
162
    private static String vary(String text) {
163
        ThreadLocalRandom random = ThreadLocalRandom.current();
164
        List<Integer> letters = new ArrayList<>();
165
        for (int i = 0; i < text.length(); i++) {
166
            if (Character.isLetter(text.charAt(i))) {
167
                letters.add(i);
168
            }
169
        }
170
        int kind = letters.isEmpty() ? random.nextInt(2) : random.nextInt(4);
171
        switch (kind) {
172
            case 0 -> {
173
                return text + " " + random.nextInt(10, 100);
174
            }
175
            case 1 -> {
176
                return text + TAILS.charAt(random.nextInt(TAILS.length()));
177
            }
178
            default -> {
179
                int at = letters.get(random.nextInt(letters.size()));
180
                char letter = text.charAt(at);
181
                String replacement = kind == 2
182
                    ? String.valueOf(Character.isUpperCase(letter)
183
                        ? Character.toLowerCase(letter) : Character.toUpperCase(letter))
184
                    : String.valueOf(letter) + letter;
185
                return text.substring(0, at) + replacement + text.substring(at + 1);
186
            }
187
        }
188
    }
189
}
190