-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
css_peace / first warden mute #69
Changes from 4 commits
01d159a
decf532
f666467
b2fc6bd
2fa50af
4c5d809
1981bfa
b048cf4
535ccdf
fa4c17d
a523859
e9b9fad
fffe439
bf043bd
eff7b35
2dda935
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
|
||
using Jailbreak.Formatting.Base; | ||
using Jailbreak.Formatting.Core; | ||
using Jailbreak.Formatting.Logistics; | ||
|
@@ -11,7 +10,7 @@ namespace Jailbreak.English.Warden; | |
|
||
public class WardenNotifications : IWardenNotifications, ILanguage<Formatting.Languages.English> | ||
{ | ||
public static FormatObject PREFIX = new HiddenFormatObject($" {ChatColors.Lime}[{ChatColors.Green}WARDEN{ChatColors.Lime}]") | ||
public static readonly FormatObject WARDEN_PREFIX = new HiddenFormatObject($" {ChatColors.Lime}[{ChatColors.Green}WARDEN{ChatColors.Lime}]") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should make make it readonly for all of them :P |
||
{ | ||
// Hide in panorama and center text | ||
Plain = false, | ||
|
@@ -22,43 +21,43 @@ public class WardenNotifications : IWardenNotifications, ILanguage<Formatting.La | |
public IView PICKING_SHORTLY => | ||
new SimpleView | ||
{ | ||
{ PREFIX, "Picking a warden shortly" }, SimpleView.NEWLINE, | ||
{ PREFIX, "To enter the warden queue, type !warden in chat." } | ||
{ WARDEN_PREFIX, "Picking a warden shortly" }, SimpleView.NEWLINE, | ||
{ WARDEN_PREFIX, "To enter the warden queue, type !warden in chat." } | ||
}; | ||
|
||
public IView NO_WARDENS => | ||
new SimpleView { PREFIX, "No wardens in queue! The next player to run !warden will become a warden." }; | ||
new SimpleView { WARDEN_PREFIX, "No wardens in queue! The next player to run !warden will become a warden." }; | ||
|
||
public IView WARDEN_LEFT => | ||
new SimpleView { PREFIX, "The warden has left the game!" }; | ||
new SimpleView { WARDEN_PREFIX, "The warden has left the game!" }; | ||
|
||
public IView WARDEN_DIED => | ||
new SimpleView { PREFIX, "The warden has died!" }; | ||
new SimpleView { WARDEN_PREFIX, "The warden has died!" }; | ||
|
||
public IView BECOME_NEXT_WARDEN => | ||
new SimpleView { PREFIX, "Type !warden to become the next warden" }; | ||
new SimpleView { WARDEN_PREFIX, "Type !warden to become the next warden" }; | ||
|
||
public IView JOIN_RAFFLE => | ||
new SimpleView { PREFIX, "You've joined the warden raffle!" }; | ||
new SimpleView { WARDEN_PREFIX, "You've joined the warden raffle!" }; | ||
|
||
public IView LEAVE_RAFFLE => | ||
new SimpleView { PREFIX, "You've left the warden raffle!" }; | ||
new SimpleView { WARDEN_PREFIX, "You've left the warden raffle!" }; | ||
|
||
public IView PASS_WARDEN(CCSPlayerController player) | ||
{ | ||
return new SimpleView { PREFIX, player, "has resigned from being warden!" }; | ||
return new SimpleView { WARDEN_PREFIX, player, "has resigned from being warden!" }; | ||
} | ||
|
||
public IView NEW_WARDEN(CCSPlayerController player) | ||
{ | ||
return new SimpleView { PREFIX, player, "is now the warden!" }; | ||
return new SimpleView { WARDEN_PREFIX, player, "is now the warden!" }; | ||
} | ||
|
||
public IView CURRENT_WARDEN(CCSPlayerController? player) | ||
{ | ||
if (player is not null) | ||
return new SimpleView { PREFIX, "The current warden is", player }; | ||
return new SimpleView { WARDEN_PREFIX, "The current warden is", player }; | ||
else | ||
return new SimpleView { PREFIX, "There is currently no warden!" }; | ||
return new SimpleView { WARDEN_PREFIX, "There is currently no warden!" }; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Jailbreak.Formatting.Base; | ||
using Jailbreak.Formatting.Logistics; | ||
using Jailbreak.Formatting.Views; | ||
using static Jailbreak.English.Warden.WardenNotifications; | ||
using static Jailbreak.English.Generic.GenericCommandNotifications; | ||
|
||
namespace Jailbreak.English.Warden; | ||
|
||
// todo add player name in notification and style it with colour | ||
public class WardenPeaceNotifications : IWardenPeaceNotifications, ILanguage<Formatting.Languages.English> | ||
{ | ||
|
||
public IView PLAYERS_MUTED_VIACMD => | ||
new SimpleView { WARDEN_PREFIX, "Prisoners and Guards are silenced for 10 seconds." }; | ||
|
||
public IView PLAYERS_UNMUTED_VIACMD => | ||
new SimpleView { WARDEN_PREFIX, "Prisoners and Guards can speak again."}; | ||
|
||
public IView PRISONERS_MUTED_STARTROUND => | ||
new SimpleView { GENERIC_PREFIX, "Prisoners are muted for 45 seconds."}; | ||
|
||
public IView PRISONERS_UNMUTED_STARTROUND => | ||
new SimpleView { GENERIC_PREFIX, "Prisoners can speak again." }; | ||
|
||
public IView PLAYERS_MUTED_FIRSTWARDEN => | ||
new SimpleView { GENERIC_PREFIX, "Prisoners and Guards are automatically silenced for 10 seconds."}; | ||
|
||
public IView PLAYERS_UNMUTED_FIRSTWARDEN => | ||
new SimpleView { GENERIC_PREFIX, "Prisoners and Guards can speak again." }; | ||
|
||
public IView PLAYERS_WARDEN_DIED => | ||
new SimpleView { GENERIC_PREFIX, "Warden is dead. Players can speak again." }; | ||
|
||
public IView PLAYERS_UNMUTED_ADMINCMD => | ||
new SimpleView { GENERIC_PREFIX, "An admin has removed the warden mute." }; | ||
|
||
public IView PLAYERS_UNMUTED_ROUNDEND => | ||
new SimpleView { GENERIC_PREFIX, "All players unmuted due to round end." }; | ||
|
||
public IView CSS_PEACE_COOLDOWN(float cooldownTime) | ||
{ | ||
return new SimpleView { GENERIC_PREFIX, $"You\'re on cooldown for {Math.Ceiling(cooldownTime)} second{((Math.Ceiling(cooldownTime) == 1) ? "." : "s." )}" }; | ||
} | ||
|
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,13 @@ | |
using Jailbreak.Formatting.Views; | ||
using Jailbreak.Public.Behaviors; | ||
using Jailbreak.Public.Extensions; | ||
using Jailbreak.Public.Mod.Logs; | ||
using Jailbreak.Public.Mod.Rebel; | ||
|
||
namespace Jailbreak.Rebel; | ||
|
||
public class RebelManager : IPluginBehavior, IRebelService | ||
{ | ||
private IRebelNotifications notifs; | ||
//private IRebelNotifications notifs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused variable? :) |
||
private readonly IRichLogService _logs; | ||
private readonly IRebelNotifications _notifs; | ||
private readonly Dictionary<CCSPlayerController, long> _rebelTimes = new(); | ||
|
@@ -121,7 +120,7 @@ public bool MarkRebel(CCSPlayerController player, long time = 120) | |
|
||
public void UnmarkRebel(CCSPlayerController player) | ||
{ | ||
notifs.NO_LONGER_REBEL.ToPlayerChat(player); | ||
_notifs.NO_LONGER_REBEL.ToPlayerChat(player); | ||
_logs.Append(_logs.Player(player), "is no longer a rebel."); | ||
|
||
_rebelTimes.Remove(player); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a cooldown to the command? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using CounterStrikeSharp.API.Core.Attributes.Registration; | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Modules.Commands; | ||
using Jailbreak.Public.Behaviors; | ||
using Jailbreak.Public.Mod.Warden; | ||
using Jailbreak.Public.Mod.Plugin; | ||
using Jailbreak.Warden.Global; | ||
using Jailbreak.Formatting.Views; | ||
using Jailbreak.Formatting.Extensions; | ||
using static Jailbreak.Public.Mod.Warden.PeaceMuteOptions; | ||
using CounterStrikeSharp.API.Modules.Admin; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
|
||
namespace Jailbreak.Warden.Commands; | ||
|
||
public class WardenPeaceCommandsBehavior : IPluginBehavior | ||
{ | ||
|
||
private readonly IWardenPeaceService _peaceService; | ||
private readonly IWardenPeaceNotifications _wardenPeaceNotifications; | ||
private readonly IEventsService _eventsService; | ||
|
||
private DateTime _lastUsedTime = DateTime.Now; | ||
|
||
public WardenPeaceCommandsBehavior(IWardenPeaceService peaceService, IEventsService eventsService, IWardenPeaceNotifications wardenPeaceNotifications) | ||
{ | ||
_peaceService = peaceService; | ||
_eventsService = eventsService; | ||
_wardenPeaceNotifications = wardenPeaceNotifications; | ||
|
||
Func<bool> wardenDeathCallback = () => | ||
{ | ||
|
||
_peaceService.UnmutePrevMutedPlayers(MuteReason.WARDEN_DIED, CsTeam.Terrorist, CsTeam.CounterTerrorist); | ||
return true; | ||
}; | ||
|
||
_eventsService.RegisterEventListener("warden_death_event", wardenDeathCallback); | ||
|
||
} | ||
|
||
[ConsoleCommand("css_peace", "Gives everybody some peace of mind by muting Prisoners/Guards for 10 seconds (warden is exempt from this).")] | ||
[CommandHelper(0, "", CommandUsage.CLIENT_ONLY)] | ||
public void Command_Peace(CCSPlayerController? invoker, CommandInfo command) | ||
{ | ||
|
||
if (invoker == null) return; | ||
|
||
// we only want the warden to be able to run this! | ||
if (!_peaceService.IsWarden(invoker)) return; | ||
|
||
// i.e. if the peace mute is active AND we have a cooldown. | ||
// we still need if css_peace command mute is active because it may have ended because of css_unpeace, warden dying, round ending... | ||
if (_peaceService.GetPeaceMuteActive() && (DateTime.Now - _lastUsedTime).Seconds < WardenPeaceBehaviour._commandMuteTime) | ||
{ | ||
_wardenPeaceNotifications.CSS_PEACE_COOLDOWN(WardenPeaceBehaviour._commandMuteTime - (DateTime.Now - _lastUsedTime).Seconds).ToAllChat(); | ||
return; | ||
} | ||
|
||
PeaceMuteOptions options = new PeaceMuteOptions(MuteReason.CSS_PEACE, WardenPeaceBehaviour._commandMuteTime, CsTeam.Terrorist, CsTeam.CounterTerrorist); | ||
_peaceService.PeaceMute(options); | ||
_lastUsedTime = DateTime.Now; | ||
|
||
} | ||
|
||
[ConsoleCommand("css_unpeace", "Lets the admins remove the warden mute.")] | ||
[CommandHelper(0, "", CommandUsage.CLIENT_ONLY)] | ||
[RequiresPermissionsOr("@css/ban", "@css/kick")] | ||
public void Command_UnPeace(CCSPlayerController? invoker, CommandInfo command) | ||
{ | ||
if (invoker == null) return; | ||
if (!_peaceService.GetPeaceMuteActive()) { return; } | ||
//if (_peaceService.IsWarden(invoker)) { return; } // todo please uncomment this, I was testing | ||
_peaceService.UnmutePrevMutedPlayers(MuteReason.ADMIN_REMOVED_PEACEMUTE, CsTeam.Terrorist, CsTeam.CounterTerrorist, CsTeam.Spectator, CsTeam.None); | ||
|
||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed all prefix's so I can statically include them in my Notification implementation