public StaticCommandItem(StaticCommand staticCommand)
 {
     Name              = staticCommand.Name;
     Category          = staticCommand.Category.Name;
     StaticCommandType = staticCommand.GetType();
     OfflineAvailable  = StaticCommandType.GetCustomAttribute <OfflineAvailableAttribute>() != null;
 }
示例#2
0
        public async Task <bool> ExecuteCommand(StaticCommand staticCommand, TransmissionEvent transmissionEvent,
                                                ExecutionEvent executionEvent, StopEvent stopEvent, List <Condition> conditions, CommandTarget target)
        {
            if (conditions != null && conditions.Count == 0)
            {
                conditions = null;
            }

            var plugin = StaticCommands[staticCommand.GetType()];

            if (plugin != null)
            {
                if (!await UploadPluginToServer(plugin))
                {
                    return(false);
                }
            }

            _connectionManager.SendCommand(new DynamicCommand
            {
                CommandId         = staticCommand.CommandId,
                Target            = target,
                Conditions        = conditions,
                TransmissionEvent = transmissionEvent,
                ExecutionEvent    = executionEvent,
                CommandParameter  = staticCommand.GetCommandParameter().Data,
                PluginHash        = plugin?.PluginHash,
                StopEvent         = stopEvent
            });

            return(true);
        }