namespace Content.Server.Whitelist;
[AdminCommand(AdminFlags.Ban)]
-public sealed class AddWhitelistCommand : IConsoleCommand
+public sealed class AddWhitelistCommand : LocalizedCommands
{
- public string Command => "whitelistadd";
- public string Description => Loc.GetString("command-whitelistadd-description");
- public string Help => Loc.GetString("command-whitelistadd-help");
- public async void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "whitelistadd";
+
+ public override async void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (args.Length != 1)
+ if (args.Length == 0)
+ {
+ shell.WriteError(Loc.GetString("shell-need-minimum-one-argument"));
+ shell.WriteLine(Help);
return;
+ }
var db = IoCManager.Resolve<IServerDbManager>();
var loc = IoCManager.Resolve<IPlayerLocator>();
- var name = args[0];
+ var name = string.Join(' ', args).Trim();
var data = await loc.LookupIdByNameAsync(name);
if (data != null)
var isWhitelisted = await db.GetWhitelistStatusAsync(guid);
if (isWhitelisted)
{
- shell.WriteLine(Loc.GetString("command-whitelistadd-existing", ("username", data.Username)));
+ shell.WriteLine(Loc.GetString("cmd-whitelistadd-existing", ("username", data.Username)));
return;
}
await db.AddToWhitelistAsync(guid);
- shell.WriteLine(Loc.GetString("command-whitelistadd-added", ("username", data.Username)));
+ shell.WriteLine(Loc.GetString("cmd-whitelistadd-added", ("username", data.Username)));
return;
}
- shell.WriteError(Loc.GetString("command-whitelistadd-not-found", ("username", args[0])));
+ shell.WriteError(Loc.GetString("cmd-whitelistadd-not-found", ("username", args[0])));
+ }
+
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ {
+ if (args.Length == 1)
+ {
+ return CompletionResult.FromHint(Loc.GetString("cmd-whitelistadd-arg-player"));
+ }
+
+ return CompletionResult.Empty;
}
}
[AdminCommand(AdminFlags.Ban)]
-public sealed class RemoveWhitelistCommand : IConsoleCommand
+public sealed class RemoveWhitelistCommand : LocalizedCommands
{
- public string Command => "whitelistremove";
- public string Description => Loc.GetString("command-whitelistremove-description");
- public string Help => Loc.GetString("command-whitelistremove-help");
- public async void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "whitelistremove";
+
+ public override async void Execute(IConsoleShell shell, string argStr, string[] args)
{
- if (args.Length != 1)
+ if (args.Length == 0)
+ {
+ shell.WriteError(Loc.GetString("shell-need-minimum-one-argument"));
+ shell.WriteLine(Help);
return;
+ }
var db = IoCManager.Resolve<IServerDbManager>();
var loc = IoCManager.Resolve<IPlayerLocator>();
- var name = args[0];
+ var name = string.Join(' ', args).Trim();
var data = await loc.LookupIdByNameAsync(name);
if (data != null)
var isWhitelisted = await db.GetWhitelistStatusAsync(guid);
if (!isWhitelisted)
{
- shell.WriteLine(Loc.GetString("command-whitelistremove-existing", ("username", data.Username)));
+ shell.WriteLine(Loc.GetString("cmd-whitelistremove-existing", ("username", data.Username)));
return;
}
await db.RemoveFromWhitelistAsync(guid);
- shell.WriteLine(Loc.GetString("command-whitelistremove-removed", ("username", data.Username)));
+ shell.WriteLine(Loc.GetString("cmd-whitelistremove-removed", ("username", data.Username)));
return;
}
- shell.WriteError(Loc.GetString("command-whitelistremove-not-found", ("username", args[0])));
+ shell.WriteError(Loc.GetString("cmd-whitelistremove-not-found", ("username", args[0])));
+ }
+
+ public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+ {
+ if (args.Length == 1)
+ {
+ return CompletionResult.FromHint(Loc.GetString("cmd-whitelistremove-arg-player"));
+ }
+
+ return CompletionResult.Empty;
}
}
[AdminCommand(AdminFlags.Ban)]
-public sealed class KickNonWhitelistedCommand : IConsoleCommand
+public sealed class KickNonWhitelistedCommand : LocalizedCommands
{
- public string Command => "kicknonwhitelisted";
- public string Description => Loc.GetString("command-kicknonwhitelisted-description");
- public string Help => Loc.GetString("command-kicknonwhitelisted-help");
- public async void Execute(IConsoleShell shell, string argStr, string[] args)
+ public override string Command => "kicknonwhitelisted";
+
+ public override async void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 0)
+ {
+ shell.WriteError(Loc.GetString("shell-wrong-arguments-number-need-specific", ("properAmount", 0), ("currentAmount", args.Length)));
+ shell.WriteLine(Help);
return;
+ }
var cfg = IoCManager.Resolve<IConfigurationManager>();
net.DisconnectChannel(session.ConnectedClient, Loc.GetString("whitelist-not-whitelisted"));
}
}
-
}
}
}
whitelist-not-whitelisted-rp = You are not whitelisted. To become whitelisted, visit our Discord (which can be found at https://spacestation14.io) and check the #rp-whitelist channel.
-command-whitelistadd-description = Adds the player with the given username to the server whitelist.
-command-whitelistadd-help = whitelistadd <username>
-command-whitelistadd-existing = {$username} is already on the whitelist!
-command-whitelistadd-added = {$username} added to the whitelist
-command-whitelistadd-not-found = Unable to find '{$username}'
+cmd-whitelistadd-desc = Adds the player with the given username to the server whitelist.
+cmd-whitelistadd-help = Usage: whitelistadd <username>
+cmd-whitelistadd-existing = {$username} is already on the whitelist!
+cmd-whitelistadd-added = {$username} added to the whitelist
+cmd-whitelistadd-not-found = Unable to find '{$username}'
+cmd-whitelistadd-arg-player = [player]
-command-whitelistremove-description = Removes the player with the given username from the server whitelist.
-command-whitelistremove-help = whitelistremove <username>
-command-whitelistremove-existing = {$username} is not on the whitelist!
-command-whitelistremove-removed = {$username} removed from the whitelist
-command-whitelistremove-not-found = Unable to find '{$username}'
+cmd-whitelistremove-desc = Removes the player with the given username from the server whitelist.
+cmd-whitelistremove-help = Usage: whitelistremove <username>
+cmd-whitelistremove-existing = {$username} is not on the whitelist!
+cmd-whitelistremove-removed = {$username} removed from the whitelist
+cmd-whitelistremove-not-found = Unable to find '{$username}'
+cmd-whitelistremove-arg-player = [player]
-command-kicknonwhitelisted-description = Kicks all non-whitelisted players from the server.
-command-kicknonwhitelisted-help = kicknonwhitelisted
+cmd-kicknonwhitelisted-desc = Kicks all non-whitelisted players from the server.
+cmd-kicknonwhitelisted-help = Usage: kicknonwhitelisted
ban-banned-permanent = This ban will only be removed via appeal.
ban-banned-permanent-appeal = This ban will only be removed via appeal. You can appeal at {$link}