From 46bae935029ba3ee5f77010d55fff0e5bee9daa1 Mon Sep 17 00:00:00 2001 From: CraftyBoss Date: Thu, 31 Mar 2022 00:34:47 +0000 Subject: [PATCH] add shine send command --- Server/Program.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Server/Program.cs b/Server/Program.cs index f4ce75e..89fb52b 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -310,7 +310,7 @@ CommandHandler.RegisterCommand("flip", args => { }); CommandHandler.RegisterCommand("shine", args => { - const string optionUsage = "Valid options: list, clear, sync"; + const string optionUsage = "Valid options: list, clear, sync, send"; if (args.Length < 1) return optionUsage; switch (args[0]) { @@ -324,6 +324,18 @@ CommandHandler.RegisterCommand("shine", args => { case "sync" when args.Length == 1: SyncShineBag(); return "Synced shine bag automatically"; + case "send" when args.Length >= 3: + if(int.TryParse(args[1], out int id)) { + Client[] players = args[2] == "*" ? server.Clients.Where(c => c.Connected).ToArray() : server.Clients.Where(c => c.Connected && args[3..].Contains(c.Name)).ToArray(); + Parallel.ForEachAsync(players, async (c,_) => { + await c.Send(new ShinePacket { + ShineId = id + }); + }).Wait(); + return $"Sent Shine Num {id}"; + } + + return optionUsage; default: return optionUsage; }