public void Execute(IRocketPlayer caller, string[] command) { RocketPermissionsManager Permissions = R.Instance.GetComponent<RocketPermissionsManager>(); if (caller != null) { if (command.Length != 1) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("kick_usage")); return; } else if (command.Length == 1) { UnturnedPlayer Player = (UnturnedPlayer)caller; CSteamID ID = Player.CSteamID; UnturnedPlayer Target = UnturnedPlayer.FromName(command[0].ToLower()); CSteamID TargetID = Target.CSteamID; foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { RocketPermissionsGroup g = Permissions.GetGroup(Jobs.LeaderPermissionGroup); if (g.Members.Exists(k => k == ID.ToString())) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null && Group.Members.Exists(k => k == TargetID.ToString())) { Permissions.RemovePlayerFromGroup(Group.Id, Target); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_left_job", Jobs.JobName)); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_kicked", Target.DisplayName)); } } } } } }
public bool GroupExists(string group) { RocketPermissionsManager rocketPerms = R.Instance.GetComponent <RocketPermissionsManager>(); RocketPermissionsGroup rpGroup = rocketPerms.GetGroup(group); if (rpGroup == null) { return(false); } return(true); }
public void Execute(IRocketPlayer caller, string[] command) { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); if (caller != null) { UnturnedPlayer Player = (UnturnedPlayer)caller; CSteamID ID = Player.CSteamID; if (command.Length != 1) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("accept_usage")); return; } else if (command.Length == 1) { UnturnedPlayer Target = UnturnedPlayer.FromName(command[0].ToLower()); if (RocketJobs.Instance.Applications.ContainsKey(Target.CSteamID)) { string JobName = RocketJobs.Instance.Applications[Target.CSteamID]; foreach (PrivateJobs Job in RocketJobs.Instance.ConfigPrivJobs) { if (Job.JobName.ToLower() == JobName.ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.LeaderPermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { if (IDS == ID.ToString()) { Permissions.AddPlayerToGroup(Job.PermissionGroup, Target); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_accepted_application", Target.CharacterName)); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_quiet_joined_job", Job.JobName)); if (RocketJobs.Instance.Configuration.Instance.AnnounceJobJoin) { UnturnedChat.Say(RocketJobs.Instance.Translate("notification_global_joined_job", Target.CharacterName, Job.JobName)); } return; } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_not_leader_of_job", Job.JobName)); return; } } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_invalid_job_in_storage")); return; } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_player_not_applying")); return; } } }
public void RemoveFromGroup(UnturnedPlayer untPlayer, string group) { RocketPermissionsManager rocketPerms = R.Instance.GetComponent <RocketPermissionsManager>(); if (GroupExists(group)) { rocketPerms.RemovePlayerFromGroup(group, untPlayer); if (Config.LogChanges) { Logger.Log(Translate("log_rank_removed_from", untPlayer.DisplayName, untPlayer.Id, group)); } } }
public void Execute(IRocketPlayer caller, string[] command) { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); if (caller != null) { UnturnedPlayer Player = (UnturnedPlayer)caller; CSteamID ID = Player.CSteamID; foreach (PublicJobs Job in RocketJobs.Instance.ConfigPubJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { if (IDS == ID.ToString()) { Permissions.RemovePlayerFromGroup(Job.PermissionGroup, caller); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_left_job", Job.JobName)); return; } } } } foreach (PrivateJobs Job in RocketJobs.Instance.ConfigPrivJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { if (IDS == ID.ToString()) { Permissions.RemovePlayerFromGroup(Job.PermissionGroup, caller); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_left_job", Job.JobName)); return; } } } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_not_in_a_job")); } }
public void Execute(IRocketPlayer caller, string[] command) { if (caller != null) { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); UnturnedPlayer Player = (UnturnedPlayer)caller; CSteamID ID = Player.CSteamID; if (command.Length > 3 || command.Length < 2) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("admin_usage")); return; } else if (command.Length == 2) { if (command[0].ToLower() == "clear") { #region FindGroupAndClear foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Group.Members = new List <string>(); return; } return; } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Group.Members = new List <string>(); return; } return; } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[1].ToLower())); return; } else if (command[0].ToLower() == "add" || command[0].ToLower() == "remove") { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("admin_usage")); return; } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("admin_usage")); return; } else if (command.Length == 3) { if (command[0].ToLower() == "clear") { #region FindGroupAndClear foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Group.Members = new List <string>(); return; } return; } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Group.Members = new List <string>(); return; } return; } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[1].ToLower())); return; } else if (command[0].ToLower() == "add") { UnturnedPlayer Target = UnturnedPlayer.FromName(command[2].ToLower()); CSteamID TargetID = Target.CSteamID; #region PreventDoubleJoining foreach (PublicJobs Job in RocketJobs.Instance.ConfigPubJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string Members in Group.Members) { if (Members == TargetID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_in_a_job_admin")); return; } } } } foreach (PrivateJobs Job in RocketJobs.Instance.ConfigPrivJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string Members in Group.Members) { if (Members == TargetID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_in_a_job_admin")); return; } } } RocketPermissionsGroup Group2 = Permissions.GetGroup(Job.LeaderPermissionGroup); if (Group2 != null) { foreach (string IDS in Group2.Members) { if (IDS == ID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_leader_of_a_job_admin")); return; } } } } #endregion #region FindGroupAndAdd foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Permissions.AddPlayerToGroup(Jobs.PermissionGroup, Target); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_quiet_joined_job_admin", Target.CharacterName, Jobs.JobName)); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_quiet_joined_job", Jobs.JobName)); if (RocketJobs.Instance.Configuration.Instance.AnnounceJobJoin) { UnturnedChat.Say(RocketJobs.Instance.Translate("notification_global_joined_job", Target.CharacterName, Jobs.JobName)); } return; } return; } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Permissions.AddPlayerToGroup(Jobs.PermissionGroup, Target); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_quiet_joined_job_admin", Target.CharacterName, Jobs.JobName)); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_quiet_joined_job", Jobs.JobName)); if (RocketJobs.Instance.Configuration.Instance.AnnounceJobJoin) { UnturnedChat.Say(RocketJobs.Instance.Translate("notification_global_joined_job", Target.CharacterName, Jobs.JobName)); } return; } return; } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[1].ToLower())); return; } else if (command[0].ToLower() == "remove") { UnturnedPlayer Target = UnturnedPlayer.FromName(command[2].ToLower()); CSteamID TargetID = Target.CSteamID; #region FindGroupAndRemove foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { foreach (string Member in Group.Members) { if (Member == TargetID.ToString()) { Permissions.RemovePlayerFromGroup(Group.Id, Target); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_left_job", Jobs.JobName)); } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_player_not_in_job", Jobs.JobName)); return; } return; } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[1].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { foreach (string Member in Group.Members) { if (Member == TargetID.ToString()) { Permissions.RemovePlayerFromGroup(Group.Id, Target); UnturnedChat.Say(Target, RocketJobs.Instance.Translate("notification_left_job", Jobs.JobName)); } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_player_not_in_job", Jobs.JobName)); return; } return; } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[1].ToLower())); } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("admin_usage")); return; } } }
public void Execute(IRocketPlayer caller, string[] command) { if (RocketTools.Instance.Configuration.Instance.EnableRPermCommand) { if (caller is ConsolePlayer) { if (command.Length <= 1) { Logger.LogWarning(RocketTools.Instance.Translate("error_usage_rperm")); } else if (command.Length == 2 && command[0].ToLower() == "create") { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); RocketPermissionsGroup NewGroup = new RocketPermissionsGroup(command[1], command[1], "", new List <string>(), new List <Permission>(), "white"); NewGroup.Prefix = ""; NewGroup.Suffix = ""; RocketPermissionsGroup OldGroup = Permissions.GetGroup(command[1]); if (OldGroup == null) { switch (Permissions.AddGroup(NewGroup)) { case RocketPermissionsProviderResult.DuplicateEntry: Logger.LogWarning(RocketTools.Instance.Translate("error_duplicate_group", command[1])); break; case RocketPermissionsProviderResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_success_group_create", command[1])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (OldGroup != null) { Logger.LogWarning(RocketTools.Instance.Translate("error_duplicate_group", command[1])); } } else if (command.Length == 2 && command[0].ToLower() == "delete") { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); switch (Permissions.DeleteGroup(command[1])) { case RocketPermissionsProviderResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[1])); break; case RocketPermissionsProviderResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_success_group_delete", command[1])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 2 && command[0].ToLower() == "details") { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); RocketPermissionsGroup Group = Permissions.GetGroup(command[1]); if (Group == null) { Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[1])); return; } else if (Group != null) { List <string> details = RocketTools.Instance.URPerm.GetDetails(command[1]); Logger.LogWarning(RocketTools.Instance.Translate("notification_details_group", details[0], details[1], details[2], details[3], details[4], details[5], details[6], details[7])); } } else if (command.Length == 3 && command[0].ToLower() == "add") { switch (RocketTools.Instance.URPerm.AddPermission(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_permission_added", command[1], command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: Logger.LogWarning(RocketTools.Instance.Translate("error_duplicate_permission", command[2])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "remove") { switch (RocketTools.Instance.URPerm.RemovePermission(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_permission_removed", command[1], command[2])); break; case PermissionsHelper.PermissionHelperResult.PermissionNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_permission", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "color") { switch (RocketTools.Instance.URPerm.SetColor(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_color_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: Logger.LogWarning(RocketTools.Instance.Translate("error_same_color", command[2])); break; case PermissionsHelper.PermissionHelperResult.InvalidColor: Logger.LogWarning(RocketTools.Instance.Translate("error_invalid_color", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "prefix") { switch (RocketTools.Instance.URPerm.SetPrefix(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_prefix_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: Logger.LogWarning(RocketTools.Instance.Translate("error_same_prefix", command[2])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "suffix") { switch (RocketTools.Instance.URPerm.SetSuffix(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_suffix_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: Logger.LogWarning(RocketTools.Instance.Translate("error_same_suffix", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "displayname") { switch (RocketTools.Instance.URPerm.SetDisplayName(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_displayname_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: Logger.LogWarning(RocketTools.Instance.Translate("error_same_displayname", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "id") { switch (RocketTools.Instance.URPerm.SetID(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_id_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: Logger.LogWarning(RocketTools.Instance.Translate("error_same_id", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "parentgroup") { switch (RocketTools.Instance.URPerm.SetParentGroup(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_parentgroup_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: Logger.LogWarning(RocketTools.Instance.Translate("error_same_parentgroup", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "list") { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); RocketPermissionsGroup Group = Permissions.GetGroup(command[2]); switch (command[1].ToLower()) { case "permissions": case "perms": case "perm": case "p": case "permission": case "ps": if (Group == null) { Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); return; } else if (Group != null) { List <Permission> Perms = RocketTools.Instance.URPerm.GetPermissions(command[2]); if (Perms.Count == 0) { Logger.LogWarning(RocketTools.Instance.Translate("notification_list_no_perms")); return; } Logger.LogWarning(RocketTools.Instance.Translate("notification_list_start_perms", command[2])); foreach (Permission Perm in Perms) { Logger.LogWarning(RocketTools.Instance.Translate("notification_list_perms", Perm.Name, Perm.Cooldown)); } } break; case "m": case "members": case "mem": case "membs": case "memb": case "mems": case "ms": if (Group == null) { Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[2])); return; } else if (Group != null) { List <string> Members = RocketTools.Instance.URPerm.GetMembers(command[2]); if (Members.Count == 0) { Logger.LogWarning(RocketTools.Instance.Translate("notification_list_no_players")); return; } Logger.LogWarning(RocketTools.Instance.Translate("notification_list_start_players", command[2])); foreach (string Player in Members) { Logger.LogWarning(RocketTools.Instance.Translate("notification_list_players", Player)); } } break; } } else if (command.Length == 4 && command[0].ToLower() == "add") { switch (RocketTools.Instance.URPerm.AddPermission(command[1], Convert.ToUInt32(command[2]), command[3])) { case PermissionsHelper.PermissionHelperResult.Success: Logger.LogWarning(RocketTools.Instance.Translate("notification_permission_added", command[1], command[3])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: Logger.LogWarning(RocketTools.Instance.Translate("error_duplicate_permission", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: Logger.LogWarning(RocketTools.Instance.Translate("error_notfound_group", command[3])); break; default: Logger.LogWarning(RocketTools.Instance.Translate("error_unknown")); break; } } else { Logger.LogWarning(RocketTools.Instance.Translate("error_usage_rperm")); } } else if (!(caller is ConsolePlayer)) { if (command.Length <= 1) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_usage_rperm")); } else if (command.Length == 2 && command[0].ToLower() == "create") { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); RocketPermissionsGroup NewGroup = new RocketPermissionsGroup(command[1], command[1], "", new List <string>(), new List <Permission>(), "white"); NewGroup.Prefix = ""; NewGroup.Suffix = ""; RocketPermissionsGroup OldGroup = Permissions.GetGroup(command[1]); if (OldGroup == null) { switch (Permissions.AddGroup(NewGroup)) { case RocketPermissionsProviderResult.DuplicateEntry: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_duplicate_group", command[1])); break; case RocketPermissionsProviderResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_success_group_create", command[1])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (OldGroup != null) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_duplicate_group", command[1])); } } else if (command.Length == 2 && command[0].ToLower() == "delete") { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); switch (Permissions.DeleteGroup(command[1])) { case RocketPermissionsProviderResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[1])); break; case RocketPermissionsProviderResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_success_group_delete", command[1])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 2 && command[0].ToLower() == "details") { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); RocketPermissionsGroup Group = Permissions.GetGroup(command[1]); if (Group == null) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[1])); return; } else if (Group != null) { List <string> details = RocketTools.Instance.URPerm.GetDetails(command[1]); UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_details_group", details[0], details[1], details[2], details[3], details[4], details[5], details[6], details[7])); } } else if (command.Length == 3 && command[0].ToLower() == "add") { switch (RocketTools.Instance.URPerm.AddPermission(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_permission_added", command[1], command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_duplicate_permission", command[2])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "remove") { switch (RocketTools.Instance.URPerm.RemovePermission(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_permission_removed", command[1], command[2])); break; case PermissionsHelper.PermissionHelperResult.PermissionNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_permission", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "color") { switch (RocketTools.Instance.URPerm.SetColor(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_color_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_same_color", command[2])); break; case PermissionsHelper.PermissionHelperResult.InvalidColor: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_invalid_color", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "prefix") { switch (RocketTools.Instance.URPerm.SetPrefix(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_prefix_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_same_prefix", command[2])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "suffix") { switch (RocketTools.Instance.URPerm.SetSuffix(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_suffix_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_same_suffix", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "displayname") { switch (RocketTools.Instance.URPerm.SetDisplayName(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_displayname_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_same_displayname", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "id") { switch (RocketTools.Instance.URPerm.SetID(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_id_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_same_id", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "parentgroup") { switch (RocketTools.Instance.URPerm.SetParentGroup(command[1], command[2])) { case PermissionsHelper.PermissionHelperResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_parentgroup_change", command[2])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_same_parentgroup", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else if (command.Length == 3 && command[0].ToLower() == "list") { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); RocketPermissionsGroup Group = Permissions.GetGroup(command[2]); switch (command[1].ToLower()) { case "permissions": case "perms": case "perm": case "p": case "permission": case "ps": if (Group == null) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); return; } else if (Group != null) { List <Permission> Perms = RocketTools.Instance.URPerm.GetPermissions(command[2]); if (Perms.Count == 0) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_list_no_perms")); return; } UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_list_start_perms", command[2])); foreach (Permission Perm in Perms) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_list_perms", Perm.Name, Perm.Cooldown)); } } break; case "m": case "members": case "mem": case "membs": case "memb": case "mems": case "ms": if (Group == null) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[2])); return; } else if (Group != null) { List <string> Members = RocketTools.Instance.URPerm.GetMembers(command[2]); if (Members.Count == 0) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_list_no_players")); return; } UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_list_start_players", command[2])); foreach (string Player in Members) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_list_players", Player)); } } break; } } else if (command.Length == 4 && command[0].ToLower() == "add") { switch (RocketTools.Instance.URPerm.AddPermission(command[1], Convert.ToUInt32(command[2]), command[3])) { case PermissionsHelper.PermissionHelperResult.Success: UnturnedChat.Say(caller, RocketTools.Instance.Translate("notification_permission_added", command[1], command[3])); break; case PermissionsHelper.PermissionHelperResult.DuplicateEntry: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_duplicate_permission", command[1])); break; case PermissionsHelper.PermissionHelperResult.GroupNotFound: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_notfound_group", command[3])); break; default: UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_unknown")); break; } } else { UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_usage_rperm")); } } } else if (!RocketTools.Instance.Configuration.Instance.EnableRPermCommand) { if (caller is ConsolePlayer) { Logger.LogWarning("Command disabled by configuration setting."); } else if (!(caller is ConsolePlayer)) { UnturnedChat.Say(caller, RocketTools.Instance.Translate("error_command_disabled")); } } }
public void Execute(IRocketPlayer caller, string[] command) { if (caller != null) { RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); UnturnedPlayer Player = (UnturnedPlayer)caller; CSteamID ID = Player.CSteamID; if (command.Length != 1) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("join_apply_usage")); return; } else if (command.Length == 1) { #region PreventMakingMoreThan1Application if (RocketJobs.Instance.Applications.ContainsKey(Player.CSteamID)) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_applying")); } #endregion #region PreventDoubleJoining foreach (PublicJobs Job in RocketJobs.Instance.ConfigPubJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { if (IDS == ID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_in_a_job")); return; } } } if (Group == null) { Logger.LogWarning("Permission Group " + Job.PermissionGroup + " does not exist!"); } } foreach (PrivateJobs Job in RocketJobs.Instance.ConfigPrivJobs) { RocketPermissionsGroup Group = Permissions.GetGroup(Job.PermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { if (IDS == ID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_already_in_a_job")); return; } } } else if (Group == null) { Logger.LogWarning("Permission Group " + Job.PermissionGroup + " does not exist!"); } RocketPermissionsGroup Group2 = Permissions.GetGroup(Job.LeaderPermissionGroup); if (Group2 != null) { foreach (string IDS in Group2.Members) { if (IDS == ID.ToString()) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_leader_of_a_job")); return; } } } else if (Group2 == null) { Logger.LogWarning("Permission Group " + Job.LeaderPermissionGroup + " does not exist!"); } } #endregion #region FindAndJoin foreach (PublicJobs Jobs in RocketJobs.Instance.ConfigPubJobs) { if (Jobs.JobName.ToLower() == command[0].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.PermissionGroup); if (Group != null) { Permissions.AddPlayerToGroup(Jobs.PermissionGroup, caller); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_quiet_joined_job", Jobs.JobName)); if (RocketJobs.Instance.Configuration.Instance.AnnounceJobJoin) { UnturnedChat.Say(RocketJobs.Instance.Translate("notification_global_joined_job", Player.CharacterName, Jobs.JobName)); } return; } else if (Group == null) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_contact_admin")); Logger.LogWarning("Permission Group " + Jobs.PermissionGroup + " does not exist!"); } } } foreach (PrivateJobs Jobs in RocketJobs.Instance.ConfigPrivJobs) { if (Jobs.JobName.ToLower() == command[0].ToLower()) { RocketPermissionsGroup Group = Permissions.GetGroup(Jobs.LeaderPermissionGroup); if (Group != null) { foreach (string IDS in Group.Members) { foreach (SteamPlayer player in Provider.clients) { if (IDS == player.playerID.steamID.ToString()) { UnturnedPlayer target = UnturnedPlayer.FromCSteamID(player.playerID.steamID); RocketJobs.Instance.Applications.Add(ID, Jobs.JobName); UnturnedChat.Say(target, RocketJobs.Instance.Translate("notification_player_applying", Player.CharacterName)); UnturnedChat.Say(caller, RocketJobs.Instance.Translate("notification_applied_to_job", Jobs.JobName)); return; } } } UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_leader_offline", Jobs.JobName)); return; } else if (Group == null) { UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_contact_admin")); Logger.LogWarning("Permission Group " + Jobs.PermissionGroup + " does not exist!"); } } } #endregion UnturnedChat.Say(caller, RocketJobs.Instance.Translate("error_job_not_found", command[0].ToLower())); } } }
//Updates the UI public void UpdateUI(UnturnedPlayer p, bool firstsend = false) { short effectshortID = (short)Configuration.Instance.UIEffectID; if (firstsend) { EffectManager.sendUIEffect(Configuration.Instance.UIEffectID, effectshortID, p.CSteamID, true); } int admin_members_integer = 0; int police_members_integer = 0; int mechanic_members_integer = 0; int medic_members_integer = 0; string admin_members_string = null; string police_members_string = null; string mechanic_members_string = null; string medic_members_string = null; var config = Configuration.Instance; RocketPermissionsManager Permissions = R.Instance.GetComponent <RocketPermissionsManager>(); RocketPermissionsGroup group_pol = R.Permissions.GetGroup(config.PoliceGroup); RocketPermissionsGroup group_med = R.Permissions.GetGroup(config.MedicGroup); RocketPermissionsGroup group_mec = R.Permissions.GetGroup(config.MechanicGroup); RocketPermissionsGroup group_ad = R.Permissions.GetGroup(config.PoliceGroup); Provider.clients.ForEach(client => { string clientid = client.playerID.steamID.m_SteamID.ToString(); if (group_pol.Members.Contains(clientid)) { police_members_integer = police_members_integer + 1; } else if (group_med.Members.Contains(clientid)) { medic_members_integer = medic_members_integer + 1; } else if (group_mec.Members.Contains(clientid)) { mechanic_members_integer = mechanic_members_integer + 1; } else if (group_ad.Members.Contains(clientid) || client.isAdmin) { admin_members_integer = admin_members_integer + 1; } }); if (config.ShowOfflineMembersFromtheGroup) { police_members_string = police_members_integer.ToString() + "/" + group_pol.Members.Count; medic_members_string = medic_members_integer.ToString() + "/" + group_med.Members.Count; mechanic_members_string = mechanic_members_integer.ToString() + "/" + group_mec.Members.Count; admin_members_string = admin_members_integer.ToString() + "/" + group_ad.Members.Count; } else { police_members_string = police_members_integer.ToString(); medic_members_string = medic_members_integer.ToString(); mechanic_members_string = mechanic_members_integer.ToString(); admin_members_string = admin_members_integer.ToString(); } EffectManager.sendUIEffectText(effectshortID, p.CSteamID, true, "police_members_count_text", Translate("ui_text", Translate("police"), police_members_string)); EffectManager.sendUIEffectText(effectshortID, p.CSteamID, true, "medic_members_count_text", Translate("ui_text", Translate("medic"), medic_members_string)); EffectManager.sendUIEffectText(effectshortID, p.CSteamID, true, "mechanic_members_count_text", Translate("ui_text", Translate("mechanic"), mechanic_members_string)); EffectManager.sendUIEffectText(effectshortID, p.CSteamID, true, "admin_members_count_text", Translate("ui_text", Translate("admin"), admin_members_string)); }