forked from AdventureTimeSS14/space_station_ADT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new command AdminToggle (AdventureTimeSS14#785)
## Описание PR <!-- Что вы изменили в этом пулл реквесте? --> - [x] Если в кратце, то введена новая команда admin_toggle для снятия и возращения прав в ручную - [x] fuckrule перенесено в другую категорию прав, т.е. отключена для игроков - [x] добавленно логирование на tippy и tip - [x] добавлено логирование на ghostkick - [ ] нельзя забанить пользователя с Permission по нику - [x] нельзя ghostkick прописать пользователю с Permission - [x] нельзя снять права с помощью admin_toggle пользователю с Permission - [x] за сущностями с HideGhostWarpComponent, нельзя следовать ## Требования <!-- В связи с наплывом ПР'ов нам необходимо убедиться, что ПР'ы следуют правильным рекомендациям. Пожалуйста, уделите время прочтению, если делаете пулл реквест (ПР) впервые. Отметьте поля ниже, чтобы подтвердить, что Вы действительно видели их (поставьте X в скобках, например [X]): --> - [x] Я прочитал(а) и следую [Руководство по созданию пулл реквестов](https://docs.spacestation14.com/en/general-development/codebase-info/pull-request-guidelines.html). Я понимаю, что в противном случае мой ПР может быть закрыт по усмотрению мейнтейнера. - [x] Я добавил скриншоты/видео к этому пулл реквесту, демонстрирующие его изменения в игре, **или** этот пулл реквест не требует демонстрации в игре ## Критические изменения <!-- Перечислите все критические изменения, включая изменения пространства имён, публичных классов/методов/полей, переименования прототипов, и предоставьте инструкции по их исправлению. --> **Чейнджлог** NO CL NO FUN <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Новые функции** - Добавлена команда `admin_toggle` для переключения административного статуса игроков. - Улучшена система управления привилегиями администраторов с добавлением проверок на разрешения. - Улучшена механика взаимодействия для призрачных сущностей в системе последователей. - **Исправления ошибок** - Команда `ShowRulesCommand` теперь проверяет права администратора перед отображением правил. - Команда `KickHideCommand` теперь предоставляет более точные сообщения об ошибках при отсутствии игрока. - **Документация** - Обновлены текстовые файлы с описанием и подсказками для команды `admin_toggle`. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
1 parent
8b53525
commit a013142
Showing
15 changed files
with
181 additions
and
15 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
Content.Server/ADT/Administration/Commands/AdminToggleCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Content.Server.Administration.Managers; | ||
using Content.Shared.Administration; | ||
using Robust.Shared.Console; | ||
using Content.Server.Administration; | ||
using Robust.Server.Player; | ||
using System.Linq; | ||
|
||
namespace Content.Server.ADT.Administration.Commands; | ||
|
||
|
||
[AdminCommand(AdminFlags.Permissions)] | ||
public sealed class AdminToggleCommand : LocalizedCommands | ||
{ | ||
[Dependency] private readonly IPlayerLocator _locator = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
public override string Command => "admin_toggle"; | ||
|
||
public override async void Execute(IConsoleShell shell, string argStr, string[] args) | ||
{ | ||
if (args.Length != 2) | ||
{ | ||
shell.WriteLine("Error: invalid arguments!"); | ||
return; | ||
} | ||
|
||
var target = args[0]; | ||
var located = await _locator.LookupIdByNameOrIdAsync(target); | ||
if (located == null) | ||
{ | ||
shell.WriteError(Loc.GetString("cmd-admin_toggle-error-args")); | ||
return; | ||
} | ||
|
||
if (!_playerManager.TryGetSessionById(located.UserId, out var targetSession)) | ||
{ | ||
shell.WriteLine("Not session it's player!"); | ||
return; | ||
} | ||
|
||
if (targetSession == null) | ||
return; | ||
|
||
var mgr = IoCManager.Resolve<IAdminManager>(); | ||
if (args[1] == "deadmin") | ||
{ | ||
mgr.DeAdmin(targetSession); | ||
} | ||
else if (args[1] == "readmin" && !(mgr.GetAdminData(targetSession, includeDeAdmin: true) == null)) | ||
{ | ||
mgr.ReAdmin(targetSession); | ||
} | ||
} | ||
|
||
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args) | ||
{ | ||
if (args.Length == 1) | ||
{ | ||
var options = _playerManager.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray(); | ||
return CompletionResult.FromHintOptions( | ||
options, | ||
LocalizationManager.GetString("cmd-ban-hint")); | ||
} | ||
if (args.Length == 2) | ||
{ | ||
var durations = new CompletionOption[] | ||
{ | ||
new("deadmin", LocalizationManager.GetString("cmd-admin_toggle-deadmin")), | ||
new("readmin", LocalizationManager.GetString("cmd-admin_toggle-readmin")), | ||
}; | ||
return CompletionResult.FromHintOptions(durations, LocalizationManager.GetString("cmd-admin_toggle-hint-duration")); | ||
} | ||
return CompletionResult.Empty; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...T/HideGhostWarp/HideGhostWarpComponent.cs → ...hared/ADT/Ghost/HideGhostWarpComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters