From d61a35a0238391b3667afd237766ede587b512f2 Mon Sep 17 00:00:00 2001 From: MSWS Date: Fri, 27 Dec 2024 12:52:58 -0800 Subject: [PATCH] Formatting --- .../LastRequest/CoinflipLocale.cs | 13 ++++--- mod/Jailbreak.Debug/Subcommands/DebugZone.cs | 36 ++++++++----------- .../Commands/SoccerCommandBehavior.cs | 16 +++------ src/Jailbreak/Jailbreak.cs | 2 ++ 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/lang/Jailbreak.English/LastRequest/CoinflipLocale.cs b/lang/Jailbreak.English/LastRequest/CoinflipLocale.cs index 1617bc3..a496dfb 100644 --- a/lang/Jailbreak.English/LastRequest/CoinflipLocale.cs +++ b/lang/Jailbreak.English/LastRequest/CoinflipLocale.cs @@ -9,8 +9,8 @@ public class CoinflipLocale : LastRequestLocale, ILRCFLocale { public IView FailedToChooseInTime(bool choice) { return new SimpleView { PREFIX, - "You failed to choose in time, defaulting to" + ChatColors.Green, - choice ? "Heads" : "Tails" + "You failed to choose in time, defaulting to", + $"{ChatColors.Green} {(choice ? "Heads" : "Tails")}{ChatColors.Grey}." }; } @@ -18,17 +18,16 @@ public class CoinflipLocale : LastRequestLocale, ILRCFLocale { return new SimpleView { PREFIX, guard, - "chose" + ChatColors.Green, - choice ? "Heads" : "Tails", - ChatColors.Default + ", flipping..." + "chose", + $" {ChatColors.Green}{(choice ? "Heads" : "Tails")}{ChatColors.Grey}, flipping..." }; } public IView CoinLandsOn(bool heads) { return new SimpleView { PREFIX, - "The coin landed on" + ChatColors.Green, - heads ? "Heads" : "Tails" + ChatColors.White + "." + "The coin landed on", + $" {ChatColors.Green}{(heads ? "Heads" : "Tails")}{ChatColors.Grey}." }; } } \ No newline at end of file diff --git a/mod/Jailbreak.Debug/Subcommands/DebugZone.cs b/mod/Jailbreak.Debug/Subcommands/DebugZone.cs index 8c797dc..9990f62 100644 --- a/mod/Jailbreak.Debug/Subcommands/DebugZone.cs +++ b/mod/Jailbreak.Debug/Subcommands/DebugZone.cs @@ -13,10 +13,11 @@ public class DebugZone(IServiceProvider services, BasePlugin plugin) private readonly IDictionary creators = new Dictionary(); - private readonly IZoneFactory? factory = services.GetService(); + private readonly IZoneFactory factory = + services.GetRequiredService(); - private readonly IZoneManager? zoneManager = - services.GetService(); + private readonly IZoneManager zoneManager = + services.GetRequiredService(); public override void OnCommand(CCSPlayerController? executor, WrappedInfo info) { @@ -27,11 +28,6 @@ public class DebugZone(IServiceProvider services, BasePlugin plugin) return; } - if (factory == null || zoneManager == null) { - info.ReplyToCommand("Zone factory or manager not found"); - return; - } - var position = executor.PlayerPawn.Value.AbsOrigin; if (info.ArgCount <= 1) { @@ -90,17 +86,15 @@ public class DebugZone(IServiceProvider services, BasePlugin plugin) } if (zoneCount == 0) { - if (specifiedType.HasValue) - info.ReplyToCommand($"No {specifiedType} zones found"); - else - info.ReplyToCommand("No zones found"); + info.ReplyToCommand(specifiedType.HasValue ? + $"No {specifiedType} zones found" : + "No zones found"); return; } - if (specifiedType.HasValue) - info.ReplyToCommand($"Showing {zoneCount} {specifiedType} zones"); - else - info.ReplyToCommand($"Showing {zoneCount} zones"); + info.ReplyToCommand(specifiedType.HasValue ? + $"Showing {zoneCount} {specifiedType} zones" : + $"Showing {zoneCount} zones"); return; case "remove": case "delete": @@ -130,7 +124,6 @@ public class DebugZone(IServiceProvider services, BasePlugin plugin) return; case "reload": case "refresh": - // Server.NextFrameAsync(async () => { Task.Run(async () => { await zoneManager.LoadZones(Server.MapName); var count = (await zoneManager.GetAllZones()).SelectMany(e => e.Value) @@ -186,11 +179,10 @@ public class DebugZone(IServiceProvider services, BasePlugin plugin) .GetAwaiter() .GetResult(); - var toRemove = new List(); - foreach (var spawn in spawns) - if (doNotTeleport.Any(d - => d.IsInsideZone(spawn.CalculateCenterPoint()))) - toRemove.Add(spawn); + var toRemove = spawns.Where(spawn + => doNotTeleport.Any( + d => d.IsInsideZone(spawn.CalculateCenterPoint()))) + .ToList(); info.ReplyToCommand("Removing " + toRemove.Count + " auto-generated zones"); diff --git a/mod/Jailbreak.Warden/Commands/SoccerCommandBehavior.cs b/mod/Jailbreak.Warden/Commands/SoccerCommandBehavior.cs index ff1a483..fd080c3 100644 --- a/mod/Jailbreak.Warden/Commands/SoccerCommandBehavior.cs +++ b/mod/Jailbreak.Warden/Commands/SoccerCommandBehavior.cs @@ -16,19 +16,11 @@ public class SoccerCommandBehavior(IWardenService warden, new("css_jb_max_soccers", "The maximum number of soccer balls that the warden can spawn", 3); - private int soccers; - - public void Start(BasePlugin basePlugin) { - basePlugin.RegisterListener(manifest - => { - manifest.AddResource( - "models/props/de_dust/hr_dust/dust_soccerball/dust_soccer_ball001.vmdl"); - }); - } + private int soccerBalls; [GameEventHandler] public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) { - soccers = 0; + soccerBalls = 0; return HookResult.Continue; } @@ -42,7 +34,7 @@ public class SoccerCommandBehavior(IWardenService warden, return; } - if (soccers >= CV_MAX_SOCCERS.Value) { + if (soccerBalls >= CV_MAX_SOCCERS.Value) { locale.TooManySoccers.ToChat(player); return; } @@ -66,6 +58,6 @@ public class SoccerCommandBehavior(IWardenService warden, ball.Teleport(loc); locale.SoccerSpawned.ToAllChat(); ball.DispatchSpawn(); - soccers++; + soccerBalls++; } } \ No newline at end of file diff --git a/src/Jailbreak/Jailbreak.cs b/src/Jailbreak/Jailbreak.cs index 2324060..905d844 100644 --- a/src/Jailbreak/Jailbreak.cs +++ b/src/Jailbreak/Jailbreak.cs @@ -39,6 +39,8 @@ public class Jailbreak : BasePlugin { manifest.AddResource("soundevents/soundevents_jb.vsndevts"); manifest.AddResource("sounds/explosion.vsnd"); manifest.AddResource("sounds/jihad.vsnd"); + manifest.AddResource( + "models/props/de_dust/hr_dust/dust_soccerball/dust_soccer_ball001.vmdl"); }); // Load Managers