From 349fc6299fb07a1d9d83ddabc0bd16864448384d Mon Sep 17 00:00:00 2001 From: Madpeter Date: Fri, 1 May 2020 16:33:31 +0100 Subject: [PATCH] Corrects a issue with the commands system not using the override min args value leading to crashs if you did not send the correct args. --- BSBshared/API/API_interface.cs | 4 +--- CLI/HttpServer/control/Interface/cmd_lib.cs | 2 +- Core/Commands/Parcel/ParcelCommandHelper.cs | 4 ++-- Core/Commands/commandlib.cs | 8 ++++---- Core/RLV/RLV_commandlib.cs | 10 +++++----- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/BSBshared/API/API_interface.cs b/BSBshared/API/API_interface.cs index 5e125fb..f7f0d06 100644 --- a/BSBshared/API/API_interface.cs +++ b/BSBshared/API/API_interface.cs @@ -10,9 +10,7 @@ namespace BetterSecondBotShared.API public abstract class API_interface { public string CommandName { get { return GetType().Name.ToLowerInvariant(); } } - - protected int min_required_args; - public int Min_Required_args { get { return min_required_args; } } + public virtual int Min_Required_args { get { return 0; } } public virtual string Helpfile { get { return "No help given"; } } public virtual string[] ArgTypes { get { return new string[] { }; } } public virtual string[] ArgHints { get { return new string[] { }; } } diff --git a/CLI/HttpServer/control/Interface/cmd_lib.cs b/CLI/HttpServer/control/Interface/cmd_lib.cs index 161f6a5..9afe597 100644 --- a/CLI/HttpServer/control/Interface/cmd_lib.cs +++ b/CLI/HttpServer/control/Interface/cmd_lib.cs @@ -11,7 +11,7 @@ namespace BetterSecondBot.HttpServer.Control.Interface public override string[] ArgHints { get { return new [] { "Command","Args (~#~ split)" }; } } public override string Helpfile { get { return "Calls the Commands interface via HTTP (returns OK if not rejected)"; } } - protected new int min_required_args = 2; + public override int Min_Required_args { get { return 2; } } public override string[] CallFunction(string[] args) { diff --git a/Core/Commands/Parcel/ParcelCommandHelper.cs b/Core/Commands/Parcel/ParcelCommandHelper.cs index 64aef83..822fdf9 100644 --- a/Core/Commands/Parcel/ParcelCommandHelper.cs +++ b/Core/Commands/Parcel/ParcelCommandHelper.cs @@ -33,12 +33,12 @@ namespace BSB.Commands public abstract class ParcelCommand_RequirePerms_1arg : ParcelCommand_RequirePerms { - protected new int min_required_args = 1; + public override int Min_Required_args { get { return 1; } } } public abstract class ParcelCommand_CheckParcel_1arg : ParcelCommand_CheckParcel { - protected new int min_required_args = 1; + public override int Min_Required_args { get { return 1; } } } public abstract class ParcelCommand_RequirePerms : ParcelCommand_CheckParcel diff --git a/Core/Commands/commandlib.cs b/Core/Commands/commandlib.cs index bbdda4c..66cd5f7 100644 --- a/Core/Commands/commandlib.cs +++ b/Core/Commands/commandlib.cs @@ -273,19 +273,19 @@ namespace BSB.Commands public abstract class CoreCommand_1arg : CoreCommand { - protected new int min_required_args = 1; + public override int Min_Required_args { get { return 1; } } } public abstract class CoreCommand_2arg : CoreCommand { - protected new int min_required_args = 2; + public override int Min_Required_args { get { return 2; } } } public abstract class CoreCommand_3arg : CoreCommand { - protected new int min_required_args = 3; + public override int Min_Required_args { get { return 3; } } } public abstract class CoreCommand_4arg : CoreCommand { - protected new int min_required_args = 4; + public override int Min_Required_args { get { return 4; } } } public abstract class CoreCommand_SmartReply_1arg : CoreCommand_1arg { diff --git a/Core/RLV/RLV_commandlib.cs b/Core/RLV/RLV_commandlib.cs index a215391..b724fb4 100644 --- a/Core/RLV/RLV_commandlib.cs +++ b/Core/RLV/RLV_commandlib.cs @@ -58,19 +58,19 @@ namespace BSB.RLV } public abstract class RLV_command_1arg : RLV_command { - protected new int min_required_args = 1; + public override int Min_Required_args { get { return 1; } } } public abstract class RLV_command_2arg : RLV_command { - protected new int min_required_args = 2; + public override int Min_Required_args { get { return 2; } } } public abstract class RLV_command_3arg : RLV_command { - protected new int min_required_args = 3; + public override int Min_Required_args { get { return 3; } } } public abstract class RLV_command_4arg : RLV_command { - protected new int min_required_args = 4; + public override int Min_Required_args { get { return 4; } } } public abstract class RLV_command : API_interface { @@ -141,7 +141,7 @@ namespace BSB.RLV public abstract class RLV_UUID_flag_4arg_yn : RLV_UUID_flag_optional_arg_yn { - protected new int min_required_args = 4; + public override int Min_Required_args { get { return 4; } } public override string Helpfile { get { return "[Class helpfile] RLV / 4arg"; } } public override string[] ArgTypes { get { return new[] { "Unknown", "Unknown", "Unknown", "Unknown" }; } } public override string[] ArgHints { get { return new[] { "Unknown", "Unknown", "Unknown", "Unknown" }; } }