public string[] OnCall(ICommandSender sender, string[] args) { Player caller = (sender is Player send) ? send : null; Server server = PluginManager.Manager.Server; const DamageType killType = DamageType.NONE; AdminToolbox.AddMissingPlayerVariables(); if (args.Length > 0) { if (args[0].ToLower() == "all" || args[0].ToLower() == "*") { int playerNum = 0; foreach (Player pl in server.GetPlayers()) { if (server.GetPlayers().Count > 1) { if (caller != null && pl.PlayerId == caller.PlayerId || (AdminToolbox.playerdict.ContainsKey(pl.SteamId) && AdminToolbox.playerdict[pl.SteamId].godMode) || pl.GetGodmode() /*|| (caller.GetUserGroup().Permissions < pl.GetUserGroup().Permissions)*/) { continue; } } pl.Kill(killType); playerNum++; } if (caller != null && !string.IsNullOrEmpty(caller.Name) && caller.Name.ToLower() != "server") { plugin.Info(caller.Name + " ran the \"SLAY\" command on: " + playerNum + " players"); } return(new string[] { playerNum + " players has been slain!" }); } Player myPlayer = GetPlayerFromString.GetPlayer(args[0]); if (myPlayer == null) { return(new string[] { "Couldn't get player: " + args[0] }); } if (myPlayer.TeamRole.Role != Role.SPECTATOR) { if (caller != null && !string.IsNullOrEmpty(caller.Name) && caller.Name.ToLower() != "server") { plugin.Info(caller.Name + " ran the \"SLAY\" command on: " + myPlayer.Name); } myPlayer.Kill(killType); return(new string[] { myPlayer.Name + " has been slain!" }); } else { return new string[] { myPlayer.Name + " is already dead!" } }; } else { return(new string[] { GetUsage() }); } }
public string[] OnCall(ICommandSender sender, string[] args) { Player caller = (sender is Player _p) ? _p : null; if (args.Length > 0) { if (bool.TryParse(args[0], out bool k)) { AdminToolbox.lockRound = k; if (caller != null) { plugin.Info("Round lock: " + k); } return(new string[] { "Round lock: " + k }); } else if (Int32.TryParse(args[0], out int l)) { if (l < 1) { AdminToolbox.lockRound = false; if (caller != null) { plugin.Info("Round lock: " + AdminToolbox.lockRound); } return(new string[] { "Round lock: " + AdminToolbox.lockRound }); } else { AdminToolbox.lockRound = true; if (caller != null) { plugin.Info("Round lock: " + AdminToolbox.lockRound); } return(new string[] { "Round lock: " + AdminToolbox.lockRound }); } } else { return new string[] { GetUsage() } }; } else { AdminToolbox.lockRound = !AdminToolbox.lockRound; if (caller != null) { plugin.Info("Round lock: " + AdminToolbox.lockRound); } return(new string[] { "Round lock: " + AdminToolbox.lockRound }); } }
public string[] OnCall(ICommandSender sender, string[] args) { Server server = PluginManager.Manager.Server; if (args.Length >= 1) { if (bool.TryParse(args[0], out bool x)) { AdminToolbox.isColored = x; AdminToolbox.isColoredCommand = true; if (AdminToolbox.isColored) { plugin.Info("@#fg=Yellow;AdminToolbox@#fg=Default; colors is set to @#fg=Green;" + AdminToolbox.isColored + "@#fg=Default;"); } else { plugin.Info("AdminToolbox colors set to" + AdminToolbox.isColored); } return(new string[] { "AdminToolbox colors set to" + AdminToolbox.isColored }); } else { return new string[] { "\"ATCOLOR " + args[0] + "\" is not a valid bool" } }; } else if (args.Length == 0) { AdminToolbox.isColored = !AdminToolbox.isColored; AdminToolbox.isColoredCommand = true; if (AdminToolbox.isColored) { plugin.Info("@#fg=Yellow;AdminToolbox@#fg=Default; colors is set to @#fg=Green;" + AdminToolbox.isColored + "@#fg=Default;"); } else { plugin.Info("AdminToolbox colors set to " + AdminToolbox.isColored); } return(new string[] { "AdminToolbox colors set to " + AdminToolbox.isColored }); } else { return new string[] { GetUsage() } }; } }
/// <summary> /// Returns a <see cref="AT_LatestReleaseInfo"/> class containing info about the latest GitHub release /// </summary> public static AT_LatestReleaseInfo GetOnlineInfo(AdminToolbox plugin) { if (ConfigManager.Manager.Config.GetBoolValue("atb_disable_networking", false) || ConfigManager.Manager.Config.GetBoolValue("admintoolbox_disable_networking", false)) { return(new AT_LatestReleaseInfo(plugin.Details.name, plugin.Details.version, plugin.Details.author, "")); } string rawResponse = string.Empty; string apiURL = "https://api.github.com/repos/Rnen/AdminToolbox/releases/latest"; string _title = "", _version = "", _author = "", _dllink = ""; try { using (UnityWebRequest ww = UnityWebRequest.Get(apiURL)) { ww.SendWebRequest(); DateTime timer = DateTime.Now.AddSeconds(2); while (!ww.isDone || !ww.downloadHandler.isDone && DateTime.Now < timer) { } rawResponse = ww.downloadHandler.text; if (string.IsNullOrEmpty(rawResponse)) { throw new Exception(); } string FindValue(string key) { plugin.Debug("Searched: " + key); string str = rawResponse.Split(Environment.NewLine.ToCharArray()).Where(s => s.Trim().StartsWith("\"" + key)).FirstOrDefault().Split(new[] { ':' }, 2).Last().Replace("\"", string.Empty).Trim(',').Trim(); plugin.Debug("Found: " + str); if (key.ToLower() == "tag_name") { return(str.Split('-').FirstOrDefault()); } return(str); } _title = FindValue("name"); _version = FindValue("tag_name"); _author = FindValue("login"); _dllink = FindValue("html_url"); //FindValue("browser_download_url"); if (string.IsNullOrEmpty(_version)) { throw new Exception(); } } } catch { plugin.Info(" \n\n - Downloading online version failed, skipping..." + "\n \n"); return(new AT_LatestReleaseInfo(plugin.Details.name, plugin.Details.version, plugin.Details.author, "")); } return(new AT_LatestReleaseInfo(_title, _version, _author, _dllink)); }
public string[] OnCall(ICommandSender sender, string[] args) { AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { if (bool.TryParse(args[0], out bool k)) { AdminToolbox.lockRound = k; plugin.Info("Round lock: " + k); return(new string[] { "Round lock: " + k }); } else if (Int32.TryParse(args[0], out int l)) { if (l < 1) { AdminToolbox.lockRound = false; plugin.Info("Round lock: " + AdminToolbox.lockRound); return(new string[] { "Round lock: " + AdminToolbox.lockRound }); } else { AdminToolbox.lockRound = true; plugin.Info("Round lock: " + AdminToolbox.lockRound); return(new string[] { "Round lock: " + AdminToolbox.lockRound }); } } else { return new string[] { GetUsage() } }; } else { AdminToolbox.lockRound = !AdminToolbox.lockRound; plugin.Info("Round lock: " + AdminToolbox.lockRound); return(new string[] { "Round lock: " + AdminToolbox.lockRound }); } }
public string[] OnCall(ICommandSender sender, string[] args) { Server server = PluginManager.Manager.Server; if (args.Length >= 1) { if (bool.TryParse(args[0], out bool x)) { AdminToolbox.isColored = x; if (!AdminToolbox.intercomLockChanged) { AdminToolbox.intercomLockChanged = true; } plugin.Info("IntercomLock set to: " + AdminToolbox.intercomLock); return(new string[] { "IntercomLock set to: " + AdminToolbox.intercomLock }); } else { return new string[] { "\"ATCOLOR " + args[0] + "\" is not a valid bool" } }; } else if (args.Length == 0) { AdminToolbox.intercomLock = !AdminToolbox.intercomLock; if (!AdminToolbox.intercomLockChanged) { AdminToolbox.intercomLockChanged = true; } plugin.Info("IntercomLock set to: " + AdminToolbox.intercomLock); return(new string[] { "IntercomLock set to: " + AdminToolbox.intercomLock }); } else { return new string[] { GetUsage() } }; } }
public string[] OnCall(ICommandSender sender, string[] args) { plugin.Info(sender + " ran the " + GetUsage() + " command!"); this.plugin.pluginManager.DisablePlugin(this.plugin); return(new string[] { "AdminToolbox Disabled" }); }
public string[] OnCall(ICommandSender sender, string[] args) { AdminToolbox.AddMissingPlayerVariables(); Server server = PluginManager.Manager.Server; if (args.Length > 0) { if (args[0].ToLower() == "all" || args[0].ToLower() == "*") { if (args.Length > 1) { if (Int32.TryParse(args[1], out int j)) { int playerNum = 0; foreach (Player pl in server.GetPlayers()) { pl.AddHealth(j); playerNum++; } if (playerNum > 1) { return new string[] { "Added " + j + " HP to " + playerNum + " player(s)" } } ; else { return new string[] { "Added " + j + " HP to " + playerNum + " player" } }; } else { return(new string[] { "Not a valid number!" }); } } else { foreach (Player pl in server.GetPlayers()) { pl.SetHealth(pl.TeamRole.MaxHP); } plugin.Info("Set all players to their default max HP"); return(new string[] { "Set all players to their default max HP" }); } } Player myPlayer = GetPlayerFromString.GetPlayer(args[0], out myPlayer); if (myPlayer == null) /*plugin.Info("Couldn't find player: " + args[0]);*/ return { (new string[] { "Couldn't find player: " + args[0] }); } if (args.Length > 1) { if (Int32.TryParse(args[1], out int j)) { myPlayer.AddHealth(j); return(new string[] { "Added " + j + " HP " + " to " + myPlayer.Name }); } else { return new string[] { "Not a valid number!" } }; } else { myPlayer.SetHealth(myPlayer.TeamRole.MaxHP); return(new string[] { "Set " + myPlayer.Name + " to full HP" }); } } else { return(new string[] { GetUsage() }); } }