Exemple #1
0
    public static void Send(string command, string data)
    {
        if (CoopPeerStarter.Dedicated)
        {
            if (CoopSteamClientStarter.IsAdmin)
            {
                switch (command)
                {
                case "kick":
                case "kickbycid":
                case "ban":
                case "banbycid":
                case "unban":
                case "save":
                case "restart":
                case "shutdown":
                case "openlogs":
                case "closelogs":
                case "treeregrowmode":
                case "allowbuildingdestruction":
                case "allowenemiescreative":
                case "allowcheats":
                case "allowdebugconsole":
                {
                    AdminCommand adminCommand = AdminCommand.Create(GlobalTargets.OnlyServer);
                    adminCommand.Command = command;
                    adminCommand.Data    = data;
                    adminCommand.Send();
                    goto IL_193;
                }

                case "help":
                    CoopAdminCommand.SendLocalMessage("Help 1/3:\r\n/kick <steamId>, /ban <steamId>, /save <slotNum>, /restart, /shutdown");
                    CoopAdminCommand.SendLocalMessage("Help 2/3:\r\n/openlogs /closelogs");
                    CoopAdminCommand.SendLocalMessage("Help 3/3:\r\n/treeregrowmode <on|off>, /allowbuildingdestruction <on|off>, /allowenemiescreative <on|off>");
                    goto IL_193;
                }
                CoopAdminCommand.SendLocalMessage(string.Concat(new string[]
                {
                    "Unknow command: '",
                    command,
                    " ",
                    data,
                    "'"
                }));
                IL_193 :;
            }
            else
            {
                CoopAdminCommand.SendLocalMessage(string.Concat(new string[]
                {
                    "Cannot execute command '",
                    command,
                    " ",
                    data,
                    "' (not connected as administrator)"
                }));
            }
        }
    }
Exemple #2
0
 public override void OnEvent(AdminCommand evnt)
 {
     if (evnt.RaisedBy.IsDedicatedServerAdmin())
     {
         CoopAdminCommand.Recv(evnt.Command, evnt.Data);
     }
 }
        public void AdminCommands(AdminCommand control, MetaData metaData)
        {
            try
            {
                switch (control)
                {
                case AdminCommand.Play:
                {
                    callback.PlayVideo(metaData, control);
                    break;
                }

                case AdminCommand.Listen:
                case AdminCommand.StopListen:
                case AdminCommand.Launch:
                case AdminCommand.Pause:
                case AdminCommand.Hop:
                case AdminCommand.Stop:
                default:
                {
                    callback.AdminCommand(control);
                    break;
                }
                }
            }
            catch (Exception)
            {
            }
        }
Exemple #4
0
        /// <summary>
        /// Returns true if command was executed locally.
        /// </summary>
        public static bool RunElevated(AdminCommand command, string param = null)
        {
            // If program is running as Administrator already.
            var argument = command.ToString();

            if (param != null)
            {
                argument = string.Format("{0}=\"{1}\"", command, param);
            }
            if (JocysCom.ClassLibrary.Security.PermissionHelper.IsElevated)
            {
                // Run command directly.
                var args = new string[] { argument };
                ProcessAdminCommands(true, args);
                return(true);
            }
            else
            {
                // Run copy of x360ce as Administrator.
                JocysCom.ClassLibrary.Win32.UacHelper.RunElevated(
                    Application.ExecutablePath,
                    argument,
                    System.Diagnostics.ProcessWindowStyle.Hidden
                    );
                return(false);
            }
        }
        private bool ProcessDsCommand(string cmd, string args, AdminClientServicePeer peer)
        {
            AdminCommand op = new AdminCommand(cmd, args);

            base.RequestOperation("DSService.DSService", op);
            return(true);
        }
        /// <summary>
        ///     Removes the <see cref="AdminCommand"/> instance.
        /// </summary>
        public AdminCommand RemoveDebugCommand()
        {
            AdminCommand tmp = this._adminCommand;

            this._adminCommand = null;
            return(tmp);
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExecuteTheCommand() throws CommandFailed, IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldExecuteTheCommand()
        {
            AdminCommand command = mock(typeof(AdminCommand));

            (new AdminTool(CannedCommand("command", command), new NullBlockerLocator(), new NullOutsideWorld(), false)).execute(null, null, "command", "the", "other", "args");
            verify(command).execute(new string[] { "the", "other", "args" });
        }
Exemple #8
0
        /// <summary>
        /// Runs the specified console command on the player
        /// </summary>
        /// <param name="command"></param>
        /// <param name="args"></param>
        public void Command(string command, params object[] args)
        {
            var adminCommand = AdminCommand.Create(entity.source);

            adminCommand.Command = command;
            adminCommand.Data    = string.Concat(args.Select(o => o.ToString()).ToArray());
            adminCommand.Send();
        }
Exemple #9
0
        /// <summary>
        /// Runs the specified server command
        /// </summary>
        /// <param name="command"></param>
        /// <param name="args"></param>
        public void Command(string command, params object[] args)
        {
            var adminCommand = AdminCommand.Create(GlobalTargets.OnlyServer);

            adminCommand.Command = command;
            adminCommand.Data    = string.Concat(args.Select(o => o.ToString()).ToArray());
            adminCommand.Send();
        }
Exemple #10
0
        /// <summary>
        /// Runs the specified server command
        /// </summary>
        /// <param name="command"></param>
        /// <param name="args"></param>
        public void Command(string command, params object[] args)
        {
            var adminCommand = AdminCommand.Create(GlobalTargets.OnlyServer);

            adminCommand.Command = command;
            adminCommand.Data    = string.Concat(args.Select(o => o.ToString()));
            adminCommand.Send();
            //CoopServerInfo.Instance.ExecuteCommand
        }
Exemple #11
0
 public static void Send(string command, string data)
 {
     if (CoopPeerStarter.Dedicated)
     {
         AdminCommand adminCommand = AdminCommand.Create(GlobalTargets.OnlyServer);
         adminCommand.Command = command;
         adminCommand.Data    = data;
     }
 }
Exemple #12
0
        private static void ServerConsoleOnInput(string input)
        {
            var inputArray   = input.Split();
            var adminCommand = AdminCommand.Create(GlobalTargets.OnlyServer);

            adminCommand.Command = inputArray[0];
            adminCommand.Data    = string.Concat(inputArray.Skip(1).Select(s => s));
            adminCommand.Send();
        }
 private bool ProcessGuildCommand(string cmd, string args, AdminClientServicePeer peer)
 {
     foreach (int num in this.GuildServiceIDs())
     {
         AdminCommand op = new AdminCommand(cmd, args);
         base.RequestOperation("GuildService.GuildService", op);
     }
     return(true);
 }
        /// <summary>
        ///     Decodes this instance.
        /// </summary>
        public override void Decode()
        {
            base.Decode();
            this._adminCommand = AdminCommandFactory.CreateDebugCommandByType(this.Stream.ReadVInt());

            if (this._adminCommand != null)
            {
                this._adminCommand.Decode(this.Stream);
            }
        }
        /// <summary>
        ///     Destructs this instance.
        /// </summary>
        public override void Destruct()
        {
            base.Destruct();

            if (this._adminCommand != null)
            {
                this._adminCommand.Destruct();
                this._adminCommand = null;
            }
        }
Exemple #16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void versionArgumentPrintsVersionEvenWithCommand()
        internal virtual void VersionArgumentPrintsVersionEvenWithCommand()
        {
            AdminCommand command      = mock(typeof(AdminCommand));
            OutsideWorld outsideWorld = mock(typeof(OutsideWorld));

            (new AdminTool(CannedCommand("command", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "command", "--version");

            verifyNoMoreInteractions(command);
            verify(outsideWorld).stdOutLine("neo4j-admin " + neo4jVersion());
            verify(outsideWorld).exit(STATUS_SUCCESS);
        }
 public ICommandResult Handle(AdminCommand command)
 {
     try
     {
         return(EditUser(_dbContext.Admins.Include(x => x.AppUser), command).Result);
     }
     catch
     {
         return(CommandResult.Failed());
     }
 }
 public ICommandResult Handle(AdminCommand command)
 {
     try
     {
         return(CreateUser(_dbContext.Admins, command).Result);
     }
     catch
     {
         return(CommandResult.Failed());
     }
 }
Exemple #19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldProvideFeedbackIfTheCommandFails()
        internal virtual void ShouldProvideFeedbackIfTheCommandFails()
        {
            OutsideWorld outsideWorld = mock(typeof(OutsideWorld));
            AdminCommand command      = args =>
            {
                throw new CommandFailed("the-failure-message");
            };

            (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "exception");
            verify(outsideWorld).stdErrLine("command failed: the-failure-message");
            verify(outsideWorld).exit(STATUS_ERROR);
        }
Exemple #20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotPrintTheStacktraceWhenTheCommandFailsIfTheDebugFlagIsNotSet()
        internal virtual void ShouldNotPrintTheStacktraceWhenTheCommandFailsIfTheDebugFlagIsNotSet()
        {
            OutsideWorld  outsideWorld = mock(typeof(OutsideWorld));
            CommandFailed exception    = new CommandFailed("");
            AdminCommand  command      = args =>
            {
                throw exception;
            };

            (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "exception");
            verify(outsideWorld, never()).printStacktrace(exception);
        }
Exemple #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldPrintTheStacktraceWhenTheCommandThrowsARuntimeExceptionIfTheDebugFlagIsSet()
        internal virtual void ShouldPrintTheStacktraceWhenTheCommandThrowsARuntimeExceptionIfTheDebugFlagIsSet()
        {
            OutsideWorld outsideWorld = mock(typeof(OutsideWorld));
            Exception    exception    = new Exception("");
            AdminCommand command      = args =>
            {
                throw exception;
            };

            (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, true)).execute(null, null, "exception");
            verify(outsideWorld).printStacktrace(exception);
        }
Exemple #22
0
 private static void ServerConsoleOnInput(string input)
 {
     input = input.Trim();
     if (!string.IsNullOrEmpty(input))
     {
         var inputArray   = input.Split();
         var adminCommand = AdminCommand.Create(GlobalTargets.OnlyServer);
         adminCommand.Command = inputArray[0];
         adminCommand.Data    = string.Concat(inputArray.Skip(1).Select(s => s).ToArray());
         adminCommand.Send();
     }
 }
Exemple #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void helpArgumentPrintsHelpForCommand()
        internal virtual void HelpArgumentPrintsHelpForCommand()
        {
            AdminCommand command      = mock(typeof(AdminCommand));
            OutsideWorld outsideWorld = mock(typeof(OutsideWorld));

            (new AdminTool(CannedCommand("command", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "command", "--help");

            verifyNoMoreInteractions(command);
            verify(outsideWorld).stdErrLine("unknown argument: --help");
            verify(outsideWorld).stdErrLine("usage: neo4j-admin command ");
            verify(outsideWorld).exit(STATUS_ERROR);
        }
 private bool ProcessItemCommand(string cmd, string args, int targetServiceID)
 {
     foreach (int num in this.ItemServiceIDs())
     {
         if (targetServiceID == -1 || num == targetServiceID)
         {
             AdminCommand op = new AdminCommand(cmd, args);
             base.RequestOperation(num, op);
         }
     }
     return(true);
 }
Exemple #25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldProvideFeedbackIfTheCommandThrowsARuntimeException()
        internal virtual void ShouldProvideFeedbackIfTheCommandThrowsARuntimeException()
        {
            OutsideWorld outsideWorld = mock(typeof(OutsideWorld));
            AdminCommand command      = args =>
            {
                throw new Exception("the-exception-message");
            };

            (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "exception");
            verify(outsideWorld).stdErrLine("unexpected error: the-exception-message");
            verify(outsideWorld).exit(STATUS_ERROR);
        }
Exemple #26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldProvideFeedbackIfTheCommandReportsAUsageProblem()
        internal virtual void ShouldProvideFeedbackIfTheCommandReportsAUsageProblem()
        {
            OutsideWorld outsideWorld = mock(typeof(OutsideWorld));
            AdminCommand command      = args =>
            {
                throw new IncorrectUsage("the-usage-message");
            };

            (new AdminTool(CannedCommand("exception", command), new NullBlockerLocator(), outsideWorld, false)).execute(null, null, "exception");
            InOrder inOrder = inOrder(outsideWorld);

            inOrder.verify(outsideWorld).stdErrLine("the-usage-message");
            verify(outsideWorld).exit(STATUS_ERROR);
        }
Exemple #27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldNotBlockIfNoneOfTheBlockersBlock() throws CommandFailed, IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldNotBlockIfNoneOfTheBlockersBlock()
        {
            AdminCommand command = mock(typeof(AdminCommand));

            AdminCommand_Blocker falseBlocker = mock(typeof(AdminCommand_Blocker));

            when(falseBlocker.DoesBlock(any(), any())).thenReturn(false);
            when(falseBlocker.Explanation()).thenReturn("falseBlocker explanation");

            BlockerLocator blockerLocator = mock(typeof(BlockerLocator));

            when(blockerLocator.FindBlockers("command")).thenReturn(Arrays.asList(falseBlocker, falseBlocker, falseBlocker));

            (new AdminTool(CannedCommand("command", command), blockerLocator, new NullOutsideWorld(), false)).execute(null, null, "command", "the", "other", "args");
            verify(command).execute(new string[] { "the", "other", "args" });
        }
Exemple #28
0
        /// <summary>
        /// Registers the admin commands.
        /// </summary>
        private void RegisterCommands()
        {
            if (this.autoRestart.AsBool)
            {
                this.RegAdminCmd("restart", AdminFlags.RCON, "Restart Description").Executed         += this.OnRestartCommandExecuted;
                this.RegAdminCmd("voterestart", AdminFlags.Vote, "Voterestart Description").Executed += this.OnVoteshutdownCommandExecuted;
                this.cancelCommand = this.RegAdminCmd("cancelrestart", AdminFlags.Changemap, "Cancelrestart Description");
            }
            else
            {
                this.RegAdminCmd("voteshutdown", AdminFlags.Vote, "Voteshutdown Description").Executed += this.OnVoteshutdownCommandExecuted;
                this.cancelCommand = this.RegAdminCmd("cancelshutdown", AdminFlags.Changemap, "Cancelshutdown Description");
            }

            this.cancelCommand.Executed += this.OnCancelshutdownCommandExecuted;
        }
Exemple #29
0
        /// <inheritdoc/>
        public override void OnLoadPlugin()
        {
            this.LoadTranslations("BaseChat.Plugin");

            this.chatMode = this.CreateConVar("ChatMode", "True", "Allow players to send messages to admin chat.").Value;

            this.AutoExecConfig(true, "BaseChat");

            this.sayCommand  = this.RegAdminCmd("say", AdminFlags.Chat, "Say Description");
            this.psayCommand = this.RegAdminCmd("psay", AdminFlags.Chat, "Psay Description");
            this.chatCommand = this.RegAdminCmd("chat", AdminFlags.Chat, "Chat Description");

            this.sayCommand.Executed  += this.OnSayCommandExecuted;
            this.psayCommand.Executed += this.OnPsayCommandExecuted;
            this.chatCommand.Executed += this.OnChatCommandExecuted;

            ChatHook.ChatMessage += this.OnChatMessage;
        }
Exemple #30
0
 public static void RunElevated(AdminCommand command)
 {
     // If program is running as Administrator already.
     if (JocysCom.ClassLibrary.Security.PermissionHelper.IsElevated)
     {
         // Run command directly.
         var args = new string[] { command.ToString() };
         ProcessAdminCommands(args);
     }
     else
     {
         // Run copy of x360ce as Administrator.
         JocysCom.ClassLibrary.Win32.UacHelper.RunElevated(
             Application.ExecutablePath,
             command.ToString(),
             System.Diagnostics.ProcessWindowStyle.Hidden
             );
     }
 }
        private void AddRowToAdminGrid(AdminCommand adminCommand)
        {
            PopupMenu menuController = new PopupMenu(this);
            int insertRowCount = this.adminGrid.Rows.Count;
            adminGrid.Rows.Insert(insertRowCount);

            SourceGrid.Cells.Views.ColumnHeader nameHeaderView1 = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader namebackHeader1 = new DevAge.Drawing.VisualElements.ColumnHeader();
            namebackHeader1.BackColor = Color.DarkSlateGray;
            nameHeaderView1.Background = namebackHeader1;
            nameHeaderView1.Border = cellBorder;
            nameHeaderView1.ForeColor = Color.White;
            nameHeaderView1.Font = new Font("굴림", 8, FontStyle.Regular);
            nameHeaderView1.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;

            adminGrid[insertRowCount, 0] = new SourceGrid.Cells.Cell(adminCommand.AdminNo);
            adminGrid[insertRowCount, 0].View = viewNormal;
            adminGrid[insertRowCount, 0].AddController(menuController);

            adminGrid[insertRowCount, 1] = new SourceGrid.Cells.Cell(adminCommand.AdminGroupName);
            adminGrid[insertRowCount, 1].View = viewNormal;
            adminGrid[insertRowCount, 1].AddController(menuController);

            adminGrid[insertRowCount, 2] = new SourceGrid.Cells.Cell(adminCommand.Name);
            adminGrid[insertRowCount, 2].View = viewNormal;
            adminGrid[insertRowCount, 2].AddController(menuController);

            adminGrid[insertRowCount, 3] = new SourceGrid.Cells.Cell(adminCommand.Id);
            adminGrid[insertRowCount, 3].View = viewNormal;
            adminGrid[insertRowCount, 3].AddController(menuController);

            adminGrid[insertRowCount, 4] = new SourceGrid.Cells.Cell(adminCommand.Password);
            adminGrid[insertRowCount, 4].View = viewNormal;
            adminGrid[insertRowCount, 4].AddController(menuController);

            adminGrid[insertRowCount, 5] = new SourceGrid.Cells.Cell(adminCommand.AdminRegDate);
            adminGrid[insertRowCount, 5].View = viewNormal;
            adminGrid[insertRowCount, 5].AddController(menuController);
        }
 public override void OnEvent(AdminCommand evnt)
 {
     if (evnt.RaisedBy.IsDedicatedServerAdmin())
     {
         CoopAdminCommand.Recv(evnt.Command, evnt.Data);
     }
 }