diff --git a/plugin/AdminChat/AdminChat.deps.json b/plugin/AdminChat/AdminChat.deps.json new file mode 100644 index 0000000..a2de834 --- /dev/null +++ b/plugin/AdminChat/AdminChat.deps.json @@ -0,0 +1,794 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v7.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v7.0": { + "AdminChat/1.0.0": { + "dependencies": { + "CounterStrikeSharp.API": "1.0.101" + }, + "runtime": { + "AdminChat.dll": {} + } + }, + "CounterStrikeSharp.API/1.0.101": { + "dependencies": { + "McMaster.NETCore.Plugins": "1.4.0", + "Microsoft.CSharp": "4.7.0", + "Microsoft.Extensions.Hosting": "7.0.0", + "Microsoft.Extensions.Hosting.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging": "7.0.0", + "Scrutor": "4.2.2", + "Serilog.Extensions.Logging": "7.0.0", + "Serilog.Sinks.Console": "5.0.0", + "Serilog.Sinks.File": "5.0.0", + "System.Data.DataSetExtensions": "4.5.0" + }, + "runtime": { + "lib/net7.0/CounterStrikeSharp.API.dll": { + "assemblyVersion": "1.0.101.0", + "fileVersion": "1.0.101.0" + } + } + }, + "McMaster.NETCore.Plugins/1.4.0": { + "dependencies": { + "Microsoft.DotNet.PlatformAbstractions": "3.1.6", + "Microsoft.Extensions.DependencyModel": "6.0.0" + }, + "runtime": { + "lib/netcoreapp3.1/McMaster.NETCore.Plugins.dll": { + "assemblyVersion": "1.4.0.0", + "fileVersion": "1.4.0.0" + } + } + }, + "Microsoft.CSharp/4.7.0": {}, + "Microsoft.DotNet.PlatformAbstractions/3.1.6": { + "runtime": { + "lib/netstandard2.0/Microsoft.DotNet.PlatformAbstractions.dll": { + "assemblyVersion": "3.1.6.0", + "fileVersion": "3.100.620.31604" + } + } + }, + "Microsoft.Extensions.Configuration/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Configuration.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Configuration.Abstractions/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Primitives": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Configuration.Abstractions.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Configuration.Binder/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Configuration.Binder.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Configuration.CommandLine/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration": "7.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Configuration.CommandLine.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Configuration.EnvironmentVariables/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration": "7.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Configuration.EnvironmentVariables.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Configuration.FileExtensions/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration": "7.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "7.0.0", + "Microsoft.Extensions.FileProviders.Physical": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Configuration.FileExtensions.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Configuration.Json/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration": "7.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", + "Microsoft.Extensions.Configuration.FileExtensions": "7.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "7.0.0", + "System.Text.Json": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Configuration.Json.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Configuration.UserSecrets/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", + "Microsoft.Extensions.Configuration.Json": "7.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "7.0.0", + "Microsoft.Extensions.FileProviders.Physical": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Configuration.UserSecrets.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.DependencyInjection/7.0.0": { + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.DependencyInjection.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions/7.0.0": { + "runtime": { + "lib/net7.0/Microsoft.Extensions.DependencyInjection.Abstractions.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.DependencyModel/6.0.0": { + "dependencies": { + "System.Buffers": "4.5.1", + "System.Memory": "4.5.4", + "System.Runtime.CompilerServices.Unsafe": "6.0.0", + "System.Text.Encodings.Web": "7.0.0", + "System.Text.Json": "7.0.0" + }, + "runtime": { + "lib/netstandard2.0/Microsoft.Extensions.DependencyModel.dll": { + "assemblyVersion": "6.0.0.0", + "fileVersion": "6.0.21.52210" + } + } + }, + "Microsoft.Extensions.FileProviders.Abstractions/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Primitives": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.FileProviders.Abstractions.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.FileProviders.Physical/7.0.0": { + "dependencies": { + "Microsoft.Extensions.FileProviders.Abstractions": "7.0.0", + "Microsoft.Extensions.FileSystemGlobbing": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.FileProviders.Physical.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.FileSystemGlobbing/7.0.0": { + "runtime": { + "lib/net7.0/Microsoft.Extensions.FileSystemGlobbing.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Hosting/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration": "7.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", + "Microsoft.Extensions.Configuration.Binder": "7.0.0", + "Microsoft.Extensions.Configuration.CommandLine": "7.0.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "7.0.0", + "Microsoft.Extensions.Configuration.FileExtensions": "7.0.0", + "Microsoft.Extensions.Configuration.Json": "7.0.0", + "Microsoft.Extensions.Configuration.UserSecrets": "7.0.0", + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "7.0.0", + "Microsoft.Extensions.FileProviders.Physical": "7.0.0", + "Microsoft.Extensions.Hosting.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Configuration": "7.0.0", + "Microsoft.Extensions.Logging.Console": "7.0.0", + "Microsoft.Extensions.Logging.Debug": "7.0.0", + "Microsoft.Extensions.Logging.EventLog": "7.0.0", + "Microsoft.Extensions.Logging.EventSource": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Hosting.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Hosting.Abstractions/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Hosting.Abstractions.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Logging/7.0.0": { + "dependencies": { + "Microsoft.Extensions.DependencyInjection": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Logging.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Logging.Abstractions/7.0.0": { + "runtime": { + "lib/net7.0/Microsoft.Extensions.Logging.Abstractions.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Logging.Configuration/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration": "7.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", + "Microsoft.Extensions.Configuration.Binder": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "Microsoft.Extensions.Options.ConfigurationExtensions": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Logging.Configuration.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Logging.Console/7.0.0": { + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging.Configuration": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Text.Json": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Logging.Console.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Logging.Debug/7.0.0": { + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Logging.Debug.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Logging.EventLog/7.0.0": { + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "System.Diagnostics.EventLog": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Logging.EventLog.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Logging.EventSource/7.0.0": { + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Logging": "7.0.0", + "Microsoft.Extensions.Logging.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0", + "System.Text.Json": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Logging.EventSource.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Options/7.0.0": { + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Options.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Options.ConfigurationExtensions/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "7.0.0", + "Microsoft.Extensions.Configuration.Binder": "7.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.Options": "7.0.0", + "Microsoft.Extensions.Primitives": "7.0.0" + }, + "runtime": { + "lib/net7.0/Microsoft.Extensions.Options.ConfigurationExtensions.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Microsoft.Extensions.Primitives/7.0.0": { + "runtime": { + "lib/net7.0/Microsoft.Extensions.Primitives.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "Scrutor/4.2.2": { + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "7.0.0", + "Microsoft.Extensions.DependencyModel": "6.0.0" + }, + "runtime": { + "lib/net6.0/Scrutor.dll": { + "assemblyVersion": "4.0.0.0", + "fileVersion": "4.0.0.0" + } + } + }, + "Serilog/3.1.0": { + "runtime": { + "lib/net7.0/Serilog.dll": { + "assemblyVersion": "2.0.0.0", + "fileVersion": "3.1.0.0" + } + } + }, + "Serilog.Extensions.Logging/7.0.0": { + "dependencies": { + "Microsoft.Extensions.Logging": "7.0.0", + "Serilog": "3.1.0" + }, + "runtime": { + "lib/net7.0/Serilog.Extensions.Logging.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.0.0" + } + } + }, + "Serilog.Sinks.Console/5.0.0": { + "dependencies": { + "Serilog": "3.1.0" + }, + "runtime": { + "lib/net7.0/Serilog.Sinks.Console.dll": { + "assemblyVersion": "5.0.0.0", + "fileVersion": "5.0.0.0" + } + } + }, + "Serilog.Sinks.File/5.0.0": { + "dependencies": { + "Serilog": "3.1.0" + }, + "runtime": { + "lib/net5.0/Serilog.Sinks.File.dll": { + "assemblyVersion": "5.0.0.0", + "fileVersion": "5.0.0.0" + } + } + }, + "System.Buffers/4.5.1": {}, + "System.Data.DataSetExtensions/4.5.0": {}, + "System.Diagnostics.EventLog/7.0.0": { + "runtime": { + "lib/net7.0/System.Diagnostics.EventLog.dll": { + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + }, + "runtimeTargets": { + "runtimes/win/lib/net7.0/System.Diagnostics.EventLog.Messages.dll": { + "rid": "win", + "assetType": "runtime", + "assemblyVersion": "7.0.0.0", + "fileVersion": "0.0.0.0" + }, + "runtimes/win/lib/net7.0/System.Diagnostics.EventLog.dll": { + "rid": "win", + "assetType": "runtime", + "assemblyVersion": "7.0.0.0", + "fileVersion": "7.0.22.51805" + } + } + }, + "System.Memory/4.5.4": {}, + "System.Runtime.CompilerServices.Unsafe/6.0.0": {}, + "System.Text.Encodings.Web/7.0.0": {}, + "System.Text.Json/7.0.0": { + "dependencies": { + "System.Text.Encodings.Web": "7.0.0" + } + } + } + }, + "libraries": { + "AdminChat/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + }, + "CounterStrikeSharp.API/1.0.101": { + "type": "package", + "serviceable": true, + "sha512": "sha512-DJ4zx1P/ci1oVFpp9F9Yaxh4q3jEAQw1K7SlTPh6Xkk7v3DAMp1wqDf79F1Bixj2ZOsTQf3N84HUff4MAWKzQA==", + "path": "counterstrikesharp.api/1.0.101", + "hashPath": "counterstrikesharp.api.1.0.101.nupkg.sha512" + }, + "McMaster.NETCore.Plugins/1.4.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-UKw5Z2/QHhkR7kiAJmqdCwVDMQV0lwsfj10+FG676r8DsJWIpxtachtEjE0qBs9WoK5GUQIqxgyFeYUSwuPszg==", + "path": "mcmaster.netcore.plugins/1.4.0", + "hashPath": "mcmaster.netcore.plugins.1.4.0.nupkg.sha512" + }, + "Microsoft.CSharp/4.7.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==", + "path": "microsoft.csharp/4.7.0", + "hashPath": "microsoft.csharp.4.7.0.nupkg.sha512" + }, + "Microsoft.DotNet.PlatformAbstractions/3.1.6": { + "type": "package", + "serviceable": true, + "sha512": "sha512-jek4XYaQ/PGUwDKKhwR8K47Uh1189PFzMeLqO83mXrXQVIpARZCcfuDedH50YDTepBkfijCZN5U/vZi++erxtg==", + "path": "microsoft.dotnet.platformabstractions/3.1.6", + "hashPath": "microsoft.dotnet.platformabstractions.3.1.6.nupkg.sha512" + }, + "Microsoft.Extensions.Configuration/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-tldQUBWt/xeH2K7/hMPPo5g8zuLc3Ro9I5d4o/XrxvxOCA2EZBtW7bCHHTc49fcBtvB8tLAb/Qsmfrq+2SJ4vA==", + "path": "microsoft.extensions.configuration/7.0.0", + "hashPath": "microsoft.extensions.configuration.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Configuration.Abstractions/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-f34u2eaqIjNO9YLHBz8rozVZ+TcFiFs0F3r7nUJd7FRkVSxk8u4OpoK226mi49MwexHOR2ibP9MFvRUaLilcQQ==", + "path": "microsoft.extensions.configuration.abstractions/7.0.0", + "hashPath": "microsoft.extensions.configuration.abstractions.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Configuration.Binder/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-tgU4u7bZsoS9MKVRiotVMAwHtbREHr5/5zSEV+JPhg46+ox47Au84E3D2IacAaB0bk5ePNaNieTlPrfjbbRJkg==", + "path": "microsoft.extensions.configuration.binder/7.0.0", + "hashPath": "microsoft.extensions.configuration.binder.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Configuration.CommandLine/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-a8Iq8SCw5m8W5pZJcPCgBpBO4E89+NaObPng+ApIhrGSv9X4JPrcFAaGM4sDgR0X83uhLgsNJq8VnGP/wqhr8A==", + "path": "microsoft.extensions.configuration.commandline/7.0.0", + "hashPath": "microsoft.extensions.configuration.commandline.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Configuration.EnvironmentVariables/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-RIkfqCkvrAogirjsqSrG1E1FxgrLsOZU2nhRbl07lrajnxzSU2isj2lwQah0CtCbLWo/pOIukQzM1GfneBUnxA==", + "path": "microsoft.extensions.configuration.environmentvariables/7.0.0", + "hashPath": "microsoft.extensions.configuration.environmentvariables.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Configuration.FileExtensions/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-xk2lRJ1RDuqe57BmgvRPyCt6zyePKUmvT6iuXqiHR+/OIIgWVR8Ff5k2p6DwmqY8a17hx/OnrekEhziEIeQP6Q==", + "path": "microsoft.extensions.configuration.fileextensions/7.0.0", + "hashPath": "microsoft.extensions.configuration.fileextensions.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Configuration.Json/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-LDNYe3uw76W35Jci+be4LDf2lkQZe0A7EEYQVChFbc509CpZ4Iupod8li4PUXPBhEUOFI/rlQNf5xkzJRQGvtA==", + "path": "microsoft.extensions.configuration.json/7.0.0", + "hashPath": "microsoft.extensions.configuration.json.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Configuration.UserSecrets/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-33HPW1PmB2RS0ietBQyvOxjp4O3wlt+4tIs8KPyMn1kqp04goiZGa7+3mc69NRLv6bphkLDy0YR7Uw3aZyf8Zw==", + "path": "microsoft.extensions.configuration.usersecrets/7.0.0", + "hashPath": "microsoft.extensions.configuration.usersecrets.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.DependencyInjection/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-elNeOmkeX3eDVG6pYVeV82p29hr+UKDaBhrZyWvWLw/EVZSYEkZlQdkp0V39k/Xehs2Qa0mvoCvkVj3eQxNQ1Q==", + "path": "microsoft.extensions.dependencyinjection/7.0.0", + "hashPath": "microsoft.extensions.dependencyinjection.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.DependencyInjection.Abstractions/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-h3j/QfmFN4S0w4C2A6X7arXij/M/OVw3uQHSOFxnND4DyAzO1F9eMX7Eti7lU/OkSthEE0WzRsfT/Dmx86jzCw==", + "path": "microsoft.extensions.dependencyinjection.abstractions/7.0.0", + "hashPath": "microsoft.extensions.dependencyinjection.abstractions.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.DependencyModel/6.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-TD5QHg98m3+QhgEV1YVoNMl5KtBw/4rjfxLHO0e/YV9bPUBDKntApP4xdrVtGgCeQZHVfC2EXIGsdpRNrr87Pg==", + "path": "microsoft.extensions.dependencymodel/6.0.0", + "hashPath": "microsoft.extensions.dependencymodel.6.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.FileProviders.Abstractions/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-NyawiW9ZT/liQb34k9YqBSNPLuuPkrjMgQZ24Y/xXX1RoiBkLUdPMaQTmxhZ5TYu8ZKZ9qayzil75JX95vGQUg==", + "path": "microsoft.extensions.fileproviders.abstractions/7.0.0", + "hashPath": "microsoft.extensions.fileproviders.abstractions.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.FileProviders.Physical/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-K8D2MTR+EtzkbZ8z80LrG7Ur64R7ZZdRLt1J5cgpc/pUWl0C6IkAUapPuK28oionHueCPELUqq0oYEvZfalNdg==", + "path": "microsoft.extensions.fileproviders.physical/7.0.0", + "hashPath": "microsoft.extensions.fileproviders.physical.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.FileSystemGlobbing/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-2jONjKHiF+E92ynz2ZFcr9OvxIw+rTGMPEH+UZGeHTEComVav93jQUWGkso8yWwVBcEJGcNcZAaqY01FFJcj7w==", + "path": "microsoft.extensions.filesystemglobbing/7.0.0", + "hashPath": "microsoft.extensions.filesystemglobbing.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Hosting/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-4nFc8xCfK26G524ioreZvz/IeIKN/gY1LApoGpaIThKqBdTwauUo4ETCf12lQcoefijqe3Imnfvnk31IezFatg==", + "path": "microsoft.extensions.hosting/7.0.0", + "hashPath": "microsoft.extensions.hosting.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Hosting.Abstractions/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-43n9Je09z0p/7ViPxfRqs5BUItRLNVh5b6JH40F2Agkh2NBsY/jpNYTtbCcxrHCsA3oRmbR6RJBzUutB4VZvNQ==", + "path": "microsoft.extensions.hosting.abstractions/7.0.0", + "hashPath": "microsoft.extensions.hosting.abstractions.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Logging/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-Nw2muoNrOG5U5qa2ZekXwudUn2BJcD41e65zwmDHb1fQegTX66UokLWZkJRpqSSHXDOWZ5V0iqhbxOEky91atA==", + "path": "microsoft.extensions.logging/7.0.0", + "hashPath": "microsoft.extensions.logging.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Logging.Abstractions/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-kmn78+LPVMOWeITUjIlfxUPDsI0R6G0RkeAMBmQxAJ7vBJn4q2dTva7pWi65ceN5vPGjJ9q/Uae2WKgvfktJAw==", + "path": "microsoft.extensions.logging.abstractions/7.0.0", + "hashPath": "microsoft.extensions.logging.abstractions.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Logging.Configuration/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-FLDA0HcffKA8ycoDQLJuCNGIE42cLWPxgdQGRBaSzZrYTkMBjnf9zrr8pGT06psLq9Q+RKWmmZczQ9bCrXEBcA==", + "path": "microsoft.extensions.logging.configuration/7.0.0", + "hashPath": "microsoft.extensions.logging.configuration.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Logging.Console/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-qt5n8bHLZPUfuRnFxJKW5q9ZwOTncdh96rtWzWpX3Y/064MlxzCSw2ELF5Jlwdo+Y4wK3I47NmUTFsV7Sg8rqg==", + "path": "microsoft.extensions.logging.console/7.0.0", + "hashPath": "microsoft.extensions.logging.console.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Logging.Debug/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-tFGGyPDpJ8ZdQdeckCArP7nZuoY3am9zJWuvp4OD1bHq65S0epW9BNHzAWeaIO4eYwWnGm1jRNt3vRciH8H6MA==", + "path": "microsoft.extensions.logging.debug/7.0.0", + "hashPath": "microsoft.extensions.logging.debug.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Logging.EventLog/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-Rp7cYL9xQRVTgjMl77H5YDxszAaO+mlA+KT0BnLSVhuCoKQQOOs1sSK2/x8BK2dZ/lKeAC/CVF+20Ef2dpKXwg==", + "path": "microsoft.extensions.logging.eventlog/7.0.0", + "hashPath": "microsoft.extensions.logging.eventlog.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Logging.EventSource/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-MxQXndQFviIyOPqyMeLNshXnmqcfzEHE2wWcr7BF1unSisJgouZ3tItnq+aJLGPojrW8OZSC/ZdRoR6wAq+c7w==", + "path": "microsoft.extensions.logging.eventsource/7.0.0", + "hashPath": "microsoft.extensions.logging.eventsource.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Options/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-lP1yBnTTU42cKpMozuafbvNtQ7QcBjr/CcK3bYOGEMH55Fjt+iecXjT6chR7vbgCMqy3PG3aNQSZgo/EuY/9qQ==", + "path": "microsoft.extensions.options/7.0.0", + "hashPath": "microsoft.extensions.options.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Options.ConfigurationExtensions/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-95UnxZkkFdXxF6vSrtJsMHCzkDeSMuUWGs2hDT54cX+U5eVajrCJ3qLyQRW+CtpTt5OJ8bmTvpQVHu1DLhH+cA==", + "path": "microsoft.extensions.options.configurationextensions/7.0.0", + "hashPath": "microsoft.extensions.options.configurationextensions.7.0.0.nupkg.sha512" + }, + "Microsoft.Extensions.Primitives/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==", + "path": "microsoft.extensions.primitives/7.0.0", + "hashPath": "microsoft.extensions.primitives.7.0.0.nupkg.sha512" + }, + "Scrutor/4.2.2": { + "type": "package", + "serviceable": true, + "sha512": "sha512-t5VIYA7WJXoJJo7s4DoHakMGwTu+MeEnZumMOhTCH7kz9xWha24G7dJNxWrHPlu0ZdZAS4jDZCxxAnyaBh7uYw==", + "path": "scrutor/4.2.2", + "hashPath": "scrutor.4.2.2.nupkg.sha512" + }, + "Serilog/3.1.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-UPJGG8Hz12obhtAELHb0q83j0YpO1vGCypUbH0P4wMZnrpcqmrSLhHkZ/4Ojc+iNVpLwZ/wPBVC3lwSzzoZ/MQ==", + "path": "serilog/3.1.0", + "hashPath": "serilog.3.1.0.nupkg.sha512" + }, + "Serilog.Extensions.Logging/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-9faU0zNQqU7I6soVhLUMYaGNpgWv6cKlKb2S5AnS8gXxzW/em5Ladm/6FMrWTnX41cdbdGPOWNAo6adi4WaJ6A==", + "path": "serilog.extensions.logging/7.0.0", + "hashPath": "serilog.extensions.logging.7.0.0.nupkg.sha512" + }, + "Serilog.Sinks.Console/5.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-IZ6bn79k+3SRXOBpwSOClUHikSkp2toGPCZ0teUkscv4dpDg9E2R2xVsNkLmwddE4OpNVO3N0xiYsAH556vN8Q==", + "path": "serilog.sinks.console/5.0.0", + "hashPath": "serilog.sinks.console.5.0.0.nupkg.sha512" + }, + "Serilog.Sinks.File/5.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-uwV5hdhWPwUH1szhO8PJpFiahqXmzPzJT/sOijH/kFgUx+cyoDTMM8MHD0adw9+Iem6itoibbUXHYslzXsLEAg==", + "path": "serilog.sinks.file/5.0.0", + "hashPath": "serilog.sinks.file.5.0.0.nupkg.sha512" + }, + "System.Buffers/4.5.1": { + "type": "package", + "serviceable": true, + "sha512": "sha512-Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==", + "path": "system.buffers/4.5.1", + "hashPath": "system.buffers.4.5.1.nupkg.sha512" + }, + "System.Data.DataSetExtensions/4.5.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-221clPs1445HkTBZPL+K9sDBdJRB8UN8rgjO3ztB0CQ26z//fmJXtlsr6whGatscsKGBrhJl5bwJuKSA8mwFOw==", + "path": "system.data.datasetextensions/4.5.0", + "hashPath": "system.data.datasetextensions.4.5.0.nupkg.sha512" + }, + "System.Diagnostics.EventLog/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-eUDP47obqQm3SFJfP6z+Fx2nJ4KKTQbXB4Q9Uesnzw9SbYdhjyoGXuvDn/gEmFY6N5Z3bFFbpAQGA7m6hrYJCw==", + "path": "system.diagnostics.eventlog/7.0.0", + "hashPath": "system.diagnostics.eventlog.7.0.0.nupkg.sha512" + }, + "System.Memory/4.5.4": { + "type": "package", + "serviceable": true, + "sha512": "sha512-1MbJTHS1lZ4bS4FmsJjnuGJOu88ZzTT2rLvrhW7Ygic+pC0NWA+3hgAen0HRdsocuQXCkUTdFn9yHJJhsijDXw==", + "path": "system.memory/4.5.4", + "hashPath": "system.memory.4.5.4.nupkg.sha512" + }, + "System.Runtime.CompilerServices.Unsafe/6.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==", + "path": "system.runtime.compilerservices.unsafe/6.0.0", + "hashPath": "system.runtime.compilerservices.unsafe.6.0.0.nupkg.sha512" + }, + "System.Text.Encodings.Web/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-OP6umVGxc0Z0MvZQBVigj4/U31Pw72ITihDWP9WiWDm+q5aoe0GaJivsfYGq53o6dxH7DcXWiCTl7+0o2CGdmg==", + "path": "system.text.encodings.web/7.0.0", + "hashPath": "system.text.encodings.web.7.0.0.nupkg.sha512" + }, + "System.Text.Json/7.0.0": { + "type": "package", + "serviceable": true, + "sha512": "sha512-DaGSsVqKsn/ia6RG8frjwmJonfos0srquhw09TlT8KRw5I43E+4gs+/bZj4K0vShJ5H9imCuXupb4RmS+dBy3w==", + "path": "system.text.json/7.0.0", + "hashPath": "system.text.json.7.0.0.nupkg.sha512" + } + } +} \ No newline at end of file diff --git a/plugin/AdminChat/AdminChat.dll b/plugin/AdminChat/AdminChat.dll new file mode 100644 index 0000000..1b22eb9 Binary files /dev/null and b/plugin/AdminChat/AdminChat.dll differ diff --git a/source/AdminChat.cs b/source/AdminChat.cs new file mode 100644 index 0000000..f515a99 --- /dev/null +++ b/source/AdminChat.cs @@ -0,0 +1,209 @@ +namespace AdminChat; + +using CounterStrikeSharp.API; +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core.Attributes; +using CounterStrikeSharp.API.Core.Attributes.Registration; +using CounterStrikeSharp.API.Modules.Admin; +using CounterStrikeSharp.API.Modules.Commands; +[MinimumApiVersion(71)] +public class AdminChat : BasePlugin +{ + public override string ModuleName => "AdminChat"; + public override string ModuleVersion => "0.1"; + public override string ModuleAuthor => "Johnoclock, WidovV"; + public override string ModuleDescription => "Admin chat"; + + public bool[] g_btoggleasay = new bool[Server.MaxPlayers + 1]; + + public override void Load(bool hotReload) + { + AddCommandListener("say", OnPlayerChat); + AddCommandListener("say_team", OnPlayerChatTeam); + + RegisterListener(OnClientDisconnect); + + new Cfg().CheckConfig(ModuleDirectory); + + Console.WriteLine("AdminChat loaded"); + } + + + public void OnClientDisconnect(int playerSlot) + { + CCSPlayerController player = Utilities.GetPlayerFromSlot(playerSlot); + + if (player.IsBot || !player.IsValid) + { + return; + } + + g_btoggleasay[playerSlot] = false; + } + + [ConsoleCommand("css_asay", "adminsay command")] + [ConsoleCommand("css_adminsay", "adminsay command")] + [RequiresPermissions("@css/chat")] + public void OnCommandAsay(CCSPlayerController? player, CommandInfo command) + { + if (player is null) + { + if (command.ArgCount < 2) + { + Console.WriteLine("Usage: css_adminsay "); + return; + } + + foreach (CCSPlayerController currentPlayer in Utilities.GetPlayers()) + { + if (!ValidClient(currentPlayer)) continue; + + currentPlayer.PrintToChat($"{Cfg.Config.ChatPrefix} {Cfg.Config.ChatHighlight}Console{Cfg.Config.ChatText}: {GetArgs(command, 1)}"); + } + return; + } + + if (!ValidClient(player)) return; + + if (command.ArgCount < 2) + { + player.PrintToChat("Usage: css_adminsay "); + return; + } + + List players = Utilities.GetPlayers(); + + foreach (CCSPlayerController currentPlayer in players) + { + if (!ValidClient(player)) continue; + + if (AdminManager.PlayerHasPermissions(currentPlayer, "@css/chat")) + { + currentPlayer.PrintToChat($"{Cfg.Config.ChatPrefix} {Cfg.Config.ChatHighlight}{player.PlayerName}{Cfg.Config.ChatText}: {GetArgs(command, 1)}"); + } + } + Console.WriteLine($"{Cfg.Config.ChatPrefix} {Cfg.Config.ChatHighlight}{player.PlayerName}{Cfg.Config.ChatText}: {GetArgs(command, 1)}"); + } + + [ConsoleCommand("css_toggleadminsay", "adminsay toggle admin chat command")] + [ConsoleCommand("css_tasay", "adminsay toggle admin chat command")] + [RequiresPermissions("@css/chat")] + public void OnCommandTAsay(CCSPlayerController? player, CommandInfo command) + { + if (!ValidClient(player!)) return; + + if (!g_btoggleasay[player.Slot]) + { + player.PrintToChat($"{Cfg.Config.ChatPrefix} Admin chat is now toggle on"); + g_btoggleasay[player.Slot] = true; + + } + else + { + player.PrintToChat($"{Cfg.Config.ChatPrefix} Admin chat is now toggle off"); + g_btoggleasay[player.Slot] = false; + } + } + + private HookResult OnPlayerChat(CCSPlayerController? player, CommandInfo info) + { + if (player is null) + { + foreach (CCSPlayerController currentPlayer in Utilities.GetPlayers()) + { + if (!ValidClient(currentPlayer)) continue; + + currentPlayer.PrintToChat($"{Cfg.Config.ChatPrefix} {Cfg.Config.ChatHighlight}Console{Cfg.Config.ChatText}: {GetArgs(info, 1)}"); + } + return HookResult.Handled; + } + + if (!g_btoggleasay[player.Slot] == true || !player.IsValid) return HookResult.Continue; + + char firstChar = info.GetArg(1)[0]; + if (firstChar == '!' || firstChar == '/') + { + return HookResult.Continue; + } + else + { + List players = Utilities.GetPlayers(); + + foreach (CCSPlayerController currentPlayer in players) + { + if (!AdminManager.PlayerHasPermissions(currentPlayer, "@css/chat")) + { + continue; + } + + currentPlayer.PrintToChat($"{Cfg.Config.ChatPrefix} {Cfg.Config.ChatHighlight}{player.PlayerName}{Cfg.Config.ChatText}: {GetArgs(info, 1)}"); + } + Console.WriteLine($"{Cfg.Config.ChatPrefix} {Cfg.Config.ChatHighlight}{player.PlayerName}{Cfg.Config.ChatText}: {GetArgs(info, 1)}"); + return HookResult.Handled; + } + } + + + private HookResult OnPlayerChatTeam(CCSPlayerController? player, CommandInfo info) + { + if (player is null) + { + foreach (CCSPlayerController currentPlayer in Utilities.GetPlayers()) + { + if (!ValidClient(currentPlayer)) continue; + + currentPlayer.PrintToChat($"{Cfg.Config.ChatPrefix} {Cfg.Config.ChatHighlight}Console{Cfg.Config.ChatText}: {GetArgs(info, 1)}"); + } + return HookResult.Handled; + } + + if (!g_btoggleasay[player.Slot] == true || !player.IsValid) return HookResult.Continue; + + char firstChar = info.GetArg(1)[0]; + if (firstChar == '!' || firstChar == '/') + { + return HookResult.Continue; + } + else + { + List players = Utilities.GetPlayers(); + + foreach (CCSPlayerController currentPlayer in players) + { + if (!AdminManager.PlayerHasPermissions(currentPlayer, "@css/chat")) + { + continue; + } + + currentPlayer.PrintToChat($"{Cfg.Config.ChatPrefix} {Cfg.Config.ChatHighlight}{player.PlayerName}{Cfg.Config.ChatText}: {GetArgs(info, 1)}"); + } + Console.WriteLine($"{Cfg.Config.ChatPrefix} {Cfg.Config.ChatHighlight}{player.PlayerName}{Cfg.Config.ChatText}: {GetArgs(info, 1)}"); + return HookResult.Handled; + } + } + + private bool ValidClient(CCSPlayerController player) + { + if (!player.IsValid || player.Connected != PlayerConnectedState.PlayerConnected || player.IsHLTV || !player.PlayerPawn.IsValid || player.UserId == -1 || player.IsBot) return false; + return true; + } + + + private string GetArgs(CommandInfo info, int start, int end = -1) + { + // Get the number of arguments to copy + int stop = end == -1 ? info.ArgCount : end; + + // Create a new array to store the arguments + string[] args = new string[stop - start]; + + // Loop through the arguments + for (int i = start; i < stop; i++) + { + // Copy the argument to the new array + args[i - start] = info.GetArg(i); + } + // Join the arguments into a string and return it + return string.Join(" ", args); + } +} \ No newline at end of file diff --git a/source/AdminChat.csproj b/source/AdminChat.csproj new file mode 100644 index 0000000..55e9d27 --- /dev/null +++ b/source/AdminChat.csproj @@ -0,0 +1,13 @@ + + + + net7.0 + enable + enable + + + + + + + diff --git a/source/AdminChat.sln b/source/AdminChat.sln new file mode 100644 index 0000000..f977b03 --- /dev/null +++ b/source/AdminChat.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.002.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdminChat", "AdminChat.csproj", "{96442F5D-3B64-4A83-876B-623EFB8A6719}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {96442F5D-3B64-4A83-876B-623EFB8A6719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {96442F5D-3B64-4A83-876B-623EFB8A6719}.Debug|Any CPU.Build.0 = Debug|Any CPU + {96442F5D-3B64-4A83-876B-623EFB8A6719}.Release|Any CPU.ActiveCfg = Release|Any CPU + {96442F5D-3B64-4A83-876B-623EFB8A6719}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F5B570AE-0138-47C1-90CD-933CA625E861} + EndGlobalSection +EndGlobal diff --git a/source/CFG.cs b/source/CFG.cs new file mode 100644 index 0000000..d358b06 --- /dev/null +++ b/source/CFG.cs @@ -0,0 +1,120 @@ +using CounterStrikeSharp.API.Modules.Utils; +using System.IO; +using System.Reflection; +using System.Text.Json; + + +namespace AdminChat; + +internal class Cfg +{ + public static Config Config = new(); + private FileSystemWatcher? watcher; + + /// + /// Checks the configuration file for the module and creates it if it does not exist. + /// + /// The directory where the module is located. + public void CheckConfig(string moduleDirectory) + { + string path = Path.Join(moduleDirectory, "config.json"); + + if (!File.Exists(path)) + { + CreateAndWriteFile(path); + } + + using (FileStream fs = new(path, FileMode.Open, FileAccess.Read)) + using (StreamReader sr = new(fs)) + { + // Deserialize the JSON from the file and load the configuration. + Config = JsonSerializer.Deserialize(sr.ReadToEnd())!; + } + + foreach (PropertyInfo prop in Config.GetType().GetProperties()) + { + if (prop.PropertyType != typeof(string)) + { + continue; + } + + prop.SetValue(Config, ModifyColorValue(prop.GetValue(Config)!.ToString()!)); + } + + // Create a new FileSystemWatcher and set its properties. + watcher = new FileSystemWatcher(); + watcher.Path = moduleDirectory; + watcher.NotifyFilter = NotifyFilters.LastWrite; + watcher.Filter = "config.json"; + + // Add event handlers. + watcher.Changed += OnChanged; + + // Begin watching. + watcher.EnableRaisingEvents = true; + } + + /// + /// Creates a new file at the specified path and writes the default configuration settings to it. + /// + /// The path where the file should be created. + private static void CreateAndWriteFile(string path) + { + + using (FileStream fs = File.Create(path)) + { + // File is created, and fs will automatically be disposed when the using block exits. + } + + Console.WriteLine($"File created: {File.Exists(path)}"); + + Config = new Config + { + ChatPrefix = "[{darkred}Admin-Chat{white}]", + ChatHighlight = "{lightred}", + ChatText = "{white}", + }; + + // Serialize the config object to JSON and write it to the file. + string jsonConfig = JsonSerializer.Serialize(Config, new JsonSerializerOptions() + { + WriteIndented = true + }); + File.WriteAllText(path, jsonConfig); + } + + // Essential method for replacing chat colors from the config file, the method can be used for other things as well. + private string ModifyColorValue(string msg) + { + if (!msg.Contains('{')) + { + return string.IsNullOrEmpty(msg) ? "" : msg; + } + + string modifiedValue = msg; + + foreach (FieldInfo field in typeof(ChatColors).GetFields()) + { + string pattern = $"{{{field.Name}}}"; + if (msg.Contains(pattern, StringComparison.OrdinalIgnoreCase)) + { + modifiedValue = modifiedValue.Replace(pattern, field.GetValue(null)!.ToString(), StringComparison.OrdinalIgnoreCase); + } + } + return modifiedValue; + } + + // Define the event handlers. + private void OnChanged(object source, FileSystemEventArgs e) + { + // Specify what is done when a file is changed, created, or deleted. + Console.WriteLine($"File: {e.FullPath} {e.ChangeType}"); + } +} + +internal class Config +{ + public string? ChatPrefix { get; set; } + public string? ChatHighlight { get; set; } + public string? ChatText { get; set; } +}