Skip to content

Commit

Permalink
Merge pull request #22 from B3none/dotnet-8
Browse files Browse the repository at this point in the history
dotnet 8 migration
  • Loading branch information
B3none authored Mar 26, 2024
2 parents 8117453 + b832c13 commit 600b303
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/plugin-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ 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
dotnet build
- 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)
Expand Down
7 changes: 2 additions & 5 deletions RetakesPlugin/Modules/Configs/MapConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Load()
}

var jsonData = File.ReadAllText(_mapConfigPath);
_mapConfigData = JsonSerializer.Deserialize<MapConfigData>(jsonData);
_mapConfigData = JsonSerializer.Deserialize<MapConfigData>(jsonData, Helpers.JsonSerializerOptions);

// TODO: Implement validation to make sure the config is valid / has enough spawns.
// if (_mapConfigData!.Spawns == null || _mapConfigData.Spawns.Count < 0)
Expand Down Expand Up @@ -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
{
Expand Down
7 changes: 2 additions & 5 deletions RetakesPlugin/Modules/Configs/RetakesConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Load()
}

var jsonData = File.ReadAllText(_retakesConfigPath);
RetakesConfigData = JsonSerializer.Deserialize<RetakesConfigData>(jsonData);
RetakesConfigData = JsonSerializer.Deserialize<RetakesConfigData>(jsonData, Helpers.JsonSerializerOptions);

if (RetakesConfigData == null)
{
Expand Down Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion RetakesPlugin/Modules/Configs/RetakesConfigData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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; }
}
2 changes: 1 addition & 1 deletion RetakesPlugin/Modules/Configs/Spawn.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
13 changes: 12 additions & 1 deletion RetakesPlugin/Modules/Helpers.cs
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion RetakesPlugin/Modules/Managers/SpawnManager.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
13 changes: 9 additions & 4 deletions RetakesPlugin/RetakesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions RetakesPlugin/RetakesPlugin.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.188" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.2" />
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.201" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.3" />
<ProjectReference Include="..\RetakesPluginShared\RetakesPluginShared.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace RetakesPlugin.Modules.Enums;
namespace RetakesPluginShared.Enums;

public enum Bombsite
{
Expand Down
5 changes: 5 additions & 0 deletions RetakesPluginShared/Events/AnnounceBombsiteEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using RetakesPluginShared.Enums;

namespace RetakesPluginShared.Events;

public record AnnounceBombsiteEvent(Bombsite Bombsite) : IRetakesPluginEvent;
12 changes: 10 additions & 2 deletions RetakesPluginShared/RetakesPluginShared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
</Description>
<Authors>B3none</Authors>

<Version>1.0.0</Version>
<Version>2.0.0</Version>

<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>RetakesPluginShared</RootNamespace>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md" Pack="true" PackagePath="\" />
<None Include="..\LICENSE" Pack="true" PackagePath="" />
</ItemGroup>
</Project>

0 comments on commit 600b303

Please sign in to comment.