Add client command integration for Build 42: define APIs, event system, hooks, patches, and Lua table converters. Include tests, documentation, and mod support.

This commit is contained in:
Overlord committed 2026-10-03 13:22:47 +02:00
1 parent af7174e128
commit a351fc237c
24 files changed
+870 -48

No files matched your search

@@ -20,6 +20,7 @@ public final class B42PatchSet implements PatchSet
new BackupStoragePatch(),
new CommandLookupPatch(),
new CommandListPatch(),
new ClientCommandPatch(),
new IsoZombieVehiclePerformancePatch(),
new IsoZombieNetworkComponentPerformancePatch(),
new IsoZombieSpotChancePerformancePatch(),
@@ -0,0 +1,43 @@
package dev.overlord.zomboidforge.compat.b42.patches;
import dev.overlord.zomboidforge.patcher.Anchor;
import dev.overlord.zomboidforge.patcher.Hook;
import dev.overlord.zomboidforge.patcher.HookArgument;
import dev.overlord.zomboidforge.patcher.Patches.CancellableHookPatch;
import java.util.List;
/**
* Makes the Lua event {@code OnClientCommand} in {@code GameServer.receiveClientCommand} depend on
* {@code ClientCommandHooks.onClientCommand(module, command, player, tbl)}:
*
* <pre>{@code
* if (!ClientCommandHooks.onClientCommand(module, command, player, tbl))
* LuaEventManager.triggerEvent("OnClientCommand", module, command, player, tbl);
* }</pre>
*
* The arguments are the method's local variables of these names.
*/
public final class ClientCommandPatch extends CancellableHookPatch
{
private static final Anchor.Call ANCHOR = new Anchor.Call(
new Anchor.Method("receiveClientCommand", "(Lzombie/core/network/ByteBufferReader;Lzombie/core/raknet/UdpConnection;S)V"),
"zombie/Lua/LuaEventManager", "triggerEvent", "(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V"
);
private static final Hook HOOK = new Hook(
"dev/overlord/zomboidforge/compat/b42/hooks/ClientCommandHooks", "onClientCommand",
"(Ljava/lang/String;Ljava/lang/String;Lzombie/characters/IsoPlayer;Lse/krka/kahlua/vm/KahluaTable;)Z"
);
private static final List<HookArgument> ARGUMENTS = List.of(
new HookArgument.Local("module"),
new HookArgument.Local("command"),
new HookArgument.Local("player"),
new HookArgument.Local("tbl")
);
public ClientCommandPatch() {
super("zombie/network/GameServer", ClientCommandPatch.ANCHOR, ClientCommandPatch.HOOK, ClientCommandPatch.ARGUMENTS);
}
}