Skip to content

Commit 9992cb0

Browse files
committed
Update 1.0.0
1 parent 847733a commit 9992cb0

17 files changed

Lines changed: 433 additions & 44 deletions

.idea/.idea.MegaAPI/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MegaAPI/API/Commands/ICommand.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,30 @@
11
namespace MegaAPI.API.Commands;
22

3-
public class ICommand
3+
/// <summary>
4+
/// Command interface.
5+
/// </summary>
6+
public interface ICommand
47
{
5-
6-
}
8+
/// <summary>
9+
/// Gets the name of the command.
10+
/// </summary>
11+
string Name { get; }
12+
13+
/// <summary>
14+
/// Gets the description of the command.
15+
/// </summary>
16+
string Description { get; }
17+
18+
/// <summary>
19+
/// Gets the alias of a command.
20+
/// </summary>
21+
string[] Aliases { get; }
22+
23+
/// <summary>
24+
/// Executes the command.
25+
/// </summary>
26+
/// <param name="arguments">argument which the player input.</param>
27+
/// <param name="response">the response to give to the player.</param>
28+
/// <returns>if the command ran.</returns>
29+
bool Execute(string[] arguments, out string response);
30+
}
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
namespace MegaAPI.API.Events.Arguments.Console;
22

3-
public class ConsoleAddingLineEventArgs
3+
using System;
4+
using MegaAPI.API.Events.Arguments.Interfaces;
5+
6+
/// <summary>
7+
/// Represents the arguments for the <see cref="Handlers.ConsoleEventsHandler.AddingLine"/> event.
8+
/// </summary>
9+
public class ConsoleAddingLineEventArgs : EventArgs, IDeniableEvent
410
{
5-
6-
}
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="ConsoleAddingLineEventArgs"/> class.
13+
/// </summary>
14+
/// <param name="line">The line to display.</param>
15+
public ConsoleAddingLineEventArgs(string line)
16+
{
17+
Line = line;
18+
IsAllowed = true;
19+
}
20+
21+
/// <summary>
22+
/// Gets or sets the line to display.
23+
/// </summary>
24+
public string Line { get; set; }
25+
26+
/// <inheritdoc/>
27+
public bool IsAllowed { get; set; }
28+
}

MegaAPI/API/Events/Arguments/Console/ConsoleExecutingCommandEventArgs.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,31 @@
44
using MegaAPI.API.Events.Arguments.Interfaces;
55

66
/// <summary>
7-
/// Represents the arguments for the <see cref="Handlers.ConsoleEventsHandler.AddingLine"/> event.
7+
/// Represents the arguments for the <see cref="Handlers.ConsoleEventsHandler.ExecutingCommand"/> event.
88
/// </summary>
9-
public class ConsoleExecutingCommand : EventArgs, IDeniableEvent
9+
public class ConsoleExecutingCommandEventArgs : EventArgs, IDeniableEvent
1010
{
1111
/// <summary>
12-
/// Initializes a new instance of the <see cref="ConsoleExecutingCommand"/> class.
12+
/// Initializes a new instance of the <see cref="ConsoleExecutingCommandEventArgs"/> class.
1313
/// </summary>
14-
/// <param name="line">The line to display.</param>
15-
public ConsoleExecutingCommand(string line)
14+
/// <param name="command">The command the user is trying to run.</param>
15+
/// <param name="arguments">The arguments the user is inputting.</param>
16+
public ConsoleExecutingCommandEventArgs(string command, string[] arguments)
1617
{
17-
Line = line;
18+
Command = command;
19+
Arguments = arguments;
1820
IsAllowed = true;
1921
}
2022

2123
/// <summary>
22-
/// Gets or sets the line to display.
24+
/// Gets or sets the command to run.
2325
/// </summary>
24-
public string Line { get; set; }
26+
public string Command { get; set; }
27+
28+
/// <summary>
29+
/// Gets or sets the arguments to use.
30+
/// </summary>
31+
public string[] Arguments { get; set; }
2532

2633
/// <inheritdoc/>
2734
public bool IsAllowed { get; set; }
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
namespace MegaAPI.API.Events.Arguments.Interfaces;
22

3-
public class IDeniableEvent
3+
/// <summary>
4+
/// Represents an event that can be cancelled.
5+
/// </summary>
6+
public interface IDeniableEvent
47
{
5-
6-
}
8+
/// <summary>
9+
/// Gets or sets a value indicating whether the event is allowed to run.
10+
/// </summary>
11+
public bool IsAllowed { get; set; }
12+
}
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
namespace MegaAPI.API.Events.Handlers;
22

3+
using MegaAPI.API.Events.Arguments.Console;
4+
35
/// <summary>
46
/// Handles all events related to the console.
57
/// </summary>
6-
public static partial class ConsoleEvents
8+
public static partial class ConsoleEventsHandler
79
{
810
/// <summary>
911
/// Gets called when <b>any</b> message gets added to the console.
1012
/// </summary>
1113
/// <remarks>
1214
/// This event is called <b>before</b> the console adds the string.
1315
/// </remarks>
14-
public static event MikEventsHandler<ObjectiveCompletingBaseEventArgs>? Completing;
16+
public static event MikEventsHandler<ConsoleAddingLineEventArgs> AddingLine;
17+
18+
/// <summary>
19+
/// Gets called when <b>any</b> command gets executed to the console.
20+
/// </summary>
21+
/// <remarks>
22+
/// This event is called <b>before</b> the console process the command.
23+
/// </remarks>
24+
public static event MikEventsHandler<ConsoleExecutingCommandEventArgs> ExecutingCommand;
25+
26+
/// <summary>
27+
/// Called before sending a cassie message.
28+
/// </summary>
29+
/// <param name="ev">The <see cref="ConsoleAddingLineEventArgs" /> instance.</param>
30+
public static void OnAddingLine(ConsoleAddingLineEventArgs ev) => AddingLine?.Invoke(ev);
31+
32+
/// <summary>
33+
/// Called before sending a cassie message.
34+
/// </summary>
35+
/// <param name="ev">The <see cref="ConsoleAddingLineEventArgs" /> instance.</param>
36+
public static void OnExecutingCommand(ConsoleExecutingCommandEventArgs ev) => ExecutingCommand?.Invoke(ev);
1537
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
namespace System.Runtime.CompilerServices.Events;
1+
namespace MegaAPI.API.Events;
22

3-
public class MikEventsHandler
4-
{
5-
6-
}
3+
/// <summary>
4+
/// Miks's event handler.
5+
/// Called when an event is triggered.
6+
/// </summary>
7+
public delegate void MikEventsHandler();
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
namespace MegaAPI.API.Events;
22

3+
using System;
4+
35
/// <summary>
4-
/// LabAPI's event handler.
5-
/// Called when an event is triggered.
6+
/// Miks's event handler with a <see cref="EventArgs"/> parameter.
7+
/// Called when an event is with the specified <see cref="EventArgs"/> triggered .
68
/// </summary>
7-
public delegate void MikEventsHandler();
9+
/// <param name="ev">The event arg instance.</param>
10+
/// <typeparam name="TEventArgs">The type of the <see cref="EventArgs"/> of the event.</typeparam>
11+
public delegate void MikEventsHandler<in TEventArgs>(TEventArgs ev)
12+
where TEventArgs : EventArgs;

MegaAPI/API/NullableAttribute.cs

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
1-
namespace MegaAPI.API;
1+
#pragma warning disable SA1600
2+
#pragma warning disable SA1402
23

3-
public class NullableAttribute
4+
namespace System.Runtime.CompilerServices
45
{
5-
6-
}
6+
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue | AttributeTargets.Field | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.GenericParameter)]
7+
internal sealed class NullableAttribute : Attribute
8+
{
9+
public readonly byte[] NullableFlags;
10+
11+
public NullableAttribute(byte nullableFlag)
12+
{
13+
NullableFlags = new byte[] { nullableFlag };
14+
}
15+
16+
public NullableAttribute(byte[] nullableFlags)
17+
{
18+
NullableFlags = nullableFlags;
19+
}
20+
}
21+
22+
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Delegate | AttributeTargets.Enum)]
23+
internal sealed class NullableContextAttribute : Attribute
24+
{
25+
public readonly byte Flag;
26+
27+
public NullableContextAttribute(byte flag)
28+
{
29+
Flag = flag;
30+
}
31+
}
32+
33+
[AttributeUsage(AttributeTargets.Assembly)]
34+
internal sealed class NullablePublicOnlyAttribute : Attribute
35+
{
36+
}
37+
}
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
namespace MegaAPI.Command;
22

3-
public class BuildVersionCommand
3+
using MegaAPI.API.Commands;
4+
5+
/// <inheritdoc />
6+
public class BuildVersionCommand : ICommand
47
{
5-
6-
}
8+
/// <inheritdoc />
9+
public string Name { get; } = "buildversion";
10+
11+
/// <inheritdoc />
12+
public string Description { get; } = "the version of the mod loader";
13+
14+
/// <inheritdoc />
15+
public string[] Aliases { get; } = ["buildinfo", "build"];
16+
17+
/// <inheritdoc />
18+
public bool Execute(string[] arguments, out string response)
19+
{
20+
response = $"Currently running MegaAPI v{MegaAPIPlugin.Instance.Info.Version}";
21+
return true;
22+
}
23+
}

0 commit comments

Comments
 (0)