SwDevtools provides opinionated building blocks for Counter-Strike 2 plugins built on SwiftlyS2.
It focuses on:
- Simple helper classes and services
- Helping speed up development flow by reducing boilerplate code
Add the package to your plugin project:
dotnet add package SwDevtoolsYour project should already reference SwiftlyS2.CS2.
Inside your BasePlugin class, create a scoped service provider when the plugin
loads and register SwDevtools services via AddSwDevtoolsKit:
using SwDevtools;
using SwiftlyS2.Shared;
using SwiftlyS2.Shared.Plugins;
public sealed class Plugin(ISwiftlyCore core) : BasePlugin(core)
{
public override void Load(bool hotReload)
{
ServiceCollection services = new();
services
.AddSwiftly(this.Core)
.AddSwDevtoolsKit(this.Core, this)
.AddSingleton<TestService>();
var provider = services.BuildServiceProvider();
provider.GetRequiredService<TestService>().Run();
}
}AddSwDevtoolsKit wires up (for now):
ISwiftlyCore– the Swiftly core instanceIPluginLogger– plugin-scoped loggerIJsonConfig– JSON configuration helperITomlConfig– TOML configuration helperITranslate– player-localized translation helper
More services will be added in the future.
Prefer constructor injection for your services:
using SwDevtools.Logging;
public sealed class TestService(IPluginLogger logger)
{
public void Run() =>
logger.Info("TestService running");
}Property injection is optional and only applies to properties explicitly
annotated with [Inject].
using SwDevtools;
using SwDevtools.Injection;
using SwDevtools.Logging;
public sealed class Plugin(ISwiftlyCore core) : BasePlugin(core)
{
[Inject] public IPluginLogger Logger { get; set; } = null!;
public override void Load(bool hotReload)
{
ServiceCollection services = new();
services
.AddSwiftly(this.Core)
.AddSwDevtoolsKit(this.Core, this);
var provider = services.BuildServiceProvider();
provider.InjectProperties(this);
this.Logger.Info("Plugin loaded");
}
}