From ef2e9fe1ea325b82f579c6ccafb4957733cb632c Mon Sep 17 00:00:00 2001
From: Mooshua <43320783+mooshua@users.noreply.github.com>
Date: Sat, 8 Jun 2024 19:17:32 -0700
Subject: [PATCH 01/27] Shared API Draft
This exposes the current service provider as a plugin capability, allowing other plugins to fetch instantiated IPluginBehaviors.
---
public/Jailbreak.Public/API.cs | 16 ++++++++++++++++
src/Jailbreak/Jailbreak.cs | 17 +++++++++++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
create mode 100644 public/Jailbreak.Public/API.cs
diff --git a/public/Jailbreak.Public/API.cs b/public/Jailbreak.Public/API.cs
new file mode 100644
index 00000000..8f14661a
--- /dev/null
+++ b/public/Jailbreak.Public/API.cs
@@ -0,0 +1,16 @@
+using CounterStrikeSharp.API.Core.Capabilities;
+
+namespace Jailbreak.Public;
+
+///
+/// The entry point to the Jailbreak API
+///
+public static class API
+{
+ ///
+ /// Grants access to the currently running service provider, if there is one.
+ /// The service provider can be used to get instantiated IPluginBehaviors and other
+ /// objects exposed to Jailbreak mods
+ ///
+ public static PluginCapability Provider { get; } = new("jailbreak:core");
+}
diff --git a/src/Jailbreak/Jailbreak.cs b/src/Jailbreak/Jailbreak.cs
index 9b56f59d..75c744d8 100644
--- a/src/Jailbreak/Jailbreak.cs
+++ b/src/Jailbreak/Jailbreak.cs
@@ -1,5 +1,8 @@
using System.Collections.Immutable;
using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Core.Capabilities;
+
+using Jailbreak.Public;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Utils;
using Microsoft.Extensions.DependencyInjection;
@@ -15,7 +18,7 @@ public class Jailbreak : BasePlugin
private IReadOnlyList? _extensions;
private readonly IServiceProvider _provider;
- private IServiceScope? _scope;
+ private IServiceScope? _scope = null;
///
/// The Jailbreak plugin.
@@ -47,7 +50,7 @@ public override void Load(bool hotReload)
// manifest.AddResource("soundevents/explosion.vsnd");
// manifest.AddResource("soundevents/jihad.vsnd");
// });
-
+
// Load Managers
FreezeManager.CreateInstance(this);
@@ -70,6 +73,15 @@ public override void Load(bool hotReload)
Logger.LogInformation("[Jailbreak] Loaded behavior {@Behavior}", extension.GetType().FullName);
}
+ // Expose the scope to other plugins
+ Capabilities.RegisterPluginCapability(API.Provider, () =>
+ {
+ if (this._scope == null)
+ throw new InvalidOperationException("Jailbreak does not have a running scope! Is the jailbreak plugin loaded?");
+
+ return this._scope.ServiceProvider;
+ });
+
base.Load(hotReload);
}
@@ -85,6 +97,7 @@ public override void Unload(bool hotReload)
// Dispose of original extensions scope
// When loading again we will get a new scope to avoid leaking state.
_scope?.Dispose();
+ _scope = null;
base.Unload(hotReload);
}
From 9ec0cd0a3086273e06e373f799a09f71f7c60d9a Mon Sep 17 00:00:00 2001
From: shook
Date: Fri, 5 Jul 2024 11:19:12 -0500
Subject: [PATCH 02/27] Add cooldown to css_guard
---
mod/Jailbreak.Teams/Queue/QueueBehavior.cs | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/mod/Jailbreak.Teams/Queue/QueueBehavior.cs b/mod/Jailbreak.Teams/Queue/QueueBehavior.cs
index bf23c043..8d5b9a24 100644
--- a/mod/Jailbreak.Teams/Queue/QueueBehavior.cs
+++ b/mod/Jailbreak.Teams/Queue/QueueBehavior.cs
@@ -23,6 +23,8 @@ public class QueueBehavior : IGuardQueue, IPluginBehavior
private readonly IPlayerState _state;
private BasePlugin _parent;
+ private readonly Dictionary _lastCommandUsage = new();
+
public QueueBehavior(IPlayerStateFactory factory, IRatioNotifications notifications, ILogger logger)
{
_logger = logger;
@@ -39,6 +41,16 @@ public bool TryEnterQueue(CCSPlayerController player)
if (player.GetTeam() == CsTeam.CounterTerrorist)
return false;
+ if (_lastCommandUsage.TryGetValue(player, out var lastUsage))
+ {
+ var timeNextUsage = lastUsage.AddSeconds(10);
+ if (timeNextUsage > DateTime.Now)
+ {
+ _generics.CommandOnCooldown(timeNextUsage).ToPlayerChat(player);
+ return false;
+ }
+ }
+
var state = _state.Get(player);
state.Position = ++_counter;
state.InQueue = true;
From 24eed96f81843e4b30d83e1165e59e847100ee28 Mon Sep 17 00:00:00 2001
From: shook
Date: Tue, 9 Jul 2024 14:56:17 -0500
Subject: [PATCH 03/27] Add Support for Logging Weapons Drops
---
.../Listeners/LogEntityParentListeners.cs | 56 +++++++++++++++++++
.../Extensions/WeaponExtensions.cs | 51 +++++++++++++++++
2 files changed, 107 insertions(+)
create mode 100644 mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
create mode 100644 public/Jailbreak.Public/Extensions/WeaponExtensions.cs
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
new file mode 100644
index 00000000..140330d3
--- /dev/null
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -0,0 +1,56 @@
+using CounterStrikeSharp.API;
+using CounterStrikeSharp.API.Core;
+using Jailbreak.Formatting.Views;
+using Jailbreak.Public.Extensions;
+
+namespace Jailbreak.Logs.Listeners;
+
+public class LogEntityParentListeners
+{
+ private readonly IRichLogService _logs;
+ private BasePlugin parent;
+ private static readonly string[] weaponStrings = {
+ "weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_cz75a", "weapon_deagle", "weapon_famas", "weapon_fiveseven", "weapon_g3sg1", "weapon_galilar",
+ "weapon_glock", "weapon_hkp2000", "weapon_m249", "weapon_m4a1", "weapon_m4a1_silencer", "weapon_m4a4", "weapon_mac10", "weapon_mag7", "weapon_mp5sd", "weapon_mp7",
+ "weapon_mp9", "weapon_negev", "weapon_nova", "weapon_p250", "weapon_p90", "weapon_revolver", "weapon_sawedoff", "weapon_scar20", "weapon_sg553", "weapon_sg556",
+ "weapon_ssg08", "weapon_taser", "weapon_tec9", "weapon_ump45", "weapon_usp_silencer", "weapon_xm1014" };
+
+ public LogEntityParentListeners(IRichLogService logs)
+ {
+ _logs = logs;
+ }
+
+ public void Start(BasePlugin parent)
+ {
+ this.parent = parent;
+
+ parent.RegisterListener(OnEntityParentChanged);
+ }
+ public void Dispose()
+ {
+ parent.RemoveListener("OnEntityParentChanged", OnEntityParentChanged);
+ }
+ public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstance newParent)
+ {
+ if (!affectedEntity.IsValid || !weaponStrings.Contains(affectedEntity.DesignerName)) return;
+
+ var weaponEntity = Utilities.GetEntityFromIndex((int)affectedEntity.Index);
+ if (weaponEntity == null) return;
+
+ var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Index);
+ if (weaponOwner == null) return;
+
+ if (!newParent.IsValid) //a.k.a parent is world
+ {
+ _logs.Append(_logs.Player(weaponOwner), $"dropped their {weaponEntity.ToFriendlyString}");
+ }
+
+ if (newParent.IsValid)
+ {
+ var weaponPickerUpper = Utilities.GetEntityFromIndex((int)(newParent.Index));
+ if (weaponPickerUpper == null) return;
+
+ _logs.Append(_logs.Player(weaponPickerUpper), "picked up", _logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/public/Jailbreak.Public/Extensions/WeaponExtensions.cs b/public/Jailbreak.Public/Extensions/WeaponExtensions.cs
new file mode 100644
index 00000000..ae478adc
--- /dev/null
+++ b/public/Jailbreak.Public/Extensions/WeaponExtensions.cs
@@ -0,0 +1,51 @@
+using CounterStrikeSharp.API.Core;
+
+namespace Jailbreak.Public.Extensions;
+
+public static class WeaponExtensions
+{
+ public static string ToFriendlyString(this CCSWeaponBase weaponEntity)
+ {
+ var designerName = weaponEntity.DesignerName;
+ switch (designerName)
+ {
+ case "weapon_ak47": return "AK47";
+ case "weapon_aug": return "AUG";
+ case "weapon_awp": return "AWP";
+ case "weapon_bizon": return "Bizon";
+ case "weapon_cz75a": return "CZ75";
+ case "weapon_deagle": return "Desert Eagle";
+ case "weapon_famas": return "Famas";
+ case "weapon_fiveseven": return "Five Seven";
+ case "weapon_g3sg1": return "G3SG1";
+ case "weapon_galilar": return "Galil";
+ case "weapon_glock": return "Glock 18";
+ case "weapon_hkp2000": return "HPK2000";
+ case "weapon_m249": return "M249";
+ case "weapon_m4a1": return "M4A1";
+ case "weapon_m4a1_silencer": return "M4A1S";
+ case "weapon_m4a4": return "M4A4";
+ case "weapon_mac10": return "MAC10";
+ case "weapon_mag7": return "MAG7";
+ case "weapon_mp5sd": return "MP5SD";
+ case "weapon_mp7": return "MP7";
+ case "weapon_mp9": return "MP9";
+ case "weapon_negev": return "Negev";
+ case "weapon_nova": return "Nova";
+ case "weapon_p250": return "P250";
+ case "weapon_p90": return "P90";
+ case "weapon_revolver": return "Revolver";
+ case "weapon_sawedoff": return "Sawed Off";
+ case "weapon_scar20": return "Scar20";
+ case "weapon_sg553": return "SG553";
+ case "weapon_sg556": return "SG556";
+ case "weapon_ssg08": return "SSG08";
+ case "weapon_taser": return "Zeus";
+ case "weapon_tec9": return "Tec9";
+ case "weapon_ump45": return "UMP45";
+ case "weapon_usp_silencer": return "USPS";
+ case "weapon_xm1014": return "XM1014";
+ default: return "UNKNOWN: Pleace Contact Tech";
+ }
+ }
+}
\ No newline at end of file
From 6fa852beb4a934de90e56cfcedbd893f954b8bcc Mon Sep 17 00:00:00 2001
From: ntm <35658945+ntm5@users.noreply.github.com>
Date: Wed, 10 Jul 2024 00:52:56 +0200
Subject: [PATCH 04/27] Remove redudant variable
---
mod/Jailbreak.LastGuard/LastGuard.cs | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/mod/Jailbreak.LastGuard/LastGuard.cs b/mod/Jailbreak.LastGuard/LastGuard.cs
index 34389520..87f22fbf 100644
--- a/mod/Jailbreak.LastGuard/LastGuard.cs
+++ b/mod/Jailbreak.LastGuard/LastGuard.cs
@@ -65,12 +65,12 @@ public int CalculateHealth()
public void StartLastGuard(CCSPlayerController lastGuard)
{
- var ctPlayerPawn = lastGuard.PlayerPawn.Value;
+ var guardPlayerPawn = lastGuard.PlayerPawn.Value;
if (ctPlayerPawn == null || !ctPlayerPawn.IsValid) return;
- var ctHealth = ctPlayerPawn.Health;
- var ctCalcHealth = CalculateHealth();
+ var guardHealth = ctPlayerPawn.Health;
+ var guardCalcHealth = CalculateHealth();
ctPlayerPawn.Health = ctHealth > ctCalcHealth ? 125 : ctCalcHealth;
Utilities.SetStateChanged(ctPlayerPawn, "CBaseEntity", "m_iHealth");
@@ -81,10 +81,9 @@ public void StartLastGuard(CCSPlayerController lastGuard)
var aliveTerrorists = Utilities.GetPlayers()
.Where(p => p.IsReal() && p is { PawnIsAlive: true, Team: CsTeam.Terrorist }).ToList();
- var guardHp = lastGuard.PlayerPawn?.Value?.Health ?? 0;
var prisonerHp = aliveTerrorists.Sum(prisoner => prisoner.PlayerPawn?.Value?.Health ?? 0);
- notifications.LG_STARTED(guardHp, prisonerHp).ToAllCenter().ToAllChat();
+ notifications.LG_STARTED(guardHealth, prisonerHp).ToAllCenter().ToAllChat();
if (string.IsNullOrEmpty(config.LastGuardWeapon)) return;
@@ -93,4 +92,4 @@ public void StartLastGuard(CCSPlayerController lastGuard)
player.GiveNamedItem(config.LastGuardWeapon);
}
}
-}
\ No newline at end of file
+}
From d334dd98265786549133069dec31e83b5e798497 Mon Sep 17 00:00:00 2001
From: ntm <35658945+ntm5@users.noreply.github.com>
Date: Wed, 10 Jul 2024 00:56:26 +0200
Subject: [PATCH 05/27] Fix namings
---
mod/Jailbreak.LastGuard/LastGuard.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mod/Jailbreak.LastGuard/LastGuard.cs b/mod/Jailbreak.LastGuard/LastGuard.cs
index 87f22fbf..694da38e 100644
--- a/mod/Jailbreak.LastGuard/LastGuard.cs
+++ b/mod/Jailbreak.LastGuard/LastGuard.cs
@@ -67,13 +67,13 @@ public void StartLastGuard(CCSPlayerController lastGuard)
{
var guardPlayerPawn = lastGuard.PlayerPawn.Value;
- if (ctPlayerPawn == null || !ctPlayerPawn.IsValid) return;
+ if (guardPlayerPawn == null || !guardPlayerPawn.IsValid) return;
- var guardHealth = ctPlayerPawn.Health;
+ var guardHealth = guardPlayerPawn.Health;
var guardCalcHealth = CalculateHealth();
- ctPlayerPawn.Health = ctHealth > ctCalcHealth ? 125 : ctCalcHealth;
- Utilities.SetStateChanged(ctPlayerPawn, "CBaseEntity", "m_iHealth");
+ ctPlayerPawn.Health = guardHealth > guardCalcHealth ? 125 : guardHealth;
+ Utilities.SetStateChanged(guardPlayerPawn, "CBaseEntity", "m_iHealth");
// foreach (var player in Utilities.GetPlayers().Where(p => p.IsReal()))
// player.ExecuteClientCommand("play sounds/lastct");
From d9b49566c26a39dede42314e62681c565563c44d Mon Sep 17 00:00:00 2001
From: ntm <35658945+ntm5@users.noreply.github.com>
Date: Wed, 10 Jul 2024 00:58:04 +0200
Subject: [PATCH 06/27] Actually fix var names
---
mod/Jailbreak.LastGuard/LastGuard.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mod/Jailbreak.LastGuard/LastGuard.cs b/mod/Jailbreak.LastGuard/LastGuard.cs
index 694da38e..af4b31fd 100644
--- a/mod/Jailbreak.LastGuard/LastGuard.cs
+++ b/mod/Jailbreak.LastGuard/LastGuard.cs
@@ -72,7 +72,7 @@ public void StartLastGuard(CCSPlayerController lastGuard)
var guardHealth = guardPlayerPawn.Health;
var guardCalcHealth = CalculateHealth();
- ctPlayerPawn.Health = guardHealth > guardCalcHealth ? 125 : guardHealth;
+ guardPlayerPawn.Health = guardHealth > guardCalcHealth ? 125 : guardHealth;
Utilities.SetStateChanged(guardPlayerPawn, "CBaseEntity", "m_iHealth");
// foreach (var player in Utilities.GetPlayers().Where(p => p.IsReal()))
From e0ab07f27bbfd9145ab1fa3db6b5f9fc2e480c49 Mon Sep 17 00:00:00 2001
From: shook
Date: Wed, 10 Jul 2024 10:04:54 -0500
Subject: [PATCH 07/27] Revert "Add cooldown to css_guard"
This reverts commit 9ec0cd0a3086273e06e373f799a09f71f7c60d9a.
---
mod/Jailbreak.Teams/Queue/QueueBehavior.cs | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/mod/Jailbreak.Teams/Queue/QueueBehavior.cs b/mod/Jailbreak.Teams/Queue/QueueBehavior.cs
index 8d5b9a24..bf23c043 100644
--- a/mod/Jailbreak.Teams/Queue/QueueBehavior.cs
+++ b/mod/Jailbreak.Teams/Queue/QueueBehavior.cs
@@ -23,8 +23,6 @@ public class QueueBehavior : IGuardQueue, IPluginBehavior
private readonly IPlayerState _state;
private BasePlugin _parent;
- private readonly Dictionary _lastCommandUsage = new();
-
public QueueBehavior(IPlayerStateFactory factory, IRatioNotifications notifications, ILogger logger)
{
_logger = logger;
@@ -41,16 +39,6 @@ public bool TryEnterQueue(CCSPlayerController player)
if (player.GetTeam() == CsTeam.CounterTerrorist)
return false;
- if (_lastCommandUsage.TryGetValue(player, out var lastUsage))
- {
- var timeNextUsage = lastUsage.AddSeconds(10);
- if (timeNextUsage > DateTime.Now)
- {
- _generics.CommandOnCooldown(timeNextUsage).ToPlayerChat(player);
- return false;
- }
- }
-
var state = _state.Get(player);
state.Position = ++_counter;
state.InQueue = true;
From 40c7e45a4df471966047b6ae6c0ac8a530b55656 Mon Sep 17 00:00:00 2001
From: shook
Date: Wed, 10 Jul 2024 10:10:12 -0500
Subject: [PATCH 08/27] Early Return
---
.../Listeners/LogEntityParentListeners.cs | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index 140330d3..21e251e4 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -43,14 +43,12 @@ public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstanc
if (!newParent.IsValid) //a.k.a parent is world
{
_logs.Append(_logs.Player(weaponOwner), $"dropped their {weaponEntity.ToFriendlyString}");
+ return;
}
- if (newParent.IsValid)
- {
- var weaponPickerUpper = Utilities.GetEntityFromIndex((int)(newParent.Index));
- if (weaponPickerUpper == null) return;
+ var weaponPickerUpper = Utilities.GetEntityFromIndex((int)(newParent.Index));
+ if (weaponPickerUpper == null) return;
- _logs.Append(_logs.Player(weaponPickerUpper), "picked up", _logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
- }
+ _logs.Append(_logs.Player(weaponPickerUpper), "picked up", _logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
}
}
\ No newline at end of file
From 15798834ad95dd9a75abd6a8a3f742b6c89fb90b Mon Sep 17 00:00:00 2001
From: ntm <35658945+ntm5@users.noreply.github.com>
Date: Thu, 11 Jul 2024 00:59:49 +0200
Subject: [PATCH 09/27] Set health to calculated health no matter what
---
mod/Jailbreak.LastGuard/LastGuard.cs | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/mod/Jailbreak.LastGuard/LastGuard.cs b/mod/Jailbreak.LastGuard/LastGuard.cs
index af4b31fd..e668746f 100644
--- a/mod/Jailbreak.LastGuard/LastGuard.cs
+++ b/mod/Jailbreak.LastGuard/LastGuard.cs
@@ -69,10 +69,9 @@ public void StartLastGuard(CCSPlayerController lastGuard)
if (guardPlayerPawn == null || !guardPlayerPawn.IsValid) return;
- var guardHealth = guardPlayerPawn.Health;
var guardCalcHealth = CalculateHealth();
- guardPlayerPawn.Health = guardHealth > guardCalcHealth ? 125 : guardHealth;
+ guardPlayerPawn.Health = guardCalcHealth;
Utilities.SetStateChanged(guardPlayerPawn, "CBaseEntity", "m_iHealth");
// foreach (var player in Utilities.GetPlayers().Where(p => p.IsReal()))
@@ -83,7 +82,7 @@ public void StartLastGuard(CCSPlayerController lastGuard)
var prisonerHp = aliveTerrorists.Sum(prisoner => prisoner.PlayerPawn?.Value?.Health ?? 0);
- notifications.LG_STARTED(guardHealth, prisonerHp).ToAllCenter().ToAllChat();
+ notifications.LG_STARTED(guardCalcHealth, prisonerHp).ToAllCenter().ToAllChat();
if (string.IsNullOrEmpty(config.LastGuardWeapon)) return;
From 3a4fbe9fa088fdb20c99cb0c82eb8b25e1a4cc4c Mon Sep 17 00:00:00 2001
From: shook
Date: Wed, 10 Jul 2024 20:23:18 -0500
Subject: [PATCH 10/27] implement plugin behavior
---
mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index 21e251e4..d05b2c7e 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -1,11 +1,12 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using Jailbreak.Formatting.Views;
+using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
namespace Jailbreak.Logs.Listeners;
-public class LogEntityParentListeners
+public class LogEntityParentListeners : IPluginBehavior
{
private readonly IRichLogService _logs;
private BasePlugin parent;
From 17fb91b69089f105a2757176a15febfe7a22e7a7 Mon Sep 17 00:00:00 2001
From: shook
Date: Wed, 10 Jul 2024 20:37:26 -0500
Subject: [PATCH 11/27] Debug
---
.../Listeners/LogEntityParentListeners.cs | 29 ++++++++++++++-----
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index d05b2c7e..c426b7dc 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -26,6 +26,7 @@ public void Start(BasePlugin parent)
this.parent = parent;
parent.RegisterListener(OnEntityParentChanged);
+ Server.PrintToChatAll("Listener Registered");
}
public void Dispose()
{
@@ -33,23 +34,35 @@ public void Dispose()
}
public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstance newParent)
{
+ Server.PrintToChatAll("Function Called");
if (!affectedEntity.IsValid || !weaponStrings.Contains(affectedEntity.DesignerName)) return;
var weaponEntity = Utilities.GetEntityFromIndex((int)affectedEntity.Index);
- if (weaponEntity == null) return;
-
- var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Index);
- if (weaponOwner == null) return;
-
- if (!newParent.IsValid) //a.k.a parent is world
+ if (weaponEntity == null)
+ {
+ Server.PrintToChatAll("weaponEntity null");
+ return;
+ }
+ var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Get().Index);
+ if (weaponOwner == null)
+ {
+ Server.PrintToChatAll("weaponOwner null");
+ return;
+ }
+ if (!newParent.IsValid) //a.k.a parent is world
{
+ Server.PrintToChatAll("log drop");
_logs.Append(_logs.Player(weaponOwner), $"dropped their {weaponEntity.ToFriendlyString}");
return;
}
var weaponPickerUpper = Utilities.GetEntityFromIndex((int)(newParent.Index));
- if (weaponPickerUpper == null) return;
-
+ if (weaponPickerUpper == null)
+ {
+ Server.PrintToChatAll("weaponPickerUpper null");
+ return;
+ }
+ Server.PrintToChatAll("Log pickup");
_logs.Append(_logs.Player(weaponPickerUpper), "picked up", _logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
}
}
\ No newline at end of file
From e52de1264deaad0697c6d232d1baae3f2c0b4362 Mon Sep 17 00:00:00 2001
From: shook
Date: Wed, 10 Jul 2024 20:38:51 -0500
Subject: [PATCH 12/27] Revert "Debug"
This reverts commit 17fb91b69089f105a2757176a15febfe7a22e7a7.
---
.../Listeners/LogEntityParentListeners.cs | 29 +++++--------------
1 file changed, 8 insertions(+), 21 deletions(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index c426b7dc..d05b2c7e 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -26,7 +26,6 @@ public void Start(BasePlugin parent)
this.parent = parent;
parent.RegisterListener(OnEntityParentChanged);
- Server.PrintToChatAll("Listener Registered");
}
public void Dispose()
{
@@ -34,35 +33,23 @@ public void Dispose()
}
public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstance newParent)
{
- Server.PrintToChatAll("Function Called");
if (!affectedEntity.IsValid || !weaponStrings.Contains(affectedEntity.DesignerName)) return;
var weaponEntity = Utilities.GetEntityFromIndex((int)affectedEntity.Index);
- if (weaponEntity == null)
- {
- Server.PrintToChatAll("weaponEntity null");
- return;
- }
- var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Get().Index);
- if (weaponOwner == null)
- {
- Server.PrintToChatAll("weaponOwner null");
- return;
- }
- if (!newParent.IsValid) //a.k.a parent is world
+ if (weaponEntity == null) return;
+
+ var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Index);
+ if (weaponOwner == null) return;
+
+ if (!newParent.IsValid) //a.k.a parent is world
{
- Server.PrintToChatAll("log drop");
_logs.Append(_logs.Player(weaponOwner), $"dropped their {weaponEntity.ToFriendlyString}");
return;
}
var weaponPickerUpper = Utilities.GetEntityFromIndex((int)(newParent.Index));
- if (weaponPickerUpper == null)
- {
- Server.PrintToChatAll("weaponPickerUpper null");
- return;
- }
- Server.PrintToChatAll("Log pickup");
+ if (weaponPickerUpper == null) return;
+
_logs.Append(_logs.Player(weaponPickerUpper), "picked up", _logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
}
}
\ No newline at end of file
From 2221464e0609f56320ad32e7bf733ad84e7fb471 Mon Sep 17 00:00:00 2001
From: shook
Date: Wed, 10 Jul 2024 20:40:42 -0500
Subject: [PATCH 13/27] debug
---
.../Listeners/LogEntityParentListeners.cs | 23 +++++++++++++++----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index d05b2c7e..5b57a725 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -26,6 +26,7 @@ public void Start(BasePlugin parent)
this.parent = parent;
parent.RegisterListener(OnEntityParentChanged);
+ Server.PrintToChatAll("Debug 1");
}
public void Dispose()
{
@@ -36,20 +37,32 @@ public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstanc
if (!affectedEntity.IsValid || !weaponStrings.Contains(affectedEntity.DesignerName)) return;
var weaponEntity = Utilities.GetEntityFromIndex((int)affectedEntity.Index);
- if (weaponEntity == null) return;
+ if (weaponEntity == null)
+ {
+ Server.PrintToChatAll("Debug 2");
+ return;
+ }
- var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Index);
- if (weaponOwner == null) return;
+ var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Get().Index);
+ if (weaponOwner == null) {
+ Server.PrintToChatAll("Debug 3");
+ return;
+ }
if (!newParent.IsValid) //a.k.a parent is world
{
_logs.Append(_logs.Player(weaponOwner), $"dropped their {weaponEntity.ToFriendlyString}");
+ Server.PrintToChatAll("Debug 4");
return;
}
var weaponPickerUpper = Utilities.GetEntityFromIndex((int)(newParent.Index));
- if (weaponPickerUpper == null) return;
-
+ if (weaponPickerUpper == null)
+ {
+ Server.PrintToChatAll("Debug 5");
+ return;
+ }
+ Server.PrintToChatAll("Debug 6");
_logs.Append(_logs.Player(weaponPickerUpper), "picked up", _logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
}
}
\ No newline at end of file
From 9a0b73f62a410ab2313f5d3eaaa8d69ef3b538b4 Mon Sep 17 00:00:00 2001
From: shook
Date: Wed, 10 Jul 2024 20:51:31 -0500
Subject: [PATCH 14/27] Actually register properly
---
mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs | 5 +++--
mod/Jailbreak.Logs/LogsServiceExtension.cs | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index 5b57a725..fd2811a7 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -28,12 +28,13 @@ public void Start(BasePlugin parent)
parent.RegisterListener(OnEntityParentChanged);
Server.PrintToChatAll("Debug 1");
}
- public void Dispose()
+ /*public void Dispose()
{
parent.RemoveListener("OnEntityParentChanged", OnEntityParentChanged);
- }
+ }*/
public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstance newParent)
{
+ Server.PrintToChatAll("Debug 7");
if (!affectedEntity.IsValid || !weaponStrings.Contains(affectedEntity.DesignerName)) return;
var weaponEntity = Utilities.GetEntityFromIndex((int)affectedEntity.Index);
diff --git a/mod/Jailbreak.Logs/LogsServiceExtension.cs b/mod/Jailbreak.Logs/LogsServiceExtension.cs
index 6918ea04..8aece7b5 100644
--- a/mod/Jailbreak.Logs/LogsServiceExtension.cs
+++ b/mod/Jailbreak.Logs/LogsServiceExtension.cs
@@ -18,9 +18,10 @@ public static void AddJailbreakLogs(this IServiceCollection services)
services.AddPluginBehavior();
services.AddPluginBehavior();
+ services.AddPluginBehavior();
- // PlayerTagHelper is a lower-level class that avoids dependency loops.
- services.AddTransient();
+ // PlayerTagHelper is a lower-level class that avoids dependency loops.
+ services.AddTransient();
services.AddTransient();
}
}
From 0bda3d046748c345957cb897e5f54441cf496a93 Mon Sep 17 00:00:00 2001
From: shook
Date: Wed, 10 Jul 2024 21:10:34 -0500
Subject: [PATCH 15/27] fix errors
---
.../Listeners/LogEntityParentListeners.cs | 24 ++++---------------
1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index fd2811a7..217f791b 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -26,7 +26,6 @@ public void Start(BasePlugin parent)
this.parent = parent;
parent.RegisterListener(OnEntityParentChanged);
- Server.PrintToChatAll("Debug 1");
}
/*public void Dispose()
{
@@ -34,36 +33,23 @@ public void Start(BasePlugin parent)
}*/
public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstance newParent)
{
- Server.PrintToChatAll("Debug 7");
if (!affectedEntity.IsValid || !weaponStrings.Contains(affectedEntity.DesignerName)) return;
var weaponEntity = Utilities.GetEntityFromIndex((int)affectedEntity.Index);
- if (weaponEntity == null)
- {
- Server.PrintToChatAll("Debug 2");
- return;
- }
+ if (weaponEntity == null || weaponEntity.PrevOwner == null) return;
- var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Get().Index);
- if (weaponOwner == null) {
- Server.PrintToChatAll("Debug 3");
- return;
- }
+ var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Index);
+ if (weaponOwner == null) return;
if (!newParent.IsValid) //a.k.a parent is world
{
_logs.Append(_logs.Player(weaponOwner), $"dropped their {weaponEntity.ToFriendlyString}");
- Server.PrintToChatAll("Debug 4");
return;
}
var weaponPickerUpper = Utilities.GetEntityFromIndex((int)(newParent.Index));
- if (weaponPickerUpper == null)
- {
- Server.PrintToChatAll("Debug 5");
- return;
- }
- Server.PrintToChatAll("Debug 6");
+ if (weaponPickerUpper == null) return;
+
_logs.Append(_logs.Player(weaponPickerUpper), "picked up", _logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
}
}
\ No newline at end of file
From 874e2bf3ee4ccefd559da4cf03e7dbfa0da17dc8 Mon Sep 17 00:00:00 2001
From: shook
Date: Wed, 10 Jul 2024 21:30:29 -0500
Subject: [PATCH 16/27] more debugging
---
mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index 217f791b..741c5d1a 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -38,8 +38,10 @@ public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstanc
var weaponEntity = Utilities.GetEntityFromIndex((int)affectedEntity.Index);
if (weaponEntity == null || weaponEntity.PrevOwner == null) return;
- var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Index);
+ var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Index);
if (weaponOwner == null) return;
+ Server.PrintToChatAll($"{weaponOwner.PlayerName}");
+ Server.PrintToChatAll($"{(int)weaponEntity.PrevOwner.Index}");
if (!newParent.IsValid) //a.k.a parent is world
{
@@ -47,7 +49,7 @@ public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstanc
return;
}
- var weaponPickerUpper = Utilities.GetEntityFromIndex((int)(newParent.Index));
+ var weaponPickerUpper = Utilities.GetEntityFromIndex((int)newParent.Index);
if (weaponPickerUpper == null) return;
_logs.Append(_logs.Player(weaponPickerUpper), "picked up", _logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
From ab2ba89a04e9262384668419ee9c970d1f6ae73d Mon Sep 17 00:00:00 2001
From: MSWS
Date: Wed, 10 Jul 2024 19:42:02 -0700
Subject: [PATCH 17/27] Start applying same styling on new logs
---
.../Listeners/LogEntityParentListeners.cs | 26 +++++++------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index 741c5d1a..3a82e1d7 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -1,31 +1,25 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using Jailbreak.Formatting.Views;
+using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
namespace Jailbreak.Logs.Listeners;
-public class LogEntityParentListeners : IPluginBehavior
-{
- private readonly IRichLogService _logs;
- private BasePlugin parent;
- private static readonly string[] weaponStrings = {
+public class LogEntityParentListeners(IRichLogService logs) : IPluginBehavior {
+ private BasePlugin parent = null!;
+ private static readonly string[] WEAPON_STRINGS = {
"weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_cz75a", "weapon_deagle", "weapon_famas", "weapon_fiveseven", "weapon_g3sg1", "weapon_galilar",
"weapon_glock", "weapon_hkp2000", "weapon_m249", "weapon_m4a1", "weapon_m4a1_silencer", "weapon_m4a4", "weapon_mac10", "weapon_mag7", "weapon_mp5sd", "weapon_mp7",
"weapon_mp9", "weapon_negev", "weapon_nova", "weapon_p250", "weapon_p90", "weapon_revolver", "weapon_sawedoff", "weapon_scar20", "weapon_sg553", "weapon_sg556",
"weapon_ssg08", "weapon_taser", "weapon_tec9", "weapon_ump45", "weapon_usp_silencer", "weapon_xm1014" };
- public LogEntityParentListeners(IRichLogService logs)
+ public void Start(BasePlugin _parent)
{
- _logs = logs;
- }
-
- public void Start(BasePlugin parent)
- {
- this.parent = parent;
+ parent = _parent;
- parent.RegisterListener(OnEntityParentChanged);
+ _parent.RegisterListener(OnEntityParentChanged);
}
/*public void Dispose()
{
@@ -33,7 +27,7 @@ public void Start(BasePlugin parent)
}*/
public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstance newParent)
{
- if (!affectedEntity.IsValid || !weaponStrings.Contains(affectedEntity.DesignerName)) return;
+ if (!affectedEntity.IsValid || !WEAPON_STRINGS.Contains(affectedEntity.DesignerName)) return;
var weaponEntity = Utilities.GetEntityFromIndex((int)affectedEntity.Index);
if (weaponEntity == null || weaponEntity.PrevOwner == null) return;
@@ -45,13 +39,13 @@ public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstanc
if (!newParent.IsValid) //a.k.a parent is world
{
- _logs.Append(_logs.Player(weaponOwner), $"dropped their {weaponEntity.ToFriendlyString}");
+ logs.Append(logs.Player(weaponOwner), $"dropped their {weaponEntity.ToFriendlyString}");
return;
}
var weaponPickerUpper = Utilities.GetEntityFromIndex((int)newParent.Index);
if (weaponPickerUpper == null) return;
- _logs.Append(_logs.Player(weaponPickerUpper), "picked up", _logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
+ logs.Append(logs.Player(weaponPickerUpper), "picked up", logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
}
}
\ No newline at end of file
From f2cda40e9bb5794fa7327021e5ff552f8ee7f821 Mon Sep 17 00:00:00 2001
From: MSWS
Date: Wed, 10 Jul 2024 19:47:20 -0700
Subject: [PATCH 18/27] Fix build
---
mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs | 1 -
1 file changed, 1 deletion(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index 3a82e1d7..20d9ff37 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -1,7 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using Jailbreak.Formatting.Views;
-using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
From c23b87455291a7ffc54e864bbfd1e8f25b875555 Mon Sep 17 00:00:00 2001
From: MSWS
Date: Wed, 10 Jul 2024 19:48:50 -0700
Subject: [PATCH 19/27] Re-apply formatting
---
.../Listeners/LogEntityParentListeners.cs | 84 +++++++++++--------
1 file changed, 51 insertions(+), 33 deletions(-)
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index 20d9ff37..07e8e029 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -7,44 +7,62 @@
namespace Jailbreak.Logs.Listeners;
public class LogEntityParentListeners(IRichLogService logs) : IPluginBehavior {
- private BasePlugin parent = null!;
- private static readonly string[] WEAPON_STRINGS = {
- "weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_cz75a", "weapon_deagle", "weapon_famas", "weapon_fiveseven", "weapon_g3sg1", "weapon_galilar",
- "weapon_glock", "weapon_hkp2000", "weapon_m249", "weapon_m4a1", "weapon_m4a1_silencer", "weapon_m4a4", "weapon_mac10", "weapon_mag7", "weapon_mp5sd", "weapon_mp7",
- "weapon_mp9", "weapon_negev", "weapon_nova", "weapon_p250", "weapon_p90", "weapon_revolver", "weapon_sawedoff", "weapon_scar20", "weapon_sg553", "weapon_sg556",
- "weapon_ssg08", "weapon_taser", "weapon_tec9", "weapon_ump45", "weapon_usp_silencer", "weapon_xm1014" };
-
- public void Start(BasePlugin _parent)
- {
- parent = _parent;
+ private BasePlugin parent = null!;
- _parent.RegisterListener(OnEntityParentChanged);
- }
- /*public void Dispose()
- {
- parent.RemoveListener("OnEntityParentChanged", OnEntityParentChanged);
- }*/
- public void OnEntityParentChanged(CEntityInstance affectedEntity, CEntityInstance newParent)
- {
- if (!affectedEntity.IsValid || !WEAPON_STRINGS.Contains(affectedEntity.DesignerName)) return;
+ private static readonly string[] WEAPON_STRINGS = [
+ "weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_cz75a",
+ "weapon_deagle", "weapon_famas", "weapon_fiveseven", "weapon_g3sg1",
+ "weapon_galilar", "weapon_glock", "weapon_hkp2000", "weapon_m249",
+ "weapon_m4a1", "weapon_m4a1_silencer", "weapon_m4a4", "weapon_mac10",
+ "weapon_mag7", "weapon_mp5sd", "weapon_mp7", "weapon_mp9", "weapon_negev",
+ "weapon_nova", "weapon_p250", "weapon_p90", "weapon_revolver",
+ "weapon_sawedoff", "weapon_scar20", "weapon_sg553", "weapon_sg556",
+ "weapon_ssg08", "weapon_taser", "weapon_tec9", "weapon_ump45",
+ "weapon_usp_silencer", "weapon_xm1014"
+ ];
- var weaponEntity = Utilities.GetEntityFromIndex((int)affectedEntity.Index);
- if (weaponEntity == null || weaponEntity.PrevOwner == null) return;
+ public void Start(BasePlugin _parent) {
+ parent = _parent;
- var weaponOwner = Utilities.GetEntityFromIndex((int)weaponEntity.PrevOwner.Index);
- if (weaponOwner == null) return;
- Server.PrintToChatAll($"{weaponOwner.PlayerName}");
- Server.PrintToChatAll($"{(int)weaponEntity.PrevOwner.Index}");
+ _parent
+ .RegisterListener<
+ CounterStrikeSharp.API.Core.Listeners.OnEntityParentChanged>(
+ OnEntityParentChanged);
+ }
- if (!newParent.IsValid) //a.k.a parent is world
- {
- logs.Append(logs.Player(weaponOwner), $"dropped their {weaponEntity.ToFriendlyString}");
- return;
- }
+ /*public void Dispose()
+ {
+ parent.RemoveListener("OnEntityParentChanged", OnEntityParentChanged);
+ }*/
+ public void OnEntityParentChanged(CEntityInstance affectedEntity,
+ CEntityInstance newParent) {
+ if (!affectedEntity.IsValid
+ || !WEAPON_STRINGS.Contains(affectedEntity.DesignerName))
+ return;
- var weaponPickerUpper = Utilities.GetEntityFromIndex((int)newParent.Index);
- if (weaponPickerUpper == null) return;
+ var weaponEntity =
+ Utilities.GetEntityFromIndex((int)affectedEntity.Index);
+ if (weaponEntity == null || weaponEntity.PrevOwner == null) return;
- logs.Append(logs.Player(weaponPickerUpper), "picked up", logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
+ var weaponOwner =
+ Utilities.GetEntityFromIndex(
+ (int)weaponEntity.PrevOwner.Index);
+ if (weaponOwner == null) return;
+ Server.PrintToChatAll($"{weaponOwner.PlayerName}");
+ Server.PrintToChatAll($"{(int)weaponEntity.PrevOwner.Index}");
+
+ if (!newParent.IsValid) //a.k.a parent is world
+ {
+ logs.Append(logs.Player(weaponOwner),
+ $"dropped their {weaponEntity.ToFriendlyString}");
+ return;
}
+
+ var weaponPickerUpper =
+ Utilities.GetEntityFromIndex((int)newParent.Index);
+ if (weaponPickerUpper == null) return;
+
+ logs.Append(logs.Player(weaponPickerUpper), "picked up",
+ logs.Player(weaponOwner), $"'s {weaponEntity.ToFriendlyString}");
+ }
}
\ No newline at end of file
From 25ad1db32c1a361d203e36c86e3d938ce3be92d5 Mon Sep 17 00:00:00 2001
From: Isaac
Date: Wed, 10 Jul 2024 20:04:05 -0700
Subject: [PATCH 20/27] Cleanup/july (#213)
Cleanup
---
Formatting.DotSettings | 82 +++
Jailbreak.sln.DotSettings | 9 +
.../Generic/GenericCommandNotifications.cs | 89 ++-
.../Jailbreak.English.csproj | 6 +-
.../LastGuard/LastGuardNotifications.cs | 41 +-
.../LastRequest/LastRequestMessages.cs | 146 ++--
.../LastRequest/RaceLRMessages.cs | 46 +-
lang/Jailbreak.English/Logs/LogMessages.cs | 44 +-
lang/Jailbreak.English/Mute/PeaceMessages.cs | 121 ++--
.../Rebel/JihadC4Notifications.cs | 35 +-
.../Rebel/RebelNotifications.cs | 24 +-
.../Warden/RollCommandNotifications.cs | 24 +-
.../Warden/SpecialTreatmentNotifications.cs | 54 +-
.../Warden/WardenNotifications.cs | 182 ++---
mod/Jailbreak.Debug/DebugCommand.cs | 57 +-
mod/Jailbreak.Debug/DebugServiceExtension.cs | 10 +-
mod/Jailbreak.Debug/Jailbreak.Debug.csproj | 12 +-
.../Subcommands/AbstractCommand.cs | 246 ++++---
mod/Jailbreak.Debug/Subcommands/LastGuard.cs | 39 +-
.../Subcommands/LastRequest.cs | 138 ++--
mod/Jailbreak.Debug/Subcommands/MarkRebel.cs | 42 +-
mod/Jailbreak.Debug/Subcommands/MarkST.cs | 37 +-
mod/Jailbreak.Debug/Subcommands/Pardon.cs | 28 +-
.../Subcommands/WrappedInfo.cs | 32 +-
mod/Jailbreak.LastGuard/LastGuard.cs | 12 +-
mod/Jailbreak.LastGuard/LastGuardConfig.cs | 7 +-
.../LastGuardServiceExtension.cs | 12 +-
mod/Jailbreak.LastRequest/EndRaceCommand.cs | 39 +-
.../Jailbreak.LastRequest.csproj | 8 +-
.../LastRequestCommand.cs | 217 +++---
.../LastRequestConfig.cs | 5 +-
.../LastRequestExtension.cs | 21 +-
.../LastRequestFactory.cs | 63 +-
.../LastRequestManager.cs | 440 ++++++------
.../LastRequestMenuSelector.cs | 45 +-
.../LastRequestPlayerSelector.cs | 67 +-
.../LastRequests/Coinflip.cs | 152 ++---
.../LastRequests/GunToss.cs | 52 +-
.../LastRequests/KnifeFight.cs | 34 +-
.../LastRequests/MagForMag.cs | 230 +++----
.../LastRequests/NoScope.cs | 148 ++--
.../LastRequests/Race.cs | 183 +++--
.../LastRequests/RockPaperScissors.cs | 197 +++---
.../LastRequests/ShotForShot.cs | 224 +++---
.../LastRequests/TeleportingRequest.cs | 32 +-
.../LastRequests/WeaponizedRequest.cs | 64 +-
mod/Jailbreak.Logs/Jailbreak.Logs.csproj | 8 +-
.../Listeners/LogDamageListeners.cs | 107 ++-
.../Listeners/LogEntityListeners.cs | 71 +-
.../Listeners/LogEntityParentListeners.cs | 6 +-
mod/Jailbreak.Logs/LogsCommand.cs | 14 +-
mod/Jailbreak.Logs/LogsManager.cs | 140 ++--
mod/Jailbreak.Logs/LogsServiceExtension.cs | 24 +-
mod/Jailbreak.Logs/Tags/PlayerTagHelper.cs | 72 +-
mod/Jailbreak.Mute/Jailbreak.Mute.csproj | 8 +-
mod/Jailbreak.Mute/MuteServiceExtension.cs | 10 +-
mod/Jailbreak.Mute/MuteSystem.cs | 369 +++++-----
mod/Jailbreak.Rebel/Jailbreak.Rebel.csproj | 8 +-
.../JihadC4/JihadC4Behavior.cs | 345 +++++-----
mod/Jailbreak.Rebel/RebelListener.cs | 37 +-
mod/Jailbreak.Rebel/RebelManager.cs | 249 +++----
mod/Jailbreak.Rebel/RebelServiceExtension.cs | 16 +-
.../Commands/PeaceCommandsBehavior.cs | 65 +-
.../Commands/RollCommandBehavior.cs | 76 +--
.../SpecialTreatmentCommandsBehavior.cs | 95 ++-
.../Commands/WardenCommandsBehavior.cs | 260 +++----
.../WardenFormatWriterExtensions.cs | 4 +-
mod/Jailbreak.Warden/Global/WardenBehavior.cs | 645 ++++++++----------
mod/Jailbreak.Warden/Jailbreak.Warden.csproj | 8 +-
.../Markers/WardenMarkerBehavior.cs | 99 ++-
.../Paint/WardenPaintBehavior.cs | 195 +++---
.../Selection/QueueFavorState.cs | 16 +-
mod/Jailbreak.Warden/Selection/QueueState.cs | 11 +-
.../Selection/WardenSelectionBehavior.cs | 248 +++----
.../SpecialTreatmentBehavior.cs | 123 ++--
mod/Jailbreak.Warden/WardenConfig.cs | 11 +-
.../WardenServiceExtension.cs | 34 +-
public/Jailbreak.Formatting/Base/IView.cs | 5 +-
.../Jailbreak.Formatting/Base/SimpleView.cs | 89 +--
.../Jailbreak.Formatting/Core/FormatObject.cs | 88 ++-
.../Jailbreak.Formatting/Core/FormatWriter.cs | 31 +-
.../Extensions/ViewExtensions.cs | 129 ++--
.../Jailbreak.Formatting.csproj | 6 +-
.../Jailbreak.Formatting/Languages/English.cs | 4 +-
.../Logistics/IDialect.cs | 8 +-
.../Logistics/ILanguage.cs | 9 +-
.../Logistics/LanguageConfig.cs | 139 ++--
.../Logistics/RegisterLanguageExtensions.cs | 16 +-
.../Objects/HiddenFormatObject.cs | 60 +-
.../Objects/IntegerFormatObject.cs | 32 +-
.../Objects/PlayerFormatObject.cs | 27 +-
.../Objects/StringFormatObject.cs | 29 +-
.../Objects/TreeFormatObject.cs | 139 ++--
.../Views/IGenericCommandNotifications.cs | 13 +-
.../Views/IJihadC4Notifications.cs | 20 +-
.../Views/ILastGuardNotifications.cs | 6 +-
.../Views/ILastRequestMessages.cs | 23 +-
.../Views/ILogMessages.cs | 41 +-
.../Views/IPeaceMessages.cs | 31 +-
.../Views/IRaceLRMessages.cs | 7 +-
.../Views/IRebelNotifications.cs | 7 +-
.../Views/IRollCommandNotications.cs | 5 +-
.../Views/ISpecialDayNotifications.cs | 17 +-
.../Views/ISpecialTreatmentNotifications.cs | 15 +-
.../Views/ITeamsNotifications.cs | 21 +-
.../Views/IWardenNotifications.cs | 79 +--
.../Views/Logging/IRichLogService.cs | 12 +-
.../Views/Logging/IRichPlayerTag.cs | 20 +-
public/Jailbreak.Public/API.cs | 20 +-
.../Behaviors/IPluginBehavior.cs | 19 +-
.../Configuration/IConfigService.cs | 22 +-
.../Extensions/EntityIOExtensions.cs | 30 +-
.../Extensions/PlayerExtensions.cs | 166 ++---
.../Extensions/ServerExtensions.cs | 45 +-
.../Extensions/ServiceCollectionExtensions.cs | 104 +--
.../Extensions/StringExtensions.cs | 11 +-
.../Extensions/VectorExtensions.cs | 77 +--
.../Jailbreak.Public/Generic/ICoroutines.cs | 17 +-
.../Jailbreak.Public/Generic/IPlayerState.cs | 10 +-
.../Generic/IPlayerStateFactory.cs | 42 +-
.../Jailbreak.Public/Jailbreak.Public.csproj | 6 +-
.../Mod/Damage/IBlockAllDamage.cs | 39 +-
.../Jailbreak.Public/Mod/Draw/BeamCircle.cs | 101 ++-
public/Jailbreak.Public/Mod/Draw/BeamLine.cs | 98 ++-
.../Jailbreak.Public/Mod/Draw/BeamedShape.cs | 37 +-
.../Mod/Draw/DrawableShape.cs | 47 +-
.../Jailbreak.Public/Mod/Draw/IColorable.cs | 7 +-
.../Mod/LastGuard/ILastGuardService.cs | 7 +-
.../Mod/LastRequest/AbstractLastRequest.cs | 36 +-
.../Mod/LastRequest/Enums/LRResult.cs | 8 +-
.../Mod/LastRequest/Enums/LRState.cs | 8 +-
.../Mod/LastRequest/Enums/LRType.cs | 103 ++-
.../Mod/LastRequest/ILastRequestFactory.cs | 9 +-
.../Mod/LastRequest/ILastRequestManager.cs | 32 +-
.../Jailbreak.Public/Mod/Logs/ILogService.cs | 13 +-
.../Jailbreak.Public/Mod/Logs/IPlayerTag.cs | 17 +-
.../Jailbreak.Public/Mod/Mute/IMuteService.cs | 15 +-
.../Jailbreak.Public/Mod/Mute/MuteReason.cs | 8 +-
.../Mod/Rebel/IJihadC4Service.cs | 40 +-
.../Mod/Rebel/IRebelService.cs | 18 +-
.../Mod/Warden/ISpecialTreatmentService.cs | 40 +-
.../Mod/Warden/IWardenSelectionService.cs | 43 +-
.../Mod/Warden/IWardenService.cs | 27 +-
.../Jailbreak.Public/Utils/FreezeManager.cs | 70 +-
.../Jailbreak.Public/Utils/TemporaryConvar.cs | 27 +-
.../Coroutines/CoroutineManager.cs | 32 +-
.../GenericServiceExtension.cs | 19 +-
.../Jailbreak.Generic.csproj | 6 +-
.../Behaviors/AliveStateTracker.cs | 21 +-
.../PlayerState/Behaviors/BaseStateTracker.cs | 35 +-
.../Behaviors/GlobalStateTracker.cs | 51 +-
.../Behaviors/RoundStateTracker.cs | 18 +-
.../PlayerState/ITrackedPlayerState.cs | 21 +-
.../PlayerState/PlayerStateFactory.cs | 42 +-
.../PlayerState/PlayerStateImpl.cs | 28 +-
src/Jailbreak/Config/ConfigService.cs | 109 ++-
src/Jailbreak/Jailbreak.cs | 137 ++--
src/Jailbreak/Jailbreak.csproj | 37 +-
src/Jailbreak/JailbreakServiceCollection.cs | 69 +-
159 files changed, 4674 insertions(+), 5668 deletions(-)
create mode 100644 Formatting.DotSettings
create mode 100644 Jailbreak.sln.DotSettings
diff --git a/Formatting.DotSettings b/Formatting.DotSettings
new file mode 100644
index 00000000..01c99f3b
--- /dev/null
+++ b/Formatting.DotSettings
@@ -0,0 +1,82 @@
+
+ Built-in: Full Cleanup
+ public private override virtual file new abstract internal protected sealed static readonly extern unsafe volatile async required
+ Remove
+ 0
+ END_OF_LINE
+ END_OF_LINE
+ False
+ False
+ True
+ END_OF_LINE
+ END_OF_LINE
+ TOGETHER_SAME_LINE
+ False
+ True
+ True
+ True
+ True
+ True
+ True
+ INDENT
+ 2
+ END_OF_LINE
+ True
+ True
+ True
+ True
+ True
+ True
+ END_OF_LINE
+ False
+ False
+ False
+ False
+ False
+ False
+ False
+ False
+ False
+ 10
+ 5
+ 5
+ 10
+ 5
+ COMPACT
+ END_OF_LINE
+ True
+ True
+ NEVER
+ NEVER
+ False
+ False
+ NEVER
+ False
+ False
+ NEVER
+ True
+ True
+ True
+ False
+ 2
+ END_OF_LINE
+ False
+ True
+ True
+ False
+ CHOP_IF_LONG
+ CHOP_IF_LONG
+ WRAP_IF_LONG
+ 80
+ WRAP_IF_LONG
+ True
+ API
+ <Policy><Descriptor Staticness="Any" AccessRightKinds="Private, ProtectedInternal, Internal, PrivateProtected" Description="Non-Public Methods"><ElementKinds><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy>
+ <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy>
+ <Policy><Descriptor Staticness="Any" AccessRightKinds="Private" Description="Constant fields (private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy>
+ <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy>
+ <Policy><Descriptor Staticness="Any" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Constant fields (not private)"><ElementKinds><Kind Name="CONSTANT_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy>
+ <Policy><Descriptor Staticness="Any" AccessRightKinds="Protected, Public, FileLocal" Description="Public Methods"><ElementKinds><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /></Policy>
+ <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Parameters"><ElementKinds><Kind Name="PARAMETER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="_" Suffix="" Style="aaBb" /></Policy></Policy>
+ <Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Enum members"><ElementKinds><Kind Name="ENUM_MEMBER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy>
+ <Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy>
\ No newline at end of file
diff --git a/Jailbreak.sln.DotSettings b/Jailbreak.sln.DotSettings
new file mode 100644
index 00000000..6b68132e
--- /dev/null
+++ b/Jailbreak.sln.DotSettings
@@ -0,0 +1,9 @@
+
+ IO
+ LR
+ ST
+
+
+
+
+
\ No newline at end of file
diff --git a/lang/Jailbreak.English/Generic/GenericCommandNotifications.cs b/lang/Jailbreak.English/Generic/GenericCommandNotifications.cs
index d4ced81a..2bcad41c 100644
--- a/lang/Jailbreak.English/Generic/GenericCommandNotifications.cs
+++ b/lang/Jailbreak.English/Generic/GenericCommandNotifications.cs
@@ -7,57 +7,50 @@
namespace Jailbreak.English.Generic;
-public class GenericCommandNotifications : IGenericCommandNotifications, ILanguage
-{
- public static FormatObject PREFIX =
- new HiddenFormatObject($" {ChatColors.DarkRed}[{ChatColors.LightRed}JB{ChatColors.DarkRed}]")
- {
- // Hide in panorama and center text
- Plain = false,
- Panorama = false,
- Chat = true
- };
+public class GenericCommandNotifications : IGenericCommandNotifications,
+ ILanguage {
+ private static readonly FormatObject PREFIX =
+ new HiddenFormatObject(
+ $" {ChatColors.DarkRed}[{ChatColors.LightRed}JB{ChatColors.DarkRed}]") {
+ // Hide in panorama and center text
+ Plain = false, Panorama = false, Chat = true
+ };
- public IView PlayerNotFound(string query)
- {
- return new SimpleView
- { PREFIX, $"{ChatColors.Red}Player '{ChatColors.LightBlue}{query}{ChatColors.Red}' not found." };
- }
+ public IView PlayerNotFound(string query) {
+ return new SimpleView {
+ PREFIX,
+ $"{ChatColors.Red}Player '{ChatColors.LightBlue}{query}{ChatColors.Red}' not found."
+ };
+ }
- public IView PlayerFoundMultiple(string query)
- {
- return new SimpleView
- {
- PREFIX,
- $"{ChatColors.Red}Multiple players found for '{ChatColors.LightBlue}{query}{ChatColors.Red}'."
- };
- }
+ public IView PlayerFoundMultiple(string query) {
+ return new SimpleView {
+ PREFIX,
+ $"{ChatColors.Red}Multiple players found for '{ChatColors.LightBlue}{query}{ChatColors.Red}'."
+ };
+ }
- public IView CommandOnCooldown(DateTime cooldownEndsAt)
- {
- var seconds = (int)(cooldownEndsAt - DateTime.Now).TotalSeconds;
- return new SimpleView
- {
- PREFIX, $"{ChatColors.Grey}Command is on cooldown for", seconds,
- $"{ChatColors.Grey}seconds!"
- };
- }
+ public IView CommandOnCooldown(DateTime cooldownEndsAt) {
+ var seconds = (int)(cooldownEndsAt - DateTime.Now).TotalSeconds;
+ return new SimpleView {
+ PREFIX,
+ $"{ChatColors.Grey}Command is on cooldown for",
+ seconds,
+ $"{ChatColors.Grey}seconds!"
+ };
+ }
- public IView InvalidParameter(string parameter, string expected)
- {
- return new SimpleView
- {
- PREFIX,
- $"{ChatColors.Red}Invalid parameter '{ChatColors.LightBlue}{parameter}{ChatColors.Red}', expected a(n) {ChatColors.White}{expected}{ChatColors.Red}."
- };
- }
+ public IView InvalidParameter(string parameter, string expected) {
+ return new SimpleView {
+ PREFIX,
+ $"{ChatColors.Red}Invalid parameter '{ChatColors.LightBlue}{parameter}{ChatColors.Red}', expected a(n) {ChatColors.White}{expected}{ChatColors.Red}."
+ };
+ }
- public IView NoPermissionMessage(string permission)
- {
- return new SimpleView
- {
- PREFIX,
- $"{ChatColors.Red}This command requires the {ChatColors.White}{permission}{ChatColors.Red} permission."
- };
- }
+ public IView NoPermissionMessage(string permission) {
+ return new SimpleView {
+ PREFIX,
+ $"{ChatColors.Red}This command requires the {ChatColors.White}{permission}{ChatColors.Red} permission."
+ };
+ }
}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/Jailbreak.English.csproj b/lang/Jailbreak.English/Jailbreak.English.csproj
index ff208cf1..814dac54 100644
--- a/lang/Jailbreak.English/Jailbreak.English.csproj
+++ b/lang/Jailbreak.English/Jailbreak.English.csproj
@@ -7,11 +7,7 @@
-
-
-
-
-
+
diff --git a/lang/Jailbreak.English/LastGuard/LastGuardNotifications.cs b/lang/Jailbreak.English/LastGuard/LastGuardNotifications.cs
index 4b09748f..31cf64aa 100644
--- a/lang/Jailbreak.English/LastGuard/LastGuardNotifications.cs
+++ b/lang/Jailbreak.English/LastGuard/LastGuardNotifications.cs
@@ -1,30 +1,29 @@
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Base;
-using Jailbreak.Formatting.Logistics;
-using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Core;
+using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Objects;
+using Jailbreak.Formatting.Views;
namespace Jailbreak.English.LastGuard;
-public class LastGuardNotifications : ILastGuardNotifications, ILanguage
-{
- public static FormatObject PREFIX =
- new HiddenFormatObject($" {ChatColors.DarkRed}[{ChatColors.LightRed}Last Guard{ChatColors.DarkRed}]")
- {
- // Hide in panorama and center text
- Plain = false,
- Panorama = false,
- Chat = true
- };
+public class LastGuardNotifications : ILastGuardNotifications,
+ ILanguage {
+ public static readonly FormatObject PREFIX =
+ new HiddenFormatObject(
+ $" {ChatColors.DarkRed}[{ChatColors.LightRed}Last Guard{ChatColors.DarkRed}]") {
+ // Hide in panorama and center text
+ Plain = false, Panorama = false, Chat = true
+ };
- public IView LG_STARTED(int ctHealth, int tHealth)
- {
- return new SimpleView()
- {
- PREFIX,
- $"{ChatColors.Red}Last Guard has been activated! Last guard has", ctHealth,
- $"{ChatColors.Red}health and Ts have", tHealth, $"{ChatColors.Red}health."
- };
- }
+ public IView LG_STARTED(int ctHealth, int tHealth) {
+ return new SimpleView {
+ PREFIX,
+ $"{ChatColors.Red}Last Guard has been activated! Last guard has",
+ ctHealth,
+ $"{ChatColors.Red}health and Ts have",
+ tHealth,
+ $"{ChatColors.Red}health."
+ };
+ }
}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/LastRequest/LastRequestMessages.cs b/lang/Jailbreak.English/LastRequest/LastRequestMessages.cs
index f4e59ee7..a25e4aca 100644
--- a/lang/Jailbreak.English/LastRequest/LastRequestMessages.cs
+++ b/lang/Jailbreak.English/LastRequest/LastRequestMessages.cs
@@ -10,90 +10,90 @@
namespace Jailbreak.English.LastRequest;
-public class LastRequestMessages : ILastRequestMessages, ILanguage
-{
- public static FormatObject PREFIX =
- new HiddenFormatObject($" {ChatColors.DarkRed}[{ChatColors.LightRed}LR{ChatColors.DarkRed}]")
- {
- // Hide in panorama and center text
- Plain = false,
- Panorama = false,
- Chat = true
- };
+public class LastRequestMessages : ILastRequestMessages,
+ ILanguage {
+ public static readonly FormatObject PREFIX =
+ new HiddenFormatObject(
+ $" {ChatColors.DarkRed}[{ChatColors.LightRed}LR{ChatColors.DarkRed}]") {
+ // Hide in panorama and center text
+ Plain = false, Panorama = false, Chat = true
+ };
- public IView LastRequestEnabled() => new SimpleView()
- {
- {
- PREFIX,
- $"Last Request has been enabled. {ChatColors.Grey}Type {ChatColors.LightBlue}!lr{ChatColors.Grey} to start a last request."
- }
+ public IView LastRequestEnabled() {
+ return new SimpleView {
+ {
+ PREFIX,
+ $"Last Request has been enabled. {ChatColors.Grey}Type {ChatColors.LightBlue}!lr{ChatColors.Grey} to start a last request."
+ }
};
+ }
- public IView LastRequestDisabled() => new SimpleView()
- {
- { PREFIX, $"{ChatColors.Grey}Last Request has been {ChatColors.Red}disabled{ChatColors.Grey}." }
+ public IView LastRequestDisabled() {
+ return new SimpleView {
+ {
+ PREFIX,
+ $"{ChatColors.Grey}Last Request has been {ChatColors.Red}disabled{ChatColors.Grey}."
+ }
};
+ }
- public IView LastRequestNotEnabled() => new SimpleView()
- {
- { PREFIX, $"{ChatColors.Red}Last Request is not enabled." }
+ public IView LastRequestNotEnabled() {
+ return new SimpleView {
+ { PREFIX, $"{ChatColors.Red}Last Request is not enabled." }
};
+ }
- public IView InvalidLastRequest(string query)
- {
- return new SimpleView()
- {
- PREFIX,
- "Invalid Last Request: ",
- query
- };
- }
+ public IView InvalidLastRequest(string query) {
+ return new SimpleView { PREFIX, "Invalid Last Request: ", query };
+ }
- public IView InvalidPlayerChoice(CCSPlayerController player, string reason)
- {
- return new SimpleView()
- {
- PREFIX,
- "Invalid player choice: ",
- player,
- " Reason: ",
- reason
- };
- }
+ public IView InvalidPlayerChoice(CCSPlayerController player, string reason) {
+ return new SimpleView {
+ PREFIX,
+ "Invalid player choice: ",
+ player,
+ " Reason: ",
+ reason
+ };
+ }
- public IView InformLastRequest(AbstractLastRequest lr)
- {
- return new SimpleView()
- {
- PREFIX,
- lr.prisoner, "is preparing a", lr.type.ToFriendlyString(),
- "Last Request against", lr.guard
- };
- }
+ public IView InformLastRequest(AbstractLastRequest lr) {
+ return new SimpleView {
+ PREFIX,
+ lr.Prisoner,
+ "is preparing a",
+ lr.Type.ToFriendlyString(),
+ "Last Request against",
+ lr.Guard
+ };
+ }
- public IView AnnounceLastRequest(AbstractLastRequest lr)
- {
- return new SimpleView()
- {
- PREFIX,
- lr.prisoner, "is doing a", lr.type.ToFriendlyString(),
- "Last Request against", lr.guard
- };
- }
+ public IView AnnounceLastRequest(AbstractLastRequest lr) {
+ return new SimpleView {
+ PREFIX,
+ lr.Prisoner,
+ "is doing a",
+ lr.Type.ToFriendlyString(),
+ "Last Request against",
+ lr.Guard
+ };
+ }
- public IView LastRequestDecided(AbstractLastRequest lr, LRResult result)
- {
- return new SimpleView()
- {
- PREFIX,
- (result == LRResult.GuardWin ? ChatColors.Blue : ChatColors.Red).ToString(),
- result == LRResult.PrisonerWin ? lr.prisoner : lr.guard,
- "won the LR."
- };
- }
+ public IView LastRequestDecided(AbstractLastRequest lr, LRResult result) {
+ return new SimpleView {
+ PREFIX,
+ (result == LRResult.GUARD_WIN ? ChatColors.Blue : ChatColors.Red)
+ .ToString(),
+ result == LRResult.PRISONER_WIN ? lr.Prisoner : lr.Guard,
+ "won the LR."
+ };
+ }
- public IView DamageBlockedInsideLastRequest => new SimpleView { PREFIX, "You or they are in LR, damage blocked." };
+ public IView DamageBlockedInsideLastRequest
+ => new SimpleView { PREFIX, "You or they are in LR, damage blocked." };
- public IView DamageBlockedNotInSameLR => new SimpleView
- { PREFIX, "You are not in the same LR as them, damage blocked." };
+ public IView DamageBlockedNotInSameLR
+ => new SimpleView {
+ PREFIX, "You are not in the same LR as them, damage blocked."
+ };
}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/LastRequest/RaceLRMessages.cs b/lang/Jailbreak.English/LastRequest/RaceLRMessages.cs
index 08b0a8d6..7fd52796 100644
--- a/lang/Jailbreak.English/LastRequest/RaceLRMessages.cs
+++ b/lang/Jailbreak.English/LastRequest/RaceLRMessages.cs
@@ -6,26 +6,32 @@
namespace Jailbreak.English.LastRequest;
-public class RaceLRMessages : IRaceLRMessages, ILanguage
-{
- public IView END_RACE_INSTRUCTION => new SimpleView()
- {
- { LastRequestMessages.PREFIX, $"Type ${ChatColors.Blue}!endrace${ChatColors.White} to set the end point!" },
- SimpleView.NEWLINE,
- { LastRequestMessages.PREFIX, $"Type ${ChatColors.Blue}!endrace${ChatColors.White} to set the end point!" },
- SimpleView.NEWLINE,
- { LastRequestMessages.PREFIX, $"Type ${ChatColors.Blue}!endrace${ChatColors.White} to set the end point!" },
- SimpleView.NEWLINE,
+// ReSharper disable ClassNeverInstantiated.Global
+public class RaceLRMessages : IRaceLRMessages,
+ ILanguage {
+ public IView EndRaceInstruction
+ => new SimpleView {
+ {
+ LastRequestMessages.PREFIX,
+ $"Type ${ChatColors.Blue}!endrace${ChatColors.White} to set the end point!"
+ },
+ SimpleView.NEWLINE, {
+ LastRequestMessages.PREFIX,
+ $"Type ${ChatColors.Blue}!endrace${ChatColors.White} to set the end point!"
+ },
+ SimpleView.NEWLINE, {
+ LastRequestMessages.PREFIX,
+ $"Type ${ChatColors.Blue}!endrace${ChatColors.White} to set the end point!"
+ },
+ SimpleView.NEWLINE
};
- public IView RACE_STARTING_MESSAGE(CCSPlayerController prisoner)
- {
- return new SimpleView()
- {
- {
- LastRequestMessages.PREFIX, prisoner,
- " is starting a race. Pay attention to where they set the end point!"
- }
- };
- }
+ public IView RaceStartingMessage(CCSPlayerController prisoner) {
+ return new SimpleView {
+ {
+ LastRequestMessages.PREFIX, prisoner,
+ " is starting a race. Pay attention to where they set the end point!"
+ }
+ };
+ }
}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/Logs/LogMessages.cs b/lang/Jailbreak.English/Logs/LogMessages.cs
index 881ca5d8..6161b337 100644
--- a/lang/Jailbreak.English/Logs/LogMessages.cs
+++ b/lang/Jailbreak.English/Logs/LogMessages.cs
@@ -1,30 +1,26 @@
-using CounterStrikeSharp.API;
-using CounterStrikeSharp.API.Modules.Utils;
-
-using Jailbreak.Formatting.Base;
-using Jailbreak.Formatting.Core;
+using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Logistics;
-using Jailbreak.Formatting.Objects;
using Jailbreak.Formatting.Views;
-using Jailbreak.Public.Extensions;
namespace Jailbreak.English.Logs;
-public class LogMessages : ILogMessages, ILanguage
-{
-
- public IView BEGIN_JAILBREAK_LOGS => new SimpleView()
- {
- { "********************************" }, SimpleView.NEWLINE,
- { "***** BEGIN JAILBREAK LOGS *****" }, SimpleView.NEWLINE,
- { "********************************" }
- };
-
- public IView END_JAILBREAK_LOGS => new SimpleView()
- {
- { "********************************" }, SimpleView.NEWLINE,
- { "****** END JAILBREAK LOGS ******" }, SimpleView.NEWLINE,
- { "********************************" }
- };
+public class
+ LogMessages : ILogMessages, ILanguage {
+ public IView BeginJailbreakLogs
+ => new SimpleView {
+ "********************************",
+ SimpleView.NEWLINE,
+ "***** BEGIN JAILBREAK LOGS *****",
+ SimpleView.NEWLINE,
+ "********************************"
+ };
-}
+ public IView EndJailbreakLogs
+ => new SimpleView {
+ "********************************",
+ SimpleView.NEWLINE,
+ "****** END JAILBREAK LOGS ******",
+ SimpleView.NEWLINE,
+ "********************************"
+ };
+}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/Mute/PeaceMessages.cs b/lang/Jailbreak.English/Mute/PeaceMessages.cs
index 9f66af34..96a0fcb9 100644
--- a/lang/Jailbreak.English/Mute/PeaceMessages.cs
+++ b/lang/Jailbreak.English/Mute/PeaceMessages.cs
@@ -1,5 +1,4 @@
-using CounterStrikeSharp.API.Core;
-using CounterStrikeSharp.API.Modules.Utils;
+using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Core;
using Jailbreak.Formatting.Logistics;
@@ -8,87 +7,71 @@
namespace Jailbreak.English.Mute;
-public class PeaceMessages : IPeaceMessages, ILanguage
-{
- private static readonly FormatObject PREFIX =
- new HiddenFormatObject(
- $" {ChatColors.DarkBlue}[{ChatColors.LightBlue}Voice{ChatColors.DarkBlue}]{ChatColors.Grey} ")
- {
- Plain = false,
- Panorama = false,
- Chat = true
- };
-
- public IView PEACE_ENACTED_BY_ADMIN(int seconds)
- {
- return new SimpleView()
- {
- PREFIX,
- "An admin has enacted peace for",
- seconds,
- "seconds."
- };
- }
+public class PeaceMessages : IPeaceMessages,
+ ILanguage {
+ private static readonly FormatObject PREFIX =
+ new HiddenFormatObject(
+ $" {ChatColors.DarkBlue}[{ChatColors.LightBlue}Voice{ChatColors.DarkBlue}]{ChatColors.Grey} ") {
+ Plain = false, Panorama = false, Chat = true
+ };
- public IView WARDEN_ENACTED_PEACE(int seconds)
- {
- return new SimpleView()
- {
- PREFIX,
- "Warden has enacted peace for",
- seconds,
- "seconds."
- };
- }
+ public IView PeaceEnactedByAdmin(int seconds) {
+ return new SimpleView {
+ PREFIX, "An admin has enacted peace for", seconds, "seconds."
+ };
+ }
- public IView GENERAL_PEACE_ENACTED(int seconds)
- {
- return new SimpleView()
- {
- PREFIX,
- "Peace has been enacted for",
- seconds,
- "seconds."
- };
- }
+ public IView WardenEnactedPeace(int seconds) {
+ return new SimpleView {
+ PREFIX, "Warden has enacted peace for", seconds, "seconds."
+ };
+ }
- public IView UNMUTED_GUARDS => new SimpleView()
- {
- { PREFIX, $"{ChatColors.Blue}Guards {ChatColors.Grey}have been unmuted." }
+ public IView GeneralPeaceEnacted(int seconds) {
+ return new SimpleView {
+ PREFIX, "Peace has been enacted for", seconds, "seconds."
};
+ }
- public IView UNMUTED_PRISONERS => new SimpleView()
- {
- { PREFIX, $"{ChatColors.LightRed}Prisoners {ChatColors.Grey}have been unmuted." }
+ public IView UnmutedGuards
+ => new SimpleView {
+ { PREFIX, $"{ChatColors.Blue}Guards {ChatColors.Grey}have been unmuted." }
};
- public IView MUTE_REMINDER => new SimpleView()
- {
- { PREFIX, ChatColors.Red, "You are currently muted!" }
+ public IView UnmutedPrisoners
+ => new SimpleView {
+ {
+ PREFIX,
+ $"{ChatColors.LightRed}Prisoners {ChatColors.Grey}have been unmuted."
+ }
};
- public IView PEACE_REMINDER => new SimpleView()
- {
- {
- PREFIX,
- $"Peace is currently active. {ChatColors.Red}You should only be talking if absolutely necessary!"
- }
+ public IView MuteReminder
+ => new SimpleView {
+ { PREFIX, ChatColors.Red, "You are currently muted!" }
};
- public IView DEAD_REMINDER => new SimpleView()
- {
- {
- PREFIX, $"{ChatColors.Red}You are dead and cannot speak!"
- }
+ public IView PeaceReminder
+ => new SimpleView {
+ {
+ PREFIX,
+ $"Peace is currently active. {ChatColors.Red}You should only be talking if absolutely necessary!"
+ }
};
- public IView ADMIN_DEAD_REMINDER => new SimpleView()
- {
- { PREFIX, "You are dead.", $"{ChatColors.Red}You should only be talking if absolutely necessary!" }
+ public IView DeadReminder
+ => new SimpleView {
+ { PREFIX, $"{ChatColors.Red}You are dead and cannot speak!" }
};
- public IView PEACE_ACTIVE => new SimpleView()
- {
- { PREFIX, "Peace is currently active." }
+ public IView AdminDeadReminder
+ => new SimpleView {
+ {
+ PREFIX, "You are dead.",
+ $"{ChatColors.Red}You should only be talking if absolutely necessary!"
+ }
};
+
+ public IView PeaceActive
+ => new SimpleView { { PREFIX, "Peace is currently active." } };
}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/Rebel/JihadC4Notifications.cs b/lang/Jailbreak.English/Rebel/JihadC4Notifications.cs
index a398895b..b9a42880 100644
--- a/lang/Jailbreak.English/Rebel/JihadC4Notifications.cs
+++ b/lang/Jailbreak.English/Rebel/JihadC4Notifications.cs
@@ -1,22 +1,31 @@
-using CounterStrikeSharp.API.Core;
-using CounterStrikeSharp.API.Modules.Utils;
+using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Views;
namespace Jailbreak.English.Rebel;
-public class JihadC4Notifications : IJihadC4Notifications, ILanguage
-{
- // public IView JIHAD_C4_DROPPED => new SimpleView { RebelNotifications.PREFIX, "You dropped your Jihad C4!" };
- public IView JIHAD_C4_PICKUP => new SimpleView { RebelNotifications.PREFIX, "You picked up a Jihad C4!" };
- public IView JIHAD_C4_RECEIVED => new SimpleView { RebelNotifications.PREFIX, "You received a Jihad C4!" };
- public IView JIHAD_C4_USAGE1 => new SimpleView { RebelNotifications.PREFIX, $"To detonate it, hold it out and press {ChatColors.Yellow + "E" + ChatColors.Default}." };
- // public IView JIHAD_C4_USAGE2 => new SimpleView { RebelNotifications.PREFIX, $"You can drop the C4 to other players with {ChatColors.Yellow + "G" + ChatColors.Default}." };
+public class JihadC4Notifications : IJihadC4Notifications,
+ ILanguage {
+ // public IView JIHAD_C4_DROPPED => new SimpleView { RebelNotifications.PREFIX, "You dropped your Jihad C4!" };
+ public IView JihadC4Pickup
+ => new SimpleView {
+ RebelNotifications.PREFIX, "You picked up a Jihad C4!"
+ };
+ public IView JihadC4Received
+ => new SimpleView { RebelNotifications.PREFIX, "You received a Jihad C4!" };
- // public IView PlayerDetonateC4(CCSPlayerController player)
- // {
- // return new SimpleView { RebelNotifications.PREFIX, $"{player.PlayerName} has detonated a Jihad C4!" };
- // }
+ public IView JihadC4Usage1
+ => new SimpleView {
+ RebelNotifications.PREFIX,
+ $"To detonate it, hold it out and press {ChatColors.Yellow + "E" + ChatColors.Default}."
+ };
+ // public IView JIHAD_C4_USAGE2 => new SimpleView { RebelNotifications.PREFIX, $"You can drop the C4 to other players with {ChatColors.Yellow + "G" + ChatColors.Default}." };
+
+
+ // public IView PlayerDetonateC4(CCSPlayerController player)
+ // {
+ // return new SimpleView { RebelNotifications.PREFIX, $"{player.PlayerName} has detonated a Jihad C4!" };
+ // }
}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/Rebel/RebelNotifications.cs b/lang/Jailbreak.English/Rebel/RebelNotifications.cs
index 37d4c1a7..4b47e540 100644
--- a/lang/Jailbreak.English/Rebel/RebelNotifications.cs
+++ b/lang/Jailbreak.English/Rebel/RebelNotifications.cs
@@ -1,5 +1,4 @@
using CounterStrikeSharp.API.Modules.Utils;
-
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Core;
using Jailbreak.Formatting.Logistics;
@@ -8,16 +7,15 @@
namespace Jailbreak.English.Rebel;
-public class RebelNotifications : IRebelNotifications, ILanguage
-{
- public static FormatObject PREFIX = new HiddenFormatObject($" {ChatColors.DarkRed}[{ChatColors.LightRed}Rebel{ChatColors.DarkRed}]")
- {
- // Hide in panorama and center text
- Plain = false,
- Panorama = false,
- Chat = true
- };
+public class RebelNotifications : IRebelNotifications,
+ ILanguage {
+ public static readonly FormatObject PREFIX =
+ new HiddenFormatObject(
+ $" {ChatColors.DarkRed}[{ChatColors.LightRed}Rebel{ChatColors.DarkRed}]") {
+ // Hide in panorama and center text
+ Plain = false, Panorama = false, Chat = true
+ };
- public IView NO_LONGER_REBEL =>
- new SimpleView() { PREFIX, "You are no longer a rebel." };
-}
+ public IView NoLongerRebel
+ => new SimpleView { PREFIX, "You are no longer a rebel." };
+}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/Warden/RollCommandNotifications.cs b/lang/Jailbreak.English/Warden/RollCommandNotifications.cs
index b1907c76..878f4450 100644
--- a/lang/Jailbreak.English/Warden/RollCommandNotifications.cs
+++ b/lang/Jailbreak.English/Warden/RollCommandNotifications.cs
@@ -7,18 +7,16 @@
namespace Jailbreak.English.Warden;
-public class RollCommandNotifications : IRollCommandNotications, ILanguage
-{
- public static FormatObject PREFIX = new HiddenFormatObject($" {ChatColors.Lime}[{ChatColors.Green}Roll{ChatColors.Lime}]")
- {
- // Hide in panorama and center text
- Plain = false,
- Panorama = false,
- Chat = true
+public class RollCommandNotifications : IRollCommandNotications,
+ ILanguage {
+ public static readonly FormatObject PREFIX =
+ new HiddenFormatObject(
+ $" {ChatColors.Lime}[{ChatColors.Green}Roll{ChatColors.Lime}]") {
+ // Hide in panorama and center text
+ Plain = false, Panorama = false, Chat = true
};
-
- public IView Roll(int roll)
- {
- return new SimpleView() { PREFIX, $"warden has rolled {roll}!" };
- }
+
+ public IView Roll(int roll) {
+ return new SimpleView { PREFIX, $"warden has rolled {roll}!" };
+ }
}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/Warden/SpecialTreatmentNotifications.cs b/lang/Jailbreak.English/Warden/SpecialTreatmentNotifications.cs
index 9bc28e30..1b5cd05a 100644
--- a/lang/Jailbreak.English/Warden/SpecialTreatmentNotifications.cs
+++ b/lang/Jailbreak.English/Warden/SpecialTreatmentNotifications.cs
@@ -8,30 +8,40 @@
namespace Jailbreak.English.Warden;
-public class SpecialTreatmentNotifications : ISpecialTreatmentNotifications, ILanguage
-{
- public static FormatObject PREFIX =
- new HiddenFormatObject($" {ChatColors.Lime}[{ChatColors.Green}ST{ChatColors.Lime}]")
- {
- // Hide in panorama and center text
- Plain = false,
- Panorama = false,
- Chat = true,
- };
+public class SpecialTreatmentNotifications : ISpecialTreatmentNotifications,
+ ILanguage {
+ public static readonly FormatObject PREFIX =
+ new HiddenFormatObject(
+ $" {ChatColors.Lime}[{ChatColors.Green}ST{ChatColors.Lime}]") {
+ // Hide in panorama and center text
+ Plain = false, Panorama = false, Chat = true
+ };
- public IView GRANTED =>
- new SimpleView { PREFIX, $"You now have {ChatColors.Green}special treatment{ChatColors.White}!" };
+ public IView Granted
+ => new SimpleView {
+ PREFIX,
+ $"You now have {ChatColors.Green}special treatment{ChatColors.White}!"
+ };
- public IView REVOKED =>
- new SimpleView { PREFIX, $"Your special treatment was {ChatColors.Red}removed{ChatColors.White}." };
+ public IView Revoked
+ => new SimpleView {
+ PREFIX,
+ $"Your special treatment was {ChatColors.Red}removed{ChatColors.White}."
+ };
- public IView GRANTED_TO(CCSPlayerController player)
- {
- return new SimpleView { PREFIX, player, $"now has {ChatColors.Grey}Special Treatment{ChatColors.White}!" };
- }
+ public IView GrantedTo(CCSPlayerController player) {
+ return new SimpleView {
+ PREFIX,
+ player,
+ $"now has {ChatColors.Grey}Special Treatment{ChatColors.White}!"
+ };
+ }
- public IView REVOKED_FROM(CCSPlayerController player)
- {
- return new SimpleView { PREFIX, player, $"{ChatColors.Red}no longer {ChatColors.Grey}has Special Treatment." };
- }
+ public IView RevokedFrom(CCSPlayerController player) {
+ return new SimpleView {
+ PREFIX,
+ player,
+ $"{ChatColors.Red}no longer {ChatColors.Grey}has Special Treatment."
+ };
+ }
}
\ No newline at end of file
diff --git a/lang/Jailbreak.English/Warden/WardenNotifications.cs b/lang/Jailbreak.English/Warden/WardenNotifications.cs
index 0305b645..a772cea4 100644
--- a/lang/Jailbreak.English/Warden/WardenNotifications.cs
+++ b/lang/Jailbreak.English/Warden/WardenNotifications.cs
@@ -8,91 +8,99 @@
namespace Jailbreak.English.Warden;
-public class WardenNotifications : IWardenNotifications, ILanguage
-{
- public static FormatObject PREFIX =
- new HiddenFormatObject($" {ChatColors.Green}[{ChatColors.Olive}WARDEN{ChatColors.Green}]")
- {
- // Hide in panorama and center text
- Plain = false,
- Panorama = false,
- Chat = true
- };
-
- public IView PICKING_SHORTLY =>
- new SimpleView
- {
- { PREFIX, $"{ChatColors.Grey}Picking a warden shortly..." }, SimpleView.NEWLINE,
- {
- PREFIX,
- $"{ChatColors.Grey}To enter the warden queue, type {ChatColors.Blue}!warden{ChatColors.Grey} in chat."
- }
- };
-
- public IView NO_WARDENS =>
- new SimpleView
- {
- PREFIX,
- $"No wardens in queue! The next player to run {ChatColors.Blue}!warden{ChatColors.White} will become a warden."
- };
-
- public IView WARDEN_LEFT =>
- new SimpleView { PREFIX, "The warden has left the game." };
-
- public IView WARDEN_DIED =>
- new SimpleView
- {
- PREFIX,
- $"{ChatColors.Red}The warden has {ChatColors.DarkRed}died{ChatColors.Red}! CTs must pursue {ChatColors.Blue}!warden{ChatColors.Red}."
- };
-
- public IView BECOME_NEXT_WARDEN =>
- new SimpleView
- { PREFIX, $"{ChatColors.Grey}Type {ChatColors.Blue}!warden{ChatColors.Grey} to become the next warden" };
-
- public IView JOIN_RAFFLE =>
- new SimpleView
- { PREFIX, $"{ChatColors.Grey}You've {ChatColors.Green}joined {ChatColors.Grey}the warden raffle." };
-
- public IView LEAVE_RAFFLE =>
- new SimpleView { PREFIX, $"{ChatColors.Grey}You've {ChatColors.Red}left {ChatColors.Grey}the warden raffle." };
-
- public IView NOT_WARDEN =>
- new SimpleView { PREFIX, $"{ChatColors.LightRed}You are not the warden." };
-
- public IView FIRE_COMMAND_FAILED =>
- new SimpleView { PREFIX, "The fire command has failed to work for some unknown reason..." };
-
- public IView PASS_WARDEN(CCSPlayerController player)
- {
- return new SimpleView { PREFIX, player, "resigned from being warden." };
- }
-
- public IView FIRE_WARDEN(CCSPlayerController player)
- {
- return new SimpleView { PREFIX, player, "was fired from being warden." };
- }
-
- public IView FIRE_WARDEN(CCSPlayerController player, CCSPlayerController admin)
- {
- return new SimpleView { PREFIX, admin, "fired", player, "from being warden." };
- }
-
- public IView NEW_WARDEN(CCSPlayerController player)
- {
- return new SimpleView { PREFIX, player, "is now the warden!" };
- }
-
- public IView CURRENT_WARDEN(CCSPlayerController? player)
- {
- if (player is not null)
- return new SimpleView { PREFIX, "The warden is", player, "." };
- else
- return new SimpleView { PREFIX, "There is no warden." };
- }
-
- public IView FIRE_COMMAND_SUCCESS(CCSPlayerController player)
- {
- return new SimpleView { PREFIX, player, "was fired and is no longer the warden." };
- }
+public class WardenNotifications : IWardenNotifications,
+ ILanguage {
+ public static readonly FormatObject PREFIX =
+ new HiddenFormatObject(
+ $" {ChatColors.Green}[{ChatColors.Olive}WARDEN{ChatColors.Green}]") {
+ // Hide in panorama and center text
+ Plain = false, Panorama = false, Chat = true
+ };
+
+ public IView PICKING_SHORTLY
+ => new SimpleView {
+ { PREFIX, $"{ChatColors.Grey}Picking a warden shortly..." },
+ SimpleView.NEWLINE, {
+ PREFIX,
+ $"{ChatColors.Grey}To enter the warden queue, type {ChatColors.Blue}!warden{ChatColors.Grey} in chat."
+ }
+ };
+
+ public IView NO_WARDENS
+ => new SimpleView {
+ PREFIX,
+ $"No wardens in queue! The next player to run {ChatColors.Blue}!warden{ChatColors.White} will become a warden."
+ };
+
+ public IView WARDEN_LEFT
+ => new SimpleView { PREFIX, "The warden has left the game." };
+
+ public IView WARDEN_DIED
+ => new SimpleView {
+ PREFIX,
+ $"{ChatColors.Red}The warden has {ChatColors.DarkRed}died{ChatColors.Red}! CTs must pursue {ChatColors.Blue}!warden{ChatColors.Red}."
+ };
+
+ public IView BECOME_NEXT_WARDEN
+ => new SimpleView {
+ PREFIX,
+ $"{ChatColors.Grey}Type {ChatColors.Blue}!warden{ChatColors.Grey} to become the next warden"
+ };
+
+ public IView JOIN_RAFFLE
+ => new SimpleView {
+ PREFIX,
+ $"{ChatColors.Grey}You've {ChatColors.Green}joined {ChatColors.Grey}the warden raffle."
+ };
+
+ public IView LEAVE_RAFFLE
+ => new SimpleView {
+ PREFIX,
+ $"{ChatColors.Grey}You've {ChatColors.Red}left {ChatColors.Grey}the warden raffle."
+ };
+
+ public IView NOT_WARDEN
+ => new SimpleView {
+ PREFIX, $"{ChatColors.LightRed}You are not the warden."
+ };
+
+ public IView FIRE_COMMAND_FAILED
+ => new SimpleView {
+ PREFIX, "The fire command has failed to work for some unknown reason..."
+ };
+
+ public IView PASS_WARDEN(CCSPlayerController player) {
+ return new SimpleView { PREFIX, player, "resigned from being warden." };
+ }
+
+ public IView FIRE_WARDEN(CCSPlayerController player) {
+ return new SimpleView { PREFIX, player, "was fired from being warden." };
+ }
+
+ public IView FIRE_WARDEN(CCSPlayerController player,
+ CCSPlayerController admin) {
+ return new SimpleView {
+ PREFIX,
+ admin,
+ "fired",
+ player,
+ "from being warden."
+ };
+ }
+
+ public IView NEW_WARDEN(CCSPlayerController player) {
+ return new SimpleView { PREFIX, player, "is now the warden!" };
+ }
+
+ public IView CURRENT_WARDEN(CCSPlayerController? player) {
+ if (player is not null)
+ return new SimpleView { PREFIX, "The warden is", player, "." };
+ return new SimpleView { PREFIX, "There is no warden." };
+ }
+
+ public IView FIRE_COMMAND_SUCCESS(CCSPlayerController player) {
+ return new SimpleView {
+ PREFIX, player, "was fired and is no longer the warden."
+ };
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Debug/DebugCommand.cs b/mod/Jailbreak.Debug/DebugCommand.cs
index c7d1404b..02903a27 100644
--- a/mod/Jailbreak.Debug/DebugCommand.cs
+++ b/mod/Jailbreak.Debug/DebugCommand.cs
@@ -9,41 +9,36 @@ namespace Jailbreak.Debug;
// css_debug [subcommand] [args] -> subcommand [args]
///
-/// The debug command allows for Developers to debug and force certain actions/gamestates.
+/// The debug command allows for Developers to debug and force certain actions/gamestates.
///
-public class DebugCommand(IServiceProvider serviceProvider) : IPluginBehavior
-{
- private readonly Dictionary _commands = new();
- private BasePlugin _plugin;
+public class DebugCommand(IServiceProvider serviceProvider) : IPluginBehavior {
+ private readonly Dictionary commands = new();
+ private BasePlugin? plugin;
- public void Start(BasePlugin parent)
- {
- _plugin = parent;
- _commands.Add("markrebel", new MarkRebel(serviceProvider));
- _commands.Add("pardon", new Pardon(serviceProvider));
- _commands.Add("lr", new Subcommands.LastRequest(serviceProvider, _plugin));
- _commands.Add("st", new MarkST(serviceProvider));
- _commands.Add("lg", new LastGuard(serviceProvider));
- }
-
- [RequiresPermissions("@css/root")]
- [ConsoleCommand("css_debug", "Debug command for Jailbreak.")]
- public void Command_Debug(CCSPlayerController? executor, CommandInfo info)
- {
- if (executor == null) return;
+ public void Start(BasePlugin basePlugin) {
+ plugin = basePlugin;
+ commands.Add("markrebel", new MarkRebel(serviceProvider));
+ commands.Add("pardon", new Pardon(serviceProvider));
+ commands.Add("lr", new Subcommands.LastRequest(serviceProvider, plugin));
+ commands.Add("st", new MarkST(serviceProvider));
+ commands.Add("lg", new LastGuard(serviceProvider));
+ }
- if (info.ArgCount == 1)
- {
- foreach (var command in _commands) info.ReplyToCommand(command.Key);
- return;
- }
+ [RequiresPermissions("@css/root")]
+ [ConsoleCommand("css_debug", "Debug command for Jailbreak.")]
+ public void Command_Debug(CCSPlayerController? executor, CommandInfo info) {
+ if (executor == null) return;
- if (!_commands.TryGetValue(info.GetArg(1), out var subcommand))
- {
- info.ReplyToCommand("Invalid subcommand");
- return;
- }
+ if (info.ArgCount == 1) {
+ foreach (var command in commands) info.ReplyToCommand(command.Key);
+ return;
+ }
- subcommand.OnCommand(executor, new WrappedInfo(info));
+ if (!commands.TryGetValue(info.GetArg(1), out var subcommand)) {
+ info.ReplyToCommand("Invalid subcommand");
+ return;
}
+
+ subcommand.OnCommand(executor, new WrappedInfo(info));
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Debug/DebugServiceExtension.cs b/mod/Jailbreak.Debug/DebugServiceExtension.cs
index 0c6f4bc7..8aa80afc 100644
--- a/mod/Jailbreak.Debug/DebugServiceExtension.cs
+++ b/mod/Jailbreak.Debug/DebugServiceExtension.cs
@@ -3,10 +3,8 @@
namespace Jailbreak.Debug;
-public static class DebugServiceExtension
-{
- public static void AddJailbreakDebug(this IServiceCollection services)
- {
- services.AddPluginBehavior();
- }
+public static class DebugServiceExtension {
+ public static void AddJailbreakDebug(this IServiceCollection services) {
+ services.AddPluginBehavior();
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Debug/Jailbreak.Debug.csproj b/mod/Jailbreak.Debug/Jailbreak.Debug.csproj
index 19918a36..97818649 100644
--- a/mod/Jailbreak.Debug/Jailbreak.Debug.csproj
+++ b/mod/Jailbreak.Debug/Jailbreak.Debug.csproj
@@ -7,14 +7,10 @@
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/mod/Jailbreak.Debug/Subcommands/AbstractCommand.cs b/mod/Jailbreak.Debug/Subcommands/AbstractCommand.cs
index a187dbb2..3afa1ae8 100644
--- a/mod/Jailbreak.Debug/Subcommands/AbstractCommand.cs
+++ b/mod/Jailbreak.Debug/Subcommands/AbstractCommand.cs
@@ -8,141 +8,135 @@
namespace Jailbreak.Debug.Subcommands;
-public abstract class AbstractCommand(IServiceProvider services)
-{
- private readonly IGenericCommandNotifications _lang = services.GetRequiredService();
- protected readonly IServiceProvider Services = services;
-
- public abstract void OnCommand(CCSPlayerController? executor, WrappedInfo info);
-
- protected TargetResult? GetTarget(WrappedInfo command, int argIndex = 1,
- Func? predicate = null)
- {
- return GetTarget(command.Info, argIndex + 1, predicate);
+public abstract class AbstractCommand(IServiceProvider services) {
+ private readonly IGenericCommandNotifications lang =
+ services.GetRequiredService();
+
+ protected readonly IServiceProvider Services = services;
+
+ public abstract void OnCommand(CCSPlayerController? executor,
+ WrappedInfo info);
+
+ protected TargetResult? GetTarget(WrappedInfo command, int argIndex = 1,
+ Func? predicate = null) {
+ return GetTarget(command.Info, argIndex + 1, predicate);
+ }
+
+ protected TargetResult? GetVulnerableTarget(WrappedInfo command,
+ int argIndex = 1, Func? predicate = null) {
+ return GetVulnerableTarget(command.Info, argIndex + 1, predicate);
+ }
+
+ protected TargetResult? GetTarget(CommandInfo command, int argIndex = 1,
+ Func? predicate = null) {
+ var matches = command.GetArgTargetResult(argIndex);
+
+ matches.Players = matches.Players.Where(player => player is {
+ IsValid: true, Connected: PlayerConnectedState.PlayerConnected
+ })
+ .ToList();
+ if (predicate != null)
+ matches.Players = matches.Players.Where(predicate).ToList();
+
+ if (!matches.Any()) {
+ if (command.CallingPlayer != null)
+ lang.PlayerNotFound(command.GetArg(argIndex))
+ .ToPlayerChat(command.CallingPlayer);
+ return null;
}
- protected TargetResult? GetVulnerableTarget(WrappedInfo command, int argIndex = 1,
- Func? predicate = null)
- {
- return GetVulnerableTarget(command.Info, argIndex + 1, predicate);
+ if (matches.Count() > 1 && command.GetArg(argIndex).StartsWith('@'))
+ return matches;
+
+ if (matches.Count() == 1 || !command.GetArg(argIndex).StartsWith('@'))
+ return matches;
+
+ if (command.CallingPlayer != null)
+ lang.PlayerFoundMultiple(command.GetArg(argIndex))
+ .ToPlayerChat(command.CallingPlayer);
+ return null;
+ }
+
+ protected TargetResult? GetVulnerableTarget(CommandInfo command,
+ int argIndex = 1, Func? predicate = null) {
+ return GetTarget(command, argIndex,
+ p => command.CallingPlayer == null || command.CallingPlayer.CanTarget(p)
+ && (predicate == null || predicate(p)));
+ }
+
+ protected TargetResult? GetSingleTarget(CommandInfo command,
+ int argIndex = 1) {
+ var matches = command.GetArgTargetResult(argIndex);
+
+ if (!matches.Any()) {
+ if (command.CallingPlayer != null)
+ lang.PlayerNotFound(command.GetArg(argIndex))
+ .ToPlayerChat(command.CallingPlayer);
+ return null;
}
- protected TargetResult? GetTarget(CommandInfo command, int argIndex = 1,
- Func? predicate = null)
- {
- var matches = command.GetArgTargetResult(argIndex);
-
- matches.Players = matches.Players.Where(player =>
- player is { IsValid: true, Connected: PlayerConnectedState.PlayerConnected }).ToList();
- if (predicate != null)
- matches.Players = matches.Players.Where(predicate).ToList();
-
- if (!matches.Any())
- {
- if (command.CallingPlayer != null)
- _lang.PlayerNotFound(command.GetArg(argIndex)).ToPlayerChat(command.CallingPlayer);
- return null;
- }
-
- if (matches.Count() > 1 && command.GetArg(argIndex).StartsWith('@'))
- return matches;
-
- if (matches.Count() == 1 || !command.GetArg(argIndex).StartsWith('@'))
- return matches;
-
- if (command.CallingPlayer != null)
- _lang.PlayerFoundMultiple(command.GetArg(argIndex)).ToPlayerChat(command.CallingPlayer);
- return null;
+ if (matches.Count() > 1) {
+ if (command.CallingPlayer != null)
+ lang.PlayerFoundMultiple(command.GetArg(argIndex))
+ .ToPlayerChat(command.CallingPlayer);
+ return null;
}
- protected TargetResult? GetVulnerableTarget(CommandInfo command, int argIndex = 1,
- Func? predicate = null)
- {
- return GetTarget(command, argIndex,
- p => command.CallingPlayer == null ||
- (command.CallingPlayer.CanTarget(p) && (predicate == null || predicate(p))));
+ return matches;
+ }
+
+ protected string GetTargetLabel(WrappedInfo info, int argIndex = 1) {
+ return GetTargetLabel(info.Info, argIndex + 1);
+ }
+
+ protected string GetTargetLabel(CommandInfo info, int argIndex = 1) {
+ switch (info.GetArg(argIndex)) {
+ case "@all":
+ return "all players";
+ case "@bots":
+ return "all bots";
+ case "@humans":
+ return "all humans";
+ case "@alive":
+ return "alive players";
+ case "@dead":
+ return "dead players";
+ case "@!me":
+ return "all except self";
+ case "@me":
+ return info.CallingPlayer == null ?
+ "Console" :
+ info.CallingPlayer.PlayerName;
+ case "@ct":
+ return "all CTs";
+ case "@t":
+ return "all Ts";
+ case "@spec":
+ return "all spectators";
+ default:
+ var player = info.GetArgTargetResult(argIndex).FirstOrDefault();
+ if (player != null) return player.PlayerName;
+ return "unknown";
}
+ }
- protected TargetResult? GetSingleTarget(CommandInfo command, int argIndex = 1)
- {
- var matches = command.GetArgTargetResult(argIndex);
-
- if (!matches.Any())
- {
- if (command.CallingPlayer != null)
- _lang.PlayerNotFound(command.GetArg(argIndex)).ToPlayerChat(command.CallingPlayer);
- return null;
- }
-
- if (matches.Count() > 1)
- {
- if (command.CallingPlayer != null)
- _lang.PlayerFoundMultiple(command.GetArg(argIndex)).ToPlayerChat(command.CallingPlayer);
- return null;
- }
-
- return matches;
- }
+ protected string GetTargetLabels(WrappedInfo info, int argIndex = 1) {
+ return GetTargetLabels(info.Info, argIndex + 1);
+ }
- protected string GetTargetLabel(WrappedInfo info, int argIndex = 1)
- {
- return GetTargetLabel(info.Info, argIndex + 1);
- }
-
- protected string GetTargetLabel(CommandInfo info, int argIndex = 1)
- {
- switch (info.GetArg(argIndex))
- {
- case "@all":
- return "all players";
- case "@bots":
- return "all bots";
- case "@humans":
- return "all humans";
- case "@alive":
- return "alive players";
- case "@dead":
- return "dead players";
- case "@!me":
- return "all except self";
- case "@me":
- return info.CallingPlayer == null ? "Console" : info.CallingPlayer.PlayerName;
- case "@ct":
- return "all CTs";
- case "@t":
- return "all Ts";
- case "@spec":
- return "all spectators";
- default:
- var player = info.GetArgTargetResult(argIndex).FirstOrDefault();
- if (player != null)
- return player.PlayerName;
- return "unknown";
- }
- }
-
- protected string GetTargetLabels(WrappedInfo info, int argIndex = 1)
- {
- return GetTargetLabels(info.Info, argIndex + 1);
- }
-
- protected string GetTargetLabels(CommandInfo info, int argIndex = 1)
- {
- var label = GetTargetLabel(info, argIndex);
- if (label.ToLower().EndsWith("s"))
- return label + "'";
- return label + "'s";
- }
+ protected string GetTargetLabels(CommandInfo info, int argIndex = 1) {
+ var label = GetTargetLabel(info, argIndex);
+ if (label.ToLower().EndsWith("s")) return label + "'";
+ return label + "'s";
+ }
}
-public static class CommandExtensions
-
-{
- internal static bool CanTarget(this CCSPlayerController controller, CCSPlayerController target)
- {
- if (!target.IsValid) return false;
- if (target.Connected != PlayerConnectedState.PlayerConnected) return false;
- if (target.IsBot || target.IsHLTV) return true;
- return AdminManager.CanPlayerTarget(controller, target);
- }
+public static class CommandExtensions {
+ public static bool CanTarget(this CCSPlayerController controller,
+ CCSPlayerController target) {
+ if (!target.IsValid) return false;
+ if (target.Connected != PlayerConnectedState.PlayerConnected) return false;
+ if (target.IsBot || target.IsHLTV) return true;
+ return AdminManager.CanPlayerTarget(controller, target);
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Debug/Subcommands/LastGuard.cs b/mod/Jailbreak.Debug/Subcommands/LastGuard.cs
index 87e44057..e0b89299 100644
--- a/mod/Jailbreak.Debug/Subcommands/LastGuard.cs
+++ b/mod/Jailbreak.Debug/Subcommands/LastGuard.cs
@@ -3,35 +3,30 @@
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastGuard;
-using Jailbreak.Public.Mod.Rebel;
-using Jailbreak.Public.Mod.Warden;
-using Jailbreak.Rebel;
using Microsoft.Extensions.DependencyInjection;
namespace Jailbreak.Debug.Subcommands;
// css_lastguard
-public class LastGuard(IServiceProvider services) : AbstractCommand(services)
-{
- public override void OnCommand(CCSPlayerController? executor, WrappedInfo info)
- {
- var lgService = Services.GetRequiredService();
+public class LastGuard(IServiceProvider services) : AbstractCommand(services) {
+ public override void OnCommand(CCSPlayerController? executor,
+ WrappedInfo info) {
+ var lgService = Services.GetRequiredService();
- var target = Utilities.GetPlayers()
- .FirstOrDefault(p => p.IsReal() && p is { Team: CsTeam.CounterTerrorist, PawnIsAlive: true });
+ var target = Utilities.GetPlayers()
+ .FirstOrDefault(p => p.IsReal() && p is {
+ Team: CsTeam.CounterTerrorist, PawnIsAlive: true
+ });
- if (info.ArgCount == 2)
- {
- var targetResult = GetVulnerableTarget(info);
- if (targetResult == null)
- return;
- target = targetResult.First();
- }
+ if (info.ArgCount == 2) {
+ var targetResult = GetVulnerableTarget(info);
+ if (targetResult == null) return;
+ target = targetResult.First();
+ }
- if (target == null)
- return;
+ if (target == null) return;
- lgService.StartLastGuard(target);
- info.ReplyToCommand("Enabled LastGuard for " + target.PlayerName);
- }
+ lgService.StartLastGuard(target);
+ info.ReplyToCommand("Enabled LastGuard for " + target.PlayerName);
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Debug/Subcommands/LastRequest.cs b/mod/Jailbreak.Debug/Subcommands/LastRequest.cs
index 9fd9ce33..e1534f32 100644
--- a/mod/Jailbreak.Debug/Subcommands/LastRequest.cs
+++ b/mod/Jailbreak.Debug/Subcommands/LastRequest.cs
@@ -11,88 +11,78 @@
namespace Jailbreak.Debug.Subcommands;
-public class LastRequest : AbstractCommand
-{
- private readonly ILastRequestManager _manager;
- private readonly LastRequestPlayerSelector _playerSelector;
- private readonly LastRequestMenuSelector _menuSelector;
- private readonly ILastRequestMessages _messages;
+public class LastRequest : AbstractCommand {
+ private readonly ILastRequestManager manager;
+ private readonly LastRequestMenuSelector menuSelector;
+ private readonly ILastRequestMessages messages;
+ private readonly LastRequestPlayerSelector playerSelector;
- private readonly BasePlugin _plugin;
+ private readonly BasePlugin plugin;
- public LastRequest(IServiceProvider services, BasePlugin plugin) : base(services)
- {
- _plugin = plugin;
- _manager = services.GetRequiredService();
- _playerSelector = new LastRequestPlayerSelector(_manager, true);
- _menuSelector = new LastRequestMenuSelector(services.GetRequiredService(),
- (type) => "css_debug lastrequest " + type);
- _messages = services.GetRequiredService();
- }
+ public LastRequest(IServiceProvider services, BasePlugin plugin) :
+ base(services) {
+ this.plugin = plugin;
+ manager = services.GetRequiredService();
+ playerSelector = new LastRequestPlayerSelector(manager, plugin, true);
+ menuSelector = new LastRequestMenuSelector(
+ services.GetRequiredService(),
+ type => "css_debug lastrequest " + type, plugin);
+ messages = services.GetRequiredService();
+ }
- // (debug) lastrequest [lr] [player]
- public override void OnCommand(CCSPlayerController? executor, WrappedInfo info)
- {
- if (executor != null && !executor.IsReal())
- return;
+ // (debug) lastrequest [lr] [player]
+ public override void OnCommand(CCSPlayerController? executor,
+ WrappedInfo info) {
+ if (executor == null || !executor.IsReal()) return;
- if (info.ArgCount == 1 && executor != null)
- {
- MenuManager.OpenCenterHtmlMenu(_plugin, executor, _menuSelector.GetMenu());
- return;
- }
+ if (info.ArgCount == 1) {
+ MenuManager.OpenCenterHtmlMenu(plugin, executor, menuSelector.GetMenu());
+ return;
+ }
- if (info.ArgCount == 2)
- {
- switch (info.GetArg(1).ToLower())
- {
- case "enable":
- _manager.EnableLR();
- info.ReplyToCommand("Last Request enabled.");
- return;
- case "disable":
- _manager.DisableLR();
- info.ReplyToCommand("Last Request disabled.");
- return;
- }
- }
+ if (info.ArgCount == 2)
+ switch (info.GetArg(1).ToLower()) {
+ case "enable":
+ manager.EnableLR();
+ info.ReplyToCommand("Last Request enabled.");
+ return;
+ case "disable":
+ manager.DisableLR();
+ info.ReplyToCommand("Last Request disabled.");
+ return;
+ }
- var type = LRTypeExtensions.FromString(info.GetArg(1));
- if (type is null)
- {
- _messages.InvalidLastRequest(info.GetArg(1)).ToPlayerChat(executor);
- return;
- }
+ var type = LRTypeExtensions.FromString(info.GetArg(1));
+ if (type is null) {
+ messages.InvalidLastRequest(info.GetArg(1)).ToPlayerChat(executor);
+ return;
+ }
- if (info.ArgCount == 2)
- {
- MenuManager.OpenCenterHtmlMenu(_plugin, executor,
- _playerSelector.CreateMenu(executor, (str) => "css_debug lastrequest " + type + " #" + str));
- return;
- }
+ if (info.ArgCount == 2) {
+ MenuManager.OpenCenterHtmlMenu(plugin, executor,
+ playerSelector.CreateMenu(executor,
+ str => "css_debug lastrequest " + type + " #" + str));
+ return;
+ }
- var fromPlayer = GetVulnerableTarget(info, 2);
- if (fromPlayer == null)
- return;
+ var fromPlayer = GetVulnerableTarget(info, 2);
+ if (fromPlayer == null) return;
- switch (info.ArgCount)
- {
- case 3 when executor != null:
- {
- if (executor.Team == CsTeam.Terrorist)
- _manager.InitiateLastRequest(executor, fromPlayer.First(), type.Value);
- else // They aren't necessarily on different teams, but this is debug so that's OK
- _manager.InitiateLastRequest(fromPlayer.First(), executor, type.Value);
- return;
- }
- case 4:
- {
- var targetPlayer = GetVulnerableTarget(info, 3);
- if (targetPlayer == null)
- return;
- _manager.InitiateLastRequest(fromPlayer.First(), targetPlayer.First(), type.Value);
- break;
- }
- }
+ switch (info.ArgCount) {
+ case 3 when executor != null: {
+ if (executor.Team == CsTeam.Terrorist)
+ manager.InitiateLastRequest(executor, fromPlayer.First(), type.Value);
+ else // They aren't necessarily on different teams, but this is debug so that's OK
+ manager.InitiateLastRequest(fromPlayer.First(), executor, type.Value);
+ return;
+ }
+ case 4: {
+ var targetPlayer = GetVulnerableTarget(info, 3);
+ if (targetPlayer == null) return;
+ manager.InitiateLastRequest(fromPlayer.First(), targetPlayer.First(),
+ type.Value);
+ break;
+ }
}
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Debug/Subcommands/MarkRebel.cs b/mod/Jailbreak.Debug/Subcommands/MarkRebel.cs
index ad7799db..083d8231 100644
--- a/mod/Jailbreak.Debug/Subcommands/MarkRebel.cs
+++ b/mod/Jailbreak.Debug/Subcommands/MarkRebel.cs
@@ -6,29 +6,27 @@
namespace Jailbreak.Debug.Subcommands;
// css_markrebel [player]
-public class MarkRebel(IServiceProvider services) : AbstractCommand(services)
-{
- public override void OnCommand(CCSPlayerController? executor, WrappedInfo info)
- {
- if (info.ArgCount == 1)
- {
- info.ReplyToCommand("Specify target?");
- return;
- }
+public class MarkRebel(IServiceProvider services) : AbstractCommand(services) {
+ public override void OnCommand(CCSPlayerController? executor,
+ WrappedInfo info) {
+ if (info.ArgCount == 1) {
+ info.ReplyToCommand("Specify target?");
+ return;
+ }
- var target = GetVulnerableTarget(info);
- if (target == null)
- return;
+ var target = GetVulnerableTarget(info);
+ if (target == null) return;
- var duration = RebelManager.MAX_REBEL_TIME;
- if (info.ArgCount == 3)
- if (!int.TryParse(info.GetArg(2), out duration))
- {
- info.ReplyToCommand("Invalid duration");
- return;
- }
+ var duration = RebelManager.MAX_REBEL_TIME;
+ if (info.ArgCount == 3)
+ if (!int.TryParse(info.GetArg(2), out duration)) {
+ info.ReplyToCommand("Invalid duration");
+ return;
+ }
- foreach (var player in target.Players) Services.GetRequiredService().MarkRebel(player, duration);
- info.ReplyToCommand($"Marked {GetTargetLabel(info)} as rebels for {duration} seconds.");
- }
+ foreach (var player in target.Players)
+ Services.GetRequiredService().MarkRebel(player, duration);
+ info.ReplyToCommand(
+ $"Marked {GetTargetLabel(info)} as rebels for {duration} seconds.");
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Debug/Subcommands/MarkST.cs b/mod/Jailbreak.Debug/Subcommands/MarkST.cs
index 49eaf39a..97c942aa 100644
--- a/mod/Jailbreak.Debug/Subcommands/MarkST.cs
+++ b/mod/Jailbreak.Debug/Subcommands/MarkST.cs
@@ -1,32 +1,27 @@
using CounterStrikeSharp.API.Core;
-using Jailbreak.Public.Mod.Rebel;
using Jailbreak.Public.Mod.Warden;
-using Jailbreak.Rebel;
using Microsoft.Extensions.DependencyInjection;
namespace Jailbreak.Debug.Subcommands;
// css_markst [player]
-public class MarkST(IServiceProvider services) : AbstractCommand(services)
-{
- public override void OnCommand(CCSPlayerController? executor, WrappedInfo info)
- {
- if (info.ArgCount == 1)
- {
- info.ReplyToCommand("Specify target?");
- return;
- }
+public class MarkST(IServiceProvider services) : AbstractCommand(services) {
+ public override void OnCommand(CCSPlayerController? executor,
+ WrappedInfo info) {
+ if (info.ArgCount == 1) {
+ info.ReplyToCommand("Specify target?");
+ return;
+ }
- var target = GetVulnerableTarget(info);
- if (target == null)
- return;
+ var target = GetVulnerableTarget(info);
+ if (target == null) return;
- var stService = Services.GetRequiredService();
- foreach (var player in target.Players)
- {
- stService.SetSpecialTreatment(player, !stService.IsSpecialTreatment(player));
- }
+ var stService = Services.GetRequiredService();
+ foreach (var player in target.Players)
+ stService.SetSpecialTreatment(player,
+ !stService.IsSpecialTreatment(player));
- info.ReplyToCommand("Toggled special treatment for " + GetTargetLabel(info) + ".");
- }
+ info.ReplyToCommand("Toggled special treatment for " + GetTargetLabel(info)
+ + ".");
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Debug/Subcommands/Pardon.cs b/mod/Jailbreak.Debug/Subcommands/Pardon.cs
index aa5a2efc..6aa146d0 100644
--- a/mod/Jailbreak.Debug/Subcommands/Pardon.cs
+++ b/mod/Jailbreak.Debug/Subcommands/Pardon.cs
@@ -5,22 +5,20 @@
namespace Jailbreak.Debug.Subcommands;
// css_pardon [player]
-public class Pardon(IServiceProvider services) : AbstractCommand(services)
-{
- public override void OnCommand(CCSPlayerController? executor, WrappedInfo info)
- {
- if (info.ArgCount == 1)
- {
- info.ReplyToCommand("Specify target?");
- return;
- }
+public class Pardon(IServiceProvider services) : AbstractCommand(services) {
+ public override void OnCommand(CCSPlayerController? executor,
+ WrappedInfo info) {
+ if (info.ArgCount == 1) {
+ info.ReplyToCommand("Specify target?");
+ return;
+ }
- var target = GetVulnerableTarget(info);
- if (target == null)
- return;
+ var target = GetVulnerableTarget(info);
+ if (target == null) return;
- foreach (var player in target.Players) Services.GetRequiredService().UnmarkRebel(player);
+ foreach (var player in target.Players)
+ Services.GetRequiredService().UnmarkRebel(player);
- info.ReplyToCommand($"Pardoned {GetTargetLabel(info)}");
- }
+ info.ReplyToCommand($"Pardoned {GetTargetLabel(info)}");
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Debug/Subcommands/WrappedInfo.cs b/mod/Jailbreak.Debug/Subcommands/WrappedInfo.cs
index c8bc6376..37893170 100644
--- a/mod/Jailbreak.Debug/Subcommands/WrappedInfo.cs
+++ b/mod/Jailbreak.Debug/Subcommands/WrappedInfo.cs
@@ -3,32 +3,24 @@
namespace Jailbreak.Debug.Subcommands;
-public class WrappedInfo(CommandInfo info)
-{
- public readonly CommandInfo Info = info;
+public class WrappedInfo(CommandInfo info) {
+ public readonly CommandInfo Info = info;
- public CCSPlayerController? CallingPlayer => Info.CallingPlayer;
+ public CCSPlayerController? CallingPlayer => Info.CallingPlayer;
- public IntPtr Handle => Info.Handle;
+ public IntPtr Handle => Info.Handle;
- public int ArgCount => Info.ArgCount - 1;
+ public int ArgCount => Info.ArgCount - 1;
- public string ArgString => Info.ArgString[(Info.ArgString.IndexOf(' ') + 1)..];
+ public string ArgString
+ => Info.ArgString[(Info.ArgString.IndexOf(' ') + 1)..];
- public string GetCommandString => Info.GetCommandString[(Info.GetCommandString.IndexOf(' ') + 1)..];
+ public string GetCommandString
+ => Info.GetCommandString[(Info.GetCommandString.IndexOf(' ') + 1)..];
- public string ArgByIndex(int index)
- {
- return Info.ArgByIndex(index + 1);
- }
+ public string ArgByIndex(int index) { return Info.ArgByIndex(index + 1); }
- public string GetArg(int index)
- {
- return Info.GetArg(index + 1);
- }
+ public string GetArg(int index) { return Info.GetArg(index + 1); }
- public void ReplyToCommand(string message)
- {
- Info.ReplyToCommand(message);
- }
+ public void ReplyToCommand(string message) { Info.ReplyToCommand(message); }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastGuard/LastGuard.cs b/mod/Jailbreak.LastGuard/LastGuard.cs
index e668746f..7654a885 100644
--- a/mod/Jailbreak.LastGuard/LastGuard.cs
+++ b/mod/Jailbreak.LastGuard/LastGuard.cs
@@ -14,7 +14,7 @@ namespace Jailbreak.LastGuard;
public class LastGuard(LastGuardConfig config, ILastGuardNotifications notifications, ILastRequestManager lrManager)
: ILastGuardService, IPluginBehavior
{
- private bool _canStart;
+ private bool canStart;
[GameEventHandler]
public HookResult OnPlayerDeathEvent(EventPlayerDeath @event, GameEventInfo info)
@@ -33,22 +33,22 @@ public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo
private void checkLastGuard(CCSPlayerController? poi)
{
if (poi == null) return;
- if (poi.Team != CsTeam.CounterTerrorist) ;
+ if (poi.Team != CsTeam.CounterTerrorist) return;
var aliveCts = Utilities.GetPlayers()
.Count(plr => plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist }) - 1;
- if (aliveCts != 1 || lrManager.IsLREnabled) ;
+ if (aliveCts != 1 || lrManager.IsLREnabled) return;
var lastGuard = Utilities.GetPlayers().First(plr =>
plr.IsReal() && plr != poi && plr is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist });
- if (_canStart)
+ if (canStart)
StartLastGuard(lastGuard);
}
[GameEventHandler]
public HookResult OnRoundStartEvent(EventRoundStart @event, GameEventInfo info)
{
- _canStart = Utilities.GetPlayers()
+ canStart = Utilities.GetPlayers()
.Count(plr => plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist }) >=
config.MinimumCTs;
return HookResult.Continue;
@@ -91,4 +91,4 @@ public void StartLastGuard(CCSPlayerController lastGuard)
player.GiveNamedItem(config.LastGuardWeapon);
}
}
-}
+}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastGuard/LastGuardConfig.cs b/mod/Jailbreak.LastGuard/LastGuardConfig.cs
index 534d7b4f..3ba834f7 100644
--- a/mod/Jailbreak.LastGuard/LastGuardConfig.cs
+++ b/mod/Jailbreak.LastGuard/LastGuardConfig.cs
@@ -1,7 +1,6 @@
namespace Jailbreak.LastGuard;
-public class LastGuardConfig
-{
- public string? LastGuardWeapon { get; } = "weapon_glock";
- public int MinimumCTs { get; } = 4;
+public class LastGuardConfig {
+ public string? LastGuardWeapon { get; } = "weapon_glock";
+ public int MinimumCTs { get; } = 4;
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastGuard/LastGuardServiceExtension.cs b/mod/Jailbreak.LastGuard/LastGuardServiceExtension.cs
index 00c1e040..7edff0b1 100644
--- a/mod/Jailbreak.LastGuard/LastGuardServiceExtension.cs
+++ b/mod/Jailbreak.LastGuard/LastGuardServiceExtension.cs
@@ -4,11 +4,9 @@
namespace Jailbreak.LastGuard;
-public static class RebelServiceExtension
-{
- public static void AddJailbreakLastGuard(this IServiceCollection collection)
- {
- collection.AddConfig("lastguard");
- collection.AddPluginBehavior();
- }
+public static class RebelServiceExtension {
+ public static void AddJailbreakLastGuard(this IServiceCollection collection) {
+ collection.AddConfig("lastguard");
+ collection.AddPluginBehavior();
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/EndRaceCommand.cs b/mod/Jailbreak.LastRequest/EndRaceCommand.cs
index 2564cc61..958bf106 100644
--- a/mod/Jailbreak.LastRequest/EndRaceCommand.cs
+++ b/mod/Jailbreak.LastRequest/EndRaceCommand.cs
@@ -1,35 +1,30 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
-using Jailbreak.LastRequest.LastRequests;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
namespace Jailbreak.LastRequest;
-public class EndRaceCommand(ILastRequestManager lrManager) : IPluginBehavior
-{
- [ConsoleCommand("css_endrace", "Used to set the end point of a race LR")]
- [CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
- public void Command_EndRace(CCSPlayerController? executor, CommandInfo info)
- {
- if (executor == null)
- return;
- var lr = lrManager.GetActiveLR(executor);
+public class EndRaceCommand(ILastRequestManager lrManager) : IPluginBehavior {
+ [ConsoleCommand("css_endrace", "Used to set the end point of a race LR")]
+ [CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
+ public void Command_EndRace(CCSPlayerController? executor, CommandInfo info) {
+ if (executor == null) return;
+ var lr = lrManager.GetActiveLR(executor);
- if (lr is not { type: LRType.Race })
- {
- info.ReplyToCommand("You must be in a race LR to use this command.");
- return;
- }
-
- if (lr.state != LRState.Pending)
- {
- info.ReplyToCommand("You must be in the pending state to use this command.");
- return;
- }
+ if (lr is not { Type: LRType.RACE }) {
+ info.ReplyToCommand("You must be in a race LR to use this command.");
+ return;
+ }
- lr.Execute();
+ if (lr.State != LRState.PENDING) {
+ info.ReplyToCommand(
+ "You must be in the pending state to use this command.");
+ return;
}
+
+ lr.Execute();
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj b/mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj
index 70f814b3..f430fd60 100644
--- a/mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj
+++ b/mod/Jailbreak.LastRequest/Jailbreak.LastRequest.csproj
@@ -7,12 +7,8 @@
-
-
-
-
-
-
+
+
diff --git a/mod/Jailbreak.LastRequest/LastRequestCommand.cs b/mod/Jailbreak.LastRequest/LastRequestCommand.cs
index 96aebda0..acaaee77 100644
--- a/mod/Jailbreak.LastRequest/LastRequestCommand.cs
+++ b/mod/Jailbreak.LastRequest/LastRequestCommand.cs
@@ -1,7 +1,6 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
-using CounterStrikeSharp.API.Modules.Commands.Targeting;
using CounterStrikeSharp.API.Modules.Menu;
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Extensions;
@@ -10,128 +9,108 @@
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
-using Microsoft.Extensions.DependencyModel;
namespace Jailbreak.LastRequest;
-public class LastRequestCommand(
- ILastRequestManager manager,
- ILastRequestMessages messages,
- IGenericCommandNotifications generic,
- ILastRequestFactory factory)
- : IPluginBehavior
-{
- private LastRequestMenuSelector _menuSelector;
- private LastRequestPlayerSelector _playerSelector;
- private BasePlugin _plugin;
-
- // css_lr
- public void Start(BasePlugin plugin)
- {
- _plugin = plugin;
- _playerSelector = new LastRequestPlayerSelector(manager);
- _menuSelector = new LastRequestMenuSelector(factory);
+public class LastRequestCommand(ILastRequestManager manager,
+ ILastRequestMessages messages, IGenericCommandNotifications generic,
+ ILastRequestFactory factory) : IPluginBehavior {
+ private LastRequestMenuSelector? menuSelector;
+ private LastRequestPlayerSelector? playerSelector;
+ private BasePlugin? plugin;
+
+ // css_lr
+ public void Start(BasePlugin basePlugin) {
+ plugin = basePlugin;
+ playerSelector = new LastRequestPlayerSelector(manager, plugin);
+ menuSelector = new LastRequestMenuSelector(factory, plugin);
+ }
+
+ [ConsoleCommand("css_lr", "Start a last request as a prisoner")]
+ [CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
+ public void Command_LastRequest(CCSPlayerController? executor,
+ CommandInfo info) {
+ if (executor == null || !executor.IsReal()) return;
+ if (executor.Team != CsTeam.Terrorist) {
+ info.ReplyToCommand("You must be a terrorist to LR.");
+ return;
}
- [ConsoleCommand("css_lr", "Start a last request as a prisoner")]
- [CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
- public void Command_LastRequest(CCSPlayerController? executor, CommandInfo info)
- {
- if (executor == null || !executor.IsReal())
- return;
- if (executor.Team != CsTeam.Terrorist)
- {
- info.ReplyToCommand("You must be a terrorist to LR.");
- return;
- }
-
- if (!executor.PawnIsAlive)
- {
- info.ReplyToCommand("You must be alive to LR.");
- return;
- }
-
- if (!manager.IsLREnabled)
- {
- messages.LastRequestNotEnabled().ToPlayerChat(executor);
- return;
- }
-
- if (!_playerSelector.WouldHavePlayers())
- {
- info.ReplyToCommand("There are no players available to LR.");
- return;
- }
-
- if (manager.IsInLR(executor))
- {
- info.ReplyToCommand("You are already in an LR!");
- return;
- }
-
- if (info.ArgCount == 1)
- {
- MenuManager.OpenCenterHtmlMenu(_plugin, executor, _menuSelector.GetMenu());
- return;
- }
-
- // Validate LR
- var type = LRTypeExtensions.FromString(info.GetArg(1));
- if (type is null)
- {
- messages.InvalidLastRequest(info.GetArg(1)).ToPlayerChat(executor);
- return;
- }
-
- if (info.ArgCount == 2)
- {
- MenuManager.OpenCenterHtmlMenu(_plugin, executor,
- _playerSelector.CreateMenu(executor, (str) => "css_lr " + type + " #" + str));
- return;
- }
-
- var target = info.GetArgTargetResult(2);
- if (target.Players.Count == 0)
- {
- generic.PlayerNotFound(info.GetArg(2));
- return;
- }
-
- if (target.Players.Count > 1)
- {
- generic.PlayerFoundMultiple(info.GetArg(2));
- return;
- }
-
- var player = target.Players.First();
- if (player.Team != CsTeam.CounterTerrorist)
- {
- messages.InvalidPlayerChoice(player, "They're not on CT!");
- return;
- }
-
- if (!player.PawnIsAlive)
- {
- messages.InvalidPlayerChoice(player, "They're not alive!");
- return;
- }
-
- if (manager.IsInLR(player))
- {
- messages.InvalidPlayerChoice(player, "They're already in an LR!");
- return;
- }
-
- //One final check in case they got the menu open in the last round
- if (!manager.IsLREnabled)
- {
- messages.LastRequestNotEnabled().ToPlayerChat(executor);
- return;
- }
-
- if (!manager.InitiateLastRequest(executor, player, (LRType)type))
- {
- info.ReplyToCommand("An error occurred while initiating the last request. Please try again later.");
- }
+ if (!executor.PawnIsAlive) {
+ info.ReplyToCommand("You must be alive to LR.");
+ return;
}
+
+ if (!manager.IsLREnabled) {
+ messages.LastRequestNotEnabled().ToPlayerChat(executor);
+ return;
+ }
+
+ if (!playerSelector!.WouldHavePlayers()) {
+ info.ReplyToCommand("There are no players available to LR.");
+ return;
+ }
+
+ if (manager.IsInLR(executor)) {
+ info.ReplyToCommand("You are already in an LR!");
+ return;
+ }
+
+ if (info.ArgCount == 1) {
+ MenuManager.OpenCenterHtmlMenu(plugin!, executor,
+ menuSelector!.GetMenu());
+ return;
+ }
+
+ // Validate LR
+ var type = LRTypeExtensions.FromString(info.GetArg(1));
+ if (type is null) {
+ messages.InvalidLastRequest(info.GetArg(1)).ToPlayerChat(executor);
+ return;
+ }
+
+ if (info.ArgCount == 2) {
+ MenuManager.OpenCenterHtmlMenu(plugin!, executor,
+ playerSelector.CreateMenu(executor,
+ str => "css_lr " + type + " #" + str));
+ return;
+ }
+
+ var target = info.GetArgTargetResult(2);
+ if (target.Players.Count == 0) {
+ generic.PlayerNotFound(info.GetArg(2));
+ return;
+ }
+
+ if (target.Players.Count > 1) {
+ generic.PlayerFoundMultiple(info.GetArg(2));
+ return;
+ }
+
+ var player = target.Players.First();
+ if (player.Team != CsTeam.CounterTerrorist) {
+ messages.InvalidPlayerChoice(player, "They're not on CT!");
+ return;
+ }
+
+ if (!player.PawnIsAlive) {
+ messages.InvalidPlayerChoice(player, "They're not alive!");
+ return;
+ }
+
+ if (manager.IsInLR(player)) {
+ messages.InvalidPlayerChoice(player, "They're already in an LR!");
+ return;
+ }
+
+ //One final check in case they got the menu open in the last round
+ if (!manager.IsLREnabled) {
+ messages.LastRequestNotEnabled().ToPlayerChat(executor);
+ return;
+ }
+
+ if (!manager.InitiateLastRequest(executor, player, (LRType)type))
+ info.ReplyToCommand(
+ "An error occurred while initiating the last request. Please try again later.");
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequestConfig.cs b/mod/Jailbreak.LastRequest/LastRequestConfig.cs
index fd59e8aa..af5ed811 100644
--- a/mod/Jailbreak.LastRequest/LastRequestConfig.cs
+++ b/mod/Jailbreak.LastRequest/LastRequestConfig.cs
@@ -1,6 +1,5 @@
namespace Jailbreak.LastRequest;
-public class LastRequestConfig
-{
- public int PrisonersToActiveLR { get; set; } = 2;
+public class LastRequestConfig {
+ public int PrisonersToActiveLR { get; set; } = 2;
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequestExtension.cs b/mod/Jailbreak.LastRequest/LastRequestExtension.cs
index 055406d5..892f6604 100644
--- a/mod/Jailbreak.LastRequest/LastRequestExtension.cs
+++ b/mod/Jailbreak.LastRequest/LastRequestExtension.cs
@@ -4,15 +4,14 @@
namespace Jailbreak.LastRequest;
-public static class LastRequestExtension
-{
- public static void AddJailbreakLastRequest(this IServiceCollection collection)
- {
- collection.AddConfig("lastrequest");
-
- collection.AddPluginBehavior();
- collection.AddPluginBehavior();
- collection.AddPluginBehavior();
- collection.AddPluginBehavior();
- }
+public static class LastRequestExtension {
+ public static void AddJailbreakLastRequest(
+ this IServiceCollection collection) {
+ collection.AddConfig("lastrequest");
+
+ collection.AddPluginBehavior();
+ collection.AddPluginBehavior();
+ collection.AddPluginBehavior();
+ collection.AddPluginBehavior();
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequestFactory.cs b/mod/Jailbreak.LastRequest/LastRequestFactory.cs
index c95dda4e..eadf903a 100644
--- a/mod/Jailbreak.LastRequest/LastRequestFactory.cs
+++ b/mod/Jailbreak.LastRequest/LastRequestFactory.cs
@@ -7,40 +7,37 @@
namespace Jailbreak.LastRequest;
-public class LastRequestFactory(ILastRequestManager manager, IServiceProvider _services) : ILastRequestFactory
-{
- private BasePlugin _plugin;
+public class LastRequestFactory(ILastRequestManager manager,
+ IServiceProvider services) : ILastRequestFactory {
+ private BasePlugin? plugin;
- public void Start(BasePlugin parent)
- {
- _plugin = parent;
- }
+ public void Start(BasePlugin basePlugin) { plugin = basePlugin; }
- public AbstractLastRequest CreateLastRequest(CCSPlayerController prisoner, CCSPlayerController guard, LRType type)
- {
- return type switch
- {
- LRType.KnifeFight => new KnifeFight(_plugin, manager, prisoner, guard),
- LRType.GunToss => new GunToss(_plugin, manager, prisoner, guard),
- LRType.NoScope => new NoScope(_plugin, manager, prisoner, guard),
- LRType.RockPaperScissors => new RockPaperScissors(_plugin, manager, prisoner, guard),
- LRType.Coinflip => new Coinflip(_plugin, manager, prisoner, guard),
- LRType.Race => new Race(_plugin, manager, prisoner, guard, _services.GetRequiredService()),
- _ => throw new ArgumentException("Invalid last request type: " + type, nameof(type))
- };
- }
+ public AbstractLastRequest CreateLastRequest(CCSPlayerController prisoner,
+ CCSPlayerController guard, LRType type) {
+ return type switch {
+ LRType.KNIFE_FIGHT => new KnifeFight(plugin!, manager, prisoner, guard),
+ LRType.GUN_TOSS => new GunToss(plugin!, manager, prisoner, guard),
+ LRType.NO_SCOPE => new NoScope(plugin!, manager, prisoner, guard),
+ LRType.ROCK_PAPER_SCISSORS => new RockPaperScissors(plugin!, manager,
+ prisoner, guard),
+ LRType.COINFLIP => new Coinflip(plugin!, manager, prisoner, guard),
+ LRType.RACE => new Race(plugin!, manager, prisoner, guard,
+ services.GetRequiredService()),
+ _ => throw new ArgumentException("Invalid last request type: " + type,
+ nameof(type))
+ };
+ }
- public bool IsValidType(LRType type)
- {
- return type switch
- {
- LRType.KnifeFight => true,
- LRType.GunToss => true,
- LRType.NoScope => true,
- LRType.RockPaperScissors => true,
- LRType.Coinflip => true,
- LRType.Race => true,
- _ => false
- };
- }
+ public bool IsValidType(LRType type) {
+ return type switch {
+ LRType.KNIFE_FIGHT => true,
+ LRType.GUN_TOSS => true,
+ LRType.NO_SCOPE => true,
+ LRType.ROCK_PAPER_SCISSORS => true,
+ LRType.COINFLIP => true,
+ LRType.RACE => true,
+ _ => false
+ };
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequestManager.cs b/mod/Jailbreak.LastRequest/LastRequestManager.cs
index 63d1e530..0e5c19c3 100644
--- a/mod/Jailbreak.LastRequest/LastRequestManager.cs
+++ b/mod/Jailbreak.LastRequest/LastRequestManager.cs
@@ -1,290 +1,238 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
-using CounterStrikeSharp.API.Modules.Cvars;
-using CounterStrikeSharp.API.Modules.Memory;
-using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Menu;
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
-using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
+using Jailbreak.Public.Mod.Damage;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
-using Jailbreak.Public.Mod.Damage;
using Microsoft.Extensions.DependencyInjection;
namespace Jailbreak.LastRequest;
-public class LastRequestManager(
- LastRequestConfig _config,
- ILastRequestMessages _messages,
- IServiceProvider _provider
-)
- : ILastRequestManager, IBlockUserDamage
-{
- private BasePlugin _parent;
- private ILastRequestFactory _factory;
-
- public bool IsLREnabled { get; set; }
- public IList ActiveLRs { get; } = new List();
-
- public void Start(BasePlugin parent)
- {
- _factory = _provider.GetRequiredService();
- _parent = parent;
- }
+public class LastRequestManager(LastRequestConfig config,
+ ILastRequestMessages messages, IServiceProvider provider)
+ : ILastRequestManager, IBlockUserDamage {
+ private ILastRequestFactory? factory;
- [GameEventHandler(HookMode.Pre)]
- public HookResult OnTakeDamage(EventPlayerHurt @event, GameEventInfo info)
- {
- IBlockUserDamage damageHandler = this;
- return damageHandler.BlockUserDamage(@event, info);
- }
+ public bool ShouldBlockDamage(CCSPlayerController player,
+ CCSPlayerController? attacker, EventPlayerHurt @event) {
+ if (!IsLREnabled) return false;
- public bool ShouldBlockDamage(CCSPlayerController player, CCSPlayerController? attacker, EventPlayerHurt @event)
- {
- if (!IsLREnabled)
- return false;
-
- if (attacker == null || !attacker.IsReal())
- {
- return false;
- }
-
- var playerLR = ((ILastRequestManager)this).GetActiveLR(player);
- var attackerLR = ((ILastRequestManager)this).GetActiveLR(attacker);
-
- if (playerLR == null && attackerLR == null)
- {
- // Neither of them is in an LR
- return false;
- }
-
- if ((playerLR == null) != (attackerLR == null))
- {
- // One of them is in an LR
- _messages.DamageBlockedInsideLastRequest.ToPlayerCenter(attacker);
- return true;
- }
-
- // Both of them are in LR
- // verify they're in same LR
- if (playerLR == null)
- return false;
-
- if (playerLR.prisoner.Equals(attacker) || playerLR.guard.Equals(attacker))
- {
- // Same LR, allow damage
- return false;
- }
-
- _messages.DamageBlockedNotInSameLR.ToPlayerCenter(attacker);
- return true;
- }
+ if (attacker == null || !attacker.IsReal()) return false;
- [GameEventHandler]
- public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
- {
- if (IsLREnabled)
- foreach (var lr in ActiveLRs)
- EndLastRequest(lr, LRResult.TimedOut);
+ var playerLR = ((ILastRequestManager)this).GetActiveLR(player);
+ var attackerLR = ((ILastRequestManager)this).GetActiveLR(attacker);
- IsLREnabled = false;
- return HookResult.Continue;
- }
+ if (playerLR == null && attackerLR == null)
+ // Neither of them is in an LR
+ return false;
- [GameEventHandler]
- public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
- {
- foreach (var player in Utilities.GetPlayers())
- {
- MenuManager.CloseActiveMenu(player);
- }
-
- if (ServerExtensions.GetGameRules().WarmupPeriod)
- return HookResult.Continue;
- if (CountAlivePrisoners() > _config.PrisonersToActiveLR)
- {
- this.IsLREnabled = false;
- return HookResult.Continue;
- }
-
- this.IsLREnabled = true;
- _messages.LastRequestEnabled().ToAllChat();
- return HookResult.Continue;
+ if (playerLR == null != (attackerLR == null)) {
+ // One of them is in an LR
+ messages.DamageBlockedInsideLastRequest.ToPlayerCenter(attacker);
+ return true;
}
- [GameEventHandler(HookMode.Post)]
- public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
- {
- var player = @event.Userid;
- if (!player.IsReal() || ServerExtensions.GetGameRules().WarmupPeriod)
- return HookResult.Continue;
-
- if (IsLREnabled)
- {
- // Handle active LRs
- var activeLr = ((ILastRequestManager)this).GetActiveLR(player);
- if (activeLr != null && activeLr.state != LRState.Completed)
- {
- var isPrisoner = activeLr.prisoner.Slot == player.Slot;
- EndLastRequest(activeLr, isPrisoner ? LRResult.GuardWin : LRResult.PrisonerWin);
- }
-
- return HookResult.Continue;
- }
-
- if (player.GetTeam() != CsTeam.Terrorist)
- return HookResult.Continue;
-
- if (CountAlivePrisoners() - 1 > _config.PrisonersToActiveLR)
- return HookResult.Continue;
-
- EnableLR(player);
- return HookResult.Continue;
- }
+ // Both of them are in LR
+ // verify they're in same LR
+ if (playerLR == null) return false;
- [GameEventHandler(HookMode.Post)]
- public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
- {
- var player = @event.Userid;
+ if (playerLR.Prisoner.Equals(attacker) || playerLR.Guard.Equals(attacker))
+ // Same LR, allow damage
+ return false;
- if (player == null) return HookResult.Continue;
+ messages.DamageBlockedNotInSameLR.ToPlayerCenter(attacker);
+ return true;
+ }
- if (!player.IsReal() || ServerExtensions.GetGameRules().WarmupPeriod)
- return HookResult.Continue;
+ public bool IsLREnabled { get; set; }
- if (IsLREnabled)
- return HookResult.Continue;
+ public IList ActiveLRs { get; } =
+ new List();
- var activeLr = ((ILastRequestManager)this).GetActiveLR(player);
+ public void Start(BasePlugin basePlugin) {
+ factory = provider.GetRequiredService();
+ }
+
+ public void DisableLR() { IsLREnabled = false; }
+
+ public void EnableLR(CCSPlayerController? died = null) {
+ messages.LastRequestEnabled().ToAllChat();
+ IsLREnabled = true;
+ setRoundTime(60);
- if (activeLr != null && activeLr.state != LRState.Active)
- {
- EndLastRequest(activeLr, player.Team == CsTeam.Terrorist ? LRResult.GuardWin : LRResult.PrisonerWin);
- return HookResult.Continue;
- }
+ foreach (var player in Utilities.GetPlayers().Where(p => p.IsReal())) {
+ // player.ExecuteClientCommand($"play sounds/lr");
+ if (player.Team != CsTeam.Terrorist || !player.PawnIsAlive) continue;
+ if (died != null && player.SteamID == died.SteamID) continue;
+ player.ExecuteClientCommandFromServer("css_lr");
+ }
+ }
- if (player.GetTeam() != CsTeam.Terrorist)
- return HookResult.Continue;
- if (CountAlivePrisoners() > _config.PrisonersToActiveLR)
- return HookResult.Continue;
+ public bool InitiateLastRequest(CCSPlayerController prisoner,
+ CCSPlayerController guard, LRType type) {
+ try {
+ var lr = factory!.CreateLastRequest(prisoner, guard, type);
+ lr.Setup();
+ ActiveLRs.Add(lr);
- EnableLR();
- return HookResult.Continue;
- }
+ if (prisoner.Pawn.Value != null) {
+ prisoner.Pawn.Value.Health = 100;
+ prisoner.PlayerPawn.Value!.ArmorValue = 0;
+ Utilities.SetStateChanged(prisoner.Pawn.Value, "CBaseEntity",
+ "m_iHealth");
+ }
- public void DisableLR()
- {
- IsLREnabled = false;
- }
- public void EnableLR(CCSPlayerController? died = null)
- {
- _messages.LastRequestEnabled().ToAllChat();
- IsLREnabled = true;
- SetRoundTime(60);
-
- foreach (var player in Utilities.GetPlayers().Where(p => p.IsReal()))
- {
- // player.ExecuteClientCommand($"play sounds/lr");
- if (player.Team != CsTeam.Terrorist || !player.PawnIsAlive)
- continue;
- if (died != null && player.SteamID == died.SteamID)
- continue;
- player.ExecuteClientCommandFromServer("css_lr");
- }
- }
+ if (guard.Pawn.Value != null) {
+ guard.Pawn.Value.Health = 100;
+ guard.PlayerPawn.Value!.ArmorValue = 0;
+ Utilities.SetStateChanged(guard.Pawn.Value, "CBaseEntity", "m_iHealth");
+ }
- private int GetCurrentRoundTime()
- {
- var gamerules = ServerExtensions.GetGameRules();
- var timeleft = (gamerules.RoundStartTime + gamerules.RoundTime) - Server.CurrentTime;
- return (int)timeleft;
+ messages.InformLastRequest(lr).ToAllChat();
+ return true;
+ } catch (ArgumentException e) {
+ Console.WriteLine(e);
+ return false;
}
+ }
- private int GetCurrentTimeElapsed()
- {
- var gamerules = ServerExtensions.GetGameRules();
- var freezeTime = gamerules.FreezeTime;
- return (int)((Server.CurrentTime - gamerules.RoundStartTime) - freezeTime);
+ public bool EndLastRequest(AbstractLastRequest lr, LRResult result) {
+ if (result is LRResult.GUARD_WIN or LRResult.PRISONER_WIN) {
+ addRoundTime(30);
+ messages.LastRequestDecided(lr, result).ToAllChat();
}
- private void SetRoundTime(int time)
- {
- var gamerules = ServerExtensions.GetGameRules();
- gamerules.RoundTime = (int)GetCurrentTimeElapsed() + time;
+ lr.OnEnd(result);
+ ActiveLRs.Remove(lr);
+ return true;
+ }
- Utilities.SetStateChanged(ServerExtensions.GetGameRulesProxy(), "CCSGameRulesProxy", "m_pGameRules");
- }
+ [GameEventHandler(HookMode.Pre)]
+ public HookResult OnTakeDamage(EventPlayerHurt @event, GameEventInfo info) {
+ IBlockUserDamage damageHandler = this;
+ return damageHandler.BlockUserDamage(@event, info);
+ }
- private void AddRoundTime(int time)
- {
- var gamerules = ServerExtensions.GetGameRules();
- gamerules.RoundTime += time;
+ [GameEventHandler]
+ public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info) {
+ if (IsLREnabled)
+ foreach (var lr in ActiveLRs)
+ EndLastRequest(lr, LRResult.TIMED_OUT);
- Utilities.SetStateChanged(ServerExtensions.GetGameRulesProxy(), "CCSGameRulesProxy", "m_pGameRules");
- }
+ IsLREnabled = false;
+ return HookResult.Continue;
+ }
- private int CountAlivePrisoners()
- {
- return Utilities.GetPlayers().Count(CountsToLR);
- }
+ [GameEventHandler]
+ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) {
+ foreach (var player in Utilities.GetPlayers())
+ MenuManager.CloseActiveMenu(player);
- private bool CountsToLR(CCSPlayerController player)
- {
- if (!player.IsReal())
- return false;
- if (!player.PawnIsAlive)
- return false;
- return player.GetTeam() == CsTeam.Terrorist;
- }
+ if (ServerExtensions.GetGameRules().WarmupPeriod)
+ return HookResult.Continue;
+ if (countAlivePrisoners() > config.PrisonersToActiveLR) {
+ IsLREnabled = false;
+ return HookResult.Continue;
+ }
- public bool InitiateLastRequest(CCSPlayerController prisoner, CCSPlayerController guard, LRType type)
- {
- try
- {
- var lr = _factory.CreateLastRequest(prisoner, guard, type);
- lr.Setup();
- ActiveLRs.Add(lr);
-
- if (prisoner.Pawn.Value != null)
- {
- prisoner.Pawn.Value.Health = 100;
- prisoner.PlayerPawn.Value!.ArmorValue = 0;
- Utilities.SetStateChanged(prisoner.Pawn.Value, "CBaseEntity", "m_iHealth");
- }
-
-
- if (guard.Pawn.Value != null)
- {
- guard.Pawn.Value.Health = 100;
- guard.PlayerPawn.Value!.ArmorValue = 0;
- Utilities.SetStateChanged(guard.Pawn.Value, "CBaseEntity", "m_iHealth");
- }
-
- _messages.InformLastRequest(lr).ToAllChat();
- return true;
- }
- catch (ArgumentException e)
- {
- Console.WriteLine(e);
- return false;
- }
- }
+ IsLREnabled = true;
+ messages.LastRequestEnabled().ToAllChat();
+ return HookResult.Continue;
+ }
+
+ [GameEventHandler]
+ public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) {
+ var player = @event.Userid;
+ if (player == null || !player.IsReal()
+ || ServerExtensions.GetGameRules().WarmupPeriod)
+ return HookResult.Continue;
+
+ if (IsLREnabled) {
+ // Handle active LRs
+ var activeLr = ((ILastRequestManager)this).GetActiveLR(player);
+ if (activeLr != null && activeLr.State != LRState.COMPLETED) {
+ var isPrisoner = activeLr.Prisoner.Slot == player.Slot;
+ EndLastRequest(activeLr,
+ isPrisoner ? LRResult.GUARD_WIN : LRResult.PRISONER_WIN);
+ }
+
+ return HookResult.Continue;
+ }
+
+ if (player.GetTeam() != CsTeam.Terrorist) return HookResult.Continue;
+
+ if (countAlivePrisoners() - 1 > config.PrisonersToActiveLR)
+ return HookResult.Continue;
+
+ EnableLR(player);
+ return HookResult.Continue;
+ }
+
+ [GameEventHandler]
+ public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event,
+ GameEventInfo info) {
+ var player = @event.Userid;
+
+ if (player == null) return HookResult.Continue;
+
+ if (!player.IsReal() || ServerExtensions.GetGameRules().WarmupPeriod)
+ return HookResult.Continue;
+
+ if (IsLREnabled) return HookResult.Continue;
- public bool EndLastRequest(AbstractLastRequest lr, LRResult result)
- {
- if (result is LRResult.GuardWin or LRResult.PrisonerWin)
- {
- AddRoundTime(30);
- _messages.LastRequestDecided(lr, result).ToAllChat();
- }
-
- lr.OnEnd(result);
- ActiveLRs.Remove(lr);
- return true;
- }
+ var activeLr = ((ILastRequestManager)this).GetActiveLR(player);
+
+ if (activeLr != null && activeLr.State != LRState.ACTIVE) {
+ EndLastRequest(activeLr,
+ player.Team == CsTeam.Terrorist ?
+ LRResult.GUARD_WIN :
+ LRResult.PRISONER_WIN);
+ return HookResult.Continue;
+ }
+
+ if (player.GetTeam() != CsTeam.Terrorist) return HookResult.Continue;
+ if (countAlivePrisoners() > config.PrisonersToActiveLR)
+ return HookResult.Continue;
+
+ EnableLR();
+ return HookResult.Continue;
+ }
+
+ private int getCurrentTimeElapsed() {
+ var gamerules = ServerExtensions.GetGameRules();
+ var freezeTime = gamerules.FreezeTime;
+ return (int)(Server.CurrentTime - gamerules.RoundStartTime - freezeTime);
+ }
+
+ private void setRoundTime(int time) {
+ var gamerules = ServerExtensions.GetGameRules();
+ gamerules.RoundTime = getCurrentTimeElapsed() + time;
+
+ Utilities.SetStateChanged(ServerExtensions.GetGameRulesProxy(),
+ "CCSGameRulesProxy", "m_pGameRules");
+ }
+
+ private void addRoundTime(int time) {
+ var gamerules = ServerExtensions.GetGameRules();
+ gamerules.RoundTime += time;
+
+ Utilities.SetStateChanged(ServerExtensions.GetGameRulesProxy(),
+ "CCSGameRulesProxy", "m_pGameRules");
+ }
+
+ private int countAlivePrisoners() {
+ return Utilities.GetPlayers().Count(prisonerCountsToLR);
+ }
+
+ private bool prisonerCountsToLR(CCSPlayerController player) {
+ if (!player.IsReal()) return false;
+ if (!player.PawnIsAlive) return false;
+ return player.GetTeam() == CsTeam.Terrorist;
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequestMenuSelector.cs b/mod/Jailbreak.LastRequest/LastRequestMenuSelector.cs
index 472b9f0b..c0cb6484 100644
--- a/mod/Jailbreak.LastRequest/LastRequestMenuSelector.cs
+++ b/mod/Jailbreak.LastRequest/LastRequestMenuSelector.cs
@@ -1,40 +1,31 @@
using CounterStrikeSharp.API.Core;
-using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.Menu;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
namespace Jailbreak.LastRequest;
-public class LastRequestMenuSelector
-{
- private readonly CenterHtmlMenu _menu;
- private readonly Func _command;
+public class LastRequestMenuSelector {
+ private readonly Func command;
+ private readonly CenterHtmlMenu menu;
- public LastRequestMenuSelector(ILastRequestFactory factory) : this(factory, (lr) => "css_lr " + ((int)lr))
- {
- }
+ public LastRequestMenuSelector(ILastRequestFactory factory, BasePlugin plugin)
+ : this(factory, lr => "css_lr " + (int)lr, plugin) { }
- public LastRequestMenuSelector(ILastRequestFactory factory, Func command)
- {
- _command = command;
- _menu = new CenterHtmlMenu("css_lr [LR] [Player]");
- foreach (LRType lr in Enum.GetValues(typeof(LRType)))
- {
- if (!factory.IsValidType(lr))
- continue;
- _menu.AddMenuOption(lr.ToFriendlyString(), (p, o) => OnSelectLR(p, lr));
- }
+ public LastRequestMenuSelector(ILastRequestFactory factory,
+ Func command, BasePlugin plugin) {
+ this.command = command;
+ menu = new CenterHtmlMenu("css_lr [LR] [Player]", plugin);
+ foreach (LRType lr in Enum.GetValues(typeof(LRType))) {
+ if (!factory.IsValidType(lr)) continue;
+ menu.AddMenuOption(lr.ToFriendlyString(), (p, _) => OnSelectLR(p, lr));
}
+ }
- public CenterHtmlMenu GetMenu()
- {
- return _menu;
- }
+ public CenterHtmlMenu GetMenu() { return menu; }
- private void OnSelectLR(CCSPlayerController player, LRType lr)
- {
- MenuManager.CloseActiveMenu(player);
- player.ExecuteClientCommandFromServer(this._command.Invoke(lr));
- }
+ private void OnSelectLR(CCSPlayerController player, LRType lr) {
+ MenuManager.CloseActiveMenu(player);
+ player.ExecuteClientCommandFromServer(command.Invoke(lr));
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs b/mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs
index 36f8e191..fb1cf0a6 100644
--- a/mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs
+++ b/mod/Jailbreak.LastRequest/LastRequestPlayerSelector.cs
@@ -4,47 +4,38 @@
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
-using Jailbreak.Public.Mod.LastRequest.Enums;
namespace Jailbreak.LastRequest;
-public class LastRequestPlayerSelector
-{
- private ILastRequestManager _lrManager;
- private bool debug;
-
- public LastRequestPlayerSelector(ILastRequestManager manager, bool debug = false)
- {
- _lrManager = manager;
- this.debug = debug;
+public class LastRequestPlayerSelector(ILastRequestManager manager,
+ BasePlugin plugin, bool debug = false) {
+ public CenterHtmlMenu CreateMenu(CCSPlayerController player,
+ Func command) {
+ var menu = new CenterHtmlMenu(command.Invoke("[Player]"), plugin);
+
+ foreach (var target in Utilities.GetPlayers()) {
+ if (!target.IsReal()) continue;
+ if (!target.PawnIsAlive
+ || target.Team != CsTeam.CounterTerrorist && !debug)
+ continue;
+ menu.AddMenuOption(target.PlayerName,
+ (_, _) => OnSelect(player, command, target.UserId.ToString()),
+ !debug && manager.IsInLR(target));
}
- public CenterHtmlMenu CreateMenu(CCSPlayerController player, Func command)
- {
- CenterHtmlMenu menu = new CenterHtmlMenu(command.Invoke("[Player]"));
-
- foreach (var target in Utilities.GetPlayers())
- {
- if (!target.IsReal())
- continue;
- if (!target.PawnIsAlive || target.Team != CsTeam.CounterTerrorist && !debug)
- continue;
- menu.AddMenuOption(target.PlayerName,
- (selector, _) =>
- OnSelect(player, command, target.UserId.ToString()),
- !debug && _lrManager.IsInLR(target)
- );
- }
-
- return menu;
- }
-
- public bool WouldHavePlayers() => Utilities.GetPlayers()
- .Any(p => p.IsReal() && p is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist });
-
- private void OnSelect(CCSPlayerController player, Func command, string? value)
- {
- MenuManager.CloseActiveMenu(player);
- player.ExecuteClientCommandFromServer(command.Invoke(value));
- }
+ return menu;
+ }
+
+ public bool WouldHavePlayers() {
+ return Utilities.GetPlayers()
+ .Any(p => p.IsReal() && p is {
+ PawnIsAlive: true, Team: CsTeam.CounterTerrorist
+ });
+ }
+
+ private void OnSelect(CCSPlayerController player,
+ Func command, string? value) {
+ MenuManager.CloseActiveMenu(player);
+ player.ExecuteClientCommandFromServer(command.Invoke(value));
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/Coinflip.cs b/mod/Jailbreak.LastRequest/LastRequests/Coinflip.cs
index 76789429..0239841e 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/Coinflip.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/Coinflip.cs
@@ -1,4 +1,3 @@
-using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Menu;
using Jailbreak.Public.Mod.LastRequest;
@@ -7,96 +6,81 @@
namespace Jailbreak.LastRequest.LastRequests;
-public class Coinflip : AbstractLastRequest
-{
- private readonly ChatMenu _menu;
- private readonly Random _rnd;
- private Timer _timeout;
+public class Coinflip : AbstractLastRequest {
+ private readonly string[] events = [
+ "A glint of silver flashes through the air...", "The coin does a 180...!",
+ "Gravity seems so much heavier...", "A quiet clink is heard...",
+ "An arrow hits the coin!", "The coin is shot in mid-air.",
+ "The answer is 42", "And yet...", "A sliver of copper falls off...",
+ "Lucky number 7...", "The coin lands on its side!",
+ "A bald eagle soars above",
+ "There wasn't enough room for the two of ya anyways...",
+ "Woosh woosh woosh", "banana rotate"
+ ];
- public Coinflip(BasePlugin plugin, ILastRequestManager manager, CCSPlayerController prisoner,
- CCSPlayerController guard) : base(plugin, manager, prisoner, guard)
- {
- _rnd = new Random();
- _menu = new ChatMenu("Heads or Tails?");
- _menu.AddMenuOption("Heads", (_, _) => Decide(true, true));
- _menu.AddMenuOption("Tails", (_, _) => Decide(false, true));
- }
+ private readonly ChatMenu menu;
+ private readonly Random rnd;
+ private Timer? timeout;
- public override LRType type => LRType.Coinflip;
+ public Coinflip(BasePlugin plugin, ILastRequestManager manager,
+ CCSPlayerController prisoner, CCSPlayerController guard) : base(plugin,
+ manager, prisoner, guard) {
+ rnd = new Random();
+ menu = new ChatMenu("Heads or Tails?");
+ menu.AddMenuOption("Heads", (_, _) => decide(true, true));
+ menu.AddMenuOption("Tails", (_, _) => decide(false, true));
+ }
- public override void Setup()
- {
- state = LRState.Pending;
- _menu.Title = "Heads or Tails? - " + prisoner.PlayerName + " vs " + guard.PlayerName;
- Execute();
- }
+ public override LRType Type => LRType.COINFLIP;
- public override void Execute()
- {
- state = LRState.Active;
- MenuManager.OpenChatMenu(guard, _menu);
+ public override void Setup() {
+ State = LRState.PENDING;
+ menu.Title = "Heads or Tails? - " + Prisoner.PlayerName + " vs "
+ + Guard.PlayerName;
+ Execute();
+ }
- _timeout = plugin.AddTimer(10, () =>
- {
- if (state != LRState.Active)
- return;
- MenuManager.CloseActiveMenu(guard);
- var choice = _rnd.Next(2) == 1;
- guard.PrintToChat($"You failed to choose in time, defaulting to {(choice ? "Heads" : "Tails")}");
- Decide(choice, true);
- });
- }
+ public override void Execute() {
+ State = LRState.ACTIVE;
+ MenuManager.OpenChatMenu(Guard, menu);
- private void Decide(bool heads, bool print)
- {
- _timeout.Kill();
- if (print)
- {
- MenuManager.CloseActiveMenu(guard);
- PrintToParticipants($"{guard.PlayerName} chose {(heads ? "Heads" : "Tails")}... flipping...");
- state = LRState.Active;
- }
- plugin.AddTimer(2, () =>
- {
- if (_rnd.Next(4) == 0)
- {
- PrintToParticipants(events[_rnd.Next(events.Length)]);
- plugin.AddTimer(2, () => Decide(heads, false));
- }
- else
- {
- var side = _rnd.Next(2) == 1;
- PrintToParticipants($"The coin lands on {(side ? "Heads" : "Tails")}!");
- manager.EndLastRequest(this, side == heads ? LRResult.GuardWin : LRResult.PrisonerWin);
- }
- });
+ timeout = Plugin.AddTimer(10, () => {
+ if (State != LRState.ACTIVE) return;
+ MenuManager.CloseActiveMenu(Guard);
+ var choice = rnd.Next(2) == 1;
+ Guard.PrintToChat(
+ $"You failed to choose in time, defaulting to {(choice ? "Heads" : "Tails")}");
+ decide(choice, true);
+ });
+ }
+
+ private void decide(bool heads, bool print) {
+ timeout?.Kill();
+ if (print) {
+ MenuManager.CloseActiveMenu(Guard);
+ PrintToParticipants(
+ $"{Guard.PlayerName} chose {(heads ? "Heads" : "Tails")}... flipping...");
+ State = LRState.ACTIVE;
}
- private readonly string[] events =
- {
- "A glint of silver flashes through the air...",
- "The coin does a 180...!",
- "Gravity seems so much heavier...",
- "A quiet clink is heard...",
- "An arrow hits the coin!",
- "The coin is shot in mid-air.",
- "The answer is 42",
- "And yet...",
- "A sliver of copper falls off...",
- "Lucky number 7...",
- "The coin lands on its side!",
- "A bald eagle soars above",
- "There wasn't enough room for the two of ya anyways...",
- "Woosh woosh woosh",
- "banana rotate"
- };
+ Plugin.AddTimer(2, () => {
+ if (rnd.Next(4) == 0) {
+ PrintToParticipants(events[rnd.Next(events.Length)]);
+ Plugin.AddTimer(2, () => decide(heads, false));
+ } else {
+ var side = rnd.Next(2) == 1;
+ PrintToParticipants($"The coin lands on {(side ? "Heads" : "Tails")}!");
+ Manager.EndLastRequest(this,
+ side == heads ? LRResult.GUARD_WIN : LRResult.PRISONER_WIN);
+ }
+ });
+ }
- public override void OnEnd(LRResult result)
- {
- state = LRState.Completed;
- if (result == LRResult.PrisonerWin)
- guard.Pawn.Value?.CommitSuicide(false, true);
- else
- prisoner.Pawn.Value?.CommitSuicide(false, true);
- }
+ public override void OnEnd(LRResult result) {
+ State = LRState.COMPLETED;
+ if (result == LRResult.PRISONER_WIN)
+ Guard.Pawn.Value?.CommitSuicide(false, true);
+ else
+ Prisoner.Pawn.Value?.CommitSuicide(false, true);
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/GunToss.cs b/mod/Jailbreak.LastRequest/LastRequests/GunToss.cs
index 36411ab7..725df533 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/GunToss.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/GunToss.cs
@@ -1,44 +1,32 @@
-using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
-using CounterStrikeSharp.API.Core.Attributes.Registration;
-using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
namespace Jailbreak.LastRequest.LastRequests;
-public class GunToss(
- BasePlugin plugin,
- ILastRequestManager manager,
- CCSPlayerController prisoner,
- CCSPlayerController guard)
- : AbstractLastRequest(plugin, manager, prisoner, guard)
-{
- public override LRType type => LRType.GunToss;
+public class GunToss(BasePlugin plugin, ILastRequestManager manager,
+ CCSPlayerController prisoner, CCSPlayerController guard)
+ : AbstractLastRequest(plugin, manager, prisoner, guard) {
+ public override LRType Type => LRType.GUN_TOSS;
- public override void Setup()
- {
- // Strip weapons, teleport T to CT
- prisoner.RemoveWeapons();
- guard.RemoveWeapons();
- guard.Teleport(prisoner);
- state = LRState.Pending;
+ public override void Setup() {
+ // Strip weapons, teleport T to CT
+ Prisoner.RemoveWeapons();
+ Guard.RemoveWeapons();
+ Guard.Teleport(Prisoner);
+ State = LRState.PENDING;
- plugin.AddTimer(3, Execute);
- }
+ Plugin.AddTimer(3, Execute);
+ }
- public override void Execute()
- {
- prisoner.GiveNamedItem("weapon_knife");
- guard.GiveNamedItem("weapon_knife");
- prisoner.GiveNamedItem("weapon_deagle");
- guard.GiveNamedItem("weapon_deagle");
- state = LRState.Active;
- }
+ public override void Execute() {
+ Prisoner.GiveNamedItem("weapon_knife");
+ Guard.GiveNamedItem("weapon_knife");
+ Prisoner.GiveNamedItem("weapon_deagle");
+ Guard.GiveNamedItem("weapon_deagle");
+ State = LRState.ACTIVE;
+ }
- public override void OnEnd(LRResult result)
- {
- state = LRState.Completed;
- }
+ public override void OnEnd(LRResult result) { State = LRState.COMPLETED; }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs b/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs
index 69821e52..f04d5a30 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/KnifeFight.cs
@@ -1,32 +1,20 @@
-using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
-using CounterStrikeSharp.API.Core.Attributes.Registration;
-using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
namespace Jailbreak.LastRequest.LastRequests;
-public class KnifeFight(
- BasePlugin plugin,
- ILastRequestManager manager,
- CCSPlayerController prisoner,
- CCSPlayerController guard)
- : WeaponizedRequest(plugin, manager,
- prisoner, guard)
-{
- public override LRType type => LRType.KnifeFight;
+public class KnifeFight(BasePlugin plugin, ILastRequestManager manager,
+ CCSPlayerController prisoner, CCSPlayerController guard)
+ : WeaponizedRequest(plugin, manager, prisoner, guard) {
+ public override LRType Type => LRType.KNIFE_FIGHT;
- public override void Execute()
- {
- PrintToParticipants("Go!");
- prisoner.GiveNamedItem("weapon_knife");
- guard.GiveNamedItem("weapon_knife");
- this.state = LRState.Active;
- }
+ public override void Execute() {
+ PrintToParticipants("Go!");
+ Prisoner.GiveNamedItem("weapon_knife");
+ Guard.GiveNamedItem("weapon_knife");
+ State = LRState.ACTIVE;
+ }
- public override void OnEnd(LRResult result)
- {
- state = LRState.Completed;
- }
+ public override void OnEnd(LRResult result) { State = LRState.COMPLETED; }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/MagForMag.cs b/mod/Jailbreak.LastRequest/LastRequests/MagForMag.cs
index bd210c28..bd129fc4 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/MagForMag.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/MagForMag.cs
@@ -1,136 +1,114 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
-using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Timers;
-using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
namespace Jailbreak.LastRequest.LastRequests;
-public class MagForMag(
- BasePlugin plugin,
- ILastRequestManager manager,
- CCSPlayerController prisoner,
- CCSPlayerController guard)
- : WeaponizedRequest(plugin, manager, prisoner, guard)
-{
- public override LRType type => LRType.GunToss;
- private CCSPlayerController whosShot;
- private int bulletCount = 7;
-
- public override void Setup()
- {
- plugin.RegisterEventHandler(OnPlayerShoot);
- base.Setup();
-
- whosShot = new Random().Next(2) == 0 ? prisoner : guard;
- PrintToParticipants(whosShot.PlayerName + " will shoot first.");
- prisoner.GiveNamedItem("weapon_deagle");
- guard.GiveNamedItem("weapon_deagle");
-
- var weapon = FindWeapon(prisoner, "weapon_deagle");
- if (weapon != null)
- setAmmoAmount(weapon, 0, 0);
- weapon = FindWeapon(guard, "weapon_deagle");
- if (weapon != null)
- setAmmoAmount(weapon, 0, 0);
- }
-
- private static CBasePlayerWeapon? FindWeapon(CCSPlayerController player, String name)
- {
- if (!player.IsReal())
- return null;
-
- var pawn = player.PlayerPawn.Value;
-
- if (pawn == null)
- return null;
-
- var weapons = pawn.WeaponServices?.MyWeapons;
-
- return weapons?.Select(weaponOpt => weaponOpt.Value).OfType()
- .FirstOrDefault(weapon => weapon.DesignerName.Contains(name));
- }
-
- private static void setAmmoAmount(CBasePlayerWeapon weapon, int primary, int reserve)
- {
- weapon.Clip1 = primary;
- Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_iClip1");
- weapon.Clip2 = reserve;
- Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_pReserveAmmo");
- }
-
- public override void Execute()
- {
- state = LRState.Active;
- var deagle = FindWeapon(whosShot, "weapon_deagle");
- if (deagle != null)
- setAmmoAmount(deagle, bulletCount, 0);
-
- plugin.AddTimer(30, () =>
- {
- if (state != LRState.Active)
- return;
- prisoner.GiveNamedItem("weapon_knife");
- guard.GiveNamedItem("weapon_knife");
- });
- plugin.AddTimer(60, () =>
- {
- if (state != LRState.Active) return;
- PrintToParticipants("Time's Up!");
- var result = guard.Health > prisoner.Health ? LRResult.GuardWin : LRResult.PrisonerWin;
- if (guard.Health == prisoner.Health)
- {
- PrintToParticipants("Even health, since " + whosShot.PlayerName + " had the shot last, they lose.");
- result = whosShot.Slot == prisoner.Slot ? LRResult.GuardWin : LRResult.PrisonerWin;
- }
- else
- {
- PrintToParticipants("Health was the deciding factor. ");
- }
-
- manager.EndLastRequest(this, result);
- if (result == LRResult.GuardWin)
- prisoner.Pawn.Value?.CommitSuicide(false, true);
- else
- guard.Pawn.Value?.CommitSuicide(false, true);
- }, TimerFlags.STOP_ON_MAPCHANGE);
- }
-
- public HookResult OnPlayerShoot(EventPlayerShoot @event, GameEventInfo info)
- {
- if (state != LRState.Active)
- return HookResult.Continue;
-
- var player = @event.Userid;
- if (!player.IsReal())
- return HookResult.Continue;
-
- if (player.Slot != prisoner.Slot && player.Slot != guard.Slot)
- return HookResult.Continue;
-
- var shootersDeagle = FindWeapon(player, "weapon_deagle");
- if (shootersDeagle == null)
- return HookResult.Continue;
-
- if (shootersDeagle.Clip1 != 0)
- return HookResult.Continue;
-
- PrintToParticipants(player.PlayerName + " has shot.");
- var opponent = player.Slot == prisoner.Slot ? guard : prisoner;
- opponent.PrintToChat("Your shot");
- var deagle = FindWeapon(opponent, "weapon_deagle");
- if (deagle != null)
- setAmmoAmount(deagle, 0, bulletCount);
- whosShot = opponent;
- return HookResult.Continue;
- }
-
- public override void OnEnd(LRResult result)
- {
- plugin.RemoveListener("player_shoot", OnPlayerShoot);
- state = LRState.Completed;
- }
+public class MagForMag(BasePlugin plugin, ILastRequestManager manager,
+ CCSPlayerController prisoner, CCSPlayerController guard)
+ : WeaponizedRequest(plugin, manager, prisoner, guard) {
+ private const int BULLET_COUNT = 7;
+ private CCSPlayerController? whosShot;
+ public override LRType Type => LRType.GUN_TOSS;
+
+ public override void Setup() {
+ Plugin.RegisterEventHandler(OnPlayerShoot);
+ base.Setup();
+
+ whosShot = new Random().Next(2) == 0 ? Prisoner : Guard;
+ PrintToParticipants(whosShot.PlayerName + " will shoot first.");
+ Prisoner.GiveNamedItem("weapon_deagle");
+ Guard.GiveNamedItem("weapon_deagle");
+
+ var weapon = findWeapon(Prisoner, "weapon_deagle");
+ if (weapon != null) setAmmoAmount(weapon, 0, 0);
+ weapon = findWeapon(Guard, "weapon_deagle");
+ if (weapon != null) setAmmoAmount(weapon, 0, 0);
+ }
+
+ private static CBasePlayerWeapon? findWeapon(CCSPlayerController player,
+ string name) {
+ if (!player.IsReal()) return null;
+
+ var pawn = player.PlayerPawn.Value;
+
+ if (pawn == null) return null;
+
+ var weapons = pawn.WeaponServices?.MyWeapons;
+
+ return weapons?.Select(weaponOpt => weaponOpt.Value)
+ .OfType()
+ .FirstOrDefault(weapon => weapon.DesignerName.Contains(name));
+ }
+
+ private static void setAmmoAmount(CBasePlayerWeapon weapon, int primary,
+ int reserve) {
+ weapon.Clip1 = primary;
+ Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_iClip1");
+ weapon.Clip2 = reserve;
+ Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_pReserveAmmo");
+ }
+
+ public override void Execute() {
+ State = LRState.ACTIVE;
+ var deagle = findWeapon(whosShot!, "weapon_deagle");
+ if (deagle != null) setAmmoAmount(deagle, BULLET_COUNT, 0);
+
+ Plugin.AddTimer(30, () => {
+ if (State != LRState.ACTIVE) return;
+ Prisoner.GiveNamedItem("weapon_knife");
+ Guard.GiveNamedItem("weapon_knife");
+ });
+ Plugin.AddTimer(60, () => {
+ if (State != LRState.ACTIVE) return;
+ PrintToParticipants("Time's Up!");
+ var result = Guard.Health > Prisoner.Health ?
+ LRResult.GUARD_WIN :
+ LRResult.PRISONER_WIN;
+ if (Guard.Health == Prisoner.Health) {
+ PrintToParticipants("Even health, since " + whosShot!.PlayerName
+ + " had the shot last, they lose.");
+ result = whosShot.Slot == Prisoner.Slot ?
+ LRResult.GUARD_WIN :
+ LRResult.PRISONER_WIN;
+ } else { PrintToParticipants("Health was the deciding factor. "); }
+
+ Manager.EndLastRequest(this, result);
+ if (result == LRResult.GUARD_WIN)
+ Prisoner.Pawn.Value?.CommitSuicide(false, true);
+ else
+ Guard.Pawn.Value?.CommitSuicide(false, true);
+ }, TimerFlags.STOP_ON_MAPCHANGE);
+ }
+
+ public HookResult OnPlayerShoot(EventPlayerShoot @event, GameEventInfo info) {
+ if (State != LRState.ACTIVE) return HookResult.Continue;
+
+ var player = @event.Userid;
+ if (!player.IsReal()) return HookResult.Continue;
+
+ if (player!.Slot != Prisoner.Slot && player.Slot != Guard.Slot)
+ return HookResult.Continue;
+
+ var shootersDeagle = findWeapon(player, "weapon_deagle");
+ if (shootersDeagle == null) return HookResult.Continue;
+
+ if (shootersDeagle.Clip1 != 0) return HookResult.Continue;
+
+ PrintToParticipants(player.PlayerName + " has shot.");
+ var opponent = player.Slot == Prisoner.Slot ? Guard : Prisoner;
+ opponent.PrintToChat("Your shot");
+ var deagle = findWeapon(opponent, "weapon_deagle");
+ if (deagle != null) setAmmoAmount(deagle, 0, BULLET_COUNT);
+ whosShot = opponent;
+ return HookResult.Continue;
+ }
+
+ public override void OnEnd(LRResult result) {
+ Plugin.RemoveListener(OnPlayerShoot);
+ State = LRState.COMPLETED;
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/NoScope.cs b/mod/Jailbreak.LastRequest/LastRequests/NoScope.cs
index 4df6c038..e7829c4f 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/NoScope.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/NoScope.cs
@@ -7,85 +7,71 @@
namespace Jailbreak.LastRequest.LastRequests;
-public class NoScope(
- BasePlugin plugin,
- ILastRequestManager manager,
- CCSPlayerController prisoner,
- CCSPlayerController guard)
- : WeaponizedRequest(plugin, manager,
- prisoner, guard)
-{
- public override LRType type => LRType.NoScope;
-
- public override void Setup()
- {
- base.Setup();
-
- plugin.RegisterListener(OnTick);
- }
-
- private void OnTick()
- {
- if (state != LRState.Active) return;
-
- if (!prisoner.IsReal() || !guard.IsReal())
- return;
-
- if (prisoner.PlayerPawn.Value == null || guard.PlayerPawn.Value == null) return;
- DisableScope(prisoner);
- DisableScope(guard);
- }
-
- private void DisableScope(CCSPlayerController player)
- {
- if (!player.IsReal())
- return;
- var pawn = player.PlayerPawn.Value;
- if (pawn == null || !pawn.IsValid)
- return;
- var weaponServices = pawn.WeaponServices;
- if (weaponServices == null)
- return;
- var activeWeapon = weaponServices.ActiveWeapon.Value;
- if (activeWeapon == null || !activeWeapon.IsValid)
- return;
- activeWeapon.NextSecondaryAttackTick = Server.TickCount + 500;
- }
-
- public override void Execute()
- {
- PrintToParticipants("Go!");
- prisoner.GiveNamedItem("weapon_ssg08");
- guard.GiveNamedItem("weapon_ssg08");
- this.state = LRState.Active;
-
- plugin.AddTimer(30, () =>
- {
- if (state != LRState.Active) return;
- prisoner.GiveNamedItem("weapon_knife");
- guard.GiveNamedItem("weapon_knife");
- }, TimerFlags.STOP_ON_MAPCHANGE);
-
- plugin.AddTimer(60, () =>
- {
- if (state != LRState.Active) return;
-
- manager.EndLastRequest(this, guard.Health > prisoner.Health ? LRResult.GuardWin : LRResult.PrisonerWin);
- }, TimerFlags.STOP_ON_MAPCHANGE);
- }
-
- public override void OnEnd(LRResult result)
- {
- this.state = LRState.Completed;
- plugin.RemoveListener("OnTick", OnTick);
-
- if(result != LRResult.GuardWin && result != LRResult.PrisonerWin)
- return;
-
- var winner = result == LRResult.GuardWin ? guard : prisoner;
-
- winner.RemoveWeapons();
- winner.GiveNamedItem("weapon_knife");
- winner.GiveNamedItem("weapon_ak47");
- }
+public class NoScope(BasePlugin plugin, ILastRequestManager manager,
+ CCSPlayerController prisoner, CCSPlayerController guard)
+ : WeaponizedRequest(plugin, manager, prisoner, guard) {
+ public override LRType Type => LRType.NO_SCOPE;
+
+ public override void Setup() {
+ base.Setup();
+
+ Plugin.RegisterListener(OnTick);
+ }
+
+ private void OnTick() {
+ if (State != LRState.ACTIVE) return;
+
+ if (!Prisoner.IsReal() || !Guard.IsReal()) return;
+
+ if (Prisoner.PlayerPawn.Value == null || Guard.PlayerPawn.Value == null)
+ return;
+ disableScope(Prisoner);
+ disableScope(Guard);
+ }
+
+ private void disableScope(CCSPlayerController player) {
+ if (!player.IsReal()) return;
+ var pawn = player.PlayerPawn.Value;
+ if (pawn == null || !pawn.IsValid) return;
+ var weaponServices = pawn.WeaponServices;
+ if (weaponServices == null) return;
+ var activeWeapon = weaponServices.ActiveWeapon.Value;
+ if (activeWeapon == null || !activeWeapon.IsValid) return;
+ activeWeapon.NextSecondaryAttackTick = Server.TickCount + 500;
+ }
+
+ public override void Execute() {
+ PrintToParticipants("Go!");
+ Prisoner.GiveNamedItem("weapon_ssg08");
+ Guard.GiveNamedItem("weapon_ssg08");
+ State = LRState.ACTIVE;
+
+ Plugin.AddTimer(30, () => {
+ if (State != LRState.ACTIVE) return;
+ Prisoner.GiveNamedItem("weapon_knife");
+ Guard.GiveNamedItem("weapon_knife");
+ }, TimerFlags.STOP_ON_MAPCHANGE);
+
+ Plugin.AddTimer(60, () => {
+ if (State != LRState.ACTIVE) return;
+
+ Manager.EndLastRequest(this,
+ Guard.Health > Prisoner.Health ?
+ LRResult.GUARD_WIN :
+ LRResult.PRISONER_WIN);
+ }, TimerFlags.STOP_ON_MAPCHANGE);
+ }
+
+ public override void OnEnd(LRResult result) {
+ State = LRState.COMPLETED;
+ Plugin.RemoveListener(OnTick);
+
+ if (result != LRResult.GUARD_WIN && result != LRResult.PRISONER_WIN) return;
+
+ var winner = result == LRResult.GUARD_WIN ? Guard : Prisoner;
+
+ winner.RemoveWeapons();
+ winner.GiveNamedItem("weapon_knife");
+ winner.GiveNamedItem("weapon_ak47");
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/Race.cs b/mod/Jailbreak.LastRequest/LastRequests/Race.cs
index f874d185..1f574964 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/Race.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/Race.cs
@@ -1,6 +1,4 @@
using System.Drawing;
-using System.Xml.Schema;
-using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Timers;
using CounterStrikeSharp.API.Modules.Utils;
@@ -14,124 +12,111 @@
namespace Jailbreak.LastRequest.LastRequests;
-public class Race(
- BasePlugin plugin,
- ILastRequestManager manager,
- CCSPlayerController prisoner,
- CCSPlayerController guard,
- IRaceLRMessages messages) : TeleportingRequest(plugin, manager, prisoner, guard)
-{
- public override LRType type => LRType.Race;
+public class Race(BasePlugin plugin, ILastRequestManager manager,
+ CCSPlayerController prisoner, CCSPlayerController guard,
+ IRaceLRMessages messages)
+ : TeleportingRequest(plugin, manager, prisoner, guard) {
+ private DateTime raceStart;
+ private Timer? raceTimer;
+ private BeamCircle? start, end;
+ private Vector? startLocation, endLocation;
+ public override LRType Type => LRType.RACE;
- private BeamCircle? start, end;
- private Vector startLocation, endLocation;
+ public override void Setup() {
+ base.Setup();
- private Timer? raceTimer;
- private DateTime raceStart;
+ Prisoner.RemoveWeapons();
- public override void Setup()
- {
- base.Setup();
+ Guard.RemoveWeapons();
+ Guard.GiveNamedItem("weapon_knife");
- prisoner.RemoveWeapons();
+ Plugin.AddTimer(3, () => {
+ if (State != LRState.PENDING) return;
+ Prisoner.GiveNamedItem("weapon_knife");
+ });
- guard.RemoveWeapons();
- guard.GiveNamedItem("weapon_knife");
+ messages.EndRaceInstruction.ToPlayerChat(Prisoner);
- plugin.AddTimer(3, () =>
- {
- if (state != LRState.Pending)
- return;
- prisoner.GiveNamedItem("weapon_knife");
- });
+ messages.RaceStartingMessage(Prisoner).ToPlayerChat(Guard);
- messages.END_RACE_INSTRUCTION.ToPlayerChat(prisoner);
+ startLocation = Prisoner.Pawn?.Value?.AbsOrigin?.Clone();
- messages.RACE_STARTING_MESSAGE(prisoner).ToPlayerChat(guard);
+ if (startLocation == null) return;
+ start = new BeamCircle(Plugin, startLocation, 20, 16);
+ start.SetColor(Color.Aqua);
+ start.Draw();
+ }
- startLocation = prisoner.Pawn.Value.AbsOrigin.Clone();
+ // Called when the prisoner types !endrace
+ public override void Execute() {
+ State = LRState.ACTIVE;
- start = new BeamCircle(plugin, startLocation, 20, 16);
- start.SetColor(Color.Aqua);
- start.Draw();
- }
+ endLocation = Prisoner.Pawn?.Value?.AbsOrigin?.Clone();
- // Called when the prisoner types !endrace
- public override void Execute()
- {
- state = LRState.Active;
+ if (endLocation == null) return;
+ end = new BeamCircle(Plugin, endLocation, 10, 32);
+ end.SetColor(Color.Red);
+ end.Draw();
- endLocation = prisoner.Pawn.Value.AbsOrigin.Clone();
+ Prisoner.Pawn?.Value?.Teleport(startLocation);
+ Guard.Pawn.Value?.Teleport(startLocation);
- end = new BeamCircle(plugin, endLocation, 10, 32);
- end.SetColor(Color.Red);
- end.Draw();
+ Guard.Freeze();
+ Prisoner.Freeze();
- prisoner.Pawn.Value.Teleport(startLocation);
- guard.Pawn.Value?.Teleport(startLocation);
+ Plugin.AddTimer(1, () => {
+ Guard.UnFreeze();
+ Prisoner.UnFreeze();
+ });
- guard.Freeze();
- prisoner.Freeze();
+ raceStart = DateTime.Now;
- plugin.AddTimer(1, () =>
- {
- guard.UnFreeze();
- prisoner.UnFreeze();
- });
+ raceTimer = Plugin.AddTimer(0.1f, tick, TimerFlags.REPEAT);
+ }
- raceStart = DateTime.Now;
+ private void tick() {
+ if (Prisoner.AbsOrigin == null || Guard.AbsOrigin == null) return;
+ var requiredDistance = getRequiredDistance();
+ var requiredDistanceSqured = MathF.Pow(requiredDistance, 2);
- raceTimer = plugin.AddTimer(0.1f, Tick, TimerFlags.REPEAT);
- }
+ end?.SetRadius(requiredDistance / 2);
+ end?.Update();
- private void Tick()
- {
- if (prisoner.AbsOrigin == null || guard.AbsOrigin == null)
- return;
- var requiredDistance = getRequiredDistance();
- var requiredDistanceSqured = MathF.Pow(requiredDistance, 2);
-
- end?.SetRadius(requiredDistance / 2);
- end?.Update();
-
- var guardDist = guard.Pawn.Value.AbsOrigin.Clone().DistanceSquared(endLocation);
-
- if (guardDist < requiredDistanceSqured)
- {
- manager.EndLastRequest(this, LRResult.GuardWin);
- return;
- }
-
- var prisonerDist = prisoner.Pawn.Value.AbsOrigin.Clone().DistanceSquared(endLocation);
- if (prisonerDist < requiredDistanceSqured)
- {
- manager.EndLastRequest(this, LRResult.PrisonerWin);
- }
- }
+ if (endLocation == null) return;
+ var guardDist = Guard.Pawn?.Value?.AbsOrigin?.Clone()
+ .DistanceSquared(endLocation);
- // https://www.desmos.com/calculator/e1qwgpmtmz
- private float getRequiredDistance()
- {
- var elapsedSeconds = (DateTime.Now - raceStart).TotalSeconds;
-
- return (float)(10 + elapsedSeconds + Math.Pow(elapsedSeconds, 2.9) / 5000);
+ if (guardDist < requiredDistanceSqured) {
+ Manager.EndLastRequest(this, LRResult.GUARD_WIN);
+ return;
}
- public override void OnEnd(LRResult result)
- {
- state = LRState.Completed;
- switch (result)
- {
- case LRResult.GuardWin:
- prisoner.Pawn.Value?.CommitSuicide(false, true);
- break;
- case LRResult.PrisonerWin:
- guard.Pawn.Value?.CommitSuicide(false, true);
- break;
- }
-
- raceTimer?.Kill();
- start?.Remove();
- end?.Remove();
+ var prisonerDist = Prisoner.Pawn?.Value?.AbsOrigin?.Clone()
+ .DistanceSquared(endLocation);
+ if (prisonerDist < requiredDistanceSqured)
+ Manager.EndLastRequest(this, LRResult.PRISONER_WIN);
+ }
+
+ // https://www.desmos.com/calculator/e1qwgpmtmz
+ private float getRequiredDistance() {
+ var elapsedSeconds = (DateTime.Now - raceStart).TotalSeconds;
+
+ return (float)(10 + elapsedSeconds + Math.Pow(elapsedSeconds, 2.9) / 5000);
+ }
+
+ public override void OnEnd(LRResult result) {
+ State = LRState.COMPLETED;
+ switch (result) {
+ case LRResult.GUARD_WIN:
+ Prisoner.Pawn.Value?.CommitSuicide(false, true);
+ break;
+ case LRResult.PRISONER_WIN:
+ Guard.Pawn.Value?.CommitSuicide(false, true);
+ break;
}
+
+ raceTimer?.Kill();
+ start?.Remove();
+ end?.Remove();
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/RockPaperScissors.cs b/mod/Jailbreak.LastRequest/LastRequests/RockPaperScissors.cs
index 1da7d88a..cee777ed 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/RockPaperScissors.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/RockPaperScissors.cs
@@ -6,116 +6,97 @@
namespace Jailbreak.LastRequest.LastRequests;
-public class RockPaperScissors : AbstractLastRequest
-{
- private ChatMenu _chatMenu;
- private int _prisonerChoice = -1, _guardChoice = -1;
-
- public RockPaperScissors(BasePlugin plugin, ILastRequestManager manager, CCSPlayerController prisoner,
- CCSPlayerController guard) : base(plugin, manager, prisoner, guard)
- {
- _chatMenu = new ChatMenu("Rock Paper Scissors");
- foreach (var option in new[] { "Rock", "Paper", "Scissors" })
- _chatMenu.AddMenuOption(option, OnSelect);
+public class RockPaperScissors : AbstractLastRequest {
+ private readonly ChatMenu chatMenu;
+ private int prisonerChoice = -1, guardChoice = -1;
+
+ public RockPaperScissors(BasePlugin plugin, ILastRequestManager manager,
+ CCSPlayerController prisoner, CCSPlayerController guard) : base(plugin,
+ manager, prisoner, guard) {
+ chatMenu = new ChatMenu("Rock Paper Scissors");
+ foreach (var option in new[] { "Rock", "Paper", "Scissors" })
+ chatMenu.AddMenuOption(option, OnSelect);
+ }
+
+ public override LRType Type => LRType.ROCK_PAPER_SCISSORS;
+
+ public override void Setup() {
+ chatMenu.Title =
+ $"Rock Paper Scissors - {Prisoner.PlayerName} vs {Guard.PlayerName}";
+ prisonerChoice = -1;
+ guardChoice = -1;
+ Plugin.AddTimer(3, Execute);
+ }
+
+ private void OnSelect(CCSPlayerController player, ChatMenuOption option) {
+ if (player.Slot != Prisoner.Slot && player.Slot != Guard.Slot) return;
+ MenuManager.CloseActiveMenu(player);
+
+ var choice = Array.IndexOf(new[] { "Rock", "Paper", "Scissors" },
+ option.Text);
+
+ if (player.Slot == Prisoner.Slot)
+ prisonerChoice = choice;
+ else
+ guardChoice = choice;
+
+ if (prisonerChoice == -1 || guardChoice == -1) {
+ PrintToParticipants(player.PlayerName + " has made their choice...");
+ return;
}
- public override void Setup()
- {
- _chatMenu.Title = $"Rock Paper Scissors - {prisoner.PlayerName} vs {guard.PlayerName}";
- _prisonerChoice = -1;
- _guardChoice = -1;
- plugin.AddTimer(3, Execute);
+ PrintToParticipants("Both players have made their choice!");
+ if (prisonerChoice == guardChoice) {
+ PrintToParticipants("It's a tie!");
+ Setup();
+ return;
}
- private void OnSelect(CCSPlayerController player, ChatMenuOption option)
- {
- if (player.Slot != prisoner.Slot && player.Slot != guard.Slot)
- return;
- MenuManager.CloseActiveMenu(player);
-
- int choice = Array.IndexOf(new[] { "Rock", "Paper", "Scissors" }, option.Text);
-
- if (player.Slot == prisoner.Slot)
- _prisonerChoice = choice;
- else
- _guardChoice = choice;
-
- if (_prisonerChoice == -1 || _guardChoice == -1)
- {
- PrintToParticipants(player.PlayerName + " has made their choice...");
- return;
- }
-
- PrintToParticipants("Both players have made their choice!");
- if (_prisonerChoice == _guardChoice)
- {
- PrintToParticipants("It's a tie!");
- Setup();
- return;
- }
-
- if (state != LRState.Active)
- return;
-
- if (_prisonerChoice == 0 && _guardChoice == 2 || _prisonerChoice == 1 && _guardChoice == 0 ||
- _prisonerChoice == 2 && _guardChoice == 1)
- manager.EndLastRequest(this, LRResult.PrisonerWin);
- else
- manager.EndLastRequest(this, LRResult.GuardWin);
- }
-
- public override LRType type => LRType.RockPaperScissors;
-
- public override void Execute()
- {
- state = LRState.Active;
- MenuManager.OpenChatMenu(prisoner, _chatMenu);
- MenuManager.OpenChatMenu(guard, _chatMenu);
-
- plugin.AddTimer(20, Timeout, TimerFlags.STOP_ON_MAPCHANGE);
- }
-
- private void Timeout()
- {
- if (state != LRState.Active)
- return;
- if (_prisonerChoice != -1)
- {
- manager.EndLastRequest(this, LRResult.PrisonerWin);
- }
- else if (_guardChoice != -1)
- {
- manager.EndLastRequest(this, LRResult.GuardWin);
- }
- else
- {
- manager.EndLastRequest(this, LRResult.TimedOut);
- }
- }
-
- public override void OnEnd(LRResult result)
- {
- state = LRState.Completed;
- if (result == LRResult.GuardWin)
- {
- prisoner.Pawn.Value!.CommitSuicide(false, true);
- }
- else if (result == LRResult.PrisonerWin)
- {
- guard.Pawn.Value!.CommitSuicide(false, true);
- }
-
- PrintToParticipants($"Prisoner chose {GetChoice(_prisonerChoice)}, Guard chose {GetChoice(_guardChoice)}");
- }
-
- private string GetChoice(int choice)
- {
- return choice switch
- {
- 0 => "Rock",
- 1 => "Paper",
- 2 => "Scissors",
- _ => "Unknown"
- };
- }
+ if (State != LRState.ACTIVE) return;
+
+ if (prisonerChoice == 0 && guardChoice == 2
+ || prisonerChoice == 1 && guardChoice == 0
+ || prisonerChoice == 2 && guardChoice == 1)
+ Manager.EndLastRequest(this, LRResult.PRISONER_WIN);
+ else
+ Manager.EndLastRequest(this, LRResult.GUARD_WIN);
+ }
+
+ public override void Execute() {
+ State = LRState.ACTIVE;
+ MenuManager.OpenChatMenu(Prisoner, chatMenu);
+ MenuManager.OpenChatMenu(Guard, chatMenu);
+
+ Plugin.AddTimer(20, timeout, TimerFlags.STOP_ON_MAPCHANGE);
+ }
+
+ private void timeout() {
+ if (State != LRState.ACTIVE) return;
+ if (prisonerChoice != -1)
+ Manager.EndLastRequest(this, LRResult.PRISONER_WIN);
+ else if (guardChoice != -1)
+ Manager.EndLastRequest(this, LRResult.GUARD_WIN);
+ else
+ Manager.EndLastRequest(this, LRResult.TIMED_OUT);
+ }
+
+ public override void OnEnd(LRResult result) {
+ State = LRState.COMPLETED;
+ if (result == LRResult.GUARD_WIN)
+ Prisoner.Pawn.Value!.CommitSuicide(false, true);
+ else if (result == LRResult.PRISONER_WIN)
+ Guard.Pawn.Value!.CommitSuicide(false, true);
+
+ PrintToParticipants(
+ $"Prisoner chose {getChoice(prisonerChoice)}, Guard chose {getChoice(guardChoice)}");
+ }
+
+ private string getChoice(int choice) {
+ return choice switch {
+ 0 => "Rock",
+ 1 => "Paper",
+ 2 => "Scissors",
+ _ => "Unknown"
+ };
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/ShotForShot.cs b/mod/Jailbreak.LastRequest/LastRequests/ShotForShot.cs
index dd2289ff..920f2fb0 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/ShotForShot.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/ShotForShot.cs
@@ -1,133 +1,115 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
-using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Timers;
-using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
namespace Jailbreak.LastRequest.LastRequests;
-public class ShotForShot(
- BasePlugin plugin,
- ILastRequestManager manager,
- CCSPlayerController prisoner,
- CCSPlayerController guard)
- : WeaponizedRequest(plugin, manager, prisoner, guard)
-{
- public override LRType type => LRType.ShotForShot;
- private CCSPlayerController whosShot;
-
- public override void Setup()
- {
- plugin.RegisterEventHandler(OnPlayerShoot);
- base.Setup();
-
- whosShot = new Random().Next(2) == 0 ? prisoner : guard;
- PrintToParticipants(whosShot.PlayerName + " will shoot first.");
- prisoner.GiveNamedItem("weapon_deagle");
- guard.GiveNamedItem("weapon_deagle");
-
- var weapon = FindWeapon(prisoner, "weapon_deagle");
- if (weapon != null)
- setAmmoAmount(weapon, 0, 0);
- weapon = FindWeapon(guard, "weapon_deagle");
- if (weapon != null)
- setAmmoAmount(weapon, 0, 0);
+public class ShotForShot(BasePlugin plugin, ILastRequestManager manager,
+ CCSPlayerController prisoner, CCSPlayerController guard)
+ : WeaponizedRequest(plugin, manager, prisoner, guard) {
+ private CCSPlayerController? whosShot;
+ public override LRType Type => LRType.SHOT_FOR_SHOT;
+
+ public override void Setup() {
+ Plugin.RegisterEventHandler(OnPlayerShoot);
+ base.Setup();
+
+ whosShot = new Random().Next(2) == 0 ? Prisoner : Guard;
+ PrintToParticipants(whosShot.PlayerName + " will shoot first.");
+ Prisoner.GiveNamedItem("weapon_deagle");
+ Guard.GiveNamedItem("weapon_deagle");
+
+ var weapon = findWeapon(Prisoner, "weapon_deagle");
+ if (weapon != null) setAmmoAmount(weapon, 0, 0);
+ weapon = findWeapon(Guard, "weapon_deagle");
+ if (weapon != null) setAmmoAmount(weapon, 0, 0);
+ }
+
+ private static CBasePlayerWeapon? findWeapon(CCSPlayerController player,
+ string name) {
+ if (!player.IsReal()) return null;
+
+ var pawn = player.PlayerPawn.Value;
+
+ if (pawn == null) return null;
+
+ var weapons = pawn.WeaponServices?.MyWeapons;
+
+ return weapons?.Select(weaponOpt => weaponOpt.Value)
+ .OfType()
+ .FirstOrDefault(weapon => weapon.DesignerName.Contains(name));
+ }
+
+ private static void setAmmoAmount(CBasePlayerWeapon weapon, int primary,
+ int reserve) {
+ weapon.Clip1 = primary;
+ Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_iClip1");
+ weapon.Clip2 = reserve;
+ Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_pReserveAmmo");
+ }
+
+ public override void Execute() {
+ State = LRState.ACTIVE;
+ if (whosShot == null) return;
+ var deagle = findWeapon(whosShot, "weapon_deagle");
+ if (deagle != null) setAmmoAmount(deagle, 1, 0);
+
+ Plugin.AddTimer(30, () => {
+ if (State != LRState.ACTIVE) return;
+ Prisoner.GiveNamedItem("weapon_knife");
+ Guard.GiveNamedItem("weapon_knife");
+ });
+ Plugin.AddTimer(60, () => {
+ if (State != LRState.ACTIVE) return;
+ PrintToParticipants("Time's Up!");
+ var result = Guard.Health > Prisoner.Health ?
+ LRResult.GUARD_WIN :
+ LRResult.PRISONER_WIN;
+ if (Guard.Health == Prisoner.Health) {
+ PrintToParticipants("Even health, since " + whosShot.PlayerName
+ + " had the shot last, they lose.");
+ result = whosShot.Slot == Prisoner.Slot ?
+ LRResult.GUARD_WIN :
+ LRResult.PRISONER_WIN;
+ } else { PrintToParticipants("Health was the deciding factor. "); }
+
+ if (result == LRResult.GUARD_WIN)
+ Prisoner.Pawn.Value?.CommitSuicide(false, true);
+ else
+ Guard.Pawn.Value?.CommitSuicide(false, true);
+ }, TimerFlags.STOP_ON_MAPCHANGE);
+ }
+
+ private HookResult OnPlayerShoot(EventPlayerShoot @event,
+ GameEventInfo info) {
+ if (State != LRState.ACTIVE) return HookResult.Continue;
+
+ var player = @event.Userid;
+ if (player == null || whosShot == null || !player.IsReal())
+ return HookResult.Continue;
+
+ if (player.Slot != Prisoner.Slot && player.Slot != Guard.Slot)
+ return HookResult.Continue;
+ if (player.Slot != whosShot.Slot) {
+ PrintToParticipants(player.PlayerName + " cheated.");
+ player.Pawn.Value?.CommitSuicide(false, true);
+ return HookResult.Handled;
}
- private static CBasePlayerWeapon? FindWeapon(CCSPlayerController player, String name)
- {
- if (!player.IsReal())
- return null;
-
- var pawn = player.PlayerPawn.Value;
-
- if (pawn == null)
- return null;
-
- var weapons = pawn.WeaponServices?.MyWeapons;
-
- return weapons?.Select(weaponOpt => weaponOpt.Value).OfType()
- .FirstOrDefault(weapon => weapon.DesignerName.Contains(name));
- }
-
- private static void setAmmoAmount(CBasePlayerWeapon weapon, int primary, int reserve)
- {
- weapon.Clip1 = primary;
- Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_iClip1");
- weapon.Clip2 = reserve;
- Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_pReserveAmmo");
- }
-
- public override void Execute()
- {
- state = LRState.Active;
- var deagle = FindWeapon(whosShot, "weapon_deagle");
- if (deagle != null)
- setAmmoAmount(deagle, 1, 0);
-
- plugin.AddTimer(30, () =>
- {
- if (state != LRState.Active)
- return;
- prisoner.GiveNamedItem("weapon_knife");
- guard.GiveNamedItem("weapon_knife");
- });
- plugin.AddTimer(60, () =>
- {
- if (state != LRState.Active) return;
- PrintToParticipants("Time's Up!");
- var result = guard.Health > prisoner.Health ? LRResult.GuardWin : LRResult.PrisonerWin;
- if (guard.Health == prisoner.Health)
- {
- PrintToParticipants("Even health, since " + whosShot.PlayerName + " had the shot last, they lose.");
- result = whosShot.Slot == prisoner.Slot ? LRResult.GuardWin : LRResult.PrisonerWin;
- }
- else
- {
- PrintToParticipants("Health was the deciding factor. ");
- }
-
- if (result == LRResult.GuardWin)
- prisoner.Pawn.Value?.CommitSuicide(false, true);
- else
- guard.Pawn.Value?.CommitSuicide(false, true);
- }, TimerFlags.STOP_ON_MAPCHANGE);
- }
-
- private HookResult OnPlayerShoot(EventPlayerShoot @event, GameEventInfo info)
- {
- if (state != LRState.Active)
- return HookResult.Continue;
-
- var player = @event.Userid;
- if (!player.IsReal())
- return HookResult.Continue;
-
- if (player.Slot != prisoner.Slot && player.Slot != guard.Slot)
- return HookResult.Continue;
- if (player.Slot != whosShot.Slot)
- {
- PrintToParticipants(player.PlayerName + " cheated.");
- player.Pawn.Value?.CommitSuicide(false, true);
- return HookResult.Handled;
- }
-
- PrintToParticipants(player.PlayerName + " has shot.");
- var opponent = player.Slot == prisoner.Slot ? guard : prisoner;
- opponent.PrintToChat("Your shot");
- var deagle = FindWeapon(opponent, "weapon_deagle");
- if (deagle != null)
- setAmmoAmount(deagle, 1, 0);
- whosShot = opponent;
- return HookResult.Continue;
- }
-
- public override void OnEnd(LRResult result)
- {
- plugin.RemoveListener("player_shoot", OnPlayerShoot);
- state = LRState.Completed;
- }
+ PrintToParticipants(player.PlayerName + " has shot.");
+ var opponent = player.Slot == Prisoner.Slot ? Guard : Prisoner;
+ opponent.PrintToChat("Your shot");
+ var deagle = findWeapon(opponent, "weapon_deagle");
+ if (deagle != null) setAmmoAmount(deagle, 1, 0);
+ whosShot = opponent;
+ return HookResult.Continue;
+ }
+
+ public override void OnEnd(LRResult result) {
+ Plugin.RemoveListener(OnPlayerShoot);
+ State = LRState.COMPLETED;
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/TeleportingRequest.cs b/mod/Jailbreak.LastRequest/LastRequests/TeleportingRequest.cs
index 3fd81221..c3ab7f1b 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/TeleportingRequest.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/TeleportingRequest.cs
@@ -5,24 +5,20 @@
namespace Jailbreak.LastRequest.LastRequests;
-public abstract class TeleportingRequest(
- BasePlugin plugin,
- ILastRequestManager manager,
- CCSPlayerController prisoner,
- CCSPlayerController guard) : AbstractLastRequest(plugin, manager, prisoner, guard)
-{
- public override void Setup()
- {
- state = LRState.Pending;
+public abstract class TeleportingRequest(BasePlugin plugin,
+ ILastRequestManager manager, CCSPlayerController prisoner,
+ CCSPlayerController guard)
+ : AbstractLastRequest(plugin, manager, prisoner, guard) {
+ public override void Setup() {
+ State = LRState.PENDING;
- guard.Teleport(prisoner);
+ Guard.Teleport(Prisoner);
- guard.Freeze();
- prisoner.Freeze();
- plugin.AddTimer(1, () =>
- {
- guard.UnFreeze();
- prisoner.UnFreeze();
- });
- }
+ Guard.Freeze();
+ Prisoner.Freeze();
+ Plugin.AddTimer(1, () => {
+ Guard.UnFreeze();
+ Prisoner.UnFreeze();
+ });
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.LastRequest/LastRequests/WeaponizedRequest.cs b/mod/Jailbreak.LastRequest/LastRequests/WeaponizedRequest.cs
index 4ceb2842..3dec811a 100644
--- a/mod/Jailbreak.LastRequest/LastRequests/WeaponizedRequest.cs
+++ b/mod/Jailbreak.LastRequest/LastRequests/WeaponizedRequest.cs
@@ -1,51 +1,41 @@
using CounterStrikeSharp.API.Core;
-using CounterStrikeSharp.API.Modules.Utils;
-using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
namespace Jailbreak.LastRequest.LastRequests;
///
-/// Represents a Last Request that involves direct PvP combat.
-///
-/// Automatically strips weapons, counts down, and calls Execute after 4 seconds.
+/// Represents a Last Request that involves direct PvP combat.
+/// Automatically strips weapons, counts down, and calls Execute after 4 seconds.
///
-public abstract class WeaponizedRequest(
- BasePlugin plugin,
- ILastRequestManager manager,
- CCSPlayerController prisoner,
- CCSPlayerController guard)
- : TeleportingRequest(plugin, manager, prisoner, guard)
-{
- public override void Setup()
- {
- base.Setup();
+public abstract class WeaponizedRequest(BasePlugin plugin,
+ ILastRequestManager manager, CCSPlayerController prisoner,
+ CCSPlayerController guard)
+ : TeleportingRequest(plugin, manager, prisoner, guard) {
+ public override void Setup() {
+ base.Setup();
- // Strip weapons, teleport T to CT
- prisoner.RemoveWeapons();
- guard.RemoveWeapons();
- for (var i = 3; i >= 1; i--)
- {
- var copy = i;
- plugin.AddTimer(3 - i, () => { PrintToParticipants($"{copy}..."); });
- }
-
- plugin.AddTimer(3, Execute);
+ // Strip weapons, teleport T to CT
+ Prisoner.RemoveWeapons();
+ Guard.RemoveWeapons();
+ for (var i = 3; i >= 1; i--) {
+ var copy = i;
+ Plugin.AddTimer(3 - i, () => { PrintToParticipants($"{copy}..."); });
}
- public override void OnEnd(LRResult result)
- {
- switch (result)
- {
- case LRResult.GuardWin:
- prisoner.Pawn.Value?.CommitSuicide(false, true);
- break;
- case LRResult.PrisonerWin:
- guard.Pawn.Value?.CommitSuicide(false, true);
- break;
- }
+ Plugin.AddTimer(3, Execute);
+ }
- state = LRState.Completed;
+ public override void OnEnd(LRResult result) {
+ switch (result) {
+ case LRResult.GUARD_WIN:
+ Prisoner.Pawn.Value?.CommitSuicide(false, true);
+ break;
+ case LRResult.PRISONER_WIN:
+ Guard.Pawn.Value?.CommitSuicide(false, true);
+ break;
}
+
+ State = LRState.COMPLETED;
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Logs/Jailbreak.Logs.csproj b/mod/Jailbreak.Logs/Jailbreak.Logs.csproj
index ff0d0386..8820ab28 100644
--- a/mod/Jailbreak.Logs/Jailbreak.Logs.csproj
+++ b/mod/Jailbreak.Logs/Jailbreak.Logs.csproj
@@ -7,11 +7,7 @@
-
-
-
-
-
-
+
+
diff --git a/mod/Jailbreak.Logs/Listeners/LogDamageListeners.cs b/mod/Jailbreak.Logs/Listeners/LogDamageListeners.cs
index e0f1b658..0db85d5a 100644
--- a/mod/Jailbreak.Logs/Listeners/LogDamageListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogDamageListeners.cs
@@ -1,70 +1,57 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
-
-using Jailbreak.Formatting.Views;
+using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
namespace Jailbreak.Logs.Listeners;
-public class LogDamageListeners : IPluginBehavior
-{
- private readonly IRichLogService _logs;
-
- public LogDamageListeners(IRichLogService logs)
- {
- _logs = logs;
- }
-
-
-
- [GameEventHandler]
- public HookResult OnGrenadeThrown(EventGrenadeThrown @event, GameEventInfo info)
- {
- var player = @event.Userid;
- if (!player.IsReal())
- return HookResult.Continue;
- var grenade = @event.Weapon;
-
- _logs.Append(_logs.Player(player), $"threw a {grenade}");
-
+public class LogDamageListeners : IPluginBehavior {
+ private readonly IRichLogService logs;
+
+ public LogDamageListeners(IRichLogService logs) { this.logs = logs; }
+
+ [GameEventHandler]
+ public HookResult OnGrenadeThrown(EventGrenadeThrown @event,
+ GameEventInfo info) {
+ var player = @event.Userid;
+ if (player == null || !player.IsReal()) return HookResult.Continue;
+ var grenade = @event.Weapon;
+
+ logs.Append(logs.Player(player), $"threw a {grenade}");
+
+ return HookResult.Continue;
+ }
+
+ [GameEventHandler]
+ public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info) {
+ var player = @event.Userid;
+ if (player == null || !player.IsReal()) return HookResult.Continue;
+ var attacker = @event.Attacker;
+
+ var isWorld = attacker == null || !attacker.IsReal();
+ var health = @event.DmgHealth;
+
+ if (isWorld) {
+ if (health > 0)
+ logs.Append("The world hurt", logs.Player(player),
+ $"for {health} damage");
+ else
+ logs.Append("The world killed", logs.Player(player));
+ } else {
+ if (attacker == null) {
+ logs.Append(logs.Player(player), "was hurt by an unknown source",
+ $"for {health} damage");
return HookResult.Continue;
- }
-
- [GameEventHandler]
- public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)
- {
- var player = @event.Userid;
- if (!player.IsReal())
- return HookResult.Continue;
- var attacker = @event.Attacker;
-
- bool isWorld = attacker == null || !attacker.IsReal();
- int health = @event.DmgHealth;
+ }
- if (isWorld)
- {
- if (health > 0)
- {
- _logs.Append($"The world hurt", _logs.Player(player), $"for {health} damage");
- }
- else
- {
- _logs.Append("The world killed", _logs.Player(player));
- }
- }
- else
- {
- if (health > 0)
- {
- _logs.Append( _logs.Player(attacker), "hurt", _logs.Player(player), $"for {health} damage");
- }
- else
- {
- _logs.Append(_logs.Player(attacker!), "killed", _logs.Player(player));
- }
- }
-
- return HookResult.Continue;
+ if (health > 0)
+ logs.Append(logs.Player(attacker), "hurt", logs.Player(player),
+ $"for {health} damage");
+ else
+ logs.Append(logs.Player(attacker), "killed", logs.Player(player));
}
-}
+
+ return HookResult.Continue;
+ }
+}
\ No newline at end of file
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityListeners.cs
index 10cc2a80..f4dd4bc4 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityListeners.cs
@@ -1,49 +1,38 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
-using CounterStrikeSharp.API.Modules.Memory;
-using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
-using CounterStrikeSharp.API.Modules.Utils;
-using Jailbreak.Formatting.Views;
+using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
namespace Jailbreak.Logs.Listeners;
-public class LogEntityListeners : IPluginBehavior
-{
- private readonly IRichLogService _logs;
-
- public LogEntityListeners(IRichLogService logs)
- {
- _logs = logs;
- }
-
- [EntityOutputHook("func_button", "OnPressed")]
- public HookResult OnButtonPressed(CEntityIOOutput output, string name, CEntityInstance activator,
- CEntityInstance caller, CVariant value, float delay)
- {
- if (!activator.TryGetController(out var player))
- return HookResult.Continue;
-
- CBaseEntity? ent = Utilities.GetEntityFromIndex((int)caller.Index);
-
-
- _logs.Append(_logs.Player(player), $"pressed a button: {ent.Entity?.Name ?? "Unlabeled"} -> {output?.Connections?.TargetDesc ?? "None"}");
- return HookResult.Continue;
- }
-
- [EntityOutputHook("func_breakable", "OnBreak")]
- public HookResult OnBreakableBroken(CEntityIOOutput output, string name, CEntityInstance activator,
- CEntityInstance caller, CVariant value, float delay)
- {
- if (!activator.TryGetController(out var player))
- return HookResult.Continue;
-
- CBaseEntity? ent = Utilities.GetEntityFromIndex((int)caller.Index);
-
-
- _logs.Append(_logs.Player(player), $"broke an entity: {ent.Entity?.Name ?? "Unlabeled"} -> {output?.Connections?.TargetDesc ?? "None"}");
- return HookResult.Continue;
- }
-}
+public class LogEntityListeners(IRichLogService logs) : IPluginBehavior {
+ [EntityOutputHook("func_button", "OnPressed")]
+ public HookResult OnButtonPressed(CEntityIOOutput output, string name,
+ CEntityInstance activator, CEntityInstance caller, CVariant value,
+ float delay) {
+ if (!activator.TryGetController(out var player)) return HookResult.Continue;
+ if (player == null || !player.IsReal()) return HookResult.Continue;
+
+ var ent = Utilities.GetEntityFromIndex((int)caller.Index);
+
+ logs.Append(logs.Player(player),
+ $"pressed a button: {ent?.Entity?.Name ?? "Unlabeled"} -> {output?.Connections?.TargetDesc ?? "None"}");
+ return HookResult.Continue;
+ }
+
+ [EntityOutputHook("func_breakable", "OnBreak")]
+ public HookResult OnBreakableBroken(CEntityIOOutput output, string name,
+ CEntityInstance activator, CEntityInstance caller, CVariant value,
+ float delay) {
+ if (!activator.TryGetController(out var player)) return HookResult.Continue;
+ if (player == null || !player.IsReal()) return HookResult.Continue;
+
+ var ent = Utilities.GetEntityFromIndex((int)caller.Index);
+
+ logs.Append(logs.Player(player),
+ $"broke an entity: {ent?.Entity?.Name ?? "Unlabeled"} -> {output?.Connections?.TargetDesc ?? "None"}");
+ return HookResult.Continue;
+ }
+}
\ No newline at end of file
diff --git a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
index 07e8e029..875e6fc4 100644
--- a/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
+++ b/mod/Jailbreak.Logs/Listeners/LogEntityParentListeners.cs
@@ -1,14 +1,12 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
-using Jailbreak.Formatting.Views;
+using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
namespace Jailbreak.Logs.Listeners;
public class LogEntityParentListeners(IRichLogService logs) : IPluginBehavior {
- private BasePlugin parent = null!;
-
private static readonly string[] WEAPON_STRINGS = [
"weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_cz75a",
"weapon_deagle", "weapon_famas", "weapon_fiveseven", "weapon_g3sg1",
@@ -22,8 +20,6 @@ public class LogEntityParentListeners(IRichLogService logs) : IPluginBehavior {
];
public void Start(BasePlugin _parent) {
- parent = _parent;
-
_parent
.RegisterListener<
CounterStrikeSharp.API.Core.Listeners.OnEntityParentChanged>(
diff --git a/mod/Jailbreak.Logs/LogsCommand.cs b/mod/Jailbreak.Logs/LogsCommand.cs
index 2c3fc698..6adb6807 100644
--- a/mod/Jailbreak.Logs/LogsCommand.cs
+++ b/mod/Jailbreak.Logs/LogsCommand.cs
@@ -7,12 +7,10 @@
namespace Jailbreak.Logs;
-public class LogsCommand(ILogService logs) : IPluginBehavior
-{
- [ConsoleCommand("css_logs")]
- [RequiresPermissionsOr("@css/ban", "@css/generic", "@css/kick")]
- public void Command_Logs(CCSPlayerController? executor, CommandInfo info)
- {
- logs.PrintLogs(executor);
- }
+public class LogsCommand(ILogService logs) : IPluginBehavior {
+ [ConsoleCommand("css_logs")]
+ [RequiresPermissionsOr("@css/ban", "@css/generic", "@css/kick")]
+ public void Command_Logs(CCSPlayerController? executor, CommandInfo info) {
+ logs.PrintLogs(executor);
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Logs/LogsManager.cs b/mod/Jailbreak.Logs/LogsManager.cs
index 253f52f4..8676dcd7 100644
--- a/mod/Jailbreak.Logs/LogsManager.cs
+++ b/mod/Jailbreak.Logs/LogsManager.cs
@@ -1,111 +1,79 @@
-using CounterStrikeSharp.API;
-using CounterStrikeSharp.API.Core;
+using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
-using CounterStrikeSharp.API.Modules.Utils;
-
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Core;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Objects;
using Jailbreak.Formatting.Views;
+using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
-using Jailbreak.Public.Mod.Logs;
-using Jailbreak.Public.Mod.Rebel;
-using Jailbreak.Public.Mod.Warden;
-using Microsoft.Extensions.DependencyInjection;
namespace Jailbreak.Logs;
-public class LogsManager : IPluginBehavior, ILogService, IRichLogService
-{
- private readonly List _logMessages = new();
+public class LogsManager : IPluginBehavior, IRichLogService {
+ private readonly List logMessages = [];
+ private readonly ILogMessages messages;
- private IRichPlayerTag _richPlayerTag;
- private ILogMessages _messages;
+ private readonly IRichPlayerTag richPlayerTag;
- public LogsManager(IServiceProvider serviceProvider, ILogMessages messages, IRichPlayerTag richPlayerTag)
- {
- _messages = messages;
- _richPlayerTag = richPlayerTag;
- }
+ public LogsManager(ILogMessages messages, IRichPlayerTag richPlayerTag) {
+ this.messages = messages;
+ this.richPlayerTag = richPlayerTag;
+ }
- [GameEventHandler]
- public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
- {
- _messages.BEGIN_JAILBREAK_LOGS
- .ToServerConsole()
- .ToAllConsole();
+ public void Append(string message) {
+ logMessages.Add(messages.CREATE_LOG(message));
+ }
- // By default, print all logs to player consoles at the end of the round.
- foreach (var log in _logMessages)
- log.ToServerConsole()
- .ToAllConsole();
+ public IEnumerable GetMessages() {
+ return logMessages.SelectMany(view => view.ToWriter().Plain);
+ }
- _messages.END_JAILBREAK_LOGS
- .ToServerConsole()
- .ToAllConsole();
+ public void Clear() { logMessages.Clear(); }
- return HookResult.Continue;
- }
+ public void PrintLogs(CCSPlayerController? player) {
+ if (player == null || !player.IsReal()) {
+ messages.BeginJailbreakLogs.ToServerConsole();
+ foreach (var log in logMessages) log.ToServerConsole();
+ messages.EndJailbreakLogs.ToServerConsole();
- [GameEventHandler]
- public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
- {
- Clear();
- return HookResult.Continue;
+ return;
}
- public void Append(params FormatObject[] objects)
- {
- _logMessages.Add(_messages.CREATE_LOG(objects));
- }
- public FormatObject Player(CCSPlayerController playerController)
- {
- return new TreeFormatObject()
- {
- playerController,
- $"[{playerController.UserId}]",
- _richPlayerTag.Rich(playerController)
- };
- }
+ messages.BeginJailbreakLogs.ToPlayerConsole(player);
+ foreach (var log in logMessages) log.ToPlayerConsole(player);
+ messages.EndJailbreakLogs.ToPlayerConsole(player);
+ }
- public void Append(string message)
- {
- _logMessages.Add(_messages.CREATE_LOG(message));
- }
+ public void Append(params FormatObject[] objects) {
+ logMessages.Add(messages.CREATE_LOG(objects));
+ }
- public IEnumerable GetMessages()
- {
- return _logMessages.SelectMany(view => view.ToWriter().Plain);
- }
+ public FormatObject Player(CCSPlayerController playerController) {
+ return new TreeFormatObject {
+ playerController,
+ $"[{playerController.UserId}]",
+ richPlayerTag.Rich(playerController)
+ };
+ }
- public void Clear()
- {
- _logMessages.Clear();
- }
+ [GameEventHandler]
+ public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info) {
+ messages.BeginJailbreakLogs.ToServerConsole().ToAllConsole();
- public void PrintLogs(CCSPlayerController? player)
- {
- if (player == null || !player.IsReal())
- {
- _messages.BEGIN_JAILBREAK_LOGS
- .ToServerConsole();
- foreach (var log in _logMessages)
- log.ToServerConsole();
- _messages.END_JAILBREAK_LOGS
- .ToServerConsole();
-
- return;
- }
-
-
- _messages.BEGIN_JAILBREAK_LOGS
- .ToPlayerConsole(player);
- foreach (var log in _logMessages)
- log.ToPlayerConsole(player);
- _messages.END_JAILBREAK_LOGS
- .ToPlayerConsole(player);
- }
-}
+ // By default, print all logs to player consoles at the end of the round.
+ foreach (var log in logMessages) log.ToServerConsole().ToAllConsole();
+
+ messages.EndJailbreakLogs.ToServerConsole().ToAllConsole();
+
+ return HookResult.Continue;
+ }
+
+ [GameEventHandler]
+ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) {
+ Clear();
+ return HookResult.Continue;
+ }
+}
\ No newline at end of file
diff --git a/mod/Jailbreak.Logs/LogsServiceExtension.cs b/mod/Jailbreak.Logs/LogsServiceExtension.cs
index 8aece7b5..caa470ef 100644
--- a/mod/Jailbreak.Logs/LogsServiceExtension.cs
+++ b/mod/Jailbreak.Logs/LogsServiceExtension.cs
@@ -1,4 +1,4 @@
-using Jailbreak.Formatting.Views;
+using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Logs.Listeners;
using Jailbreak.Logs.Tags;
using Jailbreak.Public.Extensions;
@@ -7,21 +7,21 @@
namespace Jailbreak.Logs;
-public static class LogsServiceExtension
-{
- public static void AddJailbreakLogs(this IServiceCollection services)
- {
- services.AddPluginBehavior();
- services.AddTransient(provider => provider.GetRequiredService());
+public static class LogsServiceExtension {
+ public static void AddJailbreakLogs(this IServiceCollection services) {
+ services.AddPluginBehavior();
+ services.AddTransient(provider
+ => provider.GetRequiredService());
+
+ services.AddPluginBehavior();
- services.AddPluginBehavior();
services.AddPluginBehavior();
services.AddPluginBehavior();
- services.AddPluginBehavior();
+ services.AddPluginBehavior();
- // PlayerTagHelper is a lower-level class that avoids dependency loops.
- services.AddTransient();
+ // PlayerTagHelper is a lower-level class that avoids dependency loops.
+ services.AddTransient();
services.AddTransient();
}
-}
+}
\ No newline at end of file
diff --git a/mod/Jailbreak.Logs/Tags/PlayerTagHelper.cs b/mod/Jailbreak.Logs/Tags/PlayerTagHelper.cs
index ff43c536..ac29d73d 100644
--- a/mod/Jailbreak.Logs/Tags/PlayerTagHelper.cs
+++ b/mod/Jailbreak.Logs/Tags/PlayerTagHelper.cs
@@ -1,49 +1,45 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
-
using Jailbreak.Formatting.Core;
using Jailbreak.Formatting.Objects;
-using Jailbreak.Formatting.Views;
-using Jailbreak.Public.Behaviors;
+using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Public.Extensions;
-using Jailbreak.Public.Mod.Logs;
using Jailbreak.Public.Mod.Rebel;
using Jailbreak.Public.Mod.Warden;
-
using Microsoft.Extensions.DependencyInjection;
namespace Jailbreak.Logs.Tags;
-public class PlayerTagHelper : IRichPlayerTag, IPlayerTag
-{
- private Lazy _wardenService;
- private Lazy _rebelService;
- private Lazy _specialTreatmentService;
-
- public PlayerTagHelper(IServiceProvider provider)
- {
- // Lazy-load dependencies to avoid loops, since we are a lower-level class.
- _wardenService = new ( () => provider.GetRequiredService() );
- _rebelService = new ( () => provider.GetRequiredService() );
- _specialTreatmentService = new ( () => provider.GetRequiredService() );
- }
-
- public FormatObject Rich(CCSPlayerController player)
- {
- if (_wardenService.Value.IsWarden(player))
- return new StringFormatObject("(WARDEN)", ChatColors.DarkBlue);
- if (player.GetTeam() == CsTeam.CounterTerrorist)
- return new StringFormatObject("(CT)", ChatColors.BlueGrey);
- if (_rebelService.Value.IsRebel(player))
- return new StringFormatObject("(REBEL)", ChatColors.DarkRed);
- if (_specialTreatmentService.Value.IsSpecialTreatment(player))
- return new StringFormatObject("(ST)", ChatColors.Green);
-
- return new StringFormatObject("(T)", ChatColors.Yellow);
- }
-
- public string Plain(CCSPlayerController playerController)
- {
- return Rich(playerController).ToPlain();
- }
-}
+public class PlayerTagHelper : IRichPlayerTag {
+ private readonly Lazy rebelService;
+ private readonly Lazy stService;
+ private readonly Lazy wardenService;
+
+ public PlayerTagHelper(IServiceProvider provider) {
+ // Lazy-load dependencies to avoid loops, since we are a lower-level class.
+ wardenService =
+ new Lazy(provider.GetRequiredService);
+ rebelService =
+ new Lazy(provider.GetRequiredService);
+ stService =
+ new Lazy(provider
+ .GetRequiredService);
+ }
+
+ public FormatObject Rich(CCSPlayerController player) {
+ if (wardenService.Value.IsWarden(player))
+ return new StringFormatObject("(WARDEN)", ChatColors.DarkBlue);
+ if (player.GetTeam() == CsTeam.CounterTerrorist)
+ return new StringFormatObject("(CT)", ChatColors.BlueGrey);
+ if (rebelService.Value.IsRebel(player))
+ return new StringFormatObject("(REBEL)", ChatColors.DarkRed);
+ if (stService.Value.IsSpecialTreatment(player))
+ return new StringFormatObject("(ST)", ChatColors.Green);
+
+ return new StringFormatObject("(T)", ChatColors.Yellow);
+ }
+
+ public string Plain(CCSPlayerController playerController) {
+ return Rich(playerController).ToPlain();
+ }
+}
\ No newline at end of file
diff --git a/mod/Jailbreak.Mute/Jailbreak.Mute.csproj b/mod/Jailbreak.Mute/Jailbreak.Mute.csproj
index 70f814b3..f430fd60 100644
--- a/mod/Jailbreak.Mute/Jailbreak.Mute.csproj
+++ b/mod/Jailbreak.Mute/Jailbreak.Mute.csproj
@@ -7,12 +7,8 @@
-
-
-
-
-
-
+
+
diff --git a/mod/Jailbreak.Mute/MuteServiceExtension.cs b/mod/Jailbreak.Mute/MuteServiceExtension.cs
index 1280fcb2..ac310316 100644
--- a/mod/Jailbreak.Mute/MuteServiceExtension.cs
+++ b/mod/Jailbreak.Mute/MuteServiceExtension.cs
@@ -4,10 +4,8 @@
namespace Jailbreak.Mute;
-public static class MuteServiceExtension
-{
- public static void AddJailbreakMute(this IServiceCollection services)
- {
- services.AddPluginBehavior();
- }
+public static class MuteServiceExtension {
+ public static void AddJailbreakMute(this IServiceCollection services) {
+ services.AddPluginBehavior();
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Mute/MuteSystem.cs b/mod/Jailbreak.Mute/MuteSystem.cs
index 9df2d49f..7c89be7f 100644
--- a/mod/Jailbreak.Mute/MuteSystem.cs
+++ b/mod/Jailbreak.Mute/MuteSystem.cs
@@ -14,204 +14,175 @@
namespace Jailbreak.Mute;
-public class MuteSystem(IServiceProvider provider) : IPluginBehavior, IMuteService
-{
- private BasePlugin parent;
- private DateTime lastPeace = DateTime.MinValue;
- private DateTime peaceEnd = DateTime.MinValue;
- private DateTime ctPeaceEnd = DateTime.MinValue;
-
- private IPeaceMessages messages;
- private IWardenService warden;
-
- private Timer? prisonerTimer, guardTimer;
-
- public void Start(BasePlugin parent)
- {
- this.parent = parent;
-
- messages = provider.GetRequiredService();
- warden = provider.GetRequiredService();
-
- parent.RegisterListener(OnPlayerSpeak);
- }
-
- [GameEventHandler]
- public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
- {
- UnPeaceMute();
- return HookResult.Continue;
- }
-
- [GameEventHandler]
- public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info)
- {
- UnPeaceMute();
- return HookResult.Continue;
- }
-
- public void Dispose()
- {
- parent.RemoveListener(OnPlayerSpeak);
- }
-
- public void PeaceMute(MuteReason reason)
- {
- var duration = GetPeaceDuration(reason);
- var ctDuration = Math.Min(10, duration);
- foreach (var player in Utilities.GetPlayers().Where(player => player.IsReal()))
- if (!warden.IsWarden(player))
- mute(player);
-
- switch (reason)
- {
- case MuteReason.ADMIN:
- messages.PEACE_ENACTED_BY_ADMIN(duration).ToAllChat();
- break;
- case MuteReason.WARDEN_TAKEN:
- messages.GENERAL_PEACE_ENACTED(duration).ToAllChat();
- break;
- case MuteReason.WARDEN_INVOKED:
- messages.WARDEN_ENACTED_PEACE(duration).ToAllChat();
- break;
- case MuteReason.INITIAL_WARDEN:
- messages.GENERAL_PEACE_ENACTED(duration).ToAllChat();
- break;
- }
-
- peaceEnd = DateTime.Now.AddSeconds(duration);
- ctPeaceEnd = DateTime.Now.AddSeconds(ctDuration);
- lastPeace = DateTime.Now;
-
- guardTimer?.Kill();
- prisonerTimer?.Kill();
-
- guardTimer = parent.AddTimer(ctDuration, unmuteGuards);
- prisonerTimer = parent.AddTimer(duration, unmutePrisoners);
- }
-
- private void unmuteGuards()
- {
- foreach (var player in Utilities.GetPlayers()
- .Where(player =>
- player.IsReal() && player is { Team: CsTeam.CounterTerrorist, PawnIsAlive: true }))
- unmute(player);
-
- messages.UNMUTED_GUARDS.ToAllChat();
- guardTimer = null;
- }
-
- private void unmutePrisoners()
- {
- foreach (var player in Utilities.GetPlayers()
- .Where(player =>
- player.IsReal() && player is { Team: CsTeam.Terrorist, PawnIsAlive: true }))
- unmute(player);
-
- messages.UNMUTED_PRISONERS.ToAllChat();
- prisonerTimer = null;
- }
-
- public void UnPeaceMute()
- {
- if (guardTimer != null)
- unmuteGuards();
-
- if (prisonerTimer != null)
- unmutePrisoners();
- }
-
- private int GetPeaceDuration(MuteReason reason)
- {
- var prisoners = Utilities.GetPlayers()
- .Count(c => c.IsReal() && c is { Team: CsTeam.Terrorist, PawnIsAlive: true });
- // https://www.desmos.com/calculator/gwd9cqw4yq
- var baseTime = (int)Math.Floor((prisoners + 30) / 5.0) * 5;
-
- return reason switch
- {
- MuteReason.ADMIN => baseTime,
- MuteReason.WARDEN_TAKEN => baseTime / 5,
- MuteReason.INITIAL_WARDEN => 2 * baseTime / 3,
- MuteReason.WARDEN_INVOKED => baseTime / 2,
- _ => baseTime
- };
- }
-
- private void mute(CCSPlayerController player)
- {
- if (bypassMute(player))
- return;
- player.VoiceFlags |= VoiceFlags.Muted;
- }
-
- private void unmute(CCSPlayerController player)
- {
- player.VoiceFlags &= ~VoiceFlags.Muted;
- }
-
- public bool IsPeaceEnabled()
- {
- return DateTime.Now < peaceEnd;
- }
-
- public DateTime GetLastPeace()
- {
- return lastPeace;
- }
-
- private void OnPlayerSpeak(int playerSlot)
- {
- var player = Utilities.GetPlayerFromSlot(playerSlot);
- if (player == null || !player.IsReal())
- return;
-
- if (warden.IsWarden(player))
- {
- // Always let the warden speak
- unmute(player);
- return;
- }
-
- if (!player.PawnIsAlive && !bypassMute(player))
- {
- // Normal players can't speak when dead
- messages.DEAD_REMINDER.ToPlayerCenter(player);
- mute(player);
- return;
- }
-
- if (isMuted(player))
- {
- // Remind any muted players they're muted
- messages.MUTE_REMINDER.ToPlayerCenter(player);
- return;
- }
-
- if (bypassMute(player))
- {
- // Warn admins if they're not muted
- if (IsPeaceEnabled())
- {
- if (player.Team == CsTeam.CounterTerrorist && DateTime.Now >= ctPeaceEnd)
- return;
- messages.PEACE_REMINDER.ToPlayerCenter(player);
- }
-
- if (!player.PawnIsAlive)
- messages.ADMIN_DEAD_REMINDER.ToPlayerCenter(player);
- }
- }
-
- private bool isMuted(CCSPlayerController player)
- {
- if (!player.IsReal())
- return false;
- return (player.VoiceFlags & VoiceFlags.Muted) != 0;
- }
-
- private bool bypassMute(CCSPlayerController player)
- {
- return player.IsReal() && AdminManager.PlayerHasPermissions(player, "@css/chat");
+public class MuteSystem(IServiceProvider provider)
+ : IPluginBehavior, IMuteService {
+ private DateTime ctPeaceEnd = DateTime.MinValue;
+ private DateTime lastPeace = DateTime.MinValue;
+
+ private IPeaceMessages? messages;
+ private BasePlugin? parent;
+ private DateTime peaceEnd = DateTime.MinValue;
+
+ private Timer? prisonerTimer, guardTimer;
+ private IWardenService? warden;
+
+ public void PeaceMute(MuteReason reason) {
+ var duration = getPeaceDuration(reason);
+ var ctDuration = Math.Min(10, duration);
+ foreach (var player in Utilities.GetPlayers()
+ .Where(player => player.IsReal()))
+ if (!warden!.IsWarden(player))
+ mute(player);
+
+ switch (reason) {
+ case MuteReason.ADMIN:
+ messages!.PeaceEnactedByAdmin(duration).ToAllChat();
+ break;
+ case MuteReason.WARDEN_TAKEN:
+ messages!.GeneralPeaceEnacted(duration).ToAllChat();
+ break;
+ case MuteReason.WARDEN_INVOKED:
+ messages!.WardenEnactedPeace(duration).ToAllChat();
+ break;
+ case MuteReason.INITIAL_WARDEN:
+ messages!.GeneralPeaceEnacted(duration).ToAllChat();
+ break;
+ }
+
+ peaceEnd = DateTime.Now.AddSeconds(duration);
+ ctPeaceEnd = DateTime.Now.AddSeconds(ctDuration);
+ lastPeace = DateTime.Now;
+
+ guardTimer?.Kill();
+ prisonerTimer?.Kill();
+
+ guardTimer = parent!.AddTimer(ctDuration, unmuteGuards);
+ prisonerTimer = parent!.AddTimer(duration, unmutePrisoners);
+ }
+
+ public void UnPeaceMute() {
+ if (guardTimer != null) unmuteGuards();
+
+ if (prisonerTimer != null) unmutePrisoners();
+ }
+
+ public bool IsPeaceEnabled() { return DateTime.Now < peaceEnd; }
+
+ public DateTime GetLastPeace() { return lastPeace; }
+
+ public void Start(BasePlugin basePlugin) {
+ parent = basePlugin;
+
+ messages = provider.GetRequiredService();
+ warden = provider.GetRequiredService();
+
+ basePlugin.RegisterListener(OnPlayerSpeak);
+ }
+
+ public void Dispose() { parent!.RemoveListener(OnPlayerSpeak); }
+
+ [GameEventHandler]
+ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) {
+ UnPeaceMute();
+ return HookResult.Continue;
+ }
+
+ [GameEventHandler]
+ public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info) {
+ UnPeaceMute();
+ return HookResult.Continue;
+ }
+
+ private void unmuteGuards() {
+ foreach (var player in Utilities.GetPlayers()
+ .Where(player => player.IsReal() && player is {
+ Team: CsTeam.CounterTerrorist, PawnIsAlive: true
+ }))
+ unmute(player);
+
+ messages!.UnmutedGuards.ToAllChat();
+ guardTimer = null;
+ }
+
+ private void unmutePrisoners() {
+ foreach (var player in Utilities.GetPlayers()
+ .Where(player => player.IsReal()
+ && player is { Team: CsTeam.Terrorist, PawnIsAlive: true }))
+ unmute(player);
+
+ messages!.UnmutedPrisoners.ToAllChat();
+ prisonerTimer = null;
+ }
+
+ private int getPeaceDuration(MuteReason reason) {
+ var prisoners = Utilities.GetPlayers()
+ .Count(c
+ => c.IsReal() && c is { Team: CsTeam.Terrorist, PawnIsAlive: true });
+ // https://www.desmos.com/calculator/gwd9cqw4yq
+ var baseTime = (int)Math.Floor((prisoners + 30) / 5.0) * 5;
+
+ return reason switch {
+ MuteReason.ADMIN => baseTime,
+ MuteReason.WARDEN_TAKEN => baseTime / 5,
+ MuteReason.INITIAL_WARDEN => 2 * baseTime / 3,
+ MuteReason.WARDEN_INVOKED => baseTime / 2,
+ _ => baseTime
+ };
+ }
+
+ private void mute(CCSPlayerController player) {
+ if (bypassMute(player)) return;
+ player.VoiceFlags |= VoiceFlags.Muted;
+ }
+
+ private void unmute(CCSPlayerController player) {
+ player.VoiceFlags &= ~VoiceFlags.Muted;
+ }
+
+ private void OnPlayerSpeak(int playerSlot) {
+ var player = Utilities.GetPlayerFromSlot(playerSlot);
+ if (player == null || !player.IsReal()) return;
+
+ if (warden!.IsWarden(player)) {
+ // Always let the warden speak
+ unmute(player);
+ return;
}
+
+ if (!player.PawnIsAlive && !bypassMute(player)) {
+ // Normal players can't speak when dead
+ messages!.DeadReminder.ToPlayerCenter(player);
+ mute(player);
+ return;
+ }
+
+ if (isMuted(player)) {
+ // Remind any muted players they're muted
+ messages!.MuteReminder.ToPlayerCenter(player);
+ return;
+ }
+
+ if (bypassMute(player)) {
+ // Warn admins if they're not muted
+ if (IsPeaceEnabled()) {
+ if (player.Team == CsTeam.CounterTerrorist
+ && DateTime.Now >= ctPeaceEnd)
+ return;
+ messages!.PeaceReminder.ToPlayerCenter(player);
+ }
+
+ if (!player.PawnIsAlive)
+ messages!.AdminDeadReminder.ToPlayerCenter(player);
+ }
+ }
+
+ private bool isMuted(CCSPlayerController player) {
+ if (!player.IsReal()) return false;
+ return (player.VoiceFlags & VoiceFlags.Muted) != 0;
+ }
+
+ private bool bypassMute(CCSPlayerController player) {
+ return player.IsReal()
+ && AdminManager.PlayerHasPermissions(player, "@css/chat");
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Rebel/Jailbreak.Rebel.csproj b/mod/Jailbreak.Rebel/Jailbreak.Rebel.csproj
index cf2402c3..f430fd60 100644
--- a/mod/Jailbreak.Rebel/Jailbreak.Rebel.csproj
+++ b/mod/Jailbreak.Rebel/Jailbreak.Rebel.csproj
@@ -7,12 +7,8 @@
-
-
-
-
-
-
+
+
diff --git a/mod/Jailbreak.Rebel/JihadC4/JihadC4Behavior.cs b/mod/Jailbreak.Rebel/JihadC4/JihadC4Behavior.cs
index bdf26f8d..f6677764 100644
--- a/mod/Jailbreak.Rebel/JihadC4/JihadC4Behavior.cs
+++ b/mod/Jailbreak.Rebel/JihadC4/JihadC4Behavior.cs
@@ -8,205 +8,170 @@
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.Rebel;
-using Microsoft.Extensions.Logging;
namespace Jailbreak.Rebel.JihadC4;
-public class JihadC4Behavior(IJihadC4Notifications jihadC4Notifications, IRebelService rebelService) : IPluginBehavior, IJihadC4Service
-{
- private class JihadBombMetadata(float delay, bool isDetonating)
- {
- public float Delay { get; set; } = delay;
- public bool IsDetonating { get; set; } = isDetonating;
+public class JihadC4Behavior(IJihadC4Notifications jihadC4Notifications,
+ IRebelService rebelService) : IPluginBehavior, IJihadC4Service {
+ private readonly Dictionary bombs = new();
+
+ // EmitSound(CBaseEntity* pEnt, const char* sSoundName, int nPitch, float flVolume, float flDelay)
+ private readonly MemoryFunctionVoid
+ // ReSharper disable once InconsistentNaming
+ CBaseEntity_EmitSoundParamsLinux = new(
+ "48 B8 ? ? ? ? ? ? ? ? 55 48 89 E5 41 55 41 54 49 89 FC 53 48 89 F3"); // LINUX ONLY.
+
+ private BasePlugin? plugin;
+
+ public void ClearActiveC4s() { bombs.Clear(); }
+
+ public void TryGiveC4ToPlayer(CCSPlayerController player) {
+ var bombEntity = new CC4(player.GiveNamedItem("weapon_c4"));
+ bombs.Add(bombEntity, new JihadBombMetadata(0.75f, false));
+
+ jihadC4Notifications.JihadC4Received.ToPlayerChat(player);
+ jihadC4Notifications.JihadC4Usage1.ToPlayerChat(player);
+ }
+
+ public void StartDetonationAttempt(CCSPlayerController player, float delay,
+ CC4 bombEntity) {
+ if (plugin == null) return;
+
+ tryEmitSound(player, "jb.jihad", 1, 1f, 0f);
+
+ bombs[bombEntity].Delay = delay;
+ bombs[bombEntity].IsDetonating = true;
+
+ rebelService.MarkRebel(player);
+
+ Server.RunOnTick(Server.TickCount + (int)(64 * delay),
+ () => detonate(player, bombEntity));
+ }
+
+ public void TryGiveC4ToRandomTerrorist() {
+ plugin!.AddTimer(1, () => {
+ var validTerroristPlayers = Utilities.GetPlayers()
+ .Where(player => player.IsReal() && player is {
+ Team : CsTeam.Terrorist,
+ PawnIsAlive: true,
+ IsBot : false,
+ IsValid : true
+ })
+ .ToList();
+ var numOfTerrorists = validTerroristPlayers.Count;
+ if (numOfTerrorists == 0) return;
+
+ Random rnd = new();
+ var randomIndex = rnd.Next(numOfTerrorists);
+ TryGiveC4ToPlayer(validTerroristPlayers[randomIndex]);
+ });
+ }
+
+ public void Start(BasePlugin basePlugin) {
+ plugin = basePlugin;
+ plugin.RegisterListener(playerUseC4ListenerCallback);
+ }
+
+ private void playerUseC4ListenerCallback() {
+ foreach (var (bomb, meta) in bombs) {
+ if (!bomb.IsValid) continue;
+ if (meta.IsDetonating) continue;
+
+ var bombCarrier = bomb.OwnerEntity.Value?.As()
+ .Controller.Value?.As();
+ if (bombCarrier == null || !bombCarrier.IsValid
+ || (bombCarrier.Buttons & PlayerButtons.Use) == 0)
+ continue;
+
+ var activeWeapon = bombCarrier.PlayerPawn.Value?.WeaponServices
+ ?.ActiveWeapon.Value;
+ if (activeWeapon == null || !activeWeapon.IsValid
+ || activeWeapon.Handle != bomb.Handle)
+ continue;
+
+ StartDetonationAttempt(bombCarrier, meta.Delay, bomb);
}
-
- private Dictionary _bombs = new();
-
- private BasePlugin? _basePlugin;
-
- // EmitSound(CBaseEntity* pEnt, const char* sSoundName, int nPitch, float flVolume, float flDelay)
- private readonly MemoryFunctionVoid CBaseEntity_EmitSoundParamsLinux =
- new("48 B8 ? ? ? ? ? ? ? ? 55 48 89 E5 41 55 41 54 49 89 FC 53 48 89 F3"); // LINUX ONLY.
-
- public void Start(BasePlugin basePlugin)
- {
- _basePlugin = basePlugin;
- _basePlugin.RegisterListener(PlayerUseC4ListenerCallback);
- }
-
- private void PlayerUseC4ListenerCallback()
- {
- foreach (var (bomb, meta) in _bombs)
- {
- if (!bomb.IsValid)
- continue;
- if (meta.IsDetonating)
- continue;
-
- var bombCarrier = bomb.OwnerEntity.Value?.As().Controller.Value?.As();
- if (bombCarrier == null || !bombCarrier.IsValid || (bombCarrier.Buttons & PlayerButtons.Use) == 0)
- continue;
-
- var activeWeapon = bombCarrier.PlayerPawn.Value?.WeaponServices?.ActiveWeapon.Value;
- if (activeWeapon == null || !activeWeapon.IsValid || (activeWeapon.Handle != bomb.Handle))
- continue;
-
- StartDetonationAttempt(bombCarrier, meta.Delay, bomb);
- }
- }
-
- [GameEventHandler]
- public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
- {
- ClearActiveC4s();
- TryGiveC4ToRandomTerrorist();
- return HookResult.Continue;
- }
-
- public void ClearActiveC4s()
- {
- _bombs.Clear();
+ }
+
+ [GameEventHandler]
+ public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) {
+ ClearActiveC4s();
+ TryGiveC4ToRandomTerrorist();
+ return HookResult.Continue;
+ }
+
+ [GameEventHandler]
+ public HookResult OnPlayerDropC4(EventBombDropped @event,
+ GameEventInfo info) {
+ var player = @event.Userid;
+ if (player == null || !player.IsValid) return HookResult.Continue;
+
+ var bombEntity = Utilities.GetEntityFromIndex((int)@event.Entindex);
+ if (bombEntity == null) return HookResult.Continue;
+
+ bombs.TryGetValue(bombEntity, out var bombMetadata);
+ if (bombMetadata == null) return HookResult.Continue;
+
+ if (bombMetadata.IsDetonating) {
+ bombEntity.Remove();
+ return HookResult.Stop;
}
- [GameEventHandler]
- public HookResult OnPlayerDropC4(EventBombDropped @event, GameEventInfo info)
- {
- var player = @event.Userid;
- if (player == null || !player.IsValid)
- return HookResult.Continue;
-
- var bombEntity = Utilities.GetEntityFromIndex((int)@event.Entindex);
- if (bombEntity == null)
- return HookResult.Continue;
+ return HookResult.Continue;
+ }
- _bombs.TryGetValue(bombEntity, out var bombMetadata);
- if (bombMetadata == null)
- return HookResult.Continue;
-
- if (bombMetadata.IsDetonating)
- {
- bombEntity.Remove();
- return HookResult.Stop;
- }
-
- return HookResult.Continue;
+ private void detonate(CCSPlayerController player, CC4 bomb) {
+ if (!player.IsValid || !player.IsReal() || !player.PawnIsAlive) {
+ bombs.TryGetValue(bomb, out _);
+ if (bomb.IsValid) bomb.Remove();
+ bombs.Remove(bomb);
+ return;
}
- public void TryGiveC4ToPlayer(CCSPlayerController player)
- {
- var bombEntity = new CC4(player.GiveNamedItem("weapon_c4"));
- _bombs.Add(bombEntity, new JihadBombMetadata(0.75f, false));
-
- jihadC4Notifications.JIHAD_C4_RECEIVED.ToPlayerChat(player);
- jihadC4Notifications.JIHAD_C4_USAGE1.ToPlayerChat(player);
+ tryEmitSound(player, "jb.jihadExplosion", 1, 1f, 0f);
+ var particleSystemEntity =
+ Utilities.CreateEntityByName("info_particle_system")!;
+ particleSystemEntity.EffectName =
+ "particles/explosions_fx/explosion_c4_500.vpcf";
+ particleSystemEntity.StartActive = true;
+
+ particleSystemEntity.Teleport(player.PlayerPawn.Value!.AbsOrigin!,
+ new QAngle(), new Vector());
+ particleSystemEntity.DispatchSpawn();
+
+ /* Calculate damage here, only applies to alive CTs. */
+ foreach (var ct in Utilities.GetPlayers()
+ .Where(p => p.IsReal() && p is {
+ Team: CsTeam.CounterTerrorist, PawnIsAlive: true, IsValid: true
+ })) {
+ var distanceFromBomb =
+ ct.PlayerPawn.Value!.AbsOrigin!.Distance(player.PlayerPawn.Value
+ .AbsOrigin!);
+ if (distanceFromBomb > 350f) continue;
+
+ // 350f = "bombRadius"
+ var damage = 340f;
+ damage *= (350f - distanceFromBomb) / 350f;
+ float healthRef = ct.PlayerPawn.Value.Health;
+ if (healthRef <= damage) { ct.CommitSuicide(true, true); } else {
+ ct.PlayerPawn.Value.Health -= (int)damage;
+ Utilities.SetStateChanged(ct, "CBaseEntity", "m_iHealth");
+ }
}
- public void StartDetonationAttempt(CCSPlayerController player, float delay, CC4 bombEntity)
- {
- if (_basePlugin == null)
- return;
-
- TryEmitSound(player, "jb.jihad", 1, 1f, 0f);
-
- _bombs[bombEntity].Delay = delay;
- _bombs[bombEntity].IsDetonating = true;
-
- rebelService.MarkRebel(player, 30);
-
- Server.RunOnTick(Server.TickCount + (int)(64 * delay), () => Detonate(player, bombEntity));
- }
-
- private void Detonate(CCSPlayerController player, CC4 bomb)
- {
- if (!player.IsValid || !player.IsReal() || !player.PawnIsAlive)
- {
- _bombs.TryGetValue(bomb, out var metadata);
- if (bomb.IsValid)
- bomb.Remove();
- _bombs.Remove(bomb);
- return;
- }
-
- TryEmitSound(player, "jb.jihadExplosion", 1, 1f, 0f);
- var particleSystemEntity =
- Utilities.CreateEntityByName("info_particle_system")!;
- particleSystemEntity.EffectName = "particles/explosions_fx/explosion_c4_500.vpcf";
- particleSystemEntity.StartActive = true;
-
- particleSystemEntity.Teleport(player.PlayerPawn!.Value!.AbsOrigin!, new QAngle(), new Vector());
- particleSystemEntity.DispatchSpawn();
-
- /* Calculate damage here, only applies to alive CTs. */
- foreach (var ct in Utilities.GetPlayers()
- .Where((p) => p.IsReal() && p is
- { Team: CsTeam.CounterTerrorist, PawnIsAlive: true, IsValid: true }))
- {
- var distanceFromBomb =
- ct.PlayerPawn!.Value!.AbsOrigin!.Distance(player.PlayerPawn.Value.AbsOrigin!);
- if (distanceFromBomb > 350f)
- continue;
-
- // 350f = "bombRadius"
- var damage = 340f;
- damage *= (350f - distanceFromBomb) / 350f;
- float healthRef = ct.PlayerPawn.Value.Health;
- if (healthRef <= damage)
- {
- ct.CommitSuicide(true, true);
- }
- else
- {
- ct.PlayerPawn.Value.Health -= (int)damage;
- Utilities.SetStateChanged(ct, "CBaseEntity", "m_iHealth");
- }
- }
-
- // If they didn't have the C4 make sure to remove it.
- player.CommitSuicide(true, true);
- _bombs.Remove(bomb);
- }
-
- public void TryGiveC4ToRandomTerrorist()
- {
- _basePlugin!.AddTimer(1, () =>
- {
- var validTerroristPlayers = Utilities.GetPlayers()
- .Where(player =>
- player.IsReal() && player is
- { Team: CsTeam.Terrorist, PawnIsAlive: true, IsBot: false, IsValid: true }).ToList();
- var numOfTerrorists = validTerroristPlayers.Count;
- if (numOfTerrorists == 0)
- return;
-
- Random rnd = new();
- var randomIndex = rnd.Next(numOfTerrorists);
- TryGiveC4ToPlayer(validTerroristPlayers[randomIndex]);
- });
- }
-
- private void TryEmitSound(CBaseEntity entity, string soundEventName, int pitch, float volume, float delay)
- {
- CBaseEntity_EmitSoundParamsLinux.Invoke(entity, soundEventName, pitch, volume, delay);
- }
-
- // Returns whether the weapon c4 was in their inventory or not.
- private bool TryRemoveWeaponC4(CCSPlayerController player)
- {
- if (player.PlayerPawn.Value?.WeaponServices == null)
- return false;
-
- foreach (var weapon in player.PlayerPawn.Value.WeaponServices.MyWeapons)
- {
- if (weapon.Value == null)
- continue;
-
- if (weapon.Value.DesignerName == "weapon_c4")
- {
- weapon.Value.Remove();
- return true;
- }
- }
-
- return false;
- }
+ // If they didn't have the C4 make sure to remove it.
+ player.CommitSuicide(true, true);
+ bombs.Remove(bomb);
+ }
+
+ private void tryEmitSound(CBaseEntity entity, string soundEventName,
+ int pitch, float volume, float delay) {
+ CBaseEntity_EmitSoundParamsLinux.Invoke(entity, soundEventName, pitch,
+ volume, delay);
+ }
+
+ private class JihadBombMetadata(float delay, bool isDetonating) {
+ public float Delay { get; set; } = delay;
+ public bool IsDetonating { get; set; } = isDetonating;
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Rebel/RebelListener.cs b/mod/Jailbreak.Rebel/RebelListener.cs
index a973249e..2bedd3ab 100644
--- a/mod/Jailbreak.Rebel/RebelListener.cs
+++ b/mod/Jailbreak.Rebel/RebelListener.cs
@@ -8,29 +8,22 @@
namespace Jailbreak.Rebel;
-public class RebelListener(IRebelService rebelService, ILastRequestManager lastRequestManager)
- : IPluginBehavior
-{
- [GameEventHandler]
- public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)
- {
- var player = @event.Userid;
- if (!player.IsReal())
- return HookResult.Continue;
- if (player.GetTeam() != CsTeam.CounterTerrorist)
- return HookResult.Continue;
+public class RebelListener(IRebelService rebelService,
+ ILastRequestManager lastRequestManager) : IPluginBehavior {
+ [GameEventHandler]
+ public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info) {
+ var player = @event.Userid;
+ if (player == null || !player.IsReal()) return HookResult.Continue;
+ if (player.GetTeam() != CsTeam.CounterTerrorist) return HookResult.Continue;
- var attacker = @event.Attacker;
- if (!attacker.IsReal())
- return HookResult.Continue;
+ var attacker = @event.Attacker;
+ if (attacker == null || !attacker.IsReal()) return HookResult.Continue;
- if (attacker.GetTeam() != CsTeam.Terrorist)
- return HookResult.Continue;
+ if (attacker.GetTeam() != CsTeam.Terrorist) return HookResult.Continue;
- if (lastRequestManager.IsInLR(attacker))
- return HookResult.Continue;
-
- rebelService.MarkRebel(attacker);
- return HookResult.Continue;
- }
+ if (lastRequestManager.IsInLR(attacker)) return HookResult.Continue;
+
+ rebelService.MarkRebel(attacker);
+ return HookResult.Continue;
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Rebel/RebelManager.cs b/mod/Jailbreak.Rebel/RebelManager.cs
index dd845d64..fa357a66 100644
--- a/mod/Jailbreak.Rebel/RebelManager.cs
+++ b/mod/Jailbreak.Rebel/RebelManager.cs
@@ -4,167 +4,142 @@
using CounterStrikeSharp.API.Modules.Timers;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
+using Jailbreak.Formatting.Views.Logging;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
-using Jailbreak.Public.Mod.Logs;
using Jailbreak.Public.Mod.Rebel;
namespace Jailbreak.Rebel;
-public class RebelManager(IRebelNotifications notifs, IRichLogService logs) : IPluginBehavior, IRebelService
-{
- private readonly Dictionary _rebelTimes = new();
-
- public static int MAX_REBEL_TIME = 45;
-
- public void Start(BasePlugin parent)
- {
- parent.RegisterEventHandler(OnPlayerDisconnect);
- parent.RegisterEventHandler(OnPlayerDeath);
- parent.RegisterEventHandler(OnRoundStart);
- parent.RegisterListener(OnTick);
-
- parent.AddTimer(1f, () =>
- {
- foreach (var player in GetActiveRebels())
- {
- if (!player.IsReal())
- continue;
-
- if (GetRebelTimeLeft(player) <= 0)
- {
- UnmarkRebel(player);
- continue;
- }
-
- ApplyRebelColor(player);
- SendTimeLeft(player);
- }
- }, TimerFlags.REPEAT);
- }
+public class RebelManager(IRebelNotifications notifs, IRichLogService logs)
+ : IPluginBehavior, IRebelService {
+ public static readonly int MAX_REBEL_TIME = 45;
+ private readonly Dictionary rebelTimes = new();
- private void OnTick()
- {
- foreach (var player in GetActiveRebels())
- {
- if (!player.IsReal())
- continue;
+ public void Start(BasePlugin basePlugin) {
+ basePlugin.RegisterEventHandler(OnPlayerDisconnect);
+ basePlugin.RegisterEventHandler(OnPlayerDeath);
+ basePlugin.RegisterEventHandler(OnRoundStart);
+ basePlugin.RegisterListener(OnTick);
- if (GetRebelTimeLeft(player) <= 0) continue;
+ basePlugin.AddTimer(1f, () => {
+ foreach (var player in GetActiveRebels()) {
+ if (!player.IsReal()) continue;
- SendTimeLeft(player);
+ if (GetRebelTimeLeft(player) <= 0) {
+ UnmarkRebel(player);
+ continue;
}
- }
-
- HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
- {
- _rebelTimes.Clear();
- foreach (var player in Utilities.GetPlayers())
- {
- if (!player.IsReal())
- continue;
- ApplyRebelColor(player);
- }
-
- return HookResult.Continue;
- }
- private HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
- {
- if (@event.Userid == null) return HookResult.Continue;
- if (_rebelTimes.ContainsKey(@event.Userid)) _rebelTimes.Remove(@event.Userid);
+ applyRebelColor(player);
+ sendTimeLeft(player);
+ }
+ }, TimerFlags.REPEAT);
+ }
- return HookResult.Continue;
- }
+ public ISet GetActiveRebels() {
+ return rebelTimes.Keys.ToHashSet();
+ }
- private HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
- {
- var player = @event.Userid;
- if (player == null) return HookResult.Continue;
- if (!player.IsReal())
- return HookResult.Continue;
- _rebelTimes.Remove(player);
- return HookResult.Continue;
- }
-
- public ISet GetActiveRebels()
- {
- return _rebelTimes.Keys.ToHashSet();
- }
+ public long GetRebelTimeLeft(CCSPlayerController player) {
+ if (rebelTimes.TryGetValue(player, out var time))
+ return time - DateTimeOffset.Now.ToUnixTimeSeconds();
- public long GetRebelTimeLeft(CCSPlayerController player)
- {
- if (_rebelTimes.TryGetValue(player, out long time))
- {
- return time - DateTimeOffset.Now.ToUnixTimeSeconds();
- }
+ return 0;
+ }
- return 0;
- }
+ public bool MarkRebel(CCSPlayerController player, long time = 30) {
+ if (!rebelTimes.ContainsKey(player))
+ logs.Append(logs.Player(player), "is now a rebel.");
- public bool MarkRebel(CCSPlayerController player, long time = 30)
- {
- if (!_rebelTimes.ContainsKey(player))
- {
- logs.Append(logs.Player(player), "is now a rebel.");
- }
+ rebelTimes[player] = DateTimeOffset.Now.ToUnixTimeSeconds() + time;
+ applyRebelColor(player);
+ return true;
+ }
- _rebelTimes[player] = DateTimeOffset.Now.ToUnixTimeSeconds() + time;
- ApplyRebelColor(player);
- return true;
+ public void UnmarkRebel(CCSPlayerController player) {
+ if (rebelTimes.ContainsKey(player)) {
+ notifs.NoLongerRebel.ToPlayerChat(player);
+ logs.Append(logs.Player(player), "is no longer a rebel.");
}
- public void UnmarkRebel(CCSPlayerController player)
- {
- if (_rebelTimes.ContainsKey(player))
- {
- notifs.NO_LONGER_REBEL.ToPlayerChat(player);
- logs.Append(logs.Player(player), "is no longer a rebel.");
- }
-
- _rebelTimes.Remove(player);
- ApplyRebelColor(player);
- }
+ rebelTimes.Remove(player);
+ applyRebelColor(player);
+ }
- // https://www.desmos.com/calculator/g2v6vvg7ax
- private float GetRebelTimePercentage(CCSPlayerController player)
- {
- var x = GetRebelTimeLeft(player);
- if (x > MAX_REBEL_TIME)
- return 1;
- if (x <= 0)
- return 0;
- return (float)(100 - (MAX_REBEL_TIME - x) * Math.Sqrt(MAX_REBEL_TIME - x) / 3.8f) / 100;
- }
+ private void OnTick() {
+ foreach (var player in GetActiveRebels()) {
+ if (!player.IsReal()) continue;
- 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);
+ if (GetRebelTimeLeft(player) <= 0) continue;
- return color;
+ sendTimeLeft(player);
}
+ }
- private void ApplyRebelColor(CCSPlayerController player)
- {
- if (!player.IsReal() || player.Pawn.Value == null)
- return;
- var color = GetRebelColor(player);
-
- player.Pawn.Value.RenderMode = RenderMode_t.kRenderTransColor;
- player.Pawn.Value.Render = color;
- Utilities.SetStateChanged(player.Pawn.Value, "CBaseModelEntity", "m_clrRender");
+ private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) {
+ rebelTimes.Clear();
+ foreach (var player in Utilities.GetPlayers()) {
+ if (!player.IsReal()) continue;
+ applyRebelColor(player);
}
- private void SendTimeLeft(CCSPlayerController player)
- {
- // var timeLeft = GetRebelTimeLeft(player);
- // var formattedTime = TimeSpan.FromSeconds(timeLeft).ToString(@"mm\:ss");
- var color = GetRebelColor(player);
- var formattedColor = $"";
-
- player.PrintToCenterHtml($"You are {formattedColor}rebelling");
- }
+ return HookResult.Continue;
+ }
+
+ private HookResult OnPlayerDisconnect(EventPlayerDisconnect @event,
+ GameEventInfo info) {
+ if (@event.Userid == null) return HookResult.Continue;
+ if (rebelTimes.ContainsKey(@event.Userid)) rebelTimes.Remove(@event.Userid);
+
+ return HookResult.Continue;
+ }
+
+ private HookResult OnPlayerDeath(EventPlayerDeath @event,
+ GameEventInfo info) {
+ var player = @event.Userid;
+ if (player == null) return HookResult.Continue;
+ if (!player.IsReal()) return HookResult.Continue;
+ rebelTimes.Remove(player);
+ return HookResult.Continue;
+ }
+
+ // https://www.desmos.com/calculator/g2v6vvg7ax
+ private float getRebelTimePercentage(CCSPlayerController player) {
+ var x = GetRebelTimeLeft(player);
+ if (x > MAX_REBEL_TIME) return 1;
+ if (x <= 0) return 0;
+ return (float)(100 - (MAX_REBEL_TIME - x) * Math.Sqrt(MAX_REBEL_TIME - x)
+ / 3.8f) / 100;
+ }
+
+ 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) return;
+ var color = getRebelColor(player);
+
+ player.Pawn.Value.RenderMode = RenderMode_t.kRenderTransColor;
+ player.Pawn.Value.Render = color;
+ Utilities.SetStateChanged(player.Pawn.Value, "CBaseModelEntity",
+ "m_clrRender");
+ }
+
+ private void sendTimeLeft(CCSPlayerController player) {
+ // var timeLeft = GetRebelTimeLeft(player);
+ // var formattedTime = TimeSpan.FromSeconds(timeLeft).ToString(@"mm\:ss");
+ var color = getRebelColor(player);
+ var formattedColor =
+ $"";
+
+ player.PrintToCenterHtml(
+ $"You are {formattedColor}rebelling");
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Rebel/RebelServiceExtension.cs b/mod/Jailbreak.Rebel/RebelServiceExtension.cs
index 6dc00b9f..c12f2af0 100644
--- a/mod/Jailbreak.Rebel/RebelServiceExtension.cs
+++ b/mod/Jailbreak.Rebel/RebelServiceExtension.cs
@@ -5,12 +5,10 @@
namespace Jailbreak.Rebel;
-public static class RebelServiceExtension
-{
- public static void AddJailbreakRebel(this IServiceCollection collection)
- {
- collection.AddPluginBehavior();
- collection.AddPluginBehavior();
- collection.AddPluginBehavior();
- }
-}
+public static class RebelServiceExtension {
+ public static void AddJailbreakRebel(this IServiceCollection collection) {
+ collection.AddPluginBehavior();
+ collection.AddPluginBehavior();
+ collection.AddPluginBehavior();
+ }
+}
\ No newline at end of file
diff --git a/mod/Jailbreak.Warden/Commands/PeaceCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/PeaceCommandsBehavior.cs
index 6bda2751..f4c34414 100644
--- a/mod/Jailbreak.Warden/Commands/PeaceCommandsBehavior.cs
+++ b/mod/Jailbreak.Warden/Commands/PeaceCommandsBehavior.cs
@@ -10,45 +10,38 @@
namespace Jailbreak.Warden.Commands;
-public class PeaceCommandsBehavior(
- IWardenService warden,
- IMuteService mute,
- IPeaceMessages messages,
- IWardenNotifications notifications,
- IGenericCommandNotifications generics)
- : IPluginBehavior
-{
- [ConsoleCommand("css_peace", "Invokes a peace period where only the warden can talk")]
- public void Command_Peace(CCSPlayerController? executor, CommandInfo info)
- {
- if (mute.IsPeaceEnabled())
- {
- if (executor != null)
- messages.PEACE_ACTIVE.ToPlayerChat(executor);
- return;
- }
-
- bool fromWarden = executor != null && warden.IsWarden(executor);
+public class PeaceCommandsBehavior(IWardenService warden, IMuteService mute,
+ IPeaceMessages messages, IWardenNotifications notifications,
+ IGenericCommandNotifications generics) : IPluginBehavior {
+ [ConsoleCommand("css_peace",
+ "Invokes a peace period where only the warden can talk")]
+ public void Command_Peace(CCSPlayerController? executor, CommandInfo info) {
+ if (mute.IsPeaceEnabled()) {
+ if (executor != null) messages.PeaceActive.ToPlayerChat(executor);
+ return;
+ }
- if (executor == null || AdminManager.PlayerHasPermissions(executor, "@css/cheats"))
- {
- // Server console or a high-admin is invoking the peace period, bypass cooldown
- mute.PeaceMute(fromWarden ? MuteReason.WARDEN_INVOKED : MuteReason.ADMIN);
- return;
- }
+ var fromWarden = executor != null && warden.IsWarden(executor);
- if (!warden.IsWarden(executor) && !AdminManager.PlayerHasPermissions(executor, "@css/chat"))
- {
- notifications.NOT_WARDEN.ToPlayerChat(executor);
- return;
- }
+ if (executor == null
+ || AdminManager.PlayerHasPermissions(executor, "@css/cheats")) {
+ // Server console or a high-admin is invoking the peace period, bypass cooldown
+ mute.PeaceMute(fromWarden ? MuteReason.WARDEN_INVOKED : MuteReason.ADMIN);
+ return;
+ }
- if (DateTime.Now - mute.GetLastPeace() < TimeSpan.FromSeconds(60))
- {
- generics.CommandOnCooldown(mute.GetLastPeace().AddSeconds(60)).ToPlayerChat(executor);
- return;
- }
+ if (!warden.IsWarden(executor)
+ && !AdminManager.PlayerHasPermissions(executor, "@css/chat")) {
+ notifications.NOT_WARDEN.ToPlayerChat(executor);
+ return;
+ }
- mute.PeaceMute(fromWarden ? MuteReason.WARDEN_INVOKED : MuteReason.ADMIN);
+ if (DateTime.Now - mute.GetLastPeace() < TimeSpan.FromSeconds(60)) {
+ generics.CommandOnCooldown(mute.GetLastPeace().AddSeconds(60))
+ .ToPlayerChat(executor);
+ return;
}
+
+ mute.PeaceMute(fromWarden ? MuteReason.WARDEN_INVOKED : MuteReason.ADMIN);
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Warden/Commands/RollCommandBehavior.cs b/mod/Jailbreak.Warden/Commands/RollCommandBehavior.cs
index b1b38d15..49ae9c1b 100644
--- a/mod/Jailbreak.Warden/Commands/RollCommandBehavior.cs
+++ b/mod/Jailbreak.Warden/Commands/RollCommandBehavior.cs
@@ -1,7 +1,6 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Commands;
-using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Public.Behaviors;
@@ -9,47 +8,38 @@
namespace Jailbreak.Warden.Commands;
-public class RollCommandBehavior(
- IWardenService warden,
- IRollCommandNotications notifications,
- IWardenNotifications wardenNotifications,
- IGenericCommandNotifications generics)
- : IPluginBehavior
-{
- private readonly Random _rng = new();
-
- [ConsoleCommand("css_roll",
- "Roll a number between min and max. If no min and max are provided, it will default to 0 and 10.")]
- [CommandHelper(1, "[min] [max]", CommandUsage.CLIENT_ONLY)]
- public void Command_Toggle(CCSPlayerController? player, CommandInfo command)
- {
- if (player == null)
- return;
-
- if (!warden.IsWarden(player))
- {
- wardenNotifications.NOT_WARDEN.ToPlayerChat(player);
- return;
- }
-
- var min = 0;
- var max = 10;
-
- if (command.ArgCount == 3)
- {
- if (!int.TryParse(command.GetArg(1), out min))
- {
- generics.InvalidParameter(command.GetArg(1), "number");
- return;
- }
-
- if (!int.TryParse(command.GetArg(2), out max))
- {
- generics.InvalidParameter(command.GetArg(2), "number");
- return;
- }
- }
-
- notifications.Roll(_rng.Next(min, max)).ToAllChat();
+public class RollCommandBehavior(IWardenService warden,
+ IRollCommandNotications notifications,
+ IWardenNotifications wardenNotifications,
+ IGenericCommandNotifications generics) : IPluginBehavior {
+ private readonly Random rng = new();
+
+ [ConsoleCommand("css_roll",
+ "Roll a number between min and max. If no min and max are provided, it will default to 0 and 10.")]
+ [CommandHelper(1, "[min] [max]", CommandUsage.CLIENT_ONLY)]
+ public void Command_Toggle(CCSPlayerController? player, CommandInfo command) {
+ if (player == null) return;
+
+ if (!warden.IsWarden(player)) {
+ wardenNotifications.NOT_WARDEN.ToPlayerChat(player);
+ return;
}
+
+ var min = 0;
+ var max = 10;
+
+ if (command.ArgCount == 3) {
+ if (!int.TryParse(command.GetArg(1), out min)) {
+ generics.InvalidParameter(command.GetArg(1), "number");
+ return;
+ }
+
+ if (!int.TryParse(command.GetArg(2), out max)) {
+ generics.InvalidParameter(command.GetArg(2), "number");
+ return;
+ }
+ }
+
+ notifications.Roll(rng.Next(min, max)).ToAllChat();
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Warden/Commands/SpecialTreatmentCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/SpecialTreatmentCommandsBehavior.cs
index 6d8c4090..10e09fb9 100644
--- a/mod/Jailbreak.Warden/Commands/SpecialTreatmentCommandsBehavior.cs
+++ b/mod/Jailbreak.Warden/Commands/SpecialTreatmentCommandsBehavior.cs
@@ -9,68 +9,49 @@
namespace Jailbreak.Warden.Commands;
-public class SpecialTreatmentCommandsBehavior : IPluginBehavior
-{
- private IWardenService _warden;
- private ISpecialTreatmentService _specialTreatment;
-
- private IGenericCommandNotifications _generic;
- private IWardenNotifications _wardenNotifs;
-
- public SpecialTreatmentCommandsBehavior(IWardenService warden, ISpecialTreatmentService specialTreatment,
- IGenericCommandNotifications generic, ISpecialTreatmentNotifications notifications,
- IWardenNotifications wardenNotifs)
- {
- _warden = warden;
- _specialTreatment = specialTreatment;
- _generic = generic;
- _wardenNotifs = wardenNotifs;
+public class SpecialTreatmentCommandsBehavior(IWardenService warden,
+ ISpecialTreatmentService specialTreatment,
+ IGenericCommandNotifications generic, IWardenNotifications wardenNotifs)
+ : IPluginBehavior {
+ [ConsoleCommand("css_treat",
+ "Grant or revoke special treatment from a player")]
+ [ConsoleCommand("css_st", "Grant or revoke special treatment from a player")]
+ [CommandHelper(0, "", CommandUsage.CLIENT_ONLY)]
+ public void Command_Toggle(CCSPlayerController? player, CommandInfo command) {
+ if (player == null) return;
+
+ if (!warden.IsWarden(player)) {
+ wardenNotifs.NOT_WARDEN.ToPlayerChat(player).ToPlayerConsole(player);
+ return;
}
- [ConsoleCommand("css_treat", "Grant or revoke special treatment from a player")]
- [ConsoleCommand("css_st", "Grant or revoke special treatment from a player")]
- [CommandHelper(0, "", CommandUsage.CLIENT_ONLY)]
- public void Command_Toggle(CCSPlayerController? player, CommandInfo command)
- {
- if (player == null)
- return;
-
- if (!_warden.IsWarden(player))
- {
- _wardenNotifs.NOT_WARDEN.ToPlayerChat(player).ToPlayerConsole(player);
- return;
- }
-
- if (command.ArgCount == 1)
- {
- // TODO: Pop up menu of prisoners to toggle ST for
- return;
- }
+ if (command.ArgCount == 1)
+ // TODO: Pop up menu of prisoners to toggle ST for
+ return;
- var targets = command.GetArgTargetResult(1);
- var eligible = targets
- .Where(p => p is { Team: CsTeam.Terrorist, PawnIsAlive: true })
- .ToList();
+ var targets = command.GetArgTargetResult(1);
+ var eligible = targets
+ .Where(p => p is { Team: CsTeam.Terrorist, PawnIsAlive: true })
+ .ToList();
- if (eligible.Count == 0)
- {
- _generic.PlayerNotFound(command.GetArg(1))
- .ToPlayerChat(player)
- .ToPlayerConsole(player);
- return;
- }
+ if (eligible.Count == 0) {
+ generic.PlayerNotFound(command.GetArg(1))
+ .ToPlayerChat(player)
+ .ToPlayerConsole(player);
+ return;
+ }
- if (eligible.Count != 1)
- {
- _generic.PlayerFoundMultiple(command.GetArg(1))
- .ToPlayerChat(player)
- .ToPlayerConsole(player);
- return;
- }
+ if (eligible.Count != 1) {
+ generic.PlayerFoundMultiple(command.GetArg(1))
+ .ToPlayerChat(player)
+ .ToPlayerConsole(player);
+ return;
+ }
- // One target, mark as ST.
- var special = eligible.First();
+ // One target, mark as ST.
+ var special = eligible.First();
- _specialTreatment.SetSpecialTreatment(special, !_specialTreatment.IsSpecialTreatment(special));
- }
+ specialTreatment.SetSpecialTreatment(special,
+ !specialTreatment.IsSpecialTreatment(special));
+ }
}
\ No newline at end of file
diff --git a/mod/Jailbreak.Warden/Commands/WardenCommandsBehavior.cs b/mod/Jailbreak.Warden/Commands/WardenCommandsBehavior.cs
index 064d0847..77d0f7a6 100644
--- a/mod/Jailbreak.Warden/Commands/WardenCommandsBehavior.cs
+++ b/mod/Jailbreak.Warden/Commands/WardenCommandsBehavior.cs
@@ -1,5 +1,4 @@
-using System.ComponentModel.Design;
-using CounterStrikeSharp.API;
+using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes.Registration;
using CounterStrikeSharp.API.Modules.Admin;
@@ -10,166 +9,133 @@
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.Warden;
-using Microsoft.Extensions.DependencyInjection;
namespace Jailbreak.Warden.Commands;
-public class WardenCommandsBehavior(
- IWardenNotifications _notifications,
- IWardenSelectionService _queue,
- IWardenService _warden,
- IGenericCommandNotifications _generics,
- WardenConfig _config
-) : IPluginBehavior
-{
- private readonly Dictionary _lastPassCommand = new();
-
- [GameEventHandler]
- public HookResult OnRoundStart(EventRoundStart ev, GameEventInfo info)
- {
- _lastPassCommand.Clear();
- return HookResult.Continue;
- }
+public class WardenCommandsBehavior(IWardenNotifications notifications,
+ IWardenSelectionService queue, IWardenService warden,
+ IGenericCommandNotifications generics, WardenConfig config)
+ : IPluginBehavior {
+ private readonly Dictionary lastPassCommand =
+ new();
+
+ [GameEventHandler]
+ public HookResult OnRoundStart(EventRoundStart ev, GameEventInfo info) {
+ lastPassCommand.Clear();
+ return HookResult.Continue;
+ }
+
+ [ConsoleCommand("css_pass", "Pass warden onto another player")]
+ [ConsoleCommand("css_uw", "Pass warden onto another player")]
+ [CommandHelper(0, "", CommandUsage.CLIENT_ONLY)]
+ public void Command_Pass(CCSPlayerController? player, CommandInfo command) {
+ if (player == null) return;
- [ConsoleCommand("css_pass", "Pass warden onto another player")]
- [ConsoleCommand("css_uw", "Pass warden onto another player")]
- [CommandHelper(0, "", CommandUsage.CLIENT_ONLY)]
- public void Command_Pass(CCSPlayerController? player, CommandInfo command)
- {
- if (player == null)
- return;
+ if (!warden.IsWarden(player)) return;
- if (!_warden.IsWarden(player)) return;
+ // Handle warden pass
+ notifications.PASS_WARDEN(player).ToAllChat().ToAllCenter();
- // Handle warden pass
- _notifications.PASS_WARDEN(player)
- .ToAllChat()
- .ToAllCenter();
+ // GetPlayers() returns valid players, no need to error check here.
+ foreach (var clients in Utilities.GetPlayers())
+ clients.ExecuteClientCommand(
+ $"play sounds/{config.WardenPassedSoundName}");
- // GetPlayers() returns valid players, no need to error check here.
- foreach (var clients in Utilities.GetPlayers())
- {
- clients.ExecuteClientCommand(
- $"play sounds/{_config.WardenPassedSoundName}");
- }
+ notifications.BECOME_NEXT_WARDEN.ToAllChat();
- _notifications.BECOME_NEXT_WARDEN.ToAllChat();
+ if (!warden.TryRemoveWarden(true))
+ Server.PrintToChatAll("[BUG] Couldn't remove warden :^(");
- if (!_warden.TryRemoveWarden(true))
- Server.PrintToChatAll("[BUG] Couldn't remove warden :^(");
+ lastPassCommand[player] = DateTime.Now;
+ }
- _lastPassCommand[player] = DateTime.Now;
+ [ConsoleCommand("css_fire", "Force the warden to pass")]
+ [CommandHelper(0, "", CommandUsage.CLIENT_ONLY)]
+ public void Command_Fire(CCSPlayerController? player, CommandInfo command) {
+ if (player == null) return;
+
+ if (!warden.HasWarden || warden.Warden == null) {
+ notifications.CURRENT_WARDEN(null).ToPlayerChat(player);
+ return;
}
- [ConsoleCommand("css_fire", "Force the warden to pass")]
- [CommandHelper(0, "", CommandUsage.CLIENT_ONLY)]
- public void Command_Fire(CCSPlayerController? player, CommandInfo command)
- {
- if (player == null)
- return;
-
- if (!_warden.HasWarden || _warden.Warden == null)
- {
- _notifications.CURRENT_WARDEN(null).ToPlayerChat(player);
- return;
- }
-
- if (!AdminManager.PlayerHasPermissions(player, "@css/ban"))
- {
- _generics.NoPermissionMessage("@css/ban").ToPlayerChat(player);
- return;
- }
-
- foreach (var client in Utilities.GetPlayers().Where(p => p.IsReal()))
- {
- if (AdminManager.PlayerHasPermissions(client, "@css/chat"))
- {
- _notifications.FIRE_WARDEN(_warden.Warden, player).ToPlayerChat(client);
- }
- else
- {
- _notifications.FIRE_WARDEN(_warden.Warden).ToPlayerChat(client);
- }
-
- client.ExecuteClientCommand(
- $"play sounds/{_config.WardenPassedSoundName}");
- }
-
- _notifications.BECOME_NEXT_WARDEN.ToAllChat();
-
- _lastPassCommand[_warden.Warden] = DateTime.Now;
-
- if (!_warden.TryRemoveWarden(true))
- Server.PrintToChatAll("[BUG] Couldn't remove warden :^(");
+ if (!AdminManager.PlayerHasPermissions(player, "@css/ban")) {
+ generics.NoPermissionMessage("@css/ban").ToPlayerChat(player);
+ return;
}
- [ConsoleCommand("css_warden",
- "Become a warden, Join the warden queue, or see information about the current warden.")]
- [ConsoleCommand("css_w", "Become a warden, Join the warden queue, or see information about the current warden.")]
- [CommandHelper(0, "", CommandUsage.CLIENT_ONLY)]
- public void Command_Warden(CCSPlayerController? player, CommandInfo command)
- {
- if (player == null)
- return;
-
- // Why add them to a cooldown list if they can't even be warden :)
- if (player.Team != CsTeam.CounterTerrorist || !player.PawnIsAlive)
- {
- return;
- }
-
- // If they're already in the cooldown dictionary, check if their cooldown has expired.
- if (_lastPassCommand.TryGetValue(player, out var last))
- {
- var cooldown = last.AddSeconds(15);
- if (DateTime.Now < cooldown)
- {
- _generics.CommandOnCooldown(cooldown).ToPlayerChat(player);
- return;
- }
- }
-
- // Queue is open ?
- if (_queue.Active)
- {
- if (!_queue.InQueue(player))
- {
- if (_queue.TryEnter(player))
- _notifications.JOIN_RAFFLE.ToPlayerChat(player);
- return;
- }
-
- if (_queue.InQueue(player))
- if (_queue.TryExit(player))
- _notifications.LEAVE_RAFFLE.ToPlayerChat(player);
-
- return;
- }
-
- // Is a CT and there is no warden i.e. the queue is not open/active.
- if (!_warden.HasWarden)
- {
- if (_warden.TrySetWarden(player))
- return;
- }
-
- _notifications.CURRENT_WARDEN(_warden.Warden).ToPlayerChat(player);
+ foreach (var client in Utilities.GetPlayers().Where(p => p.IsReal())) {
+ if (AdminManager.PlayerHasPermissions(client, "@css/chat"))
+ notifications.FIRE_WARDEN(warden.Warden, player).ToPlayerChat(client);
+ else
+ notifications.FIRE_WARDEN(warden.Warden).ToPlayerChat(client);
+
+ client.ExecuteClientCommand(
+ $"play sounds/{config.WardenPassedSoundName}");
}
- ///