public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { WatchListTranslation watchListTranslation = Plugin.Singleton.Config.Translation.WatchListTranslation; if (!sender.CheckPermission("ms.watchlist")) { response = watchListTranslation.InvalidPermission.Replace("{duration}", "ms.watchlist"); return(false); } if (arguments.Count == 0 || (arguments.Count == 1 && arguments.At(0) == "add")) { response = watchListTranslation.WrongUsage; return(false); } switch (arguments.At(0)) { case "add": string reason = string.Join(" ", arguments.Skip(2).Take(arguments.Count - 1)); if (string.IsNullOrEmpty(reason)) { response = watchListTranslation.ReasonNull; return(false); } HashSet <Collections.Player> targets = new(); if (arguments.At(0).Split(',').Length > 1) { foreach (var player in arguments.At(0).Split(',')) { Collections.Player dPlayer = player.GetPlayer(); if (dPlayer is null) { response = watchListTranslation.PlayerNotFound.Replace("{target}", player); continue; } if (targets.Contains(dPlayer)) { continue; } targets.Add(dPlayer); } } else { Collections.Player dPlayer = arguments.At(0).GetPlayer(); if (dPlayer == null) { response = watchListTranslation.PlayerNotFound.Replace("{player}", arguments.At(0)); return(false); } if (!targets.Contains(dPlayer)) { targets.Add(dPlayer); } } foreach (var player in targets) { ModerationSystemAPI.ApplyPunish(Player.Get(arguments.At(1)), ((CommandSender)sender).GetStaffer(), player, PunishType.WatchList, reason, DateTime.MinValue.ToString(CultureInfo.InvariantCulture)); response = watchListTranslation.PlayerAddedWatchlist.Replace("{player.name}", player.Name) .Replace("{player.userid}", $"{player.Id}@{player.Authentication}"); } break; case "list": if (arguments.Count == 1) { response = ModerationSystemAPI.GetWatchList(null); return(true); } Collections.Player target = arguments.At(1).GetPlayer(); if (target == null) { response = watchListTranslation.PlayerNotFound; return(false); } response = ModerationSystemAPI.GetWatchList(target); return(true); default: response = watchListTranslation.ActionNotFounded; return(false); } response = ""; return(true); }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { MuteTranslation muteTranslation = Plugin.Singleton.Config.Translation.MuteTranslation; if (!sender.CheckPermission("ms.mute")) { response = muteTranslation.InvalidPermission.Replace("{permission}", "ms.mute"); return(false); } if (arguments.Count < 2) { response = muteTranslation.WrongUsage; return(false); } HashSet <Collections.Player> targets = new(); if (arguments.At(0).Split(',').Length > 1) { foreach (var player in arguments.At(0).Split(',')) { Collections.Player target = player.GetPlayer(); if (target is null) { response = muteTranslation.PlayerNotFound.Replace("{target}", player); continue; } if (targets.Contains(target)) { continue; } targets.Add(target); } } else { Collections.Player dPlayer = arguments.At(0).GetPlayer(); if (dPlayer == null) { response = muteTranslation.PlayerNotFound.Replace("{player}", arguments.At(0)); return(false); } if (!targets.Contains(dPlayer)) { targets.Add(dPlayer); } } DateTime?duration = ModerationSystemAPI.ConvertToDateTime(arguments.At(1)); if (duration == null) { response = muteTranslation.InvalidDuration.Replace("{duration}", arguments.At(1)); return(false); } string reason = string.Join(" ", arguments.Skip(2).Take(arguments.Count - 2)); if (string.IsNullOrEmpty(reason)) { response = muteTranslation.ReasonNull; return(false); } if (!ModerationSystemAPI.MaxDuration(arguments.At(1), Player.Get(sender))) { response = "You can't do this duration"; return(false); } foreach (var dPlayer in targets) { if (dPlayer.IsMuted()) { response = muteTranslation.PlayerAlreadyMuted; return(false); } ModerationSystemAPI.ApplyPunish(Player.Get($"{dPlayer.Id}@{dPlayer.Authentication}"), ((CommandSender)sender).GetStaffer(), dPlayer, PunishType.Mute, reason, arguments.At(1)); ModerationSystemAPI.SendBroadcast(new Exiled.API.Features.Broadcast(Plugin.Singleton.Config.Translation.StaffTranslation.StaffMuteMessage.Content.Replace("{staffer}", sender.LogName).Replace("{target}", $"{dPlayer.Name} {dPlayer.Id}{dPlayer.Authentication}").Replace("{reason}", reason).Replace("{time}", duration.ToString()))); response = muteTranslation.PlayerMuted.Replace("{player.name}", dPlayer.Name).Replace("{player.userid}", $"{dPlayer.Id}@{dPlayer.Authentication}").Replace("{duration}", duration.ToString()).Replace("{reason}", reason); } response = ""; return(true); }
public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response) { WarnTranslation warnTranslation = Plugin.Singleton.Config.Translation.WarnTranslation; if (!sender.CheckPermission("ms.warn")) { response = warnTranslation.InvalidPermission.Replace("{permission}", "ms.warn"); return(false); } if (arguments.Count < 1) { response = warnTranslation.WrongUsage; return(false); } List <Collections.Player> targets = new(); if (arguments.At(0).Split(',').Length > 1) { foreach (var player in arguments.At(0).Split(',')) { Collections.Player target = player.GetPlayer(); if (target is null) { response = warnTranslation.PlayerNotFound.Replace("{target}", player); return(false); } if (targets.Contains(target)) { continue; } targets.Add(target); } } else { Collections.Player dPlayer = arguments.At(0).GetPlayer(); if (dPlayer == null) { response = warnTranslation.PlayerNotFound.Replace("{player}", arguments.At(0)); return(false); } if (!targets.Contains(dPlayer)) { targets.Add(dPlayer); } } string reason = string.Join(" ", arguments.Skip(1).Take(arguments.Count - 1)); if (string.IsNullOrEmpty(reason)) { response = warnTranslation.ReasonNull; return(false); } foreach (var target in targets) { ModerationSystemAPI.ApplyPunish(Player.Get($"{target.Id}@{target.Authentication}"), ((CommandSender)sender).GetStaffer(), target, PunishType.Warn, reason, DateTime.MinValue.ToString(CultureInfo.InvariantCulture)); ModerationSystemAPI.SendBroadcast(new Exiled.API.Features.Broadcast(Plugin.Singleton.Config.Translation.StaffTranslation.StaffWarnMessage.Content.Replace("{staffer}", sender.LogName).Replace("{target}", $"{target.Name} {target.Id}{target.Authentication}").Replace("{reason}", reason))); } response = warnTranslation.PlayerWarned; return(true); }