From 40cb2a9df6a0bcd2b5c4d8e017fc5f3d8cc7f560 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 7 Oct 2020 08:48:12 -0500 Subject: [PATCH] add say all (broadcast) command --- SharedLibraryCore/Commands/NativeCommands.cs | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/SharedLibraryCore/Commands/NativeCommands.cs b/SharedLibraryCore/Commands/NativeCommands.cs index edd4a5c06..df91d0892 100644 --- a/SharedLibraryCore/Commands/NativeCommands.cs +++ b/SharedLibraryCore/Commands/NativeCommands.cs @@ -239,6 +239,42 @@ namespace SharedLibraryCore.Commands } } + /// + /// Prints out a message to all clients on all servers + /// + public class SayAllCommand : Command + { + public SayAllCommand(CommandConfiguration config, ITranslationLookup translationLookup) : base(config, translationLookup) + { + Name = "sayall"; + Description = _translationLookup["COMMANDS_SAY_ALL_DESC"]; + Alias = "sa"; + Permission = Permission.Moderator; + RequiresTarget = false; + Arguments = new[] + { + new CommandArgument() + { + Name = _translationLookup["COMMANDS_ARGS_MESSAGE"], + Required = true + } + }; + } + + public override Task ExecuteAsync(GameEvent E) + { + string message = _translationLookup["COMMANDS_SAY_ALL_MESSAGE_FORMAT"].FormatExt(E.Origin.Name, E.Data); + + foreach (var server in E.Owner.Manager.GetServers()) + { + server.Broadcast(message, E.Origin); + } + + E.Origin.Tell(_translationLookup["COMMANDS_SAY_SUCCESS"]); + return Task.CompletedTask; + } + } + /// /// Temporarily bans a client ///