Skip to content

Commit

Permalink
Tidying up more...
Browse files Browse the repository at this point in the history
  • Loading branch information
MSWS committed Aug 3, 2024
1 parent 0a803e0 commit 72129a9
Show file tree
Hide file tree
Showing 59 changed files with 353 additions and 252 deletions.
2 changes: 1 addition & 1 deletion lang/Jailbreak.English/LastRequest/LastRequestLocale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Jailbreak.Formatting.Core;
using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Objects;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.LastRequest;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
Expand Down
2 changes: 1 addition & 1 deletion lang/Jailbreak.English/Mute/WardenPeaceLocale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Jailbreak.Formatting.Core;
using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Objects;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.Warden;

namespace Jailbreak.English.Mute;

Expand Down
5 changes: 4 additions & 1 deletion lang/Jailbreak.English/Warden/WardenCmdOpenLocale.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.Warden;

namespace Jailbreak.English.Warden;

Expand All @@ -15,6 +15,9 @@ public IView CannotOpenYet(int seconds) {
};
}

public IView AlreadyOpened
=> new SimpleView { WardenLocale.PREFIX, "You already opened cells." };

public IView CellsOpened
=> new SimpleView { WardenLocale.PREFIX, "The warden opened cells." };

Expand Down
2 changes: 1 addition & 1 deletion lang/Jailbreak.English/Warden/WardenCmdRollLocale.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Jailbreak.Formatting.Base;
using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.Warden;

namespace Jailbreak.English.Warden;

Expand Down
2 changes: 1 addition & 1 deletion lang/Jailbreak.English/Warden/WardenLocale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Jailbreak.Formatting.Core;
using Jailbreak.Formatting.Logistics;
using Jailbreak.Formatting.Objects;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.Warden;

namespace Jailbreak.English.Warden;

Expand Down
2 changes: 1 addition & 1 deletion mod/Jailbreak.Debug/DebugCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Start(BasePlugin basePlugin) {
commands.Add("lg", new LastGuard(serviceProvider));
commands.Add("zone", new Zone(serviceProvider, basePlugin));
commands.Add("endround", new EndRound(serviceProvider));
commands.Add("opencells", new OpenCells(serviceProvider));
commands.Add("testnearopen", new TestNearOpen(serviceProvider));
}

[RequiresPermissions("@css/root")]
Expand Down
2 changes: 1 addition & 1 deletion mod/Jailbreak.Debug/Subcommands/LastRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using CounterStrikeSharp.API.Modules.Menu;
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.LastRequest;
using Jailbreak.LastRequest;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
Expand Down
13 changes: 0 additions & 13 deletions mod/Jailbreak.Debug/Subcommands/OpenCells.cs

This file was deleted.

17 changes: 17 additions & 0 deletions mod/Jailbreak.Debug/Subcommands/TestNearOpen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using CounterStrikeSharp.API.Core;
using Jailbreak.Public.Utils;

namespace Jailbreak.Debug.Subcommands;

public class TestNearOpen(IServiceProvider services)
: AbstractCommand(services) {
public override void OnCommand(CCSPlayerController? executor,
WrappedInfo info) {
if (executor == null) return;
var pos = executor.Pawn.Value?.AbsOrigin;
if (pos == null) return;
MapUtil.OpenCells(Sensitivity.ANY, pos);
info.ReplyToCommand(
"Attempted to open cells using the button nearest to you.");
}
}
66 changes: 44 additions & 22 deletions mod/Jailbreak.Debug/Subcommands/Zone.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.Zones;
using Microsoft.Extensions.DependencyInjection;

Expand Down Expand Up @@ -160,7 +160,6 @@ await zoneManager.PushZoneWithID(innerZone, innerPair.Value.Item2,
foreach (var listZone in toList)
info.ReplyToCommand(
$"Points: {listZone.GetBorderPoints().Count()}/{listZone.GetAllPoints().Count()}Center: {listZone.CalculateCenterPoint()} Area: {listZone.GetArea()}");

return;
}

Expand All @@ -176,12 +175,19 @@ await zoneManager.PushZoneWithID(innerZone, innerPair.Value.Item2,
attemptBeginCreation(executor, specifiedType.Value);
return;
case "set":
foreach (var zone in zoneManager.GetZones(specifiedType.Value)
var zones = zoneManager.GetZones(specifiedType.Value)
.GetAwaiter()
.GetResult())
zoneManager.DeleteZone(zone.Id);
.GetResult();

Server.NextFrameAsync(async () => {
var copy = zones.ToList();

foreach (var zone in copy) await zoneManager.DeleteZone(zone.Id);

Server.NextFrame(()
=> attemptBeginCreation(executor, specifiedType.Value));
});

attemptBeginCreation(executor, specifiedType.Value);
return;
case "tpto":
case "tp":
Expand All @@ -207,6 +213,26 @@ await zoneManager.PushZoneWithID(innerZone, innerPair.Value.Item2,

info.ReplyToCommand("Teleported to zone #" + tpDestinations.First().Id);
return;
case "generate":
if (specifiedType != ZoneType.ARMORY
&& specifiedType != ZoneType.CELL) {
info.ReplyToCommand("Invalid zone type");
return;
}

var entName = specifiedType == ZoneType.CELL ?
"info_player_terrorist" :
"info_player_counterterrorist";

var spawns = Utilities
.FindAllEntitiesByDesignerName<SpawnPoint>(entName)
.Where(s => s.AbsOrigin != null)
.Select(s => s.AbsOrigin!);

var generated = factory.CreateZone(spawns);
generated.Draw(plugin, specifiedType.Value.GetColor(), 120);
info.ReplyToCommand($"Drawing auto-generated {specifiedType} zone");
return;
}
}

Expand All @@ -219,7 +245,8 @@ private void

if (type.IsSinglePoint()) {
if (executor.PlayerPawn.Value?.AbsOrigin != null) {
var zone = factory.CreateZone([executor.PlayerPawn.Value.AbsOrigin!]);
var zone =
factory.CreateZone([executor.PlayerPawn.Value.AbsOrigin!.Clone()]);
zone.Draw(plugin, type.GetColor(), 1f);
Server.NextFrameAsync(async () => {
await zoneManager.PushZone(zone, type);
Expand Down Expand Up @@ -275,26 +302,21 @@ private void
return null;
}

var validZones = value.Where(zone
=> zone.IsInsideZone(player.PlayerPawn.Value!.AbsOrigin!))
.ToList();
var validZones = value.MinBy(z
=> z.GetMinDistanceSquared(player.PlayerPawn.Value!.AbsOrigin!));

switch (validZones.Count) {
case 0:
if (print) player.PrintToChat("No zones found");
return null;
case > 1:
if (print) player.PrintToChat("Multiple zones found.");
return null;
default:
return (validZones.First(), type.Value);
if (validZones == null) {
if (print) player.PrintToChat("No zones found");
return null;
}

return (validZones, type.Value);
}

private void sendUsage(CCSPlayerController player) {
player.PrintToChat("Usage: css_zone [add/set/remove/tp] [type]");
player.PrintToChat(ChatColors.Default
+ " css_zone [addinner/show/list] <type>");
player.PrintToChat(ChatColors.Default + " css_zone [finish/reload]");
player.PrintToChat("css_zone [addinner/show/list] <type>");
player.PrintToChat("css_zone [finish/reload]");
player.PrintToChat("css_zone generate [cell/armory]");
}
}
1 change: 1 addition & 0 deletions mod/Jailbreak.LastRequest/LastRequestCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.LastRequest;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.LastRequest;
Expand Down
6 changes: 3 additions & 3 deletions mod/Jailbreak.LastRequest/LastRequestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using CounterStrikeSharp.API.Modules.Menu;
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.LastRequest;
using Jailbreak.Public;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.Damage;
Expand Down Expand Up @@ -51,7 +51,7 @@ public bool ShouldBlockDamage(CCSPlayerController player,

if (playerLR == null != (attackerLR == null)) {
// One of them is in an LR
messages.DamageBlockedInsideLastRequest.ToPlayerCenter(attacker);
messages.DamageBlockedInsideLastRequest.ToCenter(attacker);
return true;
}

Expand All @@ -62,7 +62,7 @@ public bool ShouldBlockDamage(CCSPlayerController player,
// Same LR, allow damage
return false;

messages.DamageBlockedNotInSameLR.ToPlayerCenter(attacker);
messages.DamageBlockedNotInSameLR.ToCenter(attacker);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override void Execute() {
MenuManager.OpenChatMenu(Prisoner, chatMenu);
MenuManager.OpenChatMenu(Guard, chatMenu);

Plugin.AddTimer(RoundUtil.GetTimeRemaining() - 1, timeout,
Plugin.AddTimer(Math.Min(RoundUtil.GetTimeRemaining() - 1, 25), timeout,
TimerFlags.STOP_ON_MAPCHANGE);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CounterStrikeSharp.API.Core;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.LastRequest;
using Jailbreak.Public.Mod.LastRequest;
using Jailbreak.Public.Mod.LastRequest.Enums;
using Microsoft.Extensions.DependencyInjection;
Expand Down
10 changes: 5 additions & 5 deletions mod/Jailbreak.Mute/MuteSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Utils;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.Warden;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Extensions;
using Jailbreak.Public.Mod.Mute;
Expand Down Expand Up @@ -150,14 +150,14 @@ private void OnPlayerSpeak(int playerSlot) {

if (!player.PawnIsAlive && !bypassMute(player)) {
// Normal players can't speak when dead
messages!.DeadReminder.ToPlayerCenter(player);
messages!.DeadReminder.ToCenter(player);
mute(player);
return;
}

if (isMuted(player)) {
// Remind any muted players they're muted
messages!.MuteReminder.ToPlayerCenter(player);
messages!.MuteReminder.ToCenter(player);
return;
}

Expand All @@ -167,10 +167,10 @@ private void OnPlayerSpeak(int playerSlot) {
if (IsPeaceEnabled()) {
if (player.Team == CsTeam.CounterTerrorist && DateTime.Now >= ctPeaceEnd)
return;
messages!.PeaceReminder.ToPlayerCenter(player);
messages!.PeaceReminder.ToCenter(player);
}

if (!player.PawnIsAlive) messages!.AdminDeadReminder.ToPlayerCenter(player);
if (!player.PawnIsAlive) messages!.AdminDeadReminder.ToCenter(player);
}

private bool isMuted(CCSPlayerController player) {
Expand Down
1 change: 1 addition & 0 deletions mod/Jailbreak.SpecialDay/SpecialDayCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using CounterStrikeSharp.API.Modules.Menu;
using Jailbreak.Formatting.Extensions;
using Jailbreak.Formatting.Views;
using Jailbreak.Formatting.Views.Warden;
using Jailbreak.Public.Behaviors;
using Jailbreak.Public.Mod.SpecialDay;
using Jailbreak.Public.Mod.SpecialDay.Enums;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@

namespace Jailbreak.SpecialDay.SpecialDays;

public abstract class AbstractArmoryRestrictedDay(BasePlugin plugin,
IServiceProvider provider, CsTeam restrictedTeam = CsTeam.Terrorist)
: AbstractZoneRestrictedDay(plugin, provider, restrictedTeam) {
public abstract class AbstractArmoryRestrictedDay : AbstractZoneRestrictedDay {
private readonly IServiceProvider provider1;

protected AbstractArmoryRestrictedDay(BasePlugin plugin,
IServiceProvider provider,
CsTeam restrictedTeam = CsTeam.Terrorist) : base(plugin, provider,
restrictedTeam) {
provider1 = provider;
}

public override IView ZoneReminder => ArmoryReminder;

public virtual IView ArmoryReminder
Expand All @@ -23,7 +30,7 @@ public virtual IView ArmoryReminder


override protected IZone GetZone() {
var manager = provider.GetRequiredService<IZoneManager>();
var manager = provider1.GetRequiredService<IZoneManager>();
var zones = manager.GetZones(ZoneType.ARMORY).GetAwaiter().GetResult();
if (zones.Count > 0) return new MultiZoneWrapper(zones);

Expand Down
15 changes: 11 additions & 4 deletions mod/Jailbreak.SpecialDay/SpecialDays/AbstractCellRestrictedDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@

namespace Jailbreak.SpecialDay.SpecialDays;

public abstract class AbstractCellRestrictedDay(BasePlugin plugin,
IServiceProvider provider, CsTeam restrictedTeam = CsTeam.Terrorist)
: AbstractZoneRestrictedDay(plugin, provider, restrictedTeam) {
public abstract class AbstractCellRestrictedDay : AbstractZoneRestrictedDay {
private readonly IServiceProvider provider1;

protected AbstractCellRestrictedDay(BasePlugin plugin,
IServiceProvider provider,
CsTeam restrictedTeam = CsTeam.Terrorist) : base(plugin, provider,
restrictedTeam) {
provider1 = provider;
}

public override IView ZoneReminder => CellReminder;

public virtual IView CellReminder
Expand All @@ -22,7 +29,7 @@ public virtual IView CellReminder
new SimpleView { IsdLocale.PREFIX, "Stay in cells!" };

override protected IZone GetZone() {
var manager = provider.GetRequiredService<IZoneManager>();
var manager = provider1.GetRequiredService<IZoneManager>();
var zones = manager.GetZones(ZoneType.CELL).GetAwaiter().GetResult();
if (zones.Count > 0) return new MultiZoneWrapper(zones);

Expand Down
Loading

0 comments on commit 72129a9

Please sign in to comment.