From 168acd6b8e4a964bb3a9bb8ea52f3e8080f693a7 Mon Sep 17 00:00:00 2001 From: Citrinate Date: Sun, 10 Mar 2024 18:25:21 -0400 Subject: [PATCH] Remove ASFE DisabledCmds support --- CS2Interface/AdapterBridge.cs | 10 ++++++++++ CS2Interface/CS2Interface.cs | 14 ++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CS2Interface/AdapterBridge.cs b/CS2Interface/AdapterBridge.cs index 8b5a0a8..d80af9c 100644 --- a/CS2Interface/AdapterBridge.cs +++ b/CS2Interface/AdapterBridge.cs @@ -1,6 +1,7 @@ using System; using System.Reflection; using ArchiSteamFarm.Core; +using ArchiSteamFarm.Steam; // ASFEnhanced Adapter https://github.com/chr233/ASFEnhanceAdapterDemoPlugin @@ -29,4 +30,13 @@ public static bool InitAdapter(string pluginName, string pluginId, string? cmdPr return false; } + + internal static string? Response(Bot bot, EAccess access, ulong steamID, string message, string[] args) { + // ASFEnhance wants to intercept commands meant for this plugin, for the purpose of it's DisabledCmds config setting. + // Seems buggy though: https://github.com/Citrinate/FreePackages/issues/28 + // Therefore I'm feeding it this dummy response function, as ASFEnhance requires that cmdHandler not be null. + // This disables DisabledCmds support, but should not effect PLUGINSUPDATE command support + + return null; + } } diff --git a/CS2Interface/CS2Interface.cs b/CS2Interface/CS2Interface.cs index ae2ab93..319724d 100644 --- a/CS2Interface/CS2Interface.cs +++ b/CS2Interface/CS2Interface.cs @@ -16,7 +16,6 @@ public sealed class CS2Interface : IASF, IBotModules, IBotSteamClient, IBotComma internal static ConcurrentDictionary AutoStart = new(); public string Name => nameof(CS2Interface); public Version Version => typeof(CS2Interface).Assembly.GetName().Version ?? new Version("0"); - private bool ASFEnhanceEnabled = false; public Task OnLoaded() { ASF.ArchiLogger.LogGenericInfo("Counter-Strike 2 Interface ASF Plugin by Citrinate"); @@ -24,21 +23,16 @@ public Task OnLoaded() { // ASFEnhanced Adapter https://github.com/chr233/ASFEnhanceAdapterDemoPlugin var flag = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; - var handler = typeof(Commands).GetMethod(nameof(Commands.Response), flag); + var handler = typeof(AdapterBridge).GetMethod(nameof(AdapterBridge.Response), flag); const string pluginId = nameof(CS2Interface); const string cmdPrefix = "CS2INTERFACE"; const string repoName = "Citrinate/CS2Interface"; - var registered = AdapterBridge.InitAdapter(Name, pluginId, cmdPrefix, repoName, handler); - ASFEnhanceEnabled = registered; - + AdapterBridge.InitAdapter(Name, pluginId, cmdPrefix, repoName, handler); + return Task.CompletedTask; } - public async Task OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) { - if (ASFEnhanceEnabled) { - return null; - } - + public async Task OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) { return await Commands.Response(bot, access, steamID, message, args).ConfigureAwait(false); }