Change AddAccent command to be case insensitive (#3112)

This commit is contained in:
DrSmugleaf
2021-02-09 20:21:29 +01:00
committed by GitHub
parent 9b9fbfdcfe
commit 7a069a4a0f
2 changed files with 13 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
#nullable enable #nullable enable
using System;
using System.Linq; using System.Linq;
using System.Text;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.GameObjects.Components.Mobs.Speech; using Content.Server.GameObjects.Components.Mobs.Speech;
using Content.Shared.Administration; using Content.Shared.Administration;
@@ -40,40 +40,34 @@ namespace Content.Server.Commands.Speech
// Get all components that implement the ISpeechComponent except // Get all components that implement the ISpeechComponent except
var speeches = compFactory.GetAllRefTypes() var speeches = compFactory.GetAllRefTypes()
.Where(c => typeof(IAccentComponent).IsAssignableFrom(c) && c.IsClass); .Where(c => typeof(IAccentComponent).IsAssignableFrom(c) && c.IsClass);
var msg = ""; var msg = new StringBuilder();
foreach(var s in speeches) foreach(var s in speeches)
{ {
msg += $"{compFactory.GetRegistration(s).Name}\n"; msg.Append($"{compFactory.GetRegistration(s).Name}\n");
} }
shell.WriteLine(msg);
shell.WriteLine(msg.ToString());
} }
else else
{ {
var name = args[0]; var name = args[0];
// Try to get the Component // Try to get the Component
Type type; if (!compFactory.TryGetRegistration(name, out var registration, true))
try
{ {
var comp = compFactory.GetComponent(name); shell.WriteLine($"Accent {name} not found. Try {Command} ? to get a list of all applicable accents.");
type = comp.GetType();
}
catch (Exception)
{
shell.WriteLine($"Accent {name} not found. Try {Command} ? to get a list of all appliable accents.");
return; return;
} }
var type = registration.Type;
// Check if that already exists // Check if that already exists
try if (player.AttachedEntity.HasComponent(type))
{ {
var comp = player.AttachedEntity.GetComponent(type);
shell.WriteLine("You already have this accent!"); shell.WriteLine("You already have this accent!");
return; return;
} }
catch (Exception)
{
// Accent not found
}
// Generic fuckery // Generic fuckery
var ensure = typeof(IEntity).GetMethod("AddComponent"); var ensure = typeof(IEntity).GetMethod("AddComponent");

View File

@@ -36,7 +36,7 @@ namespace Content.Shared.Administration
Permissions = 1 << 4, Permissions = 1 << 4,
/// <summary> /// <summary>
/// Ability to control teh server like restart it or change the round type. /// Ability to control the server like restart it or change the round type.
/// </summary> /// </summary>
Server = 1 << 5, Server = 1 << 5,