mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
major cleanup
This commit is contained in:
parent
b33e15377f
commit
e5242f76c7
85 changed files with 584 additions and 571 deletions
|
@ -1,6 +1,5 @@
|
|||
using ABI_RC.Core;
|
||||
using ABI_RC.Core.Base;
|
||||
using Kafe.ChatBox;
|
||||
|
||||
namespace NAK.ChatBoxExtensions.Integrations;
|
||||
|
||||
|
|
|
@ -1,25 +1,30 @@
|
|||
namespace NAK.ChatBoxExtensions.Integrations;
|
||||
|
||||
public static class Commands {
|
||||
public static class Commands
|
||||
{
|
||||
|
||||
private const string Character = "/";
|
||||
private static readonly List<Command> CommandList = new();
|
||||
|
||||
internal static void InitializeCommandHandlers() {
|
||||
internal static void InitializeCommandHandlers()
|
||||
{
|
||||
Kafe.ChatBox.API.OnMessageSent += (source, msg, notification, displayMsg) => HandleSentCommand(msg, notification, displayMsg);
|
||||
Kafe.ChatBox.API.OnMessageReceived += (source, sender, msg, notification, displayMsg) => HandleReceivedCommand(sender, msg, notification, displayMsg);
|
||||
}
|
||||
|
||||
internal static void RegisterCommand(string prefix, Action<string, bool, bool> onCommandSent = null, Action<string, string, bool, bool> onCommandReceived = null) {
|
||||
internal static void RegisterCommand(string prefix, Action<string, bool, bool> onCommandSent = null, Action<string, string, bool, bool> onCommandReceived = null)
|
||||
{
|
||||
var cmd = new Command { Prefix = prefix, OnCommandSent = onCommandSent, OnCommandReceived = onCommandReceived };
|
||||
CommandList.Add(cmd);
|
||||
}
|
||||
|
||||
internal static void UnregisterCommand(string prefix) {
|
||||
internal static void UnregisterCommand(string prefix)
|
||||
{
|
||||
CommandList.RemoveAll(cmd => cmd.Prefix == prefix);
|
||||
}
|
||||
|
||||
private class Command {
|
||||
private class Command
|
||||
{
|
||||
|
||||
internal string Prefix;
|
||||
|
||||
|
@ -30,16 +35,20 @@ public static class Commands {
|
|||
internal Action<string, string, bool, bool> OnCommandReceived;
|
||||
}
|
||||
|
||||
private static void HandleSentCommand(string message, bool notification, bool displayMsg) {
|
||||
private static void HandleSentCommand(string message, bool notification, bool displayMsg)
|
||||
{
|
||||
if (!message.StartsWith(Character)) return;
|
||||
foreach (var command in CommandList.Where(command => message.StartsWith(Character + command.Prefix))) {
|
||||
foreach (var command in CommandList.Where(command => message.StartsWith(Character + command.Prefix)))
|
||||
{
|
||||
command.OnCommandSent?.Invoke(message, notification, displayMsg);
|
||||
}
|
||||
}
|
||||
|
||||
private static void HandleReceivedCommand(string sender, string message, bool notification, bool displayMsg) {
|
||||
private static void HandleReceivedCommand(string sender, string message, bool notification, bool displayMsg)
|
||||
{
|
||||
if (!message.StartsWith(Character)) return;
|
||||
foreach (var command in CommandList.Where(command => message.StartsWith(Character + command.Prefix))) {
|
||||
foreach (var command in CommandList.Where(command => message.StartsWith(Character + command.Prefix)))
|
||||
{
|
||||
command.OnCommandReceived?.Invoke(sender, message, notification, displayMsg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ using System.Reflection;
|
|||
nameof(NAK.ChatBoxExtensions),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/ChatBoxExtensions"
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/ChatBoxExtensions"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/ChatBoxExtensions/releases/download/v1.0.1/ChatBoxExtensions.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/ChatBoxExtensions/",
|
||||
"changelog": "- Initial Release\n- No double patching. Bad. Stinky. Dont do it.",
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/ChatBoxExtensions.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/ChatBoxExtensions/",
|
||||
"changelog": "",
|
||||
"embedcolor": "#ffc700"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue