From 37e44332f306b93cbfc4c9825e4616f053371a62 Mon Sep 17 00:00:00 2001 From: destoer Date: Mon, 22 Jan 2024 16:52:33 +0000 Subject: [PATCH] implement command localization --- lang/en.json | 32 +++++++++++++++++++++++- src/Jail.cs | 53 +++++++++++++++++++++++----------------- src/Warden/JailPlayer.cs | 8 +++++- src/Warden/Warden.cs | 16 ++++++++++++ 4 files changed, 84 insertions(+), 25 deletions(-) diff --git a/lang/en.json b/lang/en.json index 961e585..0b8c0c1 100644 --- a/lang/en.json +++ b/lang/en.json @@ -27,6 +27,27 @@ "warden.gun_menu_disabled": "Gun menu is disabled!", "warden.no_warden": "Their is no warden", "warden.time": "Warden has been active for {0} minutes", + "warden.fire_guard" : "Firing guards", + + "warden.take_warden_cmd": "w", + "warden.leave_warden_cmd": "uw", + "warden.remove_warden_cmd": "rw", + "warden.fire_guard_cmd": "fire_guard", + "warden.remove_marker_cmd": "remove_marker", + "warden.marker_colour_cmd": "marker_colour", + "warden.laser_colour_cmd": "laser_colour", + "warden.gun_cmd": "guns", + "warden.time_cmd": "wtime", + "warden.list_cmd": "wcommands", + "warden.warday_cmd": "wd", + "warden.swap_guard_cmd": "swap_guard", + "warden.no_block_cmd": "wub", + "warden.block_cmd": "wb", + "warden.force_open_cmd": "force_open", + "warden.force_close_cmd": "force_close", + "warden.sd_cmd": "wsd", + "warden.sd_ff_cmd": "wsd_ff", + "mute.thirty": "All t's are muted for the first 30 seconds", "mute.speak_quietly": "T's may now speak quietly", @@ -67,6 +88,11 @@ "sd.tank_start": "Tank day started", "sd.tank_end": "Tank day ended", "sd.tank": "{0} is the tank!", + + "sd.start_cmd": "sd", + "sd.start_ff_cmd": "sd_ff", + "sd.cancel_cmd": "sd_cancel", + "lr.rebel_last": "You must be the last player alive to rebel", "lr.riot_start": "A riot has started! CT's have 15 seconds to hide", @@ -80,5 +106,9 @@ "lr.player_rebel": "{0} is a rebel!", "lr.knife_rebel": "{0} is knife a rebel!", "lr.ready": "Last request is available! Type !lr", - "lr.wait": "Please wait 15 seconds into the round before starting an lr" + "lr.wait": "Please wait 15 seconds into the round before starting an lr", + + "lr.cancel_lr_cmd": "cancel_lr", + "lr.start_lr_cmd": "lr", + "lr.stats_cmd": "lr_stats" } diff --git a/src/Jail.cs b/src/Jail.cs index 1c7ba9d..3776523 100644 --- a/src/Jail.cs +++ b/src/Jail.cs @@ -261,43 +261,50 @@ void register_listener() }); } + void add_localized_cmd(String base_name,String desc,CommandInfo.CommandCallback callback) + { + AddCommand("css_" + Localizer[base_name],desc,callback); + } + void register_commands() { // reg warden comamnds - AddCommand("w", "take warden", warden.take_warden_cmd); - AddCommand("uw", "leave warden", warden.leave_warden_cmd); - AddCommand("rw", "remove warden", warden.remove_warden_cmd); - AddCommand("clear_marker", "remove warden marker",warden.remove_marker_cmd); + add_localized_cmd("warden.take_warden_cmd", "take warden", warden.take_warden_cmd); + add_localized_cmd("warden.leave_warden_cmd", "leave warden", warden.leave_warden_cmd); + add_localized_cmd("warden.remove_warden_cmd", "remove warden", warden.remove_warden_cmd); + add_localized_cmd("warden.remove_marker_cmd","remove warden marker",warden.remove_marker_cmd); + + add_localized_cmd("warden.marker_colour_cmd", "set marker colour", warden.marker_colour_cmd); + add_localized_cmd("warden.laser_colour_cmd", "set laser colour", warden.laser_colour_cmd); - AddCommand("marker_colour", "set laser colour", warden.marker_colour_cmd); - AddCommand("laser_colour", "set laser colour", warden.laser_colour_cmd); + add_localized_cmd("warden.no_block_cmd","warden : disable block",warden.wub_cmd); + add_localized_cmd("warden.block_cmd","warden : enable block",warden.wb_cmd); - AddCommand("wub","warden : disable block",warden.wub_cmd); - AddCommand("wb","warden : enable block",warden.wb_cmd); + add_localized_cmd("warden.sd_cmd","warden : call a special day",sd.warden_sd_cmd); + add_localized_cmd("warden.sd_ff_cmd","warden : call a friendly fire special day",sd.warden_sd_ff_cmd); - AddCommand("wsd","warden : call a special day",sd.warden_sd_cmd); - AddCommand("wsd_ff","warden : call a friendly fire special day",sd.warden_sd_ff_cmd); + add_localized_cmd("warden.swap_guard","admin : move a player to ct",warden.swap_guard_cmd); - AddCommand("swap_guard","admin : move a player to ct",warden.swap_guard_cmd); + add_localized_cmd("warden.warday_cmd","warden : start warday",warden.warday_cmd); + add_localized_cmd("warden.list_cmd", "warden : show all commands",warden.cmd_info); + add_localized_cmd("warden.time_cmd","how long as warden been active?",warden.warden_time_cmd); - AddCommand("wd","warden : start warday",warden.warday_cmd); - AddCommand("wcommands", "warden : show all commands",warden.cmd_info); - AddCommand("wtime","how long as warden been active?",warden.warden_time_cmd); + add_localized_cmd("warden.gun_cmd","give ct guns",warden.cmd_ct_guns); - AddCommand("guns","give ct guns",warden.cmd_ct_guns); + add_localized_cmd("warden.force_open_cmd","force open every door and vent",warden.force_open_cmd); + add_localized_cmd("warden.force_close_cmd","force close every door",warden.force_close_cmd); - AddCommand("force_open","force open every door and vent",warden.force_open_cmd); - AddCommand("force_close","force close every door",warden.force_close_cmd); + add_localized_cmd("warden.fire_guard_cmd","admin : Remove all guards apart from warden",warden.fire_guard_cmd); // reg lr commands - AddCommand("lr","start an lr",lr.lr_cmd); - AddCommand("cancel_lr","admin : cancel lr",lr.cancel_lr_cmd); - AddCommand("lr_stats","list lr stats",jail_stats.lr_stats_cmd); + add_localized_cmd("lr.start_lr_cmd","start an lr",lr.lr_cmd); + add_localized_cmd("lr.cancel_lr_cmd","admin : cancel lr",lr.cancel_lr_cmd); + add_localized_cmd("lr.stats_cmd","list lr stats",jail_stats.lr_stats_cmd); // reg sd commands - AddCommand("sd","start a sd",sd.sd_cmd); - AddCommand("sd_ff","start a ff sd",sd.sd_ff_cmd); - AddCommand("cancel_sd","cancel an sd",sd.cancel_sd_cmd); + add_localized_cmd("sd.start_cmd","start a sd",sd.sd_cmd); + add_localized_cmd("sd.start_ff_cmd","start a ff sd",sd.sd_ff_cmd); + add_localized_cmd("sd.cancel_cmd","cancel an sd",sd.cancel_sd_cmd); AddCommandListener("jointeam",join_team); diff --git a/src/Warden/JailPlayer.cs b/src/Warden/JailPlayer.cs index 7c26beb..74d569c 100644 --- a/src/Warden/JailPlayer.cs +++ b/src/Warden/JailPlayer.cs @@ -238,6 +238,12 @@ public void reset() public void set_rebel(CCSPlayerController? player) { + // allready a rebel don't care + if(is_rebel) + { + return; + } + if(JailPlugin.event_active()) { return; @@ -260,7 +266,7 @@ public void set_rebel(CCSPlayerController? player) { if(config.colour_rebel) { - Lib.announce(REBEL_PREFIX,$"{} is a rebel",player.PlayerName); + Lib.announce(REBEL_PREFIX,$"{player.PlayerName} is a rebel"); player.set_colour(Lib.RED); } is_rebel = true; diff --git a/src/Warden/Warden.cs b/src/Warden/Warden.cs index d3f0f4e..88146e0 100644 --- a/src/Warden/Warden.cs +++ b/src/Warden/Warden.cs @@ -499,6 +499,22 @@ public void warden_death() remove_warden(); } + [RequiresPermissions("@css/generic")] + public void fire_guard_cmd(CCSPlayerController? invoke, CommandInfo command) + { + Lib.localise_announce(WARDEN_PREFIX,"warden.fire_guard"); + + // swap every guard apart from warden to T + List players = Utilities.GetPlayers(); + var valid = players.FindAll(player => player.is_valid() && player.is_ct() && !is_warden(player)); + + foreach(var player in valid) + { + player.slay(); + player.SwitchTeam(CsTeam.Terrorist); + } + } + public void death(CCSPlayerController? player, CCSPlayerController? killer) { // player is no longer on server