Nekoware v1 private Commands module 2 files, 230 lines

Nekoware v1 private Commands: Full Source Analysis

Nekoware v1 private's Commands module is a byte-identical fork of the Memeware 7.3 command system: the same LWJEB consumer on the outgoing packet bus cancels every C01PacketChatMessage that starts…

me/nekoWare/client/module/misc/Commands.java · GitHub source ↗

Published 2026-08-12 · Updated 2026-08-12

Packets This Module Uses

Analysis

Overview

Nekoware v1 private's Commands module is a byte-identical fork of the Memeware 7.3 command system: the same LWJEB consumer on the outgoing packet bus cancels every C01PacketChatMessage that starts with the '.' prefix and dispatches the stripped command word to the same eleven-branch switch table. The only differences are branding - clientName is 'Nekoware' instead of 'Memeware', editionName is 'Dev', and the module manager reference is Nekoware.INSTANCE - plus the ChatUtil tag text. The interception model is identical: client commands never reach the server, .say re-emits its payload as a C01 prefixed with U+F705, and the clip commands move the player through the vanilla teleport path.

Fork lineage

The two files are the same source tree: same package layout under me/nekoWare versus me/memewaredevs, same me.hippo.api.lwjeb event @Handler decorator, same Module.Category.MISC constructor call, and a switch table that is character-for-character the Memeware implementation including its quirks. The dead 'say' gate, the ineffective args[2] null guard on .bind, the String.replace-based command stripping, and the static clientName/editionName branding strings all carry over unchanged. Only the manager lookup (Nekoware.INSTANCE.getModuleManager) and the default branding values differ, which makes this a private rebrand of the same chat-command infrastructure rather than an independent implementation.

Dispatch and residue

Dispatch semantics are identical to the parent client: .bind writes LWJGL key binds into modules, .t/.toggle call Module.toggle(), .vclip uses setPositionAndUpdate for an immediate position packet while .hclip uses setPosition and lets the next movement tick pick up the offset, .name copies the player name to the clipboard, and .say joins its arguments and calls sendChatMessage with U+F705 prepended so the re-emitted C01 escapes the dot-prefix filter. The server-visible residue is the same three channels: the private-use-character chat output of .say, the teleport movement of the clip commands, and the user's normal chat, which passes through the interceptor untouched.

source Commands.java (dot-prefix interceptor)

Commands.java208 lines · JavaOriginal ↗
1
package me.nekoWare.client.module.misc;
2
3
import me.hippo.api.lwjeb.annotation.Handler;
4
import me.nekoWare.client.Nekoware;
5
import me.nekoWare.client.event.events.PacketOutEvent;
6
import me.nekoWare.client.module.Module;
7
import me.nekoWare.client.util.ChatUtil;
8
import net.minecraft.network.Packet;
9
import net.minecraft.network.play.client.C01PacketChatMessage;
10
import org.lwjgl.input.Keyboard;
11
12
import java.awt.*;
13
import java.awt.datatransfer.Clipboard;
14
import java.awt.datatransfer.StringSelection;
15
import java.util.Arrays;
16
import java.util.function.Consumer;
17
18
public class Commands extends Module {
19
20
    private boolean say = false;
21
22
    public static String clientName = "Nekoware";
23
    public static String editionName = "Dev";
24
    private String prefix = ".";
25
26
    public Commands() {
27
        super("Commands", 0, Module.Category.MISC);
28
    }
29
30
    @Handler
31
    public Consumer<PacketOutEvent> eventConsumer0 = (event) -> {
32
        Packet p = event.getPacket();
33
        if (p instanceof C01PacketChatMessage) {
34
            C01PacketChatMessage packet = (C01PacketChatMessage) p;
35
            String msg = packet.getMessage();
36
            String[] args = msg.split(" +");
37
            String cmd = args[0].replace(this.prefix, "").toLowerCase();
38
            if (!say) {
39
                if (msg.startsWith(this.prefix)) {
40
                    event.cancel();
41
                    switch (cmd) {
42
                        case "bind": {
43
                            if (args[2] != null) {
44
                                Module m = Nekoware.INSTANCE.getModuleManager().getModule(args[1]);
45
                                if (m != null) {
46
                                    int key = Keyboard.getKeyIndex(args[2].toUpperCase());
47
                                    if (key != -1) {
48
                                        m.setKeyBind(key);
49
                                        ChatUtil.printChat("Successfully set bind to "
50
                                                + Keyboard.getKeyName(key) + ".");
51
                                    } else {
52
                                        ChatUtil.printChat("Invalid command usage! Correct usage: .bind [module] [key]");
53
                                    }
54
                                } else {
55
                                    ChatUtil.printChat("Invalid command usage! Correct usage: .bind [module] [key]");
56
                                }
57
                            } else {
58
                                ChatUtil.printChat("Invalid command usage! Correct usage: .bind [module] [key]");
59
                            }
60
                            break;
61
                        }
62
                        case "help": {
63
                            String[] cmds = new String[] {".help", ".prefix [key]", ".bind [module] [key]", ".vclip [amount]", ".hclip [amount]", ".name", ".say [message]", ".t [module]", ".toggle [module]", ".clientname [name]", ".clientedition [edition]"};
64
                            for (String s : cmds) {
65
                                ChatUtil.printChat(s);
66
                            }
67
                            break;
68
                        }
69
                        case "vclip": {
70
                            if (args[1] != null) {
71
                                try {
72
                                    mc.thePlayer.setPositionAndUpdate(mc.thePlayer.posX, mc.thePlayer.posY + Double.parseDouble(args[1]), mc.thePlayer.posZ);
73
                                    ChatUtil.printChat("VClip'd " + Double.parseDouble(args[1]) + " blocks.");
74
                                } catch (Exception e) {
75
                                    ChatUtil.printChat("Invalid command usage! Correct usage: .vclip [amount]");
76
                                    e.printStackTrace();
77
                                }
78
                            } else {
79
                                ChatUtil.printChat("Invalid command usage! Correct usage: .vclip [amount]");
80
                            }
81
                            break;
82
                        }
83
                        case "hclip": {
84
                            if (args[1] != null) {
85
                                try {
86
                                    double yaw = Math.toRadians(mc.thePlayer.rotationYaw);
87
                                    double distance = Double.parseDouble(args[1]);
88
                                    mc.thePlayer.setPosition(mc.thePlayer.posX + -Math.sin(yaw) * distance, mc.thePlayer.posY, mc.thePlayer.posZ + Math.cos(yaw) * distance);
89
                                    ChatUtil.printChat("HClip'd " + Double.parseDouble(args[1]) + " blocks.");
90
                                } catch (Exception e) {
91
                                    ChatUtil.printChat("Invalid command usage! Correct usage: .hclip [amount]");
92
                                    e.printStackTrace();
93
                                }
94
                            } else {
95
                                ChatUtil.printChat("Invalid command usage! Correct usage: .hclip [amount]");
96
                            }
97
                            break;
98
                        }
99
                        case "name": {
100
                            String name = mc.thePlayer.getName();
101
                            StringSelection stringSelection = new StringSelection(name);
102
                            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
103
                            clipboard.setContents(stringSelection, null);
104
                            ChatUtil.printChat("Copied your username to the clipboard!");
105
                            break;
106
                        }
107
                        case "say": {
108
                            if (args[1] != null) {
109
                                try {
110
                                    String[] bruh = Arrays.copyOfRange(args, 1, args.length);
111
                                    String msg1 = String.join(" ", bruh);
112
                                    mc.thePlayer.sendChatMessage("\uF705" + msg1);
113
                                    ChatUtil.printChat("Said your chat message!");
114
                                } catch (Exception e) {
115
                                    ChatUtil.printChat("Invalid command usage! Correct usage: .say [message]");
116
                                    e.printStackTrace();
117
                                }
118
                            } else {
119
                                ChatUtil.printChat("Invalid command usage! Correct usage: .say [message]");
120
                            }
121
                            break;
122
                        }
123
                        case "t": {
124
                            if (args[1] != null) {
125
                                try {
126
                                    String[] bruh = Arrays.copyOfRange(args, 1, args.length);
127
                                    String module = String.join(" ", bruh);
128
                                    Nekoware.INSTANCE.getModuleManager().getModule(module).toggle();
129
                                    ChatUtil.printChat("Toggled " + module.toUpperCase() + ".");
130
                                } catch (Exception e) {
131
                                    ChatUtil.printChat("Invalid command usage! Correct usage: .t [module]");
132
                                    e.printStackTrace();
133
                                }
134
                            } else {
135
                                ChatUtil.printChat("Invalid command usage! Correct usage: .t [module]");
136
                            }
137
                            break;
138
                        }
139
                        case "toggle": {
140
                            if (args[1] != null) {
141
                                try {
142
                                    String[] bruh = Arrays.copyOfRange(args, 1, args.length);
143
                                    String module = String.join(" ", bruh);
144
                                    Nekoware.INSTANCE.getModuleManager().getModule(module).toggle();
145
                                    ChatUtil.printChat("Toggled " + module.toUpperCase() + ".");
146
                                } catch (Exception e) {
147
                                    ChatUtil.printChat("Invalid command usage! Correct usage: .toggle [module]");
148
                                    e.printStackTrace();
149
                                }
150
                            } else {
151
                                ChatUtil.printChat("Invalid command usage! Correct usage: .toggle [module]");
152
                            }
153
                            break;
154
                        }
155
                        case "clientname": {
156
                            if (args[1] != null) {
157
                                try {
158
                                    String[] bruh = Arrays.copyOfRange(args, 1, args.length);
159
                                    String aeiofhneaon = String.join(" ", bruh);
160
                                    this.clientName = aeiofhneaon;
161
                                    ChatUtil.printChat("Client name set to " + aeiofhneaon + ".");
162
                                } catch (Exception e) {
163
                                    ChatUtil.printChat("Invalid command usage! Correct usage: .clientname [name]");
164
                                    e.printStackTrace();
165
                                }
166
                            } else {
167
                                ChatUtil.printChat("Invalid command usage! Correct usage: .clientname [name]");
168
                            }
169
                            break;
170
                        }
171
                        case "clientedition": {
172
                            if (args[1] != null) {
173
                                try {
174
                                    String[] bruh = Arrays.copyOfRange(args, 1, args.length);
175
                                    String aeiofhneaon = String.join(" ", bruh);
176
                                    this.editionName = aeiofhneaon;
177
                                    ChatUtil.printChat("Client Edition set to " + aeiofhneaon + ".");
178
                                } catch (Exception e) {
179
                                    ChatUtil.printChat("Invalid command usage! Correct usage: .clientedition [edition]");
180
                                    e.printStackTrace();
181
                                }
182
                            } else {
183
                                ChatUtil.printChat("Invalid command usage! Correct usage: .clientedition [edition]");
184
                            }
185
                            break;
186
                        }
187
                        case "prefix": {
188
                            if (args[1] != null) {
189
                                try {
190
                                    String[] bruh = Arrays.copyOfRange(args, 1, args.length);
191
                                    String aeiofhneaon = String.join(" ", bruh);
192
                                    this.prefix = aeiofhneaon;
193
                                    ChatUtil.printChat("Prefix set to " + aeiofhneaon);
194
                                } catch (Exception e) {
195
                                    ChatUtil.printChat("Invalid command usage! Correct usage: .prefix [key]");
196
                                    e.printStackTrace();
197
                                }
198
                            } else {
199
                                ChatUtil.printChat("Invalid command usage! Correct usage: .prefix [key]");
200
                            }
201
                            break;
202
                        }
203
                    }
204
                }
205
            }
206
        }
207
    };
208
}

What this file does

The module is the eventConsumer0 field: a @Handler Consumer<PacketOutEvent> that filters C01PacketChatMessage, cancels dot-prefixed messages before the wire, and switches on the stripped first token. All eleven branches mutate local state only - module key binds, toggles, the clipboard, the static branding strings, and the instance prefix. The .say branch re-emits its payload through sendChatMessage with U+F705 prepended, which is why the second message is not re-cancelled: it no longer starts with '.'. The 'say' boolean is never assigned so the interception always runs, and the .bind branch's args[2] null check cannot work because split never yields null elements - a short invocation throws AIOOBE after cancellation, failing client-side without affecting the wire. Feedback for every branch goes through ChatUtil.printChat.

source ChatUtil.java (command feedback channel)

ChatUtil.java22 lines · JavaOriginal ↗
1
2
package me.nekoWare.client.util;
3
4
import me.nekoWare.client.util.misc.MinecraftUtil;
5
import net.minecraft.network.play.client.C01PacketChatMessage;
6
import net.minecraft.util.ChatComponentText;
7
8
public class ChatUtil implements MinecraftUtil {
9
10
    public static void printChat(final String text) {
11
        mc.thePlayer.addChatComponentMessage(new ChatComponentText("\u00a78[\u00a79Neko\u00a78]\u00a7f " + text));
12
    }
13
14
    public static void printChatFlag(final String text) {
15
        mc.thePlayer.addChatComponentMessage(new ChatComponentText("\u00a78[\u00a79Antihaker\u00a78]\u00a7f " + text));
16
    }
17
18
    public static void sendChat(final String text) {
19
        mc.thePlayer.sendQueue.addToSendQueue(new C01PacketChatMessage(text));
20
    }
21
22
}

What this file does

The Nekoware ChatUtil mirrors the Memeware one with rebranded tags: printChat renders '[Neko]'-prefixed ChatComponentText locally via addChatComponentMessage, printChatFlag uses an '[Antihaker]' tag, and sendChat builds a C01PacketChatMessage and pushes it through mc.thePlayer.sendQueue.addToSendQueue - the direct queue path, which is also what the Spammer-style modules use. All methods are static and the class implements MinecraftUtil for the mc field. The local-only printChat methods are the sole output channel for the Commands switch, so every usage message the user sees is client-rendered and never becomes a packet; only sendChat has a wire effect.

anticheat Countering Checks

The anticheat code that detects or counters the techniques this module uses. Full source, with the detection mechanism explained below each box.

anticheat NoCheatPlus Commands (server-side command rate)

Commands.java117 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.chat;
16
17
import org.bukkit.entity.Player;
18
19
import fr.neatmonster.nocheatplus.checks.Check;
20
import fr.neatmonster.nocheatplus.checks.CheckType;
21
import fr.neatmonster.nocheatplus.players.IPlayerData;
22
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
23
import fr.neatmonster.nocheatplus.utilities.TickTask;
24
25
/**
26
 * Check only for commands
27
 * @author asofold
28
 *
29
 */
30
public class Commands extends Check {
31
32
    public Commands() {
33
        super(CheckType.CHAT_COMMANDS);
34
    }
35
    
36
    /**
37
     * Checks a player for command spam
38
     * 
39
     * @param player
40
     * @param message
41
     * @param cc
42
     * @param pData
43
     * @param captcha
44
     * @return true if successful.
45
     */
46
    public boolean check(final Player player, final String message, 
47
                         final ChatConfig cc, final IPlayerData pData, 
48
                         final ICaptcha captcha) {
49
50
        final long now = System.currentTimeMillis();
51
        final int tick = TickTask.getTick();
52
        final ChatData data = pData.getGenericInstance(ChatData.class);
53
        final boolean captchaEnabled = !cc.captchaSkipCommands && pData.isCheckActive(CheckType.CHAT_CAPTCHA, player); 
54
        if (captchaEnabled){
55
            synchronized (data) {
56
                if (captcha.shouldCheckCaptcha(player, cc, data, pData)){
57
                    captcha.checkCaptcha(player, message, cc, data, true);
58
                    return true;
59
                }
60
            }
61
        }
62
63
        // Rest of the check is done without sync, because the data is only used by this check.
64
        // Weight might later be read from some prefix tree (also known / unknown).
65
        final float weight = 1f;
66
        data.commandsWeights.add(now, weight);
67
        if (tick < data.commandsShortTermTick) {
68
            // TickTask got reset.
69
            data.commandsShortTermTick = tick;
70
            data.commandsShortTermWeight = 1.0;
71
        }
72
        else if (tick - data.commandsShortTermTick < cc.commandsShortTermTicks) {
73
            if (!pData.getCurrentWorldData().shouldAdjustToLag(type) 
74
                || TickTask.getLag(50L * (tick - data.commandsShortTermTick), true) < 1.3f) {
75
                // Add up.
76
                data.commandsShortTermWeight += weight;
77
            }
78
            else {
79
                // Reset, too much lag.
80
                data.commandsShortTermTick = tick;
81
                data.commandsShortTermWeight = 1.0;
82
            }
83
        }
84
        else{
85
            // Reset.
86
            data.commandsShortTermTick = tick;
87
            data.commandsShortTermWeight = 1.0;
88
        }
89
90
        final float nw = data.commandsWeights.score(1f);
91
        final double violation = Math.max(nw - cc.commandsLevel, data.commandsShortTermWeight - cc.commandsShortTermLevel);
92
93
        if (violation > 0.0) {
94
            data.commandsVL += violation;
95
            // TODO: Evaluate if sync(data) is necessary or better for executeActions.
96
            if (captchaEnabled) {
97
                synchronized (data) {
98
                    captcha.sendNewCaptcha(player, cc, data);
99
                }
100
                return true;
101
            }
102
            else if (executeActions(player, data.commandsVL, violation, cc.commandsActions).willCancel()) {
103
                return true;
104
            }
105
        }
106
        else if (cc.chatWarningCheck && now - data.chatWarningTime > cc.chatWarningTimeout && (100f * nw / cc.commandsLevel > cc.chatWarningLevel || 100f * data.commandsShortTermWeight / cc.commandsShortTermLevel > cc.chatWarningLevel)){
107
            player.sendMessage(ColorUtil.replaceColors(cc.chatWarningMessage));
108
            data.chatWarningTime = now;
109
        }
110
        else {
111
            // TODO: This might need invalidation with time.
112
            data.commandsVL *= 0.99;
113
        }
114
        return false;
115
    }
116
117
}

How it counteracts this module

NCP's Commands check exists precisely because command streams are a spam vector: ChatListener.onPlayerCommandPreprocess feeds every PlayerCommandPreprocessEvent into it, with the source comment 'We listen to PlayerCommandPreprocess events because commands can be used for spamming too.' Each command adds weight 1.0 to data.commandsWeights (an ActionFrequency, line 66) and to a short-term tick counter that resets when server lag exceeds a factor of 1.3 (lines 67-88); the violation is max(windowScore - cc.commandsLevel, shortTermWeight - cc.commandsShortTermLevel) (line 91), escalating to a captcha or cc.commandsActions (lines 96-104).

The check cannot see this module's own commands, and that is the honest core of the countering story: the fork cancels dot-prefixed chat client-side, so PlayerCommandPreprocessEvent never fires for .bind, .t or .prefix. What the check does bound is the command traffic the fork lets through unchanged - any normal '/' command the same user issues is scored exactly as if the module did not exist, including burst patterns from the same session. For a private client whose selling point is an invisible command language, the residue it does produce is the only thing any server-side check can ever measure.

anticheat NoCheatPlus Text (message content and frequency)

Text.java331 lines · Java
1
/*
2
 * This program is free software: you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation, either version 3 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
14
 */
15
package fr.neatmonster.nocheatplus.checks.chat;
16
17
import java.util.Collections;
18
import java.util.LinkedList;
19
import java.util.List;
20
import java.util.Map;
21
22
import org.bukkit.entity.Player;
23
24
import fr.neatmonster.nocheatplus.NCPAPIProvider;
25
import fr.neatmonster.nocheatplus.checks.Check;
26
import fr.neatmonster.nocheatplus.checks.CheckType;
27
import fr.neatmonster.nocheatplus.checks.chat.analysis.MessageLetterCount;
28
import fr.neatmonster.nocheatplus.checks.chat.analysis.WordLetterCount;
29
import fr.neatmonster.nocheatplus.checks.chat.analysis.engine.LetterEngine;
30
import fr.neatmonster.nocheatplus.checks.combined.CombinedData;
31
import fr.neatmonster.nocheatplus.components.NoCheatPlusAPI;
32
import fr.neatmonster.nocheatplus.components.registry.feature.INotifyReload;
33
import fr.neatmonster.nocheatplus.config.ConfigFile;
34
import fr.neatmonster.nocheatplus.config.ConfigManager;
35
import fr.neatmonster.nocheatplus.players.IPlayerData;
36
import fr.neatmonster.nocheatplus.utilities.ColorUtil;
37
import fr.neatmonster.nocheatplus.utilities.StringUtil;
38
39
/**
40
 * Some alternative more or less advanced analysis methods.
41
 * @author asofold
42
 *
43
 */
44
public class Text extends Check implements INotifyReload {
45
46
    private LetterEngine engine = null;
47
48
    /** Not really cancelled but above threshold for actions. */
49
    private String lastCancelledMessage = "";
50
    private long lastCancelledTime = 0;
51
52
    private String lastGlobalMessage = "";
53
    private long lastGlobalTime = 0;
54
55
    public Text() {
56
        super(CheckType.CHAT_TEXT);
57
        init();
58
    }
59
60
    /**
61
     * Start analysis.
62
     * @param player
63
     *          The player who issued the message.
64
     * @param message
65
     *          The message to check.
66
     * @param captcha 
67
     *          Used for starting captcha on failure, if configured so.
68
     * @param alreadyCancelled 
69
     * @return
70
     */
71
    public boolean check(final Player player, final String message, 
72
                         final ChatConfig cc, final IPlayerData pData,
73
                         final ICaptcha captcha, boolean isMainThread, final boolean alreadyCancelled) {
74
        final ChatData data = pData.getGenericInstance(ChatData.class);
75
        synchronized (data) {
76
            return unsafeCheck(player, message, captcha, cc, data, pData, isMainThread, alreadyCancelled);
77
        }
78
    }
79
80
    private void init() {
81
        // Set some things from the global config.
82
        final ConfigFile config = ConfigManager.getConfigFile();
83
        final NoCheatPlusAPI api = NCPAPIProvider.getNoCheatPlusAPI();
84
        if (engine != null) {
85
            engine.clear();
86
            api.removeComponent(engine);
87
        }
88
        engine = new LetterEngine(config);
89
        api.addComponent(engine);
90
    }
91
92
    @Override
93
    public void onReload() {
94
        synchronized(engine) {
95
            engine.clear();
96
        }
97
        init();
98
    }
99
100
    /**
101
     * Check without further synchronization.
102
     * @param player
103
     * @param message
104
     * @param captcha
105
     * @param cc
106
     * @param data
107
     * @param isMainThread 
108
     * @param alreadyCancelled 
109
     * @return
110
     */
111
    private boolean unsafeCheck(final Player player, final String message, final ICaptcha captcha,
112
                                final ChatConfig cc, final ChatData data, final IPlayerData pData,
113
                                boolean isMainThread, final boolean alreadyCancelled) {
114
115
        // Test captcha.
116
        if (captcha.shouldCheckCaptcha(player, cc, data, pData)) {
117
            captcha.checkCaptcha(player, message, cc, data, isMainThread);
118
            return true;
119
        } 
120
        else if (alreadyCancelled) {
121
            // Skip checking.
122
            return true;
123
        }
124
125
        final long time = System.currentTimeMillis();
126
        final String lcMessage = message.trim().toLowerCase();
127
        boolean cancel = false;
128
        final boolean debug = pData.isDebugActive(type);
129
        final List<String> debugParts;
130
        if (debug) {
131
            debugParts = new LinkedList<String>();
132
            debugParts.add("Message (length=" + message.length()+"): ");
133
        }
134
        else debugParts = null;
135
136
        // Update the frequency interval weights.
137
        data.chatFrequency.update(time);
138
139
        // Score for this message (violation score).
140
        float score = 0;
141
        final MessageLetterCount letterCounts = new MessageLetterCount(message);
142
        final int msgLen = message.length();
143
144
145
146
        // (Following: random/made up criteria.)
147
        // TODO: Create tests for all methods with wordlists, fake chat (refactor for that).
148
        // Full message processing. ------------
149
        // Upper case.
150
        if (letterCounts.fullCount.upperCase > msgLen / 3) {
151
            // TODO: Regard chunks of 48 or so letters of the message for this?
152
            final float wUpperCase = 0.6f * letterCounts.fullCount.getUpperCaseRatio();
153
            score += wUpperCase  * cc.textMessageUpperCase;
154
        }
155
156
        // Letters vs. word length.
157
        if (msgLen > 4) {
158
            final float fullRep = letterCounts.fullCount.getLetterCountRatio();
159
            // Long messages: very small and very big are bad !
160
            // 128 is a quick attempt to make one long message possible on 1.11.
161
            final float wRepetition = (float) Math.min(msgLen, 128) / 15.0f * Math.abs(0.5f - fullRep);
162
            score += wRepetition * cc.textMessageLetterCount;
163
164
            // Number of words vs. length of message
165
            final float fnWords = (float) letterCounts.words.length / (float) msgLen;
166
            if (fnWords > 0.75f) { // TODO: balance or configure or remove ?
167
                score += fnWords  * cc.textMessagePartition;
168
            }
169
        }
170
171
        final CombinedData cData = pData.getGenericInstance(CombinedData.class);
172
        final long timeout = 8000; // TODO: maybe set dynamically in data.
173
        // Repetition of last message.
174
        if (cc.textMsgRepeatSelf != 0f && time - data.chatLastTime < timeout) {
175
            if (StringUtil.isSimilar(lcMessage, data.chatLastMessage, 0.8f)) {
176
                final float timeWeight = (float) (timeout - (time - data.chatLastTime)) / (float) timeout; 
177
                score += cc.textMsgRepeatSelf * timeWeight;
178
            }
179
        }
180
        // Repetition of last global message.
181
        if (cc.textMsgRepeatGlobal != 0f && time - lastGlobalTime < timeout) {
182
            if (StringUtil.isSimilar(lcMessage, lastGlobalMessage, 0.8f)) {
183
                final float timeWeight = (float) (timeout - (time - lastGlobalTime)) / (float) timeout; 
184
                score += cc.textMsgRepeatGlobal * timeWeight;
185
            }
186
        }
187
        // Repetition of last cancelled message.
188
        if (cc.textMsgRepeatCancel != 0f && time - lastCancelledTime < timeout) {
189
            if (StringUtil.isSimilar(lcMessage, lastCancelledMessage, 0.8f)) {
190
                final float timeWeight = (float) (timeout - (time - lastCancelledTime)) / (float) timeout; 
191
                score += cc.textMsgRepeatCancel * timeWeight;
192
            }
193
        }
194
        // Chat quickly after join.
195
        if (cc.textMsgAfterJoin != 0f && time - cData.lastJoinTime < timeout) {
196
            final float timeWeight = (float) (timeout - (time - cData.lastJoinTime)) / (float) timeout;
197
            score += cc.textMsgAfterJoin * timeWeight; 
198
        }
199
        // Chat without moving.
200
        if (cc.textMsgNoMoving != 0f && time - cData.lastMoveTime > timeout) {
201
            score += cc.textMsgNoMoving;
202
        }
203
204
205
206
        // Per word checks. -------------------
207
        float wWords = 0.0f;
208
        final float avwLen = (float) msgLen / (float) letterCounts.words.length; 
209
        for (final WordLetterCount word : letterCounts.words) {
210
            float wWord = 0.0f;
211
            final int wLen = word.word.length();
212
            // TODO: ? used letters vs. word length.
213
214
            // Length of word vs. av. word length.
215
            final float fLenAv = Math.abs(avwLen - (float) wLen) / avwLen;
216
            wWord += fLenAv * cc.textMessageLengthAv;
217
218
            // Length of word vs. message length;
219
            final float fLenMsg = (float) wLen / (float) msgLen;
220
            wWord += fLenMsg * cc.textMessageLengthMsg;
221
222
            // Not letter:
223
            float notLetter = word.getNotLetterRatio();
224
            notLetter *= notLetter;
225
            wWord += notLetter * cc.textMessageNoLetter;
226
227
            wWord *= wWord; // TODO: quadratic ? (configurable)
228
            wWords += wWord;
229
        }
230
        wWords /= (float) letterCounts.words.length;
231
        score += wWords;
232
233
        if (debug && score > 0f) {
234
            debugParts.add("Simple score: " + StringUtil.fdec3.format(score));
235
        }
236
237
        // Engine:
238
        // TODO: more fine grained sync !
239
        float wEngine = 0f;
240
        final Map<String, Float> engMap;
241
        synchronized (engine) {
242
            engMap = engine.process(letterCounts, player.getName(), cc, data);
243
            // TODO: more fine grained sync !s
244
            // TODO: different methods (add or max or add+max or something else).
245
            for (final Float res : engMap.values()) {
246
                if (cc.textEngineMaximum) {
247
                    wEngine = Math.max(wEngine, res.floatValue());
248
                }
249
                else wEngine += res.floatValue();
250
            }
251
        }
252
        score += wEngine;
253
254
255
        // Wrapping it up. --------------------
256
        // Add weight to frequency counts.
257
        final float normalScore = Math.max(cc.textFreqNormMin, score);
258
        data.chatFrequency.add(time, normalScore);
259
        final float accumulated = cc.textFreqNormWeight * data.chatFrequency.score(cc.textFreqNormFactor);
260
        final boolean normalViolation = accumulated > cc.textFreqNormLevel;
261
        final float shortTermScore = Math.max(cc.textFreqShortTermMin, score);
262
        data.chatShortTermFrequency.add(time, shortTermScore);
263
        // TODO: very short term (1st bucket) or do it indirectly.
264
        final float shortTermAccumulated = cc.textFreqShortTermWeight * data.chatShortTermFrequency.score(cc.textFreqShortTermFactor);
265
        final boolean shortTermViolation = shortTermAccumulated > cc.textFreqShortTermLevel;
266
267
        if (normalViolation || shortTermViolation) {
268
            lastCancelledMessage = lcMessage;
269
            lastCancelledTime = time;
270
271
            final double added;
272
            if (shortTermViolation) {
273
                added = (shortTermAccumulated - cc.textFreqShortTermLevel)/ 3.0;
274
            } 
275
            else added = (accumulated - cc.textFreqNormLevel) / 10.0; 
276
            data.textVL += added;
277
278
            if (captcha.shouldStartCaptcha(player, cc, data, pData)) {
279
                captcha.sendNewCaptcha(player, cc, data);
280
                cancel = true;
281
            }
282
            else {
283
                if (shortTermViolation) {
284
                    if (executeActions(player, data.textVL, added, cc.textFreqShortTermActions).willCancel()) {
285
                        cancel = true;
286
                    }
287
                }
288
                else if (normalViolation) {
289
                    if (executeActions(player, data.textVL, added, cc.textFreqNormActions).willCancel()) {
290
                        cancel = true;
291
                    }
292
                }
293
            }
294
        }
295
        else if (cc.chatWarningCheck && time - data.chatWarningTime > cc.chatWarningTimeout && (100f * accumulated / cc.textFreqNormLevel > cc.chatWarningLevel || 100f * shortTermAccumulated / cc.textFreqShortTermLevel > cc.chatWarningLevel)) {
296
            NCPAPIProvider.getNoCheatPlusAPI().sendMessageOnTick(player.getName(), ColorUtil.replaceColors(cc.chatWarningMessage));
297
            data.chatWarningTime = time;
298
        }
299
        else {
300
            data.textVL *= 0.95;
301
            if (cc.textAllowVLReset && normalScore < 2.0f * cc.textFreqNormWeight && shortTermScore < 2.0f * cc.textFreqShortTermWeight) {
302
                // Reset the VL.
303
                // Maybe elaborate on resetting conditions (after some timeout just divide by two or so?).
304
                data.textVL = 0.0;
305
            }
306
        }
307
308
        if (debug) {
309
            final List<String> keys = new LinkedList<String>(engMap.keySet());
310
            Collections.sort(keys);
311
            for (String key : keys) {
312
                Float s = engMap.get(key);
313
                if (s.floatValue() > 0.0f)
314
                    debugParts.add(key + ":" + StringUtil.fdec3.format(s));
315
            }
316
            if (wEngine > 0.0f)
317
                debugParts.add("Engine score (" + (cc.textEngineMaximum?"max":"sum") + "): " + StringUtil.fdec3.format(wEngine));
318
319
            debugParts.add("Final score: " +  StringUtil.fdec3.format(score));
320
            debugParts.add("Normal: min=" +  StringUtil.fdec3.format(cc.textFreqNormMin) +", weight=" +  StringUtil.fdec3.format(cc.textFreqNormWeight) + " => accumulated=" + StringUtil.fdec3.format(accumulated));
321
            debugParts.add("Short-term: min=" +  StringUtil.fdec3.format(cc.textFreqShortTermMin) +", weight=" +  StringUtil.fdec3.format(cc.textFreqShortTermWeight) + " => accumulated=" + StringUtil.fdec3.format(shortTermAccumulated));
322
            debugParts.add("vl: " + StringUtil.fdec3.format(data.textVL));
323
            debug(player, StringUtil.join(debugParts, " | "));
324
            debugParts.clear();
325
        }
326
327
        lastGlobalMessage = data.chatLastMessage = lcMessage;
328
        lastGlobalTime = data.chatLastTime = time;
329
        return cancel;
330
    }
331
}

How it counteracts this module

Text scores every chat message the server receives, which for this fork means every message that survives the dot-prefix filter. The score combines per-word notLetter ratios squared (lines 209-231), uppercase ratio beyond one third (line 150), letter-count and partition ratios for longer messages (lines 157-169), and an 8-second repeat-similarity comparison against the player's own last message via StringUtil.isSimilar(..., 0.8f) (lines 174-179). Two ActionFrequency accumulators - chatFrequency and chatShortTermFrequency - fold the per-message score into windowed totals compared against textFreqNormLevel and textFreqShortTermLevel (lines 257-265), with flat penalties for chatting within 8 seconds of joining and after 8 seconds of not moving (lines 194-202). A violation arms the captcha or executes actions (lines 267-294).

The .say output is the fork's most identifiable residue: a message beginning with U+F705, a private-use code point no legitimate client emits, scores notLetter on its first word, and a repeated .say produces byte-identical text that the repeat-similarity path compares at 0.8 similarity. The user's ordinary chat in between is scored at whatever rate they actually type, so the check does not distinguish the client from a fast human - it only measures what arrives.

anticheat Spartan ChatEvent (chat hook, no chat analysis)

ChatEvent.java19 lines · Java
1
package ai.idealistic.spartan.listeners.bukkit.standalone;
2
3
import ai.idealistic.spartan.abstraction.protocol.PlayerProtocol;
4
import ai.idealistic.spartan.functionality.concurrent.CheckThread;
5
import ai.idealistic.spartan.functionality.server.PluginBase;
6
import org.bukkit.event.EventHandler;
7
import org.bukkit.event.EventPriority;
8
import org.bukkit.event.Listener;
9
import org.bukkit.event.player.AsyncPlayerChatEvent;
10
11
public class ChatEvent implements Listener {
12
13
    @EventHandler(priority = EventPriority.HIGHEST)
14
    private void Event(AsyncPlayerChatEvent e) {
15
        PlayerProtocol p = PluginBase.getProtocol(e.getPlayer());
16
        CheckThread.run(null, () -> p.executeRunners(e.isCancelled(), e));
17
    }
18
19
}

How it counteracts this module

Spartan registers exactly one chat hook: a standalone listener at EventPriority.HIGHEST on AsyncPlayerChatEvent whose entire body resolves the player's protocol wrapper and pushes the event into Spartan's check-runner thread via p.executeRunners(e.isCancelled(), e). The honest note is that this file is a dispatch shim, not a detection: the mined corpus contains no Spartan chat-content or spam check that consumes this event, so the fork's dot-commands - which never become an AsyncPlayerChatEvent at all because they are cancelled client-side - are doubly invisible to Spartan.

What the hook does establish is the exposure surface: Spartan's HIGHEST priority means moderation plugins listening at NORMAL or LOW see the raw message first, and the .say residue (U+F705 prefix, or any chat the interceptor lets through) is fully visible in the Bukkit event chain. A server running Spartan would need a plugin in that chain to act on the residue; Spartan itself contributes nothing chat-specific here.

← Back to Analysis Hub