-
-
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
Closed
Closed
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
01d159a
Add team switch listener, fix log assignment (#40) (#41)
MSWS decf532
css_peace / first warden assigned mute
invalid-email-address f666467
added css_peace command cooldown / code cleanup
invalid-email-address b2fc6bd
css_peace cooldown added\nrevamped half of the system\nadded a flag c…
invalid-email-address 2fa50af
API documentation
invalid-email-address 4c5d809
readonly on notification classes prefixes
invalid-email-address 1981bfa
Code overhaul
invalid-email-address b048cf4
remove code repetition
invalid-email-address 535ccdf
fix
invalid-email-address fa4c17d
more logic fixes..
invalid-email-address a523859
tweaks
invalid-email-address e9b9fad
Merge branch 'dev' into mute-system
P250 fffe439
logic fixes
invalid-email-address bf043bd
Merge branch 'mute-system' of https://github.com/P250/Jailbreak into …
invalid-email-address eff7b35
admins can speak over peacemute
invalid-email-address 2dda935
tiny thing?
invalid-email-address File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." )}" }; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
mod/Jailbreak.Warden/Commands/WardenPeaceCommandsBehavior.cs
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
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; | ||
|
||
public WardenPeaceCommandsBehavior(IWardenPeaceService peaceService, IEventsService eventsService, IWardenPeaceNotifications wardenPeaceNotifications) | ||
{ | ||
_peaceService = peaceService; | ||
_eventsService = eventsService; | ||
_wardenPeaceNotifications = wardenPeaceNotifications; | ||
|
||
Func<bool> wardenDeathCallback = () => | ||
{ | ||
_peaceService.UnmutePrevMutedAlivePlayers(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 OR ADMIN to be able to run this! | ||
if (!_peaceService.IsWarden(invoker) || !AdminManager.PlayerHasPermissions(invoker, "@css/generic")) return; | ||
|
||
// we still need if css_peace command mute is active in a team because it may have ended because of various things but the cooldown wouldn't have expired yet. | ||
if (_peaceService.IsMuteActiveInTeam(CsTeam.CounterTerrorist) && (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", "@css/generic")] | ||
public void Command_UnPeace(CCSPlayerController? invoker, CommandInfo command) | ||
{ | ||
if (invoker == null) return; | ||
// this does nothing to teams that don't have any mutes, see the documentation for UnmutePrevMutedPlayers | ||
_peaceService.UnmutePrevMutedAlivePlayers(MuteReason.ADMIN_REMOVED_PEACEMUTE, CsTeam.Terrorist, CsTeam.CounterTerrorist, CsTeam.Spectator, CsTeam.None); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I should make make it readonly for all of them :P