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