diff --git a/.github/workflows/plugin-build.yml b/.github/workflows/plugin-build.yml index fad7648..8428b83 100644 --- a/.github/workflows/plugin-build.yml +++ b/.github/workflows/plugin-build.yml @@ -24,7 +24,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Change directory and build run: | cd RetakesPlugin @@ -32,8 +32,8 @@ jobs: - name: Create output directory run: | mkdir -p output/RetakesPlugin - mv ./RetakesPlugin/bin/Debug/net7.0/RetakesPlugin.dll output/RetakesPlugin/ - mv ./RetakesPlugin/bin/Debug/net7.0/RetakesPlugin.pdb output/RetakesPlugin/ + mv ./RetakesPlugin/bin/Debug/net8.0/RetakesPlugin.dll output/RetakesPlugin/ + mv ./RetakesPlugin/bin/Debug/net8.0/RetakesPlugin.pdb output/RetakesPlugin/ mv ./RetakesPlugin/map_config output/RetakesPlugin/ mv ./RetakesPlugin/lang output/RetakesPlugin/ - name: Copy output (no map configs) diff --git a/RetakesPlugin/Modules/Configs/MapConfig.cs b/RetakesPlugin/Modules/Configs/MapConfig.cs index 51bf819..b5d374e 100644 --- a/RetakesPlugin/Modules/Configs/MapConfig.cs +++ b/RetakesPlugin/Modules/Configs/MapConfig.cs @@ -29,7 +29,7 @@ public void Load() } var jsonData = File.ReadAllText(_mapConfigPath); - _mapConfigData = JsonSerializer.Deserialize(jsonData); + _mapConfigData = JsonSerializer.Deserialize(jsonData, Helpers.JsonSerializerOptions); // TODO: Implement validation to make sure the config is valid / has enough spawns. // if (_mapConfigData!.Spawns == null || _mapConfigData.Spawns.Count < 0) @@ -119,10 +119,7 @@ private MapConfigData GetSanitisedMapConfigData() private void Save() { - var jsonString = JsonSerializer.Serialize(GetSanitisedMapConfigData(), new JsonSerializerOptions - { - WriteIndented = true - }); + var jsonString = JsonSerializer.Serialize(GetSanitisedMapConfigData(), Helpers.JsonSerializerOptions); try { diff --git a/RetakesPlugin/Modules/Configs/RetakesConfig.cs b/RetakesPlugin/Modules/Configs/RetakesConfig.cs index ed63cc4..a114308 100644 --- a/RetakesPlugin/Modules/Configs/RetakesConfig.cs +++ b/RetakesPlugin/Modules/Configs/RetakesConfig.cs @@ -25,7 +25,7 @@ public void Load() } var jsonData = File.ReadAllText(_retakesConfigPath); - RetakesConfigData = JsonSerializer.Deserialize(jsonData); + RetakesConfigData = JsonSerializer.Deserialize(jsonData, Helpers.JsonSerializerOptions); if (RetakesConfigData == null) { @@ -54,10 +54,7 @@ public void Load() private void Save() { - var jsonString = JsonSerializer.Serialize(RetakesConfigData, new JsonSerializerOptions - { - WriteIndented = true - }); + var jsonString = JsonSerializer.Serialize(RetakesConfigData, Helpers.JsonSerializerOptions); try { diff --git a/RetakesPlugin/Modules/Configs/RetakesConfigData.cs b/RetakesPlugin/Modules/Configs/RetakesConfigData.cs index fa55057..139d171 100644 --- a/RetakesPlugin/Modules/Configs/RetakesConfigData.cs +++ b/RetakesPlugin/Modules/Configs/RetakesConfigData.cs @@ -2,7 +2,7 @@ public class RetakesConfigData { - public static int CurrentVersion = 7; + public static int CurrentVersion = 8; public int Version { get; set; } = CurrentVersion; public int MaxPlayers { get; set; } = 9; @@ -18,4 +18,5 @@ public class RetakesConfigData public string QueuePriorityFlag { get; set; } = "@css/vip"; public bool IsDebugMode { get; set; } = false; public bool ShouldForceEvenTeamsWhenPlayerCountIsMultipleOf10 { get; set; } = true; + public bool EnableFallbackBombsiteAnnouncement { get; set; } } diff --git a/RetakesPlugin/Modules/Configs/Spawn.cs b/RetakesPlugin/Modules/Configs/Spawn.cs index c5975d6..e122b9f 100644 --- a/RetakesPlugin/Modules/Configs/Spawn.cs +++ b/RetakesPlugin/Modules/Configs/Spawn.cs @@ -1,7 +1,7 @@ using System.Text.Json.Serialization; using CounterStrikeSharp.API.Modules.Utils; using RetakesPlugin.Modules.Configs.JsonConverters; -using RetakesPlugin.Modules.Enums; +using RetakesPluginShared.Enums; namespace RetakesPlugin.Modules.Configs; diff --git a/RetakesPlugin/Modules/Helpers.cs b/RetakesPlugin/Modules/Helpers.cs index ee261c8..4c3057c 100644 --- a/RetakesPlugin/Modules/Helpers.cs +++ b/RetakesPlugin/Modules/Helpers.cs @@ -1,17 +1,28 @@ using System.Drawing; using System.Text; +using System.Text.Json; using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Entities.Constants; using CounterStrikeSharp.API.Modules.Utils; using RetakesPlugin.Modules.Configs; -using RetakesPlugin.Modules.Enums; +using RetakesPlugin.Modules.Configs.JsonConverters; +using RetakesPluginShared.Enums; namespace RetakesPlugin.Modules; public static class Helpers { internal static readonly Random Random = new(); + internal static readonly JsonSerializerOptions JsonSerializerOptions = new() + { + WriteIndented = true, + Converters = + { + new VectorJsonConverter(), + new QAngleJsonConverter() + } + }; public static bool IsValidPlayer(CCSPlayerController? player) { diff --git a/RetakesPlugin/Modules/Managers/SpawnManager.cs b/RetakesPlugin/Modules/Managers/SpawnManager.cs index b8f3623..a887832 100644 --- a/RetakesPlugin/Modules/Managers/SpawnManager.cs +++ b/RetakesPlugin/Modules/Managers/SpawnManager.cs @@ -1,7 +1,7 @@ using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Modules.Utils; using RetakesPlugin.Modules.Configs; -using RetakesPlugin.Modules.Enums; +using RetakesPluginShared.Enums; namespace RetakesPlugin.Modules.Managers; diff --git a/RetakesPlugin/RetakesPlugin.cs b/RetakesPlugin/RetakesPlugin.cs index 8c13ac8..c49d105 100644 --- a/RetakesPlugin/RetakesPlugin.cs +++ b/RetakesPlugin/RetakesPlugin.cs @@ -8,7 +8,7 @@ using CounterStrikeSharp.API.Modules.Entities.Constants; using CounterStrikeSharp.API.Modules.Utils; using RetakesPlugin.Modules; -using RetakesPlugin.Modules.Enums; +using RetakesPluginShared.Enums; using RetakesPlugin.Modules.Configs; using RetakesPlugin.Modules.Managers; using RetakesPluginShared; @@ -17,10 +17,10 @@ namespace RetakesPlugin; -[MinimumApiVersion(180)] +[MinimumApiVersion(201)] public class RetakesPlugin : BasePlugin { - private const string Version = "1.4.3"; + private const string Version = "2.0.0"; #region Plugin info public override string ModuleName => "Retakes Plugin"; @@ -629,7 +629,12 @@ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) _planter = _spawnManager.HandleRoundSpawns(_currentBombsite, _gameManager.QueueManager.ActivePlayers); - AnnounceBombsite(_currentBombsite); + if (_retakesConfig?.RetakesConfigData?.EnableFallbackBombsiteAnnouncement is true or null) + { + AnnounceBombsite(_currentBombsite); + } + + RetakesPluginEventSenderCapability.Get()?.TriggerEvent(new AnnounceBombsiteEvent(_currentBombsite)); return HookResult.Continue; } diff --git a/RetakesPlugin/RetakesPlugin.csproj b/RetakesPlugin/RetakesPlugin.csproj index db6ee20..a94c866 100644 --- a/RetakesPlugin/RetakesPlugin.csproj +++ b/RetakesPlugin/RetakesPlugin.csproj @@ -1,13 +1,13 @@ - net7.0 + net8.0 enable enable - - + + diff --git a/RetakesPlugin/Modules/Enums/Bombsite.cs b/RetakesPluginShared/Enums/Bombsite.cs similarity index 52% rename from RetakesPlugin/Modules/Enums/Bombsite.cs rename to RetakesPluginShared/Enums/Bombsite.cs index 78e5769..d9ab2cb 100644 --- a/RetakesPlugin/Modules/Enums/Bombsite.cs +++ b/RetakesPluginShared/Enums/Bombsite.cs @@ -1,4 +1,4 @@ -namespace RetakesPlugin.Modules.Enums; +namespace RetakesPluginShared.Enums; public enum Bombsite { diff --git a/RetakesPluginShared/Events/AnnounceBombsiteEvent.cs b/RetakesPluginShared/Events/AnnounceBombsiteEvent.cs new file mode 100644 index 0000000..3d1630f --- /dev/null +++ b/RetakesPluginShared/Events/AnnounceBombsiteEvent.cs @@ -0,0 +1,5 @@ +using RetakesPluginShared.Enums; + +namespace RetakesPluginShared.Events; + +public record AnnounceBombsiteEvent(Bombsite Bombsite) : IRetakesPluginEvent; diff --git a/RetakesPluginShared/RetakesPluginShared.csproj b/RetakesPluginShared/RetakesPluginShared.csproj index 3ff6335..aad367e 100644 --- a/RetakesPluginShared/RetakesPluginShared.csproj +++ b/RetakesPluginShared/RetakesPluginShared.csproj @@ -7,12 +7,20 @@ B3none - 1.0.0 + 2.0.0 - net7.0 + net8.0 enable enable RetakesPluginShared true + + README.md + LICENSE + + + + +