Files
chrani-bot-tng-mod/Harmony/BotCommandPatch.cs
Claude 79718c0acd Fix compilation errors - use correct 7DTD APIs
- Use NetPackageChat instead of non-existent ChatCommandManager
- Use Debug.Log instead of Log.Out
- Add UnityEngine namespace
2025-11-23 17:41:37 +00:00

32 lines
941 B
C#

using HarmonyLib;
using System.Reflection;
using UnityEngine;
public class BotCommandMod : IModApi
{
public void InitMod(Mod _modInstance)
{
Debug.Log("[BotCommandMod] Loading");
var harmony = new Harmony("com.botcommand.mod");
harmony.PatchAll(Assembly.GetExecutingAssembly());
Debug.Log("[BotCommandMod] Loaded");
}
}
[HarmonyPatch(typeof(NetPackageChat))]
[HarmonyPatch("ProcessPackage")]
public class ChatCommandPatch
{
static bool Prefix(NetPackageChat __instance, World _world)
{
if (__instance.Message != null && __instance.Message.StartsWith("/bot "))
{
ClientInfo cInfo = ConnectionManager.Instance.Clients.ForEntityId(__instance.Sender);
string playerName = cInfo != null ? cInfo.playerName : "Unknown";
Debug.Log($"[Bot] {playerName}: {__instance.Message}");
return false;
}
return true;
}
}