diff --git a/mod/Jailbreak.Debug/DebugCommand.cs b/mod/Jailbreak.Debug/DebugCommand.cs index 2b953cbc..016806d1 100644 --- a/mod/Jailbreak.Debug/DebugCommand.cs +++ b/mod/Jailbreak.Debug/DebugCommand.cs @@ -18,6 +18,7 @@ public DebugCommand(IServiceProvider serviceProvider) _commands.Add("pardon", new Pardon(serviceProvider)); } + [RequiresPermissions("@css/root")] [ConsoleCommand("css_debug", "Debug command for Jailbreak.")] public void Command_Debug(CCSPlayerController? executor, CommandInfo info) diff --git a/mod/Jailbreak.Debug/Subcommands/MarkRebel.cs b/mod/Jailbreak.Debug/Subcommands/MarkRebel.cs index 6376b1d5..16db83e0 100644 --- a/mod/Jailbreak.Debug/Subcommands/MarkRebel.cs +++ b/mod/Jailbreak.Debug/Subcommands/MarkRebel.cs @@ -1,4 +1,4 @@ -using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core; using Jailbreak.Public.Mod.Rebel; using Microsoft.Extensions.DependencyInjection; diff --git a/mod/Jailbreak.Debug/Subcommands/Pardon.cs b/mod/Jailbreak.Debug/Subcommands/Pardon.cs index 4626607d..43229216 100644 --- a/mod/Jailbreak.Debug/Subcommands/Pardon.cs +++ b/mod/Jailbreak.Debug/Subcommands/Pardon.cs @@ -1,4 +1,4 @@ -using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core; using Jailbreak.Public.Mod.Rebel; using Microsoft.Extensions.DependencyInjection; diff --git a/mod/Jailbreak.Rebel/RebelManager.cs b/mod/Jailbreak.Rebel/RebelManager.cs index 6e8afc38..458d0391 100644 --- a/mod/Jailbreak.Rebel/RebelManager.cs +++ b/mod/Jailbreak.Rebel/RebelManager.cs @@ -49,6 +49,23 @@ public void Start(BasePlugin parent) }, TimerFlags.REPEAT); } + + private void OnTick() + { + foreach (var player in GetActiveRebels()) + { + if (!player.IsReal()) + continue; + + if (GetRebelTimeLeft(player) <= 0) + { + continue; + } + + SendTimeLeft(player); + } + } + public ISet GetActiveRebels() { return _rebelTimes.Keys.ToHashSet(); @@ -70,6 +87,16 @@ public bool MarkRebel(CCSPlayerController player, long time = 120) return true; } + + HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) + { + var player = @event.Userid; + if (!player.IsReal()) + return HookResult.Continue; + rebelTimes.Remove(player); + return HookResult.Continue; + } + public void UnmarkRebel(CCSPlayerController player) { _notifs.NoLongerRebel.ToPlayerChat(player); @@ -92,7 +119,7 @@ private void OnTick() } } - private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) + HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) { _rebelTimes.Clear(); foreach (var player in Utilities.GetPlayers()) @@ -142,6 +169,19 @@ private Color GetRebelColor(CCSPlayerController player) return color; } + private Color GetRebelColor(CCSPlayerController player) + { + var percent = GetRebelTimePercentage(player); + var percentRGB = 255 - (int)Math.Round(percent * 255.0); + var color = Color.FromArgb(254, 255, percentRGB, percentRGB); + if (percent <= 0) + { + color = Color.FromArgb(254, 255, 255, 255); + } + + return color; + } + private void ApplyRebelColor(CCSPlayerController player) { if (!player.IsReal() || player.Pawn.Value == null) diff --git a/public/Jailbreak.Formatting/Logistics/LanguageConfig.cs b/public/Jailbreak.Formatting/Logistics/LanguageConfig.cs index e96df713..582bc3e0 100644 --- a/public/Jailbreak.Formatting/Logistics/LanguageConfig.cs +++ b/public/Jailbreak.Formatting/Logistics/LanguageConfig.cs @@ -31,6 +31,12 @@ public void WithWarden() _collection.AddSingleton(); } + public void WithGenericCommand() + where TGenericCommand : class, ILanguage, IGenericCommandNotifications + { + _collection.AddSingleton(); + } + public void WithRebel() where TRebel : class, ILanguage, IRebelNotifications { diff --git a/src/Jailbreak/Jailbreak.csproj b/src/Jailbreak/Jailbreak.csproj index 75360569..2a615055 100644 --- a/src/Jailbreak/Jailbreak.csproj +++ b/src/Jailbreak/Jailbreak.csproj @@ -32,14 +32,14 @@ - - - - - - - - + + + + + + + + diff --git a/src/Jailbreak/JailbreakServiceCollection.cs b/src/Jailbreak/JailbreakServiceCollection.cs index 0c2e225a..84757b36 100644 --- a/src/Jailbreak/JailbreakServiceCollection.cs +++ b/src/Jailbreak/JailbreakServiceCollection.cs @@ -44,4 +44,4 @@ public void ConfigureServices(IServiceCollection serviceCollection) config.WithRebel(); }); } -} \ No newline at end of file +}