/// <summary>
        /// Parses new console command
        /// </summary>
        /// <param name="Line">Command to parse</param>
        /// <param name="server">Current Server instance</param>
        public void parseConsoleCommand(String Line, Server server)
        {
            ConsoleSender cSender = new ConsoleSender(server);
            cSender.ConsoleCommand.Message = Line;
            Sender sender = new Sender();
            sender.Op = true;
            cSender.ConsoleCommand.Sender = sender;
            server.PluginManager.processHook(Hooks.CONSOLE_COMMAND, cSender.ConsoleCommand);
            if (cSender.ConsoleCommand.Cancelled)
            {
                return;
            }

            if (Line.Contains("\""))
            {
                String[] commands = new String[Line.Substring(0, Line.IndexOf("\"")).Split(' ').Length + Line.Substring(Line.LastIndexOf("\"")).Split(' ').Length - 1];
                String[] temp = Line.Substring(0, Line.IndexOf("\"")).Trim().Split(' ');
                String[] temp2 = Line.Substring(Line.LastIndexOf("\"") + 1).Trim().Split(' ');
                String[] temp3 = new String[temp.Length + 1];
                temp.CopyTo(temp3, 0);

                temp3[temp3.Length - 1] = Line.Substring(Line.IndexOf("\""), Line.LastIndexOf("\"") - Line.IndexOf("\"")).Remove(0,1);

                temp3.CopyTo(commands, 0);
                temp2.CopyTo(commands, temp3.Length);

                if (commands == null || commands.Length <= 0)
                {
                    Program.tConsole.WriteLine("Issue parsing Console Command for " + Hooks.CONSOLE_COMMAND.ToString());
                    return;
                }
                switchCommands(commands, cSender.ConsoleCommand.Sender);

            }
            else
            {
                String[] commands = Line.Trim().ToLower().Split(' ');

                if (commands == null || commands.Length <= 0)
                {
                    Program.tConsole.WriteLine("Issue parsing Console Command for " + Hooks.CONSOLE_COMMAND.ToString());
                    return;
                }
                switchCommands(commands, cSender.ConsoleCommand.Sender);
            }
        }
        public void parseConsoleCommand(string Line, Server server)
        {
            ConsoleSender cSender = new ConsoleSender(server);
            cSender.getConsoleCommand().setMessage(Line);
            cSender.getConsoleCommand().setSender(new Sender());
            server.getPluginManager().processHook(Hooks.CONSOLE_COMMAND, cSender.getConsoleCommand());
            if (cSender.getConsoleCommand().getCancelled())
            {
                return;
            }

            string[] commands = Line.Trim().ToLower().Split(' ');
            if (commands == null || commands.Length <= 0)
            {
                Console.WriteLine("Issue parsing Console Command for " + Hooks.CONSOLE_COMMAND.ToString());
                return;
            }
            switchCommands(commands, cSender.getConsoleCommand().getSender());
        }
        public static bool OpenDoor(int x, int y, int direction, bool state = false, DoorOpener opener = DoorOpener.SERVER, ISender sender = null)
        {
            if (sender == null)
            {
                sender = new ConsoleSender();
            }

            if (Program.properties.NPCDoorOpenCancel && opener == DoorOpener.NPC)
                return false;

            DoorStateChangeEvent doorEvent = new DoorStateChangeEvent();
            doorEvent.Sender = sender;
            doorEvent.X = x;
            doorEvent.Y = y;
            doorEvent.Direction = direction;
            doorEvent.Opener = opener;
            doorEvent.isOpened = state;
            Program.server.PluginManager.processHook(Hooks.DOOR_STATECHANGE, doorEvent);
            if (doorEvent.Cancelled)
            {
                NetMessage.SendData(19, -1, -1, "", 1, (float)x, (float)y, 0); //Inform the client of the update
                return false;
            }

            int num = 0;
            if (Main.tile.At(x, y - 1).FrameY == 0 && Main.tile.At(x, y - 1).Type == Main.tile.At(x, y).Type)
            {
                num = y - 1;
            }
            else if (Main.tile.At(x, y - 2).FrameY == 0 && Main.tile.At(x, y - 2).Type == Main.tile.At(x, y).Type)
            {
                num = y - 2;
            }
            else if (Main.tile.At(x, y + 1).FrameY == 0 && Main.tile.At(x, y + 1).Type == Main.tile.At(x, y).Type)
            {
                num = y + 1;
            }
            else
            {
                num = y;
            }
            int num2 = x;
            short num3 = 0;
            int num4;
            if (direction == -1)
            {
                num2 = x - 1;
                num3 = 36;
                num4 = x - 1;
            }
            else
            {
                num2 = x;
                num4 = x + 1;
            }
            bool flag = true;
            for (int k = num; k < num + 3; k++)
            {
                if (Main.tile.At(num4, k).Active)
                {
                    if (Main.tile.At(num4, k).Type != 3 && Main.tile.At(num4, k).Type != 24 && Main.tile.At(num4, k).Type != 52 && Main.tile.At(num4, k).Type != 61 && Main.tile.At(num4, k).Type != 62 && Main.tile.At(num4, k).Type != 69 && Main.tile.At(num4, k).Type != 71 && Main.tile.At(num4, k).Type != 73 && Main.tile.At(num4, k).Type != 74)
                    {
                        flag = false;
                        break;
                    }
                    WorldModify.KillTile(num4, k, false, false, false);
                }
            }
            if (flag)
            {
                Main.tile.At(num2, num).SetActive (true);
                Main.tile.At(num2, num).SetType (11);
                Main.tile.At(num2, num).SetFrameY (0);
                Main.tile.At(num2, num).SetFrameX (num3);
                Main.tile.At(num2 + 1, num).SetActive (true);
                Main.tile.At(num2 + 1, num).SetType (11);
                Main.tile.At(num2 + 1, num).SetFrameY (0);
                Main.tile.At(num2 + 1, num).SetFrameX ((short)(num3 + 18));
                Main.tile.At(num2, num + 1).SetActive (true);
                Main.tile.At(num2, num + 1).SetType (11);
                Main.tile.At(num2, num + 1).SetFrameY (18);
                Main.tile.At(num2, num + 1).SetFrameX (num3);
                Main.tile.At(num2 + 1, num + 1).SetActive (true);
                Main.tile.At(num2 + 1, num + 1).SetType (11);
                Main.tile.At(num2 + 1, num + 1).SetFrameY (18);
                Main.tile.At(num2 + 1, num + 1).SetFrameX ((short)(num3 + 18));
                Main.tile.At(num2, num + 2).SetActive (true);
                Main.tile.At(num2, num + 2).SetType (11);
                Main.tile.At(num2, num + 2).SetFrameY (36);
                Main.tile.At(num2, num + 2).SetFrameX (num3);
                Main.tile.At(num2 + 1, num + 2).SetActive (true);
                Main.tile.At(num2 + 1, num + 2).SetType (11);
                Main.tile.At(num2 + 1, num + 2).SetFrameY (36);
                Main.tile.At(num2 + 1, num + 2).SetFrameX ((short)(num3 + 18));
                for (int l = num2 - 1; l <= num2 + 2; l++)
                {
                    for (int m = num - 1; m <= num + 2; m++)
                    {
                        WorldModify.TileFrame(l, m, false, false);
                    }
                }
            }
            return flag;
        }
        public static bool CloseDoor(int x, int y, bool forced = false, DoorOpener opener = DoorOpener.SERVER, ISender sender = null)
        {
            if (sender == null)
            {
                sender = new ConsoleSender ();
            }

            if (Program.properties.NPCDoorOpenCancel && opener == DoorOpener.NPC)
                return false;

            DoorStateChangeEvent doorEvent = new DoorStateChangeEvent();
            doorEvent.Sender = sender;
            doorEvent.X = x;
            doorEvent.Y = y;
            doorEvent.Direction = 1;
            doorEvent.Opener = opener;
            doorEvent.isOpened = forced;
            Program.server.PluginManager.processHook(Hooks.DOOR_STATECHANGE, doorEvent);
            if (doorEvent.Cancelled)
            {
                NetMessage.SendData(19, -1, -1, "", 0, (float)x, (float)y, 0); //Inform the client of the update
                return false;
            }

            int num = 0;
            int num2 = x;
            int num3 = y;

            int frameX = (int)Main.tile.At(x, y).FrameX;
            int frameY = (int)Main.tile.At(x, y).FrameY;
            if (frameX == 0)
            {
                num2 = x;
                num = 1;
            }
            else if (frameX == 18)
            {
                num2 = x - 1;
                num = 1;
            }
            else if (frameX == 36)
            {
                num2 = x + 1;
                num = -1;
            }
            else if (frameX == 54)
            {
                num2 = x;
                num = -1;
            }
            if (frameY == 0)
            {
                num3 = y;
            }
            else if (frameY == 18)
            {
                num3 = y - 1;
            }
            else if (frameY == 36)
            {
                num3 = y - 2;
            }
            int num4 = num2;
            if (num == -1)
            {
                num4 = num2 - 1;
            }
            if (!forced)
            {
                for (int k = num3; k < num3 + 3; k++)
                {
                    if (!Collision.EmptyTile(num2, k, true))
                    {
                        return false;
                    }
                }
            }
            for (int l = num4; l < num4 + 2; l++)
            {
                for (int m = num3; m < num3 + 3; m++)
                {
                    if (l == num2)
                    {
                        Main.tile.At(l, m).SetType (10);
                        Main.tile.At(l, m).SetFrameX ((short)(WorldModify.genRand.Next(3) * 18));
                    }
                    else
                    {
                        Main.tile.At(l, m).SetActive (false);
                    }
                }
            }
            for (int n = num2 - 1; n <= num2 + 1; n++)
            {
                for (int num5 = num3 - 1; num5 <= num3 + 2; num5++)
                {
                    WorldModify.TileFrame(n, num5, false, false);
                }
            }
            return true;
        }
        /// <summary>
        /// Parses new console command
        /// </summary>
        /// <param name="line">Command to parse</param>
        /// <param name="sender">Sending entity</param>
        public void ParseConsoleCommand(string line, ConsoleSender sender = null)
        {
            line = line.Trim();

            if (sender == null)
            {
                sender = consoleSender;
            }

            ParseAndProcess (sender, line);
        }
        /// <summary>
        /// Parses new console command
        /// </summary>
        /// <param name="line">Command to parse</param>
        /// <param name="server">Current Server instance</param>
        /// <param name="sender">Sender of the Command</param>
        public void ParseConsoleCommand(string line, Server server, ConsoleSender sender = null)
        {
            line = line.Trim();

            if (sender == null)
            {
                sender = consoleSender;
            }

            var ev = new ConsoleCommandEvent ();
            ev.Sender = sender;
            ev.Message = line;
            server.PluginManager.processHook (Hooks.CONSOLE_COMMAND, ev);
            if (ev.Cancelled)
            {
                return;
            }

            ParseAndProcess (sender, line);
        }
        public static bool OpenDoor(int x, int y, int direction, ISender sender)
        {
            if (sender == null)
            {
                sender = new ConsoleSender();
            }

            if (Program.properties.NPCDoorOpenCancel && sender is NPC)
                return false;

            var ctx = new HookContext
            {
                Sender = sender,
            };

            var args = new HookArgs.DoorStateChanged
            {
                X = x, Y = y,
                Direction = direction,
                Open = true,
            };

            HookPoints.DoorStateChanged.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick ())
                return false;

            if (ctx.Result == HookResult.IGNORE)
                return false;

            if (ctx.Result == HookResult.RECTIFY)
            {
                NetMessage.SendData(19, -1, -1, "", 1, (float)x, (float)y, 0); //Inform the client of the update
                return false;
            }

            int num = 0;
            if (Main.tile.At(x, y - 1).FrameY == 0 && Main.tile.At(x, y - 1).Type == Main.tile.At(x, y).Type)
            {
                num = y - 1;
            }
            else if (Main.tile.At(x, y - 2).FrameY == 0 && Main.tile.At(x, y - 2).Type == Main.tile.At(x, y).Type)
            {
                num = y - 2;
            }
            else if (Main.tile.At(x, y + 1).FrameY == 0 && Main.tile.At(x, y + 1).Type == Main.tile.At(x, y).Type)
            {
                num = y + 1;
            }
            else
            {
                num = y;
            }
            int num2 = x;
            short num3 = 0;
            int num4;
            if (direction == -1)
            {
                num2 = x - 1;
                num3 = 36;
                num4 = x - 1;
            }
            else
            {
                num2 = x;
                num4 = x + 1;
            }
            bool flag = true;
            for (int k = num; k < num + 3; k++)
            {
                if (Main.tile.At(num4, k).Active)
                {
                    if (Main.tile.At(num4, k).Type != 3 && Main.tile.At(num4, k).Type != 24 && Main.tile.At(num4, k).Type != 52 && Main.tile.At(num4, k).Type != 61 && Main.tile.At(num4, k).Type != 62 && Main.tile.At(num4, k).Type != 69 && Main.tile.At(num4, k).Type != 71 && Main.tile.At(num4, k).Type != 73 && Main.tile.At(num4, k).Type != 74)
                    {
                        flag = false;
                        break;
                    }
                    WorldModify.KillTile(num4, k, false, false, false);
                }
            }
            if (flag)
            {
                Main.tile.At(num2, num).SetActive (true);
                Main.tile.At(num2, num).SetType (11);
                Main.tile.At(num2, num).SetFrameY (0);
                Main.tile.At(num2, num).SetFrameX (num3);
                Main.tile.At(num2 + 1, num).SetActive (true);
                Main.tile.At(num2 + 1, num).SetType (11);
                Main.tile.At(num2 + 1, num).SetFrameY (0);
                Main.tile.At(num2 + 1, num).SetFrameX ((short)(num3 + 18));
                Main.tile.At(num2, num + 1).SetActive (true);
                Main.tile.At(num2, num + 1).SetType (11);
                Main.tile.At(num2, num + 1).SetFrameY (18);
                Main.tile.At(num2, num + 1).SetFrameX (num3);
                Main.tile.At(num2 + 1, num + 1).SetActive (true);
                Main.tile.At(num2 + 1, num + 1).SetType (11);
                Main.tile.At(num2 + 1, num + 1).SetFrameY (18);
                Main.tile.At(num2 + 1, num + 1).SetFrameX ((short)(num3 + 18));
                Main.tile.At(num2, num + 2).SetActive (true);
                Main.tile.At(num2, num + 2).SetType (11);
                Main.tile.At(num2, num + 2).SetFrameY (36);
                Main.tile.At(num2, num + 2).SetFrameX (num3);
                Main.tile.At(num2 + 1, num + 2).SetActive (true);
                Main.tile.At(num2 + 1, num + 2).SetType (11);
                Main.tile.At(num2 + 1, num + 2).SetFrameY (36);
                Main.tile.At(num2 + 1, num + 2).SetFrameX ((short)(num3 + 18));
                for (int l = num2 - 1; l <= num2 + 2; l++)
                {
                    for (int m = num - 1; m <= num + 2; m++)
                    {
                        WorldModify.TileFrame(l, m, false, false);
                    }
                }
            }
            return flag;
        }
        public static bool CloseDoor(int x, int y, bool forced, ISender sender)
        {
            if (sender == null)
            {
                sender = new ConsoleSender ();
            }

            if (Program.properties.NPCDoorOpenCancel && sender is NPC)
                return false;

            var ctx = new HookContext
            {
                Sender = sender,
            };

            var args = new HookArgs.DoorStateChanged
            {
                X = x, Y = y,
                Direction = 1,
                Open = false,
            };

            HookPoints.DoorStateChanged.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick ())
                return false;

            if (ctx.Result == HookResult.IGNORE)
                return false;

            if (ctx.Result == HookResult.RECTIFY)
            {
                NetMessage.SendData(19, -1, -1, "", 0, (float)x, (float)y, 0); //Inform the client of the update
                return false;
            }

            int num = 0;
            int num2 = x;
            int num3 = y;

            int frameX = (int)Main.tile.At(x, y).FrameX;
            int frameY = (int)Main.tile.At(x, y).FrameY;
            if (frameX == 0)
            {
                num2 = x;
                num = 1;
            }
            else if (frameX == 18)
            {
                num2 = x - 1;
                num = 1;
            }
            else if (frameX == 36)
            {
                num2 = x + 1;
                num = -1;
            }
            else if (frameX == 54)
            {
                num2 = x;
                num = -1;
            }
            if (frameY == 0)
            {
                num3 = y;
            }
            else if (frameY == 18)
            {
                num3 = y - 1;
            }
            else if (frameY == 36)
            {
                num3 = y - 2;
            }
            int num4 = num2;
            if (num == -1)
            {
                num4 = num2 - 1;
            }
            if (!forced)
            {
                for (int k = num3; k < num3 + 3; k++)
                {
                    if (!Collision.EmptyTile(num2, k, true))
                    {
                        return false;
                    }
                }
            }
            for (int l = num4; l < num4 + 2; l++)
            {
                for (int m = num3; m < num3 + 3; m++)
                {
                    if (l == num2)
                    {
                        Main.tile.At(l, m).SetType (10);
                        Main.tile.At(l, m).SetFrameX ((short)(WorldModify.genRand.Next(3) * 18));
                    }
                    else
                    {
                        Main.tile.At(l, m).SetActive (false);
                    }
                }
            }
            for (int n = num2 - 1; n <= num2 + 1; n++)
            {
                for (int num5 = num3 - 1; num5 <= num3 + 2; num5++)
                {
                    WorldModify.TileFrame(n, num5, false, false);
                }
            }
            return true;
        }
        public static bool CloseDoor(int i, int j, bool forced = false, DoorOpener opener = DoorOpener.SERVER, ISender sender = null)
        {
            if (sender == null)
            {
                sender = new ConsoleSender ();
            }

            DoorStateChangeEvent doorEvent = new DoorStateChangeEvent();
            doorEvent.Sender = sender;
            doorEvent.X = i;
            doorEvent.Y = j;
            doorEvent.Direction = 1;
            doorEvent.Opener = opener;
            doorEvent.isOpened = forced;
            Program.server.PluginManager.processHook(Hooks.DOOR_STATECHANGE, doorEvent);
            if (doorEvent.Cancelled)
            {
                return true;
            }

            int num = 0;
            int num2 = i;
            int num3 = j;

            int frameX = (int)Main.tile.At(i, j).FrameX;
            int frameY = (int)Main.tile.At(i, j).FrameY;
            if (frameX == 0)
            {
                num2 = i;
                num = 1;
            }
            else if (frameX == 18)
            {
                num2 = i - 1;
                num = 1;
            }
            else if (frameX == 36)
            {
                num2 = i + 1;
                num = -1;
            }
            else if (frameX == 54)
            {
                num2 = i;
                num = -1;
            }
            if (frameY == 0)
            {
                num3 = j;
            }
            else if (frameY == 18)
            {
                num3 = j - 1;
            }
            else if (frameY == 36)
            {
                num3 = j - 2;
            }
            int num4 = num2;
            if (num == -1)
            {
                num4 = num2 - 1;
            }
            if (!forced)
            {
                for (int k = num3; k < num3 + 3; k++)
                {
                    if (!Collision.EmptyTile(num2, k, true))
                    {
                        return false;
                    }
                }
            }
            for (int l = num4; l < num4 + 2; l++)
            {
                for (int m = num3; m < num3 + 3; m++)
                {
                    if (l == num2)
                    {
                        Main.tile.At(l, m).SetType (10);
                        Main.tile.At(l, m).SetFrameX ((short)(WorldModify.genRand.Next(3) * 18));
                    }
                    else
                    {
                        Main.tile.At(l, m).SetActive (false);
                    }
                }
            }
            for (int n = num2 - 1; n <= num2 + 1; n++)
            {
                for (int num5 = num3 - 1; num5 <= num3 + 2; num5++)
                {
                    WorldModify.TileFrame(n, num5, false, false);
                }
            }
            return true;
        }