22
33using LabApi . Features . Enums ;
44
5+ using LabExtended . Commands . Tokens ;
6+ using LabExtended . Commands . Utilities ;
57using LabExtended . Commands . Interfaces ;
68using LabExtended . Commands . Parameters ;
79
810using LabExtended . API ;
9- using LabExtended . Commands . Tokens ;
10- using LabExtended . Commands . Utilities ;
11- using LabExtended . Extensions ;
1211using LabExtended . Utilities ;
12+ using LabExtended . Extensions ;
1313
1414using NorthwoodLib . Pools ;
1515
16- #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
17-
1816namespace LabExtended . Commands ;
1917
2018/// <summary>
@@ -62,66 +60,63 @@ public class CommandBase
6260 /// </summary>
6361 public string Line => Context . Line ;
6462
63+ /// <summary>
64+ /// Gets the dictionary of the overload that is currently being initialized.
65+ /// </summary>
66+ public Dictionary < string , CommandParameterBuilder > Parameters { get ; } = new ( ) ;
67+
6568 /// <summary>
6669 /// Gets or sets the context's response.
6770 /// </summary>
6871 public CommandResponse ? Response
6972 {
7073 get => Context . Response ;
71- set => Context . Response = value ;
74+ set => Context . Response = value ! ;
7275 }
7376
74- /// <summary>
75- /// Called when an overload is called for the first time.
76- /// <remarks><b><paramref name="overloadName"/> will be null if the default overload is being initialized!</b></remarks>
77- /// </summary>
78- /// <param name="overloadName">Name of the overload that is being initialized.</param>
79- /// <param name="parameters">The overload's parameters.</param>
80- public virtual void OnInitializeOverload ( string ? overloadName , Dictionary < string , CommandParameterBuilder > parameters ) { }
81-
8277 /// <summary>
8378 /// Responds to the command.
8479 /// </summary>
8580 /// <param name="content">The message to respond with.</param>
8681 /// <param name="isSuccess">Whether or not the command was successfully executed.</param>
8782 public void Respond ( object content , bool isSuccess = true )
88- => Response = new ( isSuccess , false , false , null , content . ToString ( ) ) ;
83+ => Response = new ( isSuccess , false , false , null ! , content . ToString ( ) ) ;
8984
9085 /// <summary>
9186 /// Responds to the command.
9287 /// </summary>
9388 /// <param name="contentBuilder">Delegate used to build the command's response.</param>
9489 /// <param name="isSuccess">Whether or not the command was successfully executed.</param>
9590 public void Respond ( Action < StringBuilder > contentBuilder , bool isSuccess = true )
96- => Response = new ( isSuccess , false , false , null , StringBuilderPool . Shared . BuildString ( contentBuilder ) ) ;
91+ => Response = new ( isSuccess , false , false , null ! , StringBuilderPool . Shared . BuildString ( contentBuilder ) ) ;
9792
9893 /// <summary>
9994 /// Responds to the command with a success.
10095 /// </summary>
10196 /// <param name="content">The message to respond with.</param>
10297 public void Ok ( object content )
103- => Response = new ( true , false , false , null , content . ToString ( ) ) ;
98+ => Response = new ( true , false , false , null ! , content . ToString ( ) ) ;
10499
105100 /// <summary>
106101 /// Responds to the command with a success.
107102 /// </summary>
108103 /// <param name="contentBuilder">The delegate used to build the command's response.</param>
109104 public void Ok ( Action < StringBuilder > contentBuilder )
110- => Response = new ( true , false , false , null , StringBuilderPool . Shared . BuildString ( contentBuilder ) ) ;
105+ => Response = new ( true , false , false , null ! , StringBuilderPool . Shared . BuildString ( contentBuilder ) ) ;
111106
112107 /// <summary>
113108 /// Responds to the command with a failure.
114109 /// </summary>
115110 /// <param name="content">The message to respond with.</param>
116111 public void Fail ( object content )
117- => Response = new ( false , false , false , null , content . ToString ( ) ) ;
112+ => Response = new ( false , false , false , null ! , content . ToString ( ) ) ;
118113
119114 /// <summary>
120115 /// Responds to the command with a failure.
121116 /// </summary>
122117 /// <param name="contentBuilder">The delegate used to build the command's response.</param>
123118 public void Fail ( Action < StringBuilder > contentBuilder )
124- => Response = new ( false , false , false , null , StringBuilderPool . Shared . BuildString ( contentBuilder ) ) ;
119+ => Response = new ( false , false , false , null ! , StringBuilderPool . Shared . BuildString ( contentBuilder ) ) ;
125120
126121 /// <summary>
127122 /// Responds to the command with an input request.
@@ -155,7 +150,7 @@ void OnInput(string result)
155150 var argList = ListPool < string > . Shared . Rent ( ) ;
156151
157152 var ctx = new CommandContext ( ) ;
158- var parameter = new CommandParameter ( typeof ( T ) , string . Empty , string . Empty , null , false ) ;
153+ var parameter = new CommandParameter ( typeof ( T ) , string . Empty , string . Empty , null ! , false ) ;
159154
160155 ctx . Args = argList ;
161156 ctx . Line = result ;
@@ -181,7 +176,7 @@ void OnInput(string result)
181176 return ;
182177 }
183178
184- onInput ? . InvokeSafe ( ( T ) parsed . Value ) ;
179+ onInput ? . InvokeSafe ( ( T ) parsed . Value ! ) ;
185180
186181 ListPool < string > . Shared . Return ( argList ) ;
187182 ListPool < ICommandToken > . Shared . Return ( list ) ;
@@ -219,17 +214,14 @@ public void Write(Action<StringBuilder> contentBuilder, bool success = true)
219214 /// <param name="content">The content of the message.</param>
220215 /// <param name="success">Whether or not to show the message as successful.</param>
221216 public void WriteThread ( object content , bool success = true )
222- {
223- ThreadUtils . RunOnMainThread ( ( ) => Write ( content , success ) ) ;
224- }
217+ => ThreadUtils . RunOnMainThread ( ( ) => Write ( content , success ) ) ;
218+
225219
226220 /// <summary>
227221 /// Writes a message into the sender's console (you should use this method if you want to respond from another thread).
228222 /// </summary>
229223 /// <param name="contentBuilder">The delegate used to build the message.</param>
230224 /// <param name="success">Whether or not to show the message as successful.</param>
231225 public void WriteThread ( Action < StringBuilder > contentBuilder , bool success = true )
232- {
233- ThreadUtils . RunOnMainThread ( ( ) => Write ( contentBuilder , success ) ) ;
234- }
226+ => ThreadUtils . RunOnMainThread ( ( ) => Write ( contentBuilder , success ) ) ;
235227}
0 commit comments