private void OnMake(EntityUid uid, string name, string description, string rules, bool makeSentient) { var player = _playerManager.LocalPlayer; if (player == null) { return; } var makeGhostRoleCommand = $"makeghostrole " + $"\"{CommandParsing.Escape(uid.ToString())}\" " + $"\"{CommandParsing.Escape(name)}\" " + $"\"{CommandParsing.Escape(description)}\" " + $"\"{CommandParsing.Escape(rules)}\""; _consoleHost.ExecuteCommand(player.Session, makeGhostRoleCommand); if (makeSentient) { var makeSentientCommand = $"makesentient \"{CommandParsing.Escape(uid.ToString())}\""; _consoleHost.ExecuteCommand(player.Session, makeSentientCommand); } _window.Close(); }
public void Execute(IConsoleShell shell, string argStr, string[] args) { var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("Only players can use this command"); return; } #if DEBUG shell.WriteError("WARNING: The server is using a debug build. You are risking losing your changes."); #endif var mapManager = IoCManager.Resolve <IMapManager>(); int mapId; string mapName; switch (args.Length) { case 1: if (player.AttachedEntity == null) { shell.WriteLine("The map name argument cannot be omitted if you have no entity."); return; } mapId = (int)mapManager.NextMapId(); mapName = args[0]; break; case 2: if (!int.TryParse(args[0], out var id)) { shell.WriteLine($"{args[0]} is not a valid integer."); return; } mapId = id; mapName = args[1]; break; default: shell.WriteLine(Help); return; } shell.ExecuteCommand($"addmap {mapId} false"); shell.ExecuteCommand($"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\" true"); shell.ExecuteCommand("aghost"); shell.ExecuteCommand($"tp 0 0 {mapId}"); var newGrid = mapManager.GetAllGrids().OrderByDescending(g => (int)g.Index).First(); var pauseManager = IoCManager.Resolve <IPauseManager>(); pauseManager.SetMapPaused(newGrid.ParentMapId, true); shell.WriteLine($"Created unloaded map from file {mapName} with id {mapId}. Use \"savebp {newGrid.Index} foo.yml\" to save the new grid as a map."); }
private void _onChatBoxTextSubmitted(ChatBox chatBox, string text) { DebugTools.Assert(chatBox == _currentChatBox); if (string.IsNullOrWhiteSpace(text)) { return; } switch (text[0]) { case ConCmdSlash: { // run locally var conInput = text.Substring(1); _console.ProcessCommand(conInput); break; } case OOCAlias: { var conInput = text.Substring(1); _console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\""); break; } case AdminChatAlias: { var conInput = text.Substring(1); if (_groupController.CanCommand("asay")) { _console.ProcessCommand($"asay \"{CommandParsing.Escape(conInput)}\""); } else { _console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\""); } break; } case MeAlias: { var conInput = text.Substring(1); _console.ProcessCommand($"me \"{CommandParsing.Escape(conInput)}\""); break; } default: { var conInput = _currentChatBox.DefaultChatFormat != null ? string.Format(_currentChatBox.DefaultChatFormat, CommandParsing.Escape(text)) : text; _console.ProcessCommand(conInput); break; } } }
private void SubmitKickButtonOnPressed(BaseButton.ButtonEventArgs obj) { if (_selectedSession == null) { return; } IoCManager.Resolve <IClientConsoleHost>().ExecuteCommand( $"kick \"{_selectedSession.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\""); }
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) { if (player == null) { shell.SendText(player, "Only players can use this command"); return; } var mapManager = IoCManager.Resolve <IMapManager>(); int mapId; string mapName; switch (args.Length) { case 1: if (player.AttachedEntity == null) { shell.SendText(player, "The map name argument cannot be omitted if you have no entity."); return; } mapId = (int)mapManager.NextMapId(); mapName = args[0]; break; case 2: if (!int.TryParse(args[0], out var id)) { shell.SendText(player, $"{args[0]} is not a valid integer."); return; } mapId = id; mapName = args[1]; break; default: shell.SendText(player, Help); return; } shell.ExecuteCommand(player, $"addmap {mapId} false"); shell.ExecuteCommand(player, $"loadbp {mapId} \"{CommandParsing.Escape(mapName)}\""); shell.ExecuteCommand(player, "aghost"); shell.ExecuteCommand(player, $"tp 0 0 {mapId}"); var newGrid = mapManager.GetAllGrids().OrderByDescending(g => g.Index).First(); var pauseManager = IoCManager.Resolve <IPauseManager>(); pauseManager.SetMapPaused(newGrid.ParentMapId, true); shell.SendText(player, $"Created unloaded map from file {mapName} with id {mapId}. Use \"savebp {newGrid.Index} foo.yml\" to save the new grid as a map."); }
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args) { if (player == null) { shell.SendText(player, "Only players can use this command"); return; } if (args.Length != 2) { shell.SendText(player, Help); return; } shell.ExecuteCommand(player, $"addmap {args[0]} false"); shell.ExecuteCommand(player, $"loadbp {args[0]} \"{CommandParsing.Escape(args[1])}\""); shell.ExecuteCommand(player, $"aghost"); shell.ExecuteCommand(player, $"tp 0 0 {args[0]}"); shell.SendText(player, $"Created unloaded map from file {args[1]} with id {args[0]}. Use \"savebp 4 foo.yml\" to save it."); }
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj) { // Small verification if Player Name exists IoCManager.Resolve <IClientConsoleHost>().ExecuteCommand( $"ban \"{PlayerNameLine.Text}\" \"{CommandParsing.Escape(ReasonLine.Text)}\" {MinutesLine.Text}"); }
private void _onChatBoxTextSubmitted(ChatBox chatBox, string text) { DebugTools.Assert(chatBox == _currentChatBox); if (string.IsNullOrWhiteSpace(text)) { return; } // Check if message is longer than the character limit if (text.Length > _maxMessageLength) { string locWarning = Loc.GetString("Your message exceeds {0} character limit", _maxMessageLength); _currentChatBox?.AddLine(locWarning, ChatChannel.Server, Color.Orange); _currentChatBox.ClearOnEnter = false; // The text shouldn't be cleared if it hasn't been sent return; } switch (text[0]) { case ConCmdSlash: { // run locally var conInput = text.Substring(1); _console.ProcessCommand(conInput); break; } case OOCAlias: { var conInput = text.Substring(1); if (string.IsNullOrWhiteSpace(conInput)) { return; } _console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\""); break; } case AdminChatAlias: { var conInput = text.Substring(1); if (string.IsNullOrWhiteSpace(conInput)) { return; } if (_groupController.CanCommand("asay")) { _console.ProcessCommand($"asay \"{CommandParsing.Escape(conInput)}\""); } else { _console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\""); } break; } case MeAlias: { var conInput = text.Substring(1); if (string.IsNullOrWhiteSpace(conInput)) { return; } _console.ProcessCommand($"me \"{CommandParsing.Escape(conInput)}\""); break; } default: { var conInput = _currentChatBox.DefaultChatFormat != null ? string.Format(_currentChatBox.DefaultChatFormat, CommandParsing.Escape(text)) : text; _console.ProcessCommand(conInput); break; } } }
public LateJoinGui() { IoCManager.InjectDependencies(this); Title = Loc.GetString("Late Join"); var jobList = new VBoxContainer(); var vBox = new VBoxContainer { Children = { new ScrollContainer { SizeFlagsVertical = SizeFlags.FillExpand, Children = { jobList } } } }; Contents.AddChild(vBox); foreach (var job in _prototypeManager.EnumeratePrototypes <JobPrototype>().OrderBy(j => j.Name)) { var jobButton = new JobButton { JobId = job.ID }; var jobSelector = new HBoxContainer { SizeFlagsHorizontal = SizeFlags.FillExpand }; var icon = new TextureRect { TextureScale = (2, 2), Stretch = TextureRect.StretchMode.KeepCentered }; if (job.Icon != null) { var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), job.Icon); icon.Texture = specifier.Frame0(); } jobSelector.AddChild(icon); var jobLabel = new Label { Text = job.Name }; jobSelector.AddChild(jobLabel); jobButton.AddChild(jobSelector); jobList.AddChild(jobButton); jobButton.OnPressed += args => { SelectedId?.Invoke(jobButton.JobId); }; } SelectedId += jobId => { Logger.InfoS("latejoin", $"Late joining as ID: {jobId}"); _console.ProcessCommand($"joingame {CommandParsing.Escape(jobId)}"); Close(); }; }
public void TestEscape(string source, string expected) { var escaped = CommandParsing.Escape(source); Assert.That(escaped, Is.EqualTo(expected)); }
public void Execute(IConsoleShell shell, string argStr, string[] args) { var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("Only players can use this command"); return; } #if DEBUG shell.WriteError("WARNING: The server is using a debug build. You are risking losing your changes."); #endif var mapManager = IoCManager.Resolve <IMapManager>(); int mapId; string mapName; switch (args.Length) { case 1: if (player.AttachedEntity == null) { shell.WriteError("The map name argument cannot be omitted if you have no entity."); return; } mapId = (int)mapManager.NextMapId(); mapName = args[0]; break; case 2: if (!int.TryParse(args[0], out var id)) { shell.WriteError($"{args[0]} is not a valid integer."); return; } mapId = id; mapName = args[1]; break; default: shell.WriteLine(Help); return; } // loadmap checks for this on its own but we want to avoid running our other commands. if (mapManager.MapExists(new MapId(mapId))) { shell.WriteError($"Map {mapId} already exists"); return; } shell.ExecuteCommand("sudo cvar events.enabled false"); shell.ExecuteCommand($"loadmap {mapId} \"{CommandParsing.Escape(mapName)}\" true"); if (player.AttachedEntity is { Valid : true } playerEntity&& _entities.GetComponent <MetaDataComponent>(playerEntity).EntityPrototype?.ID != "AdminObserver") { shell.ExecuteCommand("aghost"); } shell.ExecuteCommand($"tp 0 0 {mapId}"); shell.RemoteExecuteCommand("showmarkers"); var newGrid = mapManager.GetAllGrids().OrderByDescending(g => (int)g.Index).First(); var pauseManager = IoCManager.Resolve <IPauseManager>(); pauseManager.SetMapPaused(newGrid.ParentMapId, true); shell.WriteLine($"Created unloaded map from file {mapName} with id {mapId}. Use \"savebp {newGrid.Index} foo.yml\" to save the new grid as a map."); }
public void Execute(IConsoleShell shell, string argStr, string[] args) { var player = shell.Player as IPlayerSession; if (player == null) { shell.WriteLine("Only players can use this command"); return; } if (args.Length > 2) { shell.WriteLine(Help); return; } #if DEBUG shell.WriteError("WARNING: The server is using a debug build. You are risking losing your changes."); #endif var mapManager = IoCManager.Resolve <IMapManager>(); MapId mapId; // Get the map ID to use if (args.Length == 2) { if (!int.TryParse(args[1], out var id)) { shell.WriteError($"{args[1]} is not a valid integer."); return; } mapId = new MapId(id); if (mapManager.MapExists(mapId)) { shell.WriteError($"Map {mapId} already exists"); return; } } else { mapId = mapManager.NextMapId(); } // either load a map or create a new one. if (args.Length == 0) { shell.ExecuteCommand($"addmap {mapId} false"); } else { shell.ExecuteCommand($"loadmap {mapId} \"{CommandParsing.Escape(args[0])}\""); } // was the map actually created? if (!mapManager.MapExists(mapId)) { shell.WriteError($"An error occurred when creating the new map."); return; } // map successfully created. run misc helpful mapping commands if (player.AttachedEntity is { Valid : true } playerEntity&& _entities.GetComponent <MetaDataComponent>(playerEntity).EntityPrototype?.ID != "AdminObserver") { shell.ExecuteCommand("aghost"); } shell.ExecuteCommand("sudo cvar events.enabled false"); shell.ExecuteCommand($"tp 0 0 {mapId}"); shell.RemoteExecuteCommand("showmarkers"); shell.RemoteExecuteCommand("togglelight"); shell.RemoteExecuteCommand("showsubfloorforever"); mapManager.SetMapPaused(mapId, true); if (args.Length != 0) { shell.WriteLine($"Created uninitialized map from file {args[0]} with id {mapId}."); } else { shell.WriteLine($"Created a new uninitialized map with id {mapId}."); } }