/// <summary> /// De-OPs a given Player. /// </summary> /// <param name="server">Current Server instance</param> /// <param name="sender">Sending player</param> /// <param name="args">Arguments sent with command</param> public static void DeopPlayer(Server server, ISender sender, ArgumentList args) { if (args.Count > 0) { String player = string.Join(" ", args).Trim(); server.notifyOps("De-Opping " + player + " {" + sender.Name + "}", true); if (Player.isInOpList(player, server)) { Program.server.OpList.removeException(player + ":" + Player.GetPlayerPassword(player, server)); } if (!server.OpList.Save()) { server.notifyOps("OpList Failed to Save due. {" + sender.Name + "}", true); return; } Player playerInstance = server.GetPlayerByName(player); if (playerInstance != null) { if (playerInstance.Op && playerInstance.HasClientMod) //Deop the client too { playerInstance.Op = false; if (playerInstance.HasClientMod) { NetMessage.SendData(Packet.CLIENT_MOD, playerInstance.whoAmi); } } else { playerInstance.Op = false; } playerInstance.sendMessage("You have been De-Opped!.", ChatColour.Green); } } else { sender.sendMessage("Please review that command"); } }
/// <summary> /// Restarts the server /// </summary> /// <param name="server">Current Server instance</param> /// <param name="sender">Sending player</param> /// <param name="args">Arguments sent with command</param> public static void Restart(Server server, ISender sender, ArgumentList args) { server.notifyOps("Restarting the Server {" + sender.Name + "}", true); Statics.keepRunning = true; server.StopServer(); while (Statics.serverStarted) { Thread.Sleep(10); } ProgramLog.Log("Starting the Server"); server.Initialize(); WorldIO.loadWorld(); Program.updateThread = new ProgramThread ("Updt", Program.UpdateLoop); server.StartServer(); Statics.keepRunning = false; }
/// <summary> /// Reloads Plugins. /// </summary> /// <param name="server">Current Server instance</param> /// <param name="sender">Sending player</param> /// <param name="args">Arguments sent with command</param> public static void Reload(Server server, ISender sender, ArgumentList args) { Boolean parseData = args.TryPop("-data"); server.notifyOps("Reloading plugins.", true); server.PluginManager.ReloadPlugins(); if (parseData) { server.notifyOps("Reloading properties.", true); Program.properties.Save(); Program.properties.Load(); } return; }
/// <summary> /// Sets OP status to a given Player. /// </summary> /// <param name="server">Current Server instance</param> /// <param name="sender">Sending player</param> /// <param name="args">Arguments sent with command</param> public static void OpPlayer(Server server, ISender sender, ArgumentList args) { if (args.Count > 1) { String Password = args[args.Count - 1]; String player = string.Join(" ", args); player = player.Remove(player.IndexOf(Password), Password.Length).Trim().ToLower(); server.notifyOps("Opping " + player + " {" + sender.Name + "}", true); server.OpList.addException(player + ":" + Password, true, player.Length + 1); if (!server.OpList.Save()) { server.notifyOps("OpList Failed to Save due. {" + sender.Name + "}", true); return; } Player playerInstance = server.GetPlayerByName(player); if (playerInstance != null) { playerInstance.sendMessage("You are now OP!", ChatColour.Green); playerInstance.Op = true; if (playerInstance.HasClientMod) { NetMessage.SendData(Packet.CLIENT_MOD, playerInstance.whoAmi); } } } else { sender.sendMessage("Please review that command"); } }
/// <summary> /// Closes the Server all connections. /// </summary> /// <param name="server">Current Server instance</param> /// <param name="sender">Sending player</param> /// <param name="args">Arguments sent with command</param> public static void Exit(Server server, ISender sender, ArgumentList args) { if (sender is Player) // || sender is RConSender) //Requested for Rcon Users. { sender.sendMessage("You cannot perform that action.", 255, 238, 130, 238); return; } args.ParseNone(); server.notifyOps("Exiting on request.", true); server.StopServer(); return; }
/// <summary> /// Reloads Plugins. /// </summary> /// <param name="server">Current Server instance</param> /// <param name="sender">Sending player</param> /// <param name="args">Arguments sent with command</param> public static void Reload(Server server, ISender sender, ArgumentList args) { args.ParseNone(); server.notifyOps("Reloading plugins.", true); server.PluginManager.ReloadPlugins(); return; }