This commit is contained in:
Axwabo 2023-10-27 18:46:42 +02:00
parent f6379df7c8
commit 6bcb554c40
4 changed files with 22 additions and 77 deletions

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props" Condition="Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props')"/>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -49,12 +48,6 @@
<Reference Include="CommandSystem.Core">
<HintPath>$(NW-ASSEMBLIES)\CommandSystem.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis, Version=3.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.3.3.1\lib\netstandard2.0\Microsoft.CodeAnalysis.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=3.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.3.3.1\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>$(NW-ASSEMBLIES)\Mirror.dll</HintPath>
</Reference>
@ -62,40 +55,16 @@
<HintPath>$(NW-ASSEMBLIES)\Mirror.Components.dll</HintPath>
</Reference>
<Reference Include="mscorlib"/>
<Reference Include="PluginAPI, Version=13.1.0.0, Culture=neutral, processorArchitecture=Amd64">
<HintPath>..\packages\Northwood.PluginAPI.13.1.0\lib\net48\PluginAPI.dll</HintPath>
<Reference Include="PluginAPI">
<HintPath>$(NW-ASSEMBLIES)\PluginAPI.dll</HintPath>
</Reference>
<Reference Include="Pooling">
<HintPath>$(NW-ASSEMBLIES)\Pooling.dll</HintPath>
</Reference>
<Reference Include="System"/>
<Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics"/>
<Reference Include="System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encoding.CodePages, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encoding.CodePages.4.5.1\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.3\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Xml"/>
<Reference Include="UnityEngine">
<HintPath>$(NW-ASSEMBLIES)\UnityEngine.dll</HintPath>
@ -103,9 +72,6 @@
<Reference Include="UnityEngine.CoreModule">
<HintPath>$(NW-ASSEMBLIES)\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="YamlDotNet, Version=11.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<HintPath>..\packages\YamlDotNet.11.0.1\lib\net45\YamlDotNet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DeathLogConfig.cs"/>
@ -114,20 +80,7 @@
<Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="ToggleLogsCommand.cs"/>
</ItemGroup>
<ItemGroup>
<None Include="packages.config"/>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll"/>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll"/>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeAnalysis.Analyzers.2.9.8\build\Microsoft.CodeAnalysis.Analyzers.props'))"/>
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -132,8 +132,8 @@ public static class LogHandler
private static string WeaponStatusMessage(bool show, bool hasWeaponEquipped, bool carriesWeapon, float sizeScalar) =>
show && (carriesWeapon || hasWeaponEquipped)
? (hasWeaponEquipped
? " Victim was " + "holding".Underline() + " a weapon."
: " Victim had a weapon " + "in their inventory.".Underline()
? " Victim was " + "holding".Underline() + " a weapon"
: " Victim had a weapon " + "in their inventory".Underline()
).Color(Cyan).Size(30.Scale(sizeScalar))
: "";

View File

@ -6,7 +6,8 @@ using RemoteAdmin;
namespace DeathLog;
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public sealed class ToggleLogsCommand : ICommand {
public sealed class ToggleLogsCommand : ICommand
{
public static readonly HashSet<string> HiddenIdList = new();
public static readonly Dictionary<string, float> SizeScalar = new();
@ -15,16 +16,20 @@ public sealed class ToggleLogsCommand : ICommand {
public string[] Aliases { get; } = {"tkl"};
public string Description => "Toggles the visibility of kill logs or changes the font size scalar for the caller.";
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response) {
if (sender is not PlayerCommandSender {ReferenceHub.characterClassManager.UserId: var id}) {
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (sender is not PlayerCommandSender {ReferenceHub.authManager.UserId: var id})
{
response = "You must be a player to use this command.";
return false;
}
if (arguments.Count < 1) {
if (arguments.Count < 1)
{
if (HiddenIdList.Add(id))
response = "You will no longer see kill logs.";
else {
else
{
HiddenIdList.Remove(id);
response = "You will now see kill logs.";
}
@ -32,7 +37,8 @@ public sealed class ToggleLogsCommand : ICommand {
return true;
}
switch (arguments.At(0).ToLower()) {
switch (arguments.At(0).ToLower())
{
case "on" or "enable" or "true" or "yes":
HiddenIdList.Remove(id);
response = "You will now see kill logs.";
@ -46,13 +52,16 @@ public sealed class ToggleLogsCommand : ICommand {
}
}
private static bool ParseScalar(ArraySegment<string> arguments, string id, out string response) {
if (!float.TryParse(arguments.At(0), out var scalar)) {
private static bool ParseScalar(ArraySegment<string> arguments, string id, out string response)
{
if (!float.TryParse(arguments.At(0), out var scalar))
{
response = "Invalid argument. Expected a float or a boolean.";
return false;
}
if (scalar is not (> 0 and <= 5)) {
if (scalar is not (> 0 and <= 5))
{
response = "Invalid argument. Expected a float in range 0-5.";
return false;
}

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CodeAnalysis.Analyzers" version="2.9.8" targetFramework="net48"
developmentDependency="true"/>
<package id="Microsoft.CodeAnalysis.CSharp" version="3.3.1" targetFramework="net48"/>
<package id="Microsoft.CodeAnalysis.Common" version="3.3.1" targetFramework="net48"/>
<package id="Northwood.PluginAPI" version="13.1.0" targetFramework="net48"/>
<package id="System.Buffers" version="4.4.0" targetFramework="net48"/>
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net48"/>
<package id="System.Memory" version="4.5.3" targetFramework="net48"/>
<package id="System.Numerics.Vectors" version="4.4.0" targetFramework="net48"/>
<package id="System.Reflection.Metadata" version="1.6.0" targetFramework="net48"/>
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="net48"/>
<package id="System.Text.Encoding.CodePages" version="4.5.1" targetFramework="net48"/>
<package id="System.Threading.Tasks.Extensions" version="4.5.3" targetFramework="net48"/>
<package id="YamlDotNet" version="11.0.1" targetFramework="net48"/>
</packages>