Config → IPluginConfig: consolidated config, model split, conventions, ILogger#12
Merged
Conversation
Adds ConfigApplier.Apply which copies a RetakesAllocatorConfig into the static state the rest of the plugin reads (Utils.PREFIX, Core.NadesConfig, Allocator weapon lists, Votes settings). Weapon lists are mutated in-place to preserve the existing list instances other code holds by reference. Utils.PREFIX/PREFIX_CON now default to string.Empty instead of reading Core.Config (which is null until config is applied). Also adds a StaticState xUnit collection to sequence test classes that share static state, preventing parallel-run interference.
…ct across reloads
…r via NuGet Reference MySqlConnector through a NuGet PackageReference instead of the committed MySqlConnector.dll (a 2.3.0-beta build). CopyLocalLockFileAssemblies still ships it to the plugin build output for deployment, so no binary needs to live in the repo.
… via ILogger A broad cleanup of the module layer, building on the IPluginConfig migration: - Consolidate the config DTOs (ConnectionConfig/PrefixConfig/PistolRoundConfig/ NadesConfig) alongside RetakesAllocatorConfig under RetakesAllocator.Modules.Config and delete the three hand-rolled JSON readers (Config.cs, Votes/Config.cs, Weapons/Config.cs). - Move the persisted model types (Weapon, Vote, Nades) into Modules/Models/. - Apply C# naming conventions across the layer: public members to PascalCase (PREFIX -> Prefix, vote -> Vote, player -> Controller, currentVote -> CurrentVote, playerIndex -> PlayerIndex), private fields to _camelCase (votes -> _votes, VotePercentage -> _votePercentage, IgnoreRoundEnd -> _ignoreRoundEnd), and underscore locals/params to camelCase (players_t -> playersT, map_name -> mapName). - Replace the custom Console-based PrintToServer and the throwing ThrowError helper with Microsoft.Extensions.Logging via BasePlugin.Logger: structured, level- appropriate logs (Information for lifecycle, Error with the exception for DB failures, Debug for spawn-skip diagnostics). Fatal paths now log and degrade instead of throwing. - Remove the dead O(N^2) outer loop in Votes_OnMapStart and fix the RequiredPrecentage typo to RequiredPercentage. Build clean, 16 tests green.
Add RetakesAllocator.sln referencing the plugin and test projects so the test project is visible in Rider, and ignore *.DotSettings.user.
…se requirements Rewrite the README Config/Weapons sections for the single CounterStrikeSharp-managed config file (with the real generated default), and bump the CI release notes to require CounterStrikeSharp v1.0.360 / API 360.
Keep RetakesAllocator.Tests visible in the solution but remove its Build.0 entries so a solution/Release build compiles only the plugin. Mark the test csproj non-packable/non-publishable; it is built only when tests are run explicitly via dotnet test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the three hand-rolled JSON config readers (main config, weapon lists, votes) with a single CounterStrikeSharp
IPluginConfig<RetakesAllocatorConfig>consolidated config, then cleans up the module layer around it.Breaking change for existing servers: configuration moves to the single CounterStrikeSharp-managed file at
addons/counterstrikesharp/configs/plugins/RetakesAllocator/RetakesAllocator.json. The oldconfigs/retakes_allocator.json,configs/weapons/*.json, andconfigs/votes.jsonfiles are no longer read.What's included
Config → IPluginConfig
RetakesAllocatorConfig : BasePluginConfigwith a labeled JSON section per subsystem;CoreimplementsIPluginConfig<…>and loads/applies config inOnConfigParsed(beforeLoad, and on file-watch hot reload).ConfigApplier.Applycopies config into the static state the rest of the plugin reads (weapon lists mutated in place to preserve held references).css_weapons_reloadre-applies the in-memory config.Module-layer cleanup
Weapon,Vote,Nades) split intoModules/Models/; config DTOs consolidated underModules.Config.PREFIX→Prefix,vote→Vote,player→Controller,currentVote→CurrentVote), private fields to_camelCase, underscore locals to camelCase. Fixed theRequiredPrecentagetypo and a dead O(N²) loop inVotes_OnMapStart.Console-basedPrintToServer/ throwingThrowErrortoMicrosoft.Extensions.LoggingviaBasePlugin.Logger, with structured templates and appropriate levels. Note: previously-fatal paths (DB connect failure, invalid config) now log and continue instead of throwing.Build / deps / CI
.dll; CounterStrikeSharp bumped to 1.0.360 (API 360).build/and a tag-triggered GitHub release job that packages it.RetakesAllocator.sln(plugin + tests); the test project is excluded from solution/release builds and built only when runningdotnet test.Docs
Testing
dotnet build RetakesAllocator.sln -c Release— clean (plugin only).dotnet test tests/RetakesAllocator.Tests/RetakesAllocator.Tests.csproj— 16 passing.