mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
further cleanup of repo
This commit is contained in:
parent
4f8dcb0cd0
commit
323eb92f2e
140 changed files with 1 additions and 2430 deletions
56
.Deprecated/ChatBoxExtensions/Integrations/Base.cs
Normal file
56
.Deprecated/ChatBoxExtensions/Integrations/Base.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
using ABI_RC.Core.Networking;
|
||||
using ABI_RC.Core.Player;
|
||||
|
||||
namespace NAK.ChatBoxExtensions.Integrations;
|
||||
|
||||
public class CommandBase
|
||||
{
|
||||
internal static bool IsCommandForAll(string argument)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(argument)) return false;
|
||||
return argument == "*" || argument.StartsWith("@a") || argument.StartsWith("@e");
|
||||
}
|
||||
|
||||
internal static bool IsCommandForLocalPlayer(string argument)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(argument)) return false;
|
||||
if (argument.Contains("*"))
|
||||
{
|
||||
string partialName = argument.Replace("*", "").Trim();
|
||||
if (String.IsNullOrWhiteSpace(partialName)) return false;
|
||||
return AuthManager.Username.Contains(partialName);
|
||||
}
|
||||
return AuthManager.Username == argument;
|
||||
}
|
||||
|
||||
internal static void LocalCommandIgnoreOthers(string argument, Action<string[]> callback)
|
||||
{
|
||||
string[] args = argument.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray();
|
||||
|
||||
// will fail if arguments are specified which arent local player
|
||||
if (args.Length == 0 || IsCommandForAll(args[0]) || IsCommandForLocalPlayer(args[0])) callback(args);
|
||||
}
|
||||
|
||||
//remote must specify exact player, wont respawn to all
|
||||
internal static void RemoteCommandListenForSelf(string argument, Action<string[]> callback)
|
||||
{
|
||||
string[] args = argument.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray();
|
||||
|
||||
if (args.Length == 0) return;
|
||||
if (IsCommandForLocalPlayer(args[0])) callback(args);
|
||||
}
|
||||
|
||||
// remote must specify player or all, ignore commands without arguments
|
||||
internal static void RemoteCommandListenForAll(string argument, Action<string[]> callback)
|
||||
{
|
||||
string[] args = argument.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray();
|
||||
|
||||
if (args.Length == 0) return;
|
||||
if (IsCommandForAll(args[0]) || IsCommandForLocalPlayer(args[0])) callback(args);
|
||||
}
|
||||
|
||||
internal static string GetPlayerUsername(string guid)
|
||||
{
|
||||
return CVRPlayerManager.Instance.TryGetPlayerName(guid);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue