public static void ExampleCommand(Server server, ISender sender, ArgumentList args)
        {
            int arg;
            //if the user enters /tdsmpluginexample -test 1, it will retreive the next value '1' and put into 'arg' as an integer.
            if (args.TryParseOne<int>("-test", out arg))
                sender.sendMessage(sender.Name + " Argument: " + arg);
            else
            {
                //For new people, I would not really expect you to understand the following.
                //If needed I can simplify this down...
                String Platform = Terraria_Server.Definitions.Platform.Type.ToString();
                switch (Terraria_Server.Definitions.Platform.Type)
                {
                    case Terraria_Server.Definitions.Platform.PlatformType.LINUX:
                        Platform = "Linux";
                        break;
                    case Terraria_Server.Definitions.Platform.PlatformType.MAC:
                        Platform = "Mac";
                        break;
                    case Terraria_Server.Definitions.Platform.PlatformType.WINDOWS:
                        Platform = "Windows";
                        break;
                }
                (sender as Player).sendMessage("TDSM Plugin Example, Running OS: " + Platform, ChatColour.DarkGreen);

            }
        }
Esempio n. 2
0
        public static void TestPoint(Server server, ISender sender, ArgumentList args)
        {
            string param;
            Player player = server.GetPlayerByName(sender.Name);

            if (args.TryGetString(0, out param))
            {
                switch (param.ToUpper())
                {
                    case "LOBBY":
                        player.sendMessage("Teleporting to the lobby", Login.plugin.chatColor);
                        Login.plugin.TeleportPlayerToPoint(player, Login.LOBBY);
                        break;
                    case "VALIDATED":
                        player.sendMessage("Teleporting to the validated point", Login.plugin.chatColor);
                        Login.plugin.TeleportPlayerToPoint(player, Login.VALIDATED);
                        break;
                    default:
                        player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
                        break;
                }
            }
            else
                player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
        }
Esempio n. 3
0
        public static void SetPoint(Server server, ISender sender, ArgumentList args)
        {
            string param;
            Player player = server.GetPlayerByName(sender.Name);

            if (args.TryGetString(0, out param))
            {
                switch (param.ToUpper())
                {
                    case "LOBBY":
                        player.PluginData["lobby"] = true;
                        player.sendMessage("Hit a block where you want the lobby to be", Login.plugin.chatColor);
                        break;
                    case "VALIDATED":
                        player.PluginData["validated"] = true;
                        player.sendMessage("Hit a block where you want the validated point to be", Login.plugin.chatColor);
                        break;
                    default:
                        player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
                        break;
                }
            }
            else
                player.sendMessage("You must specify either lobby or validated", Login.plugin.chatColor);
        }
Esempio n. 4
0
        public static void InvalidatePlayer(Server server, ISender sender, ArgumentList args)
        {
            string playerName, param;
            Player player = server.GetPlayerByName(sender.Name);

            if (args.TryGetString(0, out playerName))
            {
                if (server.GetPlayerByName(playerName) != null)
                {
                    Login.plugin.SetPlayerInvalid(playerName);
                    SendMessage(player, "You have invalidated " + playerName);
                }
                else
                {
                    if (args.TryGetString(1, out param))
                    {
                        if (param.ToUpper() == "FORCE")
                        {
                            Login.plugin.SetPlayerInvalid(playerName);
                            SendMessage(player, "You have invalidated " + playerName);
                        }
                        else
                            SendMessage(player, "Usage: /invalidate <player> (force)");
                    }
                    else
                    {
                        SendMessage(player, "There is no current player names " + playerName);
                        SendMessage(player, "Use /invalidate <player> force to remove offline players");
                    }
                }
            }
            else
                SendMessage(player, "You must supply a player name");
        }
Esempio n. 5
0
        public static void roll(Server server, ISender sender, ArgumentList args)
        {
            Random random = new Random();
            int result = 0;
            int times = 1;
            int die = 6;

            if (args.Count > 0)
            {
                string[] arg = args[0].Split('d');
                times = Int32.Parse(arg[0]);
                die = Int32.Parse(arg[1]);
            }

            for (int i = 0; i < times; i++)
            {
                result += random.Next(1, die);
            }

            Player player = server.GetPlayerByName(sender.Name);

            if (! player.PluginData.ContainsKey("roll"))
            {
                player.PluginData.Add("roll", result);
            }
            else
            {
                player.PluginData["roll"] = result;
            }

            server.notifyAll(player.Name + " rolled a " + player.PluginData["roll"] + " on " + times.ToString() + "d" + die.ToString(), true);
        }
 /// <summary>
 /// 3rd person talking.
 /// </summary>
 /// <param name="server">Current Server instance</param>
 /// <param name="sender">Sending player</param>
 /// <param name="message">Message to send</param>
 public static void Action(Server server, ISender sender, string message)
 {
     ProgramLog.Chat.Log("* " + sender.Name + " " + message);
     if (sender is Player)
         NetMessage.SendData(25, -1, -1, "* " + sender.Name + " " + message, 255, 200, 100, 0);
     else
         NetMessage.SendData(25, -1, -1, "* " + sender.Name + " " + message, 255, 238, 130, 238);
 }
        public World(Server Server, int MaxTilesX, int MaxTilesY)
        {
            maxTilesY = MaxTilesY;
            maxTilesX = MaxTilesX;

            server = Server;

            UpdateWorldCoords(false);
        }
        public static void AddUser(Server server, ISender sender, ArgumentList args)
        {
            String User = "", IP = "";
            Int32 Slot;

            args.TryParseOne<String>("-ip", out IP); //Optional

            //IP or name?
            if (args.TryParseTwo<String, Int32>("-name", out User, "-slot", out Slot))
            {
                String[] exceptions = new String[2];
                if (User.Length > 0)
                {
                    exceptions[0] = User;
                }
                if (IP.Length > 0)
                {
                    exceptions[1] = IP;
                }

                Region.Region region = null;
                for (int i = 0; i < Regions.regionManager.Regions.Count; i++)
                {
                    if (Slot == i)
                        region = Regions.regionManager.Regions[i];
                    break;
                }

                if (region == null)
                    throw new CommandError("Specified Region Slot was incorrect.");

                //List<String> users = new List<String>();
                int usersAdded = 0;
                foreach (String toInflate in exceptions)
                {
                    if (toInflate != null)
                        foreach (String inflatee in toInflate.Split(','))
                        {
                            region.UserList.Add(inflatee);
                            usersAdded++;
                        }
                }

                if (usersAdded > 0)
                {
                    sender.sendMessage(string.Format("{0} users were added to {1}", usersAdded, region.Name),
                        255, 0, 255, 0);
                    Regions.Log(sender.Name + " created region {0} with {1} user/s", region.Name, usersAdded);
                }
                else
                    throw new CommandError("A user was not able to be added to a Region.");
            }
            else
                throw new CommandError("Invalid arguments, Please review your command.");
        }
        public World(Server server, int MaxTilesX, int MaxTilesY)
        {
            BottomWorld = DEFAULT_BOTTOM_WORLD;
            TopWorld = DEFAULT_TOP_WORLD;
            LeftWorld = DEFAULT_LEFT_WORLD;
            RightWorld = DEFAULT_RIGHT_WORLD;
            maxTilesY = MaxTilesY;
            maxTilesX = MaxTilesX;

            Server = server;

            UpdateWorldCoords(false);
        }
        public static void Create(Server server, ISender sender, ArgumentList args)
        {
            if (sender is Player)
            {
                String Name = "";
                String Desc = "";
                Boolean Restrict = args.TryPop("-res");
                Boolean RestrictNPC = args.TryPop("-npcres");

                if (args.TryParseTwo<String, String>("-name", out Name, "-desc", out Desc)
                    && Name.Trim().Length > 0)
                {
                    var player = sender as Player;
                    if (Selection.isInSelectionlist(player))
                    {
                        Vector2[] regionAxis = Selection.GetSelection(player);

                        Region.Region rgn = new Region.Region();
                        rgn.Name = Name;
                        rgn.Description = Desc;
                        rgn.Point1 = regionAxis[0];
                        rgn.Point2 = regionAxis[1];
                        rgn.Restricted = Restrict;
                        rgn.RestrictedNPCs = RestrictNPC;

                        if (rgn.IsValidRegion())
                        {
                            Regions.regionManager.Regions.Add(rgn);
                            if(Regions.regionManager.SaveRegion(rgn))
                                player.sendMessage("Region '" + Name + "' was successfully created.", ChatColour.Green);
                            else
                                player.sendMessage("There was an issue while saving the region", ChatColour.Red);
                        }
                        else
                        {
                            player.sendMessage("There was an issue while creating the region", ChatColour.Red);
                        }
                    }
                    else
                    {
                        player.sendMessage("You need to select a region first!", ChatColour.Red);
                    }
                }
                else
                {
                    throw new CommandError("You have not specified certain arguments");
                }
            }
        }
        /// <summary>
        /// Adds a player or ip (Exception) to the ban list.
        /// </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 Ban(Server server, ISender sender, ArgumentList args)
        {
            if (args != null && args.Count > 0)
            {
                //We now should check to make sure they are off the server...
                Player banee = Program.server.GetPlayerByName(args[0]);

                if (banee == null)
                {
                    foreach (Player player in Program.server.PlayerList)
                    {
                        var ip = Netplay.slots[player.whoAmi].remoteAddress.Split(':')[0];
                        if (ip == args[0])
                        {
                            banee = player;
                        }
                    }
                }

                Program.server.BanList.addException(args[0]);

                if (banee != null)
                {
                    banee.Kick("You have been banned from this Server.");
                    Program.server.BanList.addException(Netplay.slots[banee.whoAmi].
                        remoteAddress.Split(':')[0]);
                }

                Program.server.notifyOps(args[0] + " has been banned {" + sender.Name + "}", true);
                if (!Program.server.BanList.Save())
                {
                    Program.server.notifyOps("BanList Failed to Save due to " + sender.Name + "'s command", true);
                }
            }
            else
            {
                sender.sendMessage("Please review that command");
            }
        }
 /// <summary>
 /// Settles water like in the startup routine.
 /// </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 SettleWater(Server server, ISender sender, ArgumentList args)
 {
     if (!Liquid.panicMode)
     {
         sender.sendMessage("Settling Liquids...");
         Liquid.StartPanic();
         sender.sendMessage("Complete.");
     }
     else
     {
         sender.sendMessage("Liquids are already settling");
     }
 }
 /// <summary>
 /// Sends a Server Message to all online Players.
 /// </summary>
 /// <param name="server">Current Server instance</param>
 /// <param name="sender">Sending player</param>
 /// <param name="message">Message to send</param>
 public static void Say(Server server, ISender sender, string message)
 {
     ProgramLog.Chat.Log("<" + sender.Name + "> " + message);
     if (sender is Player)
         NetMessage.SendData(25, -1, -1, "<" + sender.Name + "> " + message, 255, 255, 255, 255);
     else
         NetMessage.SendData(25, -1, -1, "<" + sender.Name + "> " + message, 255, 238, 180, 238);
 }
        /// <summary>
        /// Executes the world data save routine.
        /// </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 SaveAll(Server server, ISender sender, ArgumentList args)
        {
            Program.server.notifyOps("Saving World...", true);

            WorldIO.saveWorld(Program.server.World.SavePath, false);
            while (WorldModify.saveLock)
            {
            }

            Program.server.notifyOps("Saving Data...", true);

            Program.server.BanList.Save();
            Program.server.WhiteList.Save();

            Program.server.notifyOps("Saving Complete.", true);
        }
        /// <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>
        /// Lists currently enabled 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 ListPlugins(Server server, ISender sender, ArgumentList args)
        {
            if (server.PluginManager.PluginList.Count > 0)
            {
                String plugins = "";

                foreach (Plugin.Plugin plugin in server.PluginManager.PluginList.Values)
                {
                    if (!plugin.Enabled || plugin.Name.Trim().Length > 0)
                    {
                        plugins += ", " + plugin.Name.Trim();
                    }
                }
                if (plugins.StartsWith(","))
                {
                    plugins = plugins.Remove(0, 1).Trim(); //Remove the ', ' from the start and trim the ends
                }
                sender.sendMessage("Loaded Plugins: " + plugins + ".");
            }
            else
            {
                sender.sendMessage("There are no loaded plugins.");
            }
        }
 public void setServer(Server Server)
 {
     server = Server;
 }
 public static void Reload(Server server)
 {
     server.getPluginManager().ReloadPlugins();
 }
        /// <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>
        /// Allows Operators to login.
        /// </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 OpLogin(Server server, ISender sender, ArgumentList args)
        {
            if (sender is Player)
            {
                Player player = sender as Player;
                String Password = string.Join(" ", args).Trim();
                if (player.isInOpList())
                {
                    if (player.Password.Equals(Password))
                    {
                        player.Op = true;
                        player.sendMessage("Successfully Logged in as OP.", ChatColour.DarkGreen);

                        if (player.HasClientMod)
                        {
                            NetMessage.SendData(Packet.CLIENT_MOD, player.whoAmi);
                        }
                    }
                    else
                    {
                        player.sendMessage("Incorrect OP Password.", ChatColour.DarkRed);
                    }
                }
                else
                {
                    player.sendMessage("You need to be Assigned OP Privledges.", ChatColour.DarkRed);
                }
            }
        }
        /// <summary>
        /// Prints a Playerlist.
        /// </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 OldList(Server server, ISender sender, ArgumentList args)
        {
            args.ParseNone();

            var players = from p in Server.players where p.Active select p.Name;
            sender.sendMessage(string.Concat("Current players: ", string.Join(", ", players), "."), 255, 255, 240, 20);
        }
        /// <summary>
        /// Enables or disables NPC spawning
        /// </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 NPCSpawns(Server server, ISender sender, ArgumentList args)
        {
            args.ParseNone();

            Main.stopSpawns = !Main.stopSpawns;
            sender.sendMessage("NPC Spawning is now " + ((Main.stopSpawns) ? "off" : "on") + "!");
        }
        /// <summary>
        /// Enable/disable and get details about specific 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 ManagePlugins(Server server, ISender sender, ArgumentList args)
        {
            /*
             * Commands:
             *      list    - shows all plugins
             *      info    - shows a plugin's author & description etc
             *      disable - disables a plugin
             *      enable  - enables a plugin
             */
            if (args.Count > 0 && args[0] != null && args[0].Trim().Length > 0)
            {
                String command = args[0].Trim();
                args.RemoveAt(0); //Allow the commands to use any additional arguments without also getting the command
                switch (command)
                {
                    case "list":
                        {
                            if (server.PluginManager.PluginList.Count > 0)
                            {
                                String plugins = "";

                                foreach (Plugin.Plugin plugin in server.PluginManager.PluginList.Values)
                                {
                                    if (plugin.Name.Trim().Length > 0)
                                    {
                                        plugins += ", " + plugin.Name.Trim() + ((!plugin.Enabled) ? "[DISABLED] " : " ");
                                    }
                                }
                                if (plugins.StartsWith(","))
                                {
                                    plugins = plugins.Remove(0, 1).Trim(); //Remove the ', ' from the start and trim the ends
                                }
                                sender.sendMessage("Plugins: " + plugins + ".");
                            }
                            else
                            {
                                sender.sendMessage("There are no installed plugins.");
                            }
                            break;
                        }
                    case "info":
                        {
                            if (!(args.Count > 1 && args[1] != null && args[0].Trim().Length > 0))
                            {
                                sender.sendMessage("Please review your argument count.");
                            }

                            String pluginName = string.Join(" ", args);

                            if (server.PluginManager.PluginList.Count > 0)
                            {
                                Plugin.Plugin fplugin = server.PluginManager.GetPlugin(pluginName);
                                if (fplugin != null)
                                {
                                    sender.sendMessage("Plugin Name: " + fplugin.Name);
                                    sender.sendMessage("Plugin Author: " + fplugin.Author);
                                    sender.sendMessage("Plugin Description: " + fplugin.Description);
                                    sender.sendMessage("Plugin Enabled: " + fplugin.Enabled.ToString());
                                }
                                else
                                {
                                    sender.sendMessage("The plugin \"" + args[1] + "\" was not found.");
                                }
                            }
                            else
                            {
                                sender.sendMessage("There are no plugins loaded.");
                            }
                            break;
                        }
                    case "disable":
                        {
                            if (!(args.Count > 1 && args[1] != null && args[1].Trim().Length > 0))
                            {
                                sender.sendMessage("Please review your argument count.");
                            }

                            String pluginName = string.Join(" ", args);

                            if (server.PluginManager.PluginList.Count > 0)
                            {
                                Plugin.Plugin fplugin = server.PluginManager.GetPlugin(pluginName);
                                if (fplugin != null)
                                {
                                    if (fplugin.Enabled)
                                    {
                                        if (server.PluginManager.DisablePlugin(fplugin.Name))
                                        {
                                            sender.sendMessage(pluginName + " was disabled!");
                                        }
                                        else
                                        {
                                            sender.sendMessage("There was an issue disabling plugin \"" + pluginName + "\".");
                                        }
                                    }
                                    else
                                    {
                                        sender.sendMessage("The plugin \"" + pluginName + "\" is already disabled.");
                                    }
                                }
                                else
                                {
                                    sender.sendMessage("The plugin \"" + pluginName + "\" could not be found.");
                                }
                            }
                            else
                            {
                                sender.sendMessage("There are no plugins loaded.");
                            }
                            break;
                        }
                    case "enable":
                        {
                            if (!(args.Count > 1 && args[1] != null && args[0].Trim().Length > 0))
                            {
                                sender.sendMessage("Please review your argument count.");
                            }

                            String pluginName = string.Join(" ", args);

                            if (server.PluginManager.PluginList.Count > 0)
                            {
                                Plugin.Plugin fplugin = server.PluginManager.GetPlugin(pluginName);
                                if (fplugin != null)
                                {
                                    if (!fplugin.Enabled)
                                    {
                                        if (server.PluginManager.EnablePlugin(fplugin.Name))
                                        {
                                            sender.sendMessage(args[1] + " was enabled!");
                                        }
                                        else
                                        {
                                            sender.sendMessage("There was an issue enabling plugin \"" + pluginName + "\".");
                                        }
                                    }
                                    else
                                    {
                                        sender.sendMessage("The plugin \"" + pluginName + "\" is already enabled.");
                                    }
                                }
                                else
                                {
                                    sender.sendMessage("The plugin \"" + pluginName + "\" could not be found.");
                                }
                            }
                            else
                            {
                                sender.sendMessage("There are no plugins loaded.");
                            }
                            break;
                        }
                    default:
                        {
                            sender.sendMessage("Please review your argument count");
                            break;
                        }
                }
            }
        }
        /// <summary>
        /// Sends the help list to the requesting player's chat.
        /// </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 ShowHelp(Server server, ISender sender, ArgumentList args)
        {
            if (args == null || args.Count < 1)
            {
                for (int i = 0; i < Program.commandParser.serverCommands.Values.Count; i++)
                {
                    String Key = Program.commandParser.serverCommands.Keys.ToArray()[i];
                    CommandInfo cmdInfo = Program.commandParser.serverCommands.Values.ToArray()[i];
                    if (CommandParser.CheckAccessLevel(cmdInfo, sender) && !Key.StartsWith("."))
                    {
                        String tab = "\t";
                        if (Key.Length < 8)
                        {
                            tab = "\t\t";
                        }
                        String Message = "\t" + Key + tab + "- " + cmdInfo.description;
                        if (sender is Player)
                        {
                            Message = Message.Replace("\t", "");
                        }
                        sender.sendMessage(Message);
                    }
                }
            }
            else
            {
                int maxPages = (Program.commandParser.serverCommands.Values.Count / 5) + 1;
                if (maxPages > 0 && args.Count > 1 && args[0] != null)
                {
                    try
                    {
                        int selectingPage = Int32.Parse(args[0].Trim());

                        if (selectingPage < maxPages)
                        {
                            for (int i = 0; i < maxPages; i++)
                            {
                                if ((selectingPage <= i))
                                {
                                    selectingPage = i * ((Program.commandParser.serverCommands.Values.Count / 5) + 1);
                                    break;
                                }
                            }

                            int toPage = Program.commandParser.serverCommands.Values.Count;
                            if (selectingPage + 5 < toPage)
                            {
                                toPage = selectingPage + 5;
                            }

                            for (int i = selectingPage; i < toPage; i++)
                            {
                                String Key = Program.commandParser.serverCommands.Keys.ToArray()[i];
                                CommandInfo cmdInfo = Program.commandParser.serverCommands.Values.ToArray()[i];
                                if (CommandParser.CheckAccessLevel(cmdInfo, sender) && !Key.StartsWith("."))
                                {
                                    String tab = "\t";
                                    if (Key.Length < 8)
                                    {
                                        tab = "\t\t";
                                    }
                                    String Message = "\t" + Key + tab + "- " + cmdInfo.description;
                                    if (sender is Player)
                                    {
                                        Message = Message.Replace("\t", "");
                                    }
                                    sender.sendMessage(Message);
                                }
                            }
                        }
                        else
                        {
                            sender.sendMessage("Invalid page! Use: 0 -> " + (maxPages - 1).ToString());
                        }
                    }
                    catch (Exception)
                    {
                        ShowHelp(server, sender, null);
                    }
                }
                else
                {
                    ShowHelp(server, sender, null);
                }
            }
        }
 public static void Exit(Server server)
 {
     server.StopServer();
 }
        /// <summary>
        /// Purge Server data
        /// </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 Purge(Server server, ISender sender, ArgumentList args)
        {
            var all = args.TryPop("all");
            var something = false;

            if (all || args.TryPop("proj") || args.TryPop("projectiles"))
            {
                something = true;

                ProgramLog.Admin.Log("Purging all projectiles.");

                var msg = NetMessage.PrepareThreadInstance();

                msg.PlayerChat(255, "<Server> Purging all projectiles.", 255, 180, 100);

                lock (Main.updatingProjectiles)
                {
                    foreach (var projectile in Main.projectile)
                    {
                        projectile.Active = false;
                        projectile.type = ProjectileType.UNKNOWN;

                        msg.Projectile(projectile);
                    }

                    msg.Broadcast();
                }
            }

            if (all || args.TryPop("npc") || args.TryPop("npcs"))
            {
                something = true;

                ProgramLog.Admin.Log("Purging all NPCs.");

                var msg = NetMessage.PrepareThreadInstance();

                msg.PlayerChat(255, "<Server> Purging all NPCs.", 255, 180, 100);

                lock (Main.updatingNPCs)
                {
                    foreach (var npc in Main.npcs)
                    {
                        if (npc.Active)
                        {
                            npc.Active = false;
                            npc.life = 0;
                            npc.netUpdate = false;
                            npc.Name = "";

                            msg.NPCInfo(npc.whoAmI);
                        }
                    }

                    msg.Broadcast();
                }
            }

            if (all || args.TryPop("item") || args.TryPop("items"))
            {
                something = true;

                ProgramLog.Admin.Log("Purging all items.");

                var msg = NetMessage.PrepareThreadInstance();

                msg.PlayerChat(255, "<Server> Purging all items.", 255, 180, 100);

                lock (Main.updatingItems)
                {
                    for (int i = 0; i < 200; i++)
                    {
                        var item = Main.item[i];
                        if (item.Active)
                        {
                            Main.item[i] = new Item(); // this is what Main does when ignoreErrors is on *shrug*
                            msg.ItemInfo(i);
                            msg.ItemOwnerInfo(i);
                        }
                    }

                    msg.Broadcast();
                }
            }

            if (!something)
                throw new CommandError("");
        }
        public static void Restart(Sender sender, Server server)
        {
            if (sender is Player)
            {
                Player player = ((Player)sender);
                if (!player.Op)
                {
                    player.sendMessage("You Cannot Perform That Action.", 255, 238f, 130f, 238f);
                    return;
                }
            }

            Statics.keepRunning = true;
            server.StopServer();
            while (Statics.serverStarted);
            Program.tConsole.WriteLine("Starting the Server");
            server.Initialize();
            WorldGen.loadWorld();
            server.StartServer();
            Program.updateThread = new Thread(Program.Updater);
            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>
        /// Allows Operators to logout.
        /// </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 OpLogout(Server server, ISender sender, ArgumentList args)
        {
            if (sender is Player)
            {
                var player = sender as Player;
                if (sender.Op)
                {
                    player.Op = false;
                    player.sendMessage("Successfully Logged Out.", ChatColour.DarkRed);

                    if (player.HasClientMod)
                    {
                        NetMessage.SendData(Packet.CLIENT_MOD, player.whoAmi);
                    }
                }
                else
                {
                    player.sendMessage("You need to be Assigned OP Privledges.", ChatColour.DarkRed);
                }
            }
        }
        /// <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;
        }