Beispiel #1
0
 public override void Use(Player p, string message)
 {
     if (p == null) { Player.SendMessage(p, "Command not usable in Console."); return; }
     if (!p.group.CanExecute(Command.all.Find("static")) || !p.group.CanExecute(Command.all.Find("cuboid"))) { p.SendMessage("You must have access to both /static and /cuboid commands."); return; }
     if (p.staticCommands) { p.staticCommands = false; p.ClearBlockchange(); p.BlockAction = 0; p.SendMessage("/zz has finished."); }
     else { Command.all.Find("static").Use(p, "cuboid " + message); }
 }
Beispiel #2
0
        public override void Use(Player p, string message)
        {
            p.staticCommands = !p.staticCommands;
            p.ClearBlockchange();
            p.BlockAction = 0;

            Player.SendMessage(p, "Static mode: &a" + p.staticCommands.ToString());

            try
            {
                if (message != "")
                {
                    if (message.IndexOf(' ') == -1)
                    {
                        if (p.group.CanExecute(Command.all.Find(message)))
                            Command.all.Find(message).Use(p, "");
                        else
                            Player.SendMessage(p, "Cannot use that command.");
                    }
                    else
                    {
                        if (p.group.CanExecute(Command.all.Find(message.Split(' ')[0])))
                            Command.all.Find(message.Split(' ')[0]).Use(p, message.Substring(message.IndexOf(' ') + 1));
                        else
                            Player.SendMessage(p, "Cannot use that command.");
                    }
                }
            }
            catch { Player.SendMessage(p, "Could not find specified command"); }
        }
Beispiel #3
0
        public void EntryChange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            portalPos bp = (portalPos)p.blockchangeObject;

            if (bp.Multi.ToLower() == "multi" && type == Block.red && bp.port.Count > 0) { ExitChange(p, x, y, z, type); return; }

            byte b = p.level.GetTile(x, y, z);
            p.level.Blockchange(p, x, y, z, bp.type);
            p.SendBlockchange(x, y, z, Block.green);
            portPos Port;

            Port.portMapName = p.level.name;
            Port.x = x; Port.y = y; Port.z = z;

            bp.port.Add(Port);

            p.blockchangeObject = bp;

            if (bp.Multi.ToLower() != "multi")
            {
                p.Blockchange += new Player.BlockchangeEventHandler(ExitChange);
                Player.SendMessage(p, "&aEntry block placed");
            }
            else if (bp.Multi.ToLower() == "multi")
            {
                p.Blockchange += new Player.BlockchangeEventHandler(EntryChange);
                Player.SendMessage(p, "&aEntry block placed. &cPlace a Red block for exit.");
            }
        }
Beispiel #4
0
        public void ExitChange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            portalPos bp = (portalPos)p.blockchangeObject;

            foreach (portPos pos in bp.port)
            {
                DataTable Portals = MySQL.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z);
                Portals.Dispose();

                if (Portals.Rows.Count == 0)
                {
                    MySQL.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")");
                }
                else
                {
                    MySQL.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z);
                }
                //DB

                if (pos.portMapName == p.level.name) p.SendBlockchange(pos.x, pos.y, pos.z, bp.type);
            }

            Player.SendMessage(p, "&3Exit" + "&g block placed");

            if (p.staticCommands) { bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += new Player.BlockchangeEventHandler(EntryChange); }
        }
Beispiel #5
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            int counter = 0;
            ushort xx, yy, zz;
            for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        if (selectedBlock <= 0)
                        {
                            counter++;
                            p.SendBlockchange(xx, yy, zz, 0); // xray block
                        }
                        else
                        {
                            if (p.level.GetTile(xx, yy, zz) == selectedBlock) // check if block is selected block
                            {
                                counter++;
                                p.SendBlockchange(xx, yy, zz, 0); // xray block
                            }
                        }
            Player.SendMessage(p, "X-Rayed " + counter + " blocks.");
            Player.SendMessage(p, "Use /reveal to restore all x-rayed blocks.");
        }
Beispiel #6
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            Level.Zone Zn;

            Zn.smallX = Math.Min(cpos.x, x);
            Zn.smallY = Math.Min(cpos.y, y);
            Zn.smallZ = Math.Min(cpos.z, z);
            Zn.bigX = Math.Max(cpos.x, x);
            Zn.bigY = Math.Max(cpos.y, y);
            Zn.bigZ = Math.Max(cpos.z, z);
            Zn.Owner = cpos.Owner;

            p.level.ZoneList.Add(Zn);

            //DB
            MySQL.executeQuery("INSERT INTO `Zone" + p.level.name + "` (SmallX, SmallY, SmallZ, BigX, BigY, BigZ, Owner) VALUES (" + Zn.smallX + ", " + Zn.smallY + ", " + Zn.smallZ + ", " + Zn.bigX + ", " + Zn.bigY + ", " + Zn.bigZ + ", '" + Zn.Owner + "')");
            //DB

            Player.SendMessage(p, "Added zone for &b" + cpos.Owner);
        }
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            cpos.message = cpos.message.Replace("'", "\\'");

            DataTable Messages = MySQL.fillData("SELECT * FROM `Commandblocks" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
            Messages.Dispose();

            if (Messages.Rows.Count == 0)
            {
                MySQL.executeQuery("INSERT INTO `Commandblocks" + p.level.name + "` (X, Y, Z, Message) VALUES (" + (int)x + ", " + (int)y + ", " + (int)z + ", '" + cpos.message + "')");
            }
            else
            {
                MySQL.executeQuery("UPDATE `Commandblocks" + p.level.name + "` SET Message='" + cpos.message + "' WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);
            }

            Player.SendMessage(p, "Message block placed.");
            p.level.Blockchange(p, x, y, z, cpos.type);
            p.SendBlockchange(x, y, z, cpos.type);

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Beispiel #8
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            ushort xx, yy, zz; int foundBlocks = 0;

            for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) != cpos.toIgnore) foundBlocks++;
                    }

            Player.SendMessage(p, foundBlocks + " blocks are between (" + cpos.x + ", " + cpos.y + ", " + cpos.z + ") and (" + x + ", " + y + ", " + z + ")");

            ushort xdiff = (ushort)((Math.Max(cpos.x, x)) - Math.Min(cpos.x, x));
            ushort ydiff = (ushort)((Math.Max(cpos.y, y)) - Math.Min(cpos.y, y));
            ushort zdiff = (ushort)((Math.Max(cpos.z, z)) - Math.Min(cpos.z, z));

            Player.SendMessage(p, "The selected area was " + xdiff + " blocks wide, " + ydiff + " blocks high, " + zdiff + " blocks deep.");

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Beispiel #9
0
 public void AddGoalPos(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     p.level.Blockchange(x, y, z, Block.air);
     if (type == Block.red && goalBuffer.Count > 0)
     {
         p.SendBlockchange(x, y, z, Block.air);
         foreach (PushBallTeam.Pos pp in goalBuffer)
         {
             p.level.pushBall.pushBallTeams.Find(team => team.color == goalPosColor[1]).goalPositions.Add(pp);
             p.SendBlockchange(pp.x, pp.y, pp.z, Block.air);
         }
         Player.SendMessage(p, "Goal positions selected for " + p.level.pushBall.pushBallTeams.Find(team => team.color == goalPosColor[1]).teamstring);
         goalBuffer.Clear();
         goalPosColor = "";
     }
     else
     {
         p.SendBlockchange(x, y, z, Block.green);
         PushBallTeam.Pos gp = new PushBallTeam.Pos();
         gp.x = x; gp.y = y; gp.z = z;
         goalBuffer.Add(gp);
         Player.SendMessage(p, "&aGoal position added. &cPlace a red block to finish.");
         p.Blockchange += new Player.BlockchangeEventHandler(AddGoalPos);
     }
 }
Beispiel #10
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            List<CatchPos> buffer = new List<CatchPos>();
            CatchPos pos = new CatchPos();
            //int totalChecks = 0;

            //if (Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z) > 8000) { Player.SendMessage(p, "Tried to restart too many blocks. You may only restart 8000"); return; }

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
            {
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                {
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        if (p.level.GetTile(xx, yy, zz) != Block.air)
                        {
                            pos.x = xx; pos.y = yy; pos.z = zz;
                            pos.extraInfo = cpos.extraInfo;
                            buffer.Add(pos);
                        }
                    }
                }
            }

            try
            {
                if (cpos.extraInfo == "")
                {
                    if (buffer.Count > Server.rpNormLimit)
                    {
                        Player.SendMessage(p, "Cannot restart more than " + Server.rpNormLimit + " blocks.");
                        Player.SendMessage(p, "Tried to restart " + buffer.Count + " blocks.");
                        return;
                    }
                }
                else
                {
                    if (buffer.Count > Server.rpLimit)
                    {
                        Player.SendMessage(p, "Tried to add physics to " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "Cannot add physics to more than " + Server.rpLimit + " blocks.");
                        return;
                    }
                }
            }
            catch { return; }

            foreach (CatchPos pos1 in buffer)
            {
                p.level.AddCheck(p.level.PosToInt(pos1.x, pos1.y, pos1.z), pos1.extraInfo, true);
            }

            Player.SendMessage(p, "Activated " + buffer.Count + " blocks.");
            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Beispiel #11
0
        public void AboutBlockchange(Player p, ushort x, ushort y, ushort z, byte type)
        {
            if (!p.staticCommands) p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            if (b == Block.Zero) { Player.SendMessage(p, "Invalid Block(" + x + "," + y + "," + z + ")!"); return; }
            p.SendBlockchange(x, y, z, b);

            string message = "Block (" + x + "," + y + "," + z + "): ";
            message += "&f" + b + " = " + Block.Name(b);
            Player.SendMessage(p, message + "&g.");
            message = p.level.foundInfo(x, y, z);
            if (message != "") Player.SendMessage(p, "Physics information: &a" + message);

            DataTable Blocks = MySQL.fillData("SELECT * FROM `Block" + p.level.name + "` WHERE X=" + (int)x + " AND Y=" + (int)y + " AND Z=" + (int)z);

            string Username, TimePerformed, BlockUsed;
            bool Deleted, foundOne = false;

            for (int i = 0; i < Blocks.Rows.Count; i++)
            {
                foundOne = true;
                Username = Blocks.Rows[i]["Username"].ToString();
                TimePerformed = DateTime.Parse(Blocks.Rows[i]["TimePerformed"].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
                BlockUsed = Block.Name((byte)Blocks.Rows[i]["Type"]).ToString();
                Deleted = (bool)Blocks.Rows[i]["Deleted"];

                if (!Deleted)
                    Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed);
                else
                    Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed);
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }

            List<Level.BlockPos> inCache = p.level.blockCache.FindAll(bP => bP.x == x && bP.y == y && bP.z == z);

            for (int i = 0; i < inCache.Count; i++)
            {
                foundOne = true;
                Deleted = inCache[i].deleted;
                Username = inCache[i].name;
                TimePerformed = inCache[i].TimePerformed.ToString("yyyy-MM-dd HH:mm:ss");
                BlockUsed = Block.Name(inCache[i].type);

                if (!Deleted)
                    Player.SendMessage(p, "&3Created by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed);
                else
                    Player.SendMessage(p, "&4Destroyed by " + Server.FindColor(Username.Trim()) + Username.Trim() + "&g, using &3" + BlockUsed);
                Player.SendMessage(p, "Date and time modified: &2" + TimePerformed);
            }

            if (!foundOne)
                Player.SendMessage(p, "This block has not been modified since the map was cleared.");

            Blocks.Dispose();

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Beispiel #12
0
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     byte b = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, b);
     CatchPos bp = (CatchPos)p.blockchangeObject;
     bp.x = x; bp.y = y; bp.z = z; p.blockchangeObject = bp;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
Beispiel #13
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            if (cpos.y == y)
            {
                Player.SendMessage(p, "Cannot create a stairway 0 blocks high.");
                return;
            }

            ushort xx, zz; int currentState = 0;
            xx = cpos.x; zz = cpos.z;

            if (cpos.x > x && cpos.z > z) currentState = 0;
            else if (cpos.x > x && cpos.z < z) currentState = 1;
            else if (cpos.x < x && cpos.z > z) currentState = 2;
            else currentState = 3;

            for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
            {
                if (currentState == 0)
                {
                    xx++; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    xx++; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 1;
                }
                else if (currentState == 1)
                {
                    zz++; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    zz++; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 2;
                }
                else if (currentState == 2)
                {
                    xx--; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    xx--; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 3;
                }
                else
                {
                    zz--; p.level.Blockchange(p, xx, yy, zz, Block.staircasestep);
                    zz--; p.level.Blockchange(p, xx, yy, zz, Block.staircasefull);
                    currentState = 0;
                }
                /*
                if (cpos.x == xx && cpos.z == zz || cpos.x == xx + 1 && cpos.z == zz) xx++;
                else if (cpos.x == xx + 2 && cpos.z == zz || cpos.x == xx + 2 && cpos.z == zz + 1) zz++;
                else if (cpos.x == xx + 2 && cpos.z == zz + 2 || cpos.x == xx + 1 && cpos.z == zz + 2) xx--;
                else zz--;
                */
            }

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Beispiel #14
0
 public override void Use(Player p, string message)
 {
     p.ClearBlockchange();
     switch (message.ToLower())
     {
         case "2":
         case "cactus": p.Blockchange += new Player.BlockchangeEventHandler(AddCactus); break;
         default: p.Blockchange += new Player.BlockchangeEventHandler(AddTree); break;
     }
     Player.SendMessage(p, "Select where you wish your tree to grow");
     p.painting = false;
 }
Beispiel #15
0
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     byte b = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, b);
     Level.Reflection r = (Level.Reflection)p.blockchangeObject;
     Level.ReflectionPos rp = new Level.ReflectionPos();
     rp.x = x; rp.y = y; rp.z = z;
     r.reflectionPositions.Add(rp);
     p.blockchangeObject = r;
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange2);
 }
Beispiel #16
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            int[] xxx = { Math.Min(cpos.x, x), Math.Max(cpos.x, x) };
            int[] yyy = { Math.Min(cpos.y, y), Math.Max(cpos.y, y) };
            int[] zzz = { Math.Min(cpos.z, z), Math.Max(cpos.z, z) };

            bool unevenZ, unevenY, unevenX;

            ushort medz = (ushort)(GetMedian(zzz, out unevenZ));
            ushort medy = (ushort)(GetMedian(yyy, out unevenY));
            ushort medx = (ushort)(GetMedian(xxx, out unevenX));

            ushort meepZ = (unevenZ) ? (ushort)(medz + 1) : (ushort)0;
            ushort meepY = (unevenY) ? (ushort)(medy + 1) : (ushort)0;
            ushort meepX = (unevenX) ? (ushort)(medx + 1) : (ushort)0;

            if (unevenZ)
            {
                Player.SendMessage(p, "The Z coordinate was even. Placing 2 blocks for accuracy.");
            }
            if (unevenY)
            {
                Player.SendMessage(p, "The Y coordinate was even. Placing 2 blocks for accuracy.");
            }
            if (unevenX)
            {
                Player.SendMessage(p, "The X coordinate was even. Placing 2 blocks for accuracy.");
            }

            if (p.level.GetTile(medx, medy, medz) != type)
            {
                p.level.Blockchange(p, medx, medy, medz, type);
                if (meepZ != 0)
                {
                    p.level.Blockchange(p, medx, medy, meepZ, type);
                }
                if (meepY != 0)
                {
                    p.level.Blockchange(p, medx, meepY, meepZ, type);
                }
                if (meepX != 0)
                {
                    p.level.Blockchange(p, meepX, medy, meepZ, type);
                }
            }

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Beispiel #17
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;

            p.CopyBuffer.Clear();
            int TotalAir = 0;
            if (cpos.type == 2) p.copyAir = true; else p.copyAir = false;

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        b = p.level.GetTile(xx, yy, zz);
                        if (Block.canPlace(p, b))
                        {
                            if (b == Block.air && cpos.type != 2 || cpos.ignoreTypes.Contains(b)) TotalAir++;

                            if (cpos.ignoreTypes.Contains(b)) BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), Block.air);
                            else BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), b);
                        }
                        else BufferAdd(p, (ushort)(xx - cpos.x), (ushort)(yy - cpos.y), (ushort)(zz - cpos.z), Block.air);
                    }

            if ((p.CopyBuffer.Count - TotalAir) > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to copy " + p.CopyBuffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot copy more than " + p.group.maxBlocks + ".");
                p.CopyBuffer.Clear();
                return;
            }

            if (cpos.type == 1)
                for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                        for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                        {
                            b = p.level.GetTile(xx, yy, zz);
                            if (b != Block.air && Block.canPlace(p, b))
                                p.level.Blockchange(p, xx, yy, zz, Block.air);
                        }

            Player.SendMessage(p, (p.CopyBuffer.Count - TotalAir) + " blocks copied.");
            if (allowoffset != -1)
            {
                Player.SendMessage(p, "Place a block to determine where to paste from");
                p.Blockchange += new Player.BlockchangeEventHandler(Blockchange3);
            }
        }
Beispiel #18
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);

            Player.UndoPos Pos1;
            //p.UndoBuffer.Clear();

            Level l = p.level;
            p.activeCuboids++;
            Thread t = new Thread(new ThreadStart(delegate
            {
                try
                {
                    int c = 0;
                    p.CopyBuffer.ForEach(delegate(Player.CopyPos pos)
                    {
                        c++;
                        if (p.activeCuboids == 0) return;
                        Pos1.x = (ushort)(Math.Abs(pos.x) + x);
                        Pos1.y = (ushort)(Math.Abs(pos.y) + y);
                        Pos1.z = (ushort)(Math.Abs(pos.z) + z);

                        if (pos.type != Block.air || p.copyAir)
                            unchecked
                            {
                                if (p.level.GetTile(Pos1.x, Pos1.y, Pos1.z) != Block.Zero)
                                    l.Blockchange(p, (ushort)(Pos1.x + p.copyoffset[0]), (ushort)(Pos1.y + p.copyoffset[1]), (ushort)(Pos1.z + p.copyoffset[2]), pos.type);
                            }
                        if (Server.throttle > 0)
                        {
                            while (Server.pauseCuboids) { Thread.Sleep(1000); }
                            if (c >= Server.throttle)
                            {
                                c = 0;
                                if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                            }
                        }
                    });
                    Player.SendMessage(p, "Pasted " + p.CopyBuffer.Count + " blocks.");
                    if (p.activeCuboids > 0) p.activeCuboids--;
                    if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
            })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();
        }
Beispiel #19
0
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            unchecked { if (cpos.type != (byte)-1) { type = cpos.type; } }
            List<Pos> buffer = new List<Pos>();
            Pos pos;

            bool AddMe = false;

            for (ushort xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                    for (ushort zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                    {
                        AddMe = false;

                        if (p.level.GetTile((ushort)(xx - 1), yy, zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile((ushort)(xx + 1), yy, zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, (ushort)(yy - 1), zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, (ushort)(yy + 1), zz) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, yy, (ushort)(zz - 1)) == cpos.type) AddMe = true;
                        else if (p.level.GetTile(xx, yy, (ushort)(zz + 1)) == cpos.type) AddMe = true;

                        if (AddMe && p.level.GetTile(xx, yy, zz) != cpos.type) { pos.x = xx; pos.y = yy; pos.z = zz; buffer.Add(pos); }
                    }

            if (buffer.Count > p.group.maxBlocks)
            {
                Player.SendMessage(p, "You tried to outline more than " + buffer.Count + " blocks.");
                Player.SendMessage(p, "You cannot outline more than " + p.group.maxBlocks + ".");
                return;
            }

            buffer.ForEach(delegate(Pos pos1)
            {
                p.level.Blockchange(p, pos1.x, pos1.y, pos1.z, cpos.type2);
            });

            Player.SendMessage(p, "You outlined " + buffer.Count + " blocks.");

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Beispiel #20
0
 public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
 {
     p.ClearBlockchange();
     byte b = p.level.GetTile(x, y, z);
     p.SendBlockchange(x, y, z, b);
     bool there = false;
     while (!there )
     {
         y++;
         if (Block.Walkthrough(p.level.GetTile(x, y, z)))
             if (Block.Walkthrough(p.level.GetTile(x, (ushort)(y + 1), z)))
                 if (!Block.Walkthrough(p.level.GetTile(x, (ushort)(y - 1), z)))
                 {
                     Player.SendMessage(p, "Teleported up.");
                     unchecked { p.SendPos((byte)-1, (ushort)(x * 32), (ushort)((y + 1) * 32), (ushort)(z * 32), p.rot[0], p.rot[1]); }
                     there = true;
                 }
     }
     if (!there) { Player.SendMessage(p, "No free spaces available."); }
     if (p.staticCommands) { p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1); }
 }
Beispiel #21
0
 public override void Use(Player p, string message)
 {
     p.ClearBlockchange();
     p.painting = false;
     p.BlockAction = 0;
     p.megaBoid = false;
     p.cmdTimer = false;
     p.staticCommands = false;
     p.deleteMode = false;
     p.ZoneCheck = false;
     p.modeType = 0;
     p.aiming = false;
     p.brushing = false;
     p.onTrain = false;
     p.autobuild = false;
     p.activeCuboids = 0;
     p.zoneDel = false;
     p.isFlying = false;
     p.storedMessage = "";
     foreach (Level l in Server.levels)
     {
         if (l.reflections.ContainsKey(p.name.ToLower()))
             l.reflections.Remove(p.name.ToLower());
         if (l.reflectionLines.ContainsKey(p.name.ToLower()))
             l.reflectionLines.Remove(p.name.ToLower());
     }
     // plugins
     /*p.noKick = false;
     p.noSendMessage = false;
     p.noJoin = false;
     p.noDisconnect = false;
     p.noMove = false;
     p.noChat = false;
     p.noCommand = false;
     p.noDeath = false;
     p.noBuild = false;*/
     Player.SendMessage(p, "Every toggle or action was aborted.");
 }
Beispiel #22
0
 public override void Use(Player p, string message)
 {
     if (p == null) { Player.SendMessage(p, "Command not usable in Console."); return; }
     if (message == "") { Help(p); return; }
     switch (message.Split(' ')[0].ToLower())
     {
         case "enable":
             if (p.level.ctfmode) { Player.SendMessage(p, "CTF game is in progress."); return; }
             if (p.level.spleefstarted) { Player.SendMessage(p, "Spleef game is in progress."); return; }
             if (p.level.zombiegame) { Player.SendMessage(p, "Infection game is in progress."); return; }
             if (p.level.pushBallEnabled) { Player.SendMessage(p, "PushBall is already enabled on this level. Use /pushball disable to disable."); return; }
             p.level.pushBallEnabled = true;
             p.level.ChatLevel("PushBall mode enabled.");
             break;
         case "disable":
             if (!p.level.pushBallEnabled) { Player.SendMessage(p, "PushBall has not been enabled yet on this level. Use /pushball enable to enable."); return; }
             if (p.level.pushBallStarted) { Command.all.Find("pushball").Use(p, "end"); }
             p.level.pushBallEnabled = false;
             p.level.ChatLevel("PushBall mode disabled.");
             break;
         case "start":
             if (!p.level.pushBallEnabled) { Player.SendMessage(p, "Please enable PushBall mode with /pushball enable, first."); return; }
             if (p.level.players.Count < 2) { Player.SendMessage(p, "Must have at least 2 players to play."); return; }
             if (p.level.pushBall.pushBallTeams.Count < 2) { Player.SendMessage(p, "Must have at least 2 teams to play."); return; }
             if (!p.level.pushBall.ballSpawnSet) { Player.SendMessage(p, "Set the ball spawn first with /pushball ballspawn."); return; }
             p.level.pushBallStarted = true;
             p.level.pushBall.Start();
             break;
         case "stop": case "end":
             if (!p.level.pushBallStarted) { Player.SendMessage(p, "PushBall game has not started."); return; }
             p.level.pushBallStarted = false;
             p.level.pushBall.End(null);
             p.level.ChatLevel(p.color + p.name + " &ehas ended the PushBall game!");
             break;
         case "ballspawn":
             PushBall.Pos ballSpawn = new PushBall.Pos();
             ballSpawn.x = (ushort)(p.pos[0] / 32);
             ballSpawn.y = (ushort)(p.pos[1] / 32);
             ballSpawn.z = (ushort)(p.pos[2] / 32);
             p.level.pushBall.ballSpawn = ballSpawn;
             p.level.pushBall.ballSpawnSet = true;
             Player.SendMessage(p, "Ball spawn point has been set.");
             break;
         case "points":
             if (message.Split(' ').Length <= 1) { Help(p); return; }
             try { p.level.pushBall.winPoints = int.Parse(message.Split(' ')[1]); }
             catch { Player.SendMessage(p, "Max points value must be numeric."); return; }
             Player.SendMessage(p, "Max points set to " + p.level.pushBall.winPoints + ".");
             break;
         case "spawn":
             if (c.Parse(message.Split(' ')[1]) == "") { Player.SendMessage(p, "Invalid team color chosen."); return; }
             char teamCol = (char)c.Parse(message.Split(' ')[1])[1];
             if (p.level.pushBall.pushBallTeams.Find(team => team.color == teamCol) == null) { Player.SendMessage(p, "Invalid team color chosen."); return; }
             AddSpawn(p, c.Parse(message.Split(' ')[1]));
             break;
         case "goal":
             if (message.Split(' ').Length != 2) { Help(p); return; }
             if (c.Parse(message.Split(' ')[1]) == "") { Player.SendMessage(p, "Invalid team color chosen."); return; }
             switch ((char)c.Parse(message.Split(' ')[1])[1])
             {
                 case '2':
                 case '5':
                 case '8':
                 case '9':
                 case 'c':
                 case 'e':
                 case 'f':
                     goalPosColor = c.Parse(message.Split(' ')[1]);
                     Player.SendMessage(p, "Start placing blocks to select your goal area.");
                     p.ClearBlockchange();
                     p.Blockchange += new Player.BlockchangeEventHandler(AddGoalPos);
                     break;
                 default:
                     Player.SendMessage(p, "Invalid team color chosen.");
                     return;
             }
             break;
         case "team":
             string color = c.Parse(message.Split(' ')[2]);
             if (color == "") { Player.SendMessage(p, "Invalid team color chosen."); return; }
             switch ((char)color[1])
             {
                 case '2':
                 case '5':
                 case '8':
                 case '9':
                 case 'c':
                 case 'e':
                 case 'f':
                     if (message.Split(' ')[1].ToLower() == "add")
                     {
                         //if (p.level.pushBall.pushBallTeams.Count == 2) { Player.SendMessage(p, "Cannot have more than 2 teams in PushBall."); return; }
                         AddTeam(p, color);
                     }
                     else if (message.Split(' ')[1].ToLower() == "del") RemoveTeam(p, color);
                     else Help(p);
                     break;
                 default:
                     Player.SendMessage(p, "Invalid team color chosen.");
                     return;
             }
             break;
         case "clear":
             List<PushBallTeam> storedT = new List<PushBallTeam>();
             for (int i = 0; i < p.level.pushBall.pushBallTeams.Count; i++)
             {
                 storedT.Add(p.level.pushBall.pushBallTeams[i]);
             }
             foreach (PushBallTeam t in storedT)
             {
                 p.level.pushBall.RemoveTeam("&" + t.color);
             }
             //p.level.ctfgame.onTeamCheck.Stop();
             //p.level.ctfgame.onTeamCheck.Dispose();
             p.level.pushBallStarted = false;
             p.level.pushBallEnabled = false;
             p.level.pushBall = new PushBall();
             p.level.pushBall.level = p.level;
             Player.SendMessage(p, "PushBall data has been cleared.");
             break;
         case "instructions":
             Player.SendMultiple(p, new string[] {
                 "&9How to play PushBall by MCDawn:",
                 "1. Enable PushBall mode with /pushball enable.",
                 "2. Add ball spawn point with /pushball ballspawn.",
                 "3. Set maxpoints if needed with /pushball points <number>. Default is 3.",
                 "4. Add at least 2 teams to play with with /pushball team add/del <color>.",
                 "5. Add spawns for each team with /pushball spawn <team>. There can be more than one spawn.",
                 "6. Add goal positions for each team with /pushball goal <team>.",
                 "7. Start the game with /pushball start, and play :D.",
                 "If you want to stop mid-game, you can use /pushball end, and then disabling PushBall mode with /pushball disable.",
                 "To clear all PushBall data from the level, use /pushball clear."
             });
             break;
         default: Help(p); return;
     }
 }
Beispiel #23
0
        void AddTree(Player p, ushort x, ushort y, ushort z, byte type)
        {
            Random Rand = new Random();

            byte height = (byte)Rand.Next(5, 8);
            for (ushort yy = 0; yy < height; yy++) p.level.Blockchange(p, x, (ushort)(y + yy), z, Block.trunk);

            short top = (short)(height - Rand.Next(2, 4));

            for (short xx = (short)-top; xx <= top; ++xx)
            {
                for (short yy = (short)-top; yy <= top; ++yy)
                {
                    for (short zz = (short)-top; zz <= top; ++zz)
                    {
                        short Dist = (short)(Math.Sqrt(xx * xx + yy * yy + zz * zz));
                        if (Dist < top + 1)
                        {
                            if (Rand.Next((int)(Dist)) < 2)
                            {
                                try
                                {
                                    p.level.Blockchange(p, (ushort)(x + xx), (ushort)(y + yy + height), (ushort)(z + zz), Block.leaf);
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
            if (!p.staticCommands) p.ClearBlockchange();
        }
Beispiel #24
0
 public override void Use(Player p, string message)
 {
     if (!p.brushing && message.Trim() == "") { Help(p); return; }
     if (message.Trim().ToLower() == "off" || (message.Trim() == "" && p.brushing))
     {
         p.brushing = false;
         p.ClearBlockchange();
         Player.SendMessage(p, "Brushing mode turned off.");
         return;
     }
     if (message.Split(' ').Length > 3 || message.Split(' ').Length < 3) { Help(p); return; }
     ushort radius;
     try { radius = ushort.Parse(message.Split(' ')[0]); }
     catch { Help(p); return; }
     BrushType bt;
     switch (message.Split(' ')[2].ToLower())
     {
         case "sphere": bt = BrushType.sphere; break;
         case "cube": bt = BrushType.cube; break;
         case "random": bt = BrushType.random; break;
         default: Help(p); return;
     }
     byte t = Block.Byte(message.Split(' ')[1].ToLower());
     if (t == 255) { Player.SendMessage(p, "There is no block \"" + message + "\"."); return; }
     if (!Block.canPlace(p, t)) { Player.SendMessage(p, "Cannot place that."); return; }
     CatchPos cpos; cpos.x = 0; cpos.y = 0; cpos.z = 0; cpos.type = t; cpos.brush = bt; cpos.radius = radius;
     p.blockchangeObject = cpos;
     Player.SendMessage(p, "Brushing mode activated. Place/destroy blocks to use the brush.");
     p.brushing = true;
     p.ClearBlockchange();
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
 }
Beispiel #25
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            cpos.x = (ushort)(x + cpos.radius); cpos.y = (ushort)(y + cpos.radius); cpos.z = (ushort)(z + cpos.radius);
            x = (ushort)(x - cpos.radius); y = (ushort)(y - cpos.radius); z = (ushort)(z - cpos.radius);
            type = cpos.type;
            unchecked { if (cpos.type != (byte)-1) type = cpos.type; else type = p.bindings[type]; }
            List<Pos> buffer = new List<Pos>();

            ushort xx; ushort yy; ushort zz;

            // find axis lengths
            double rx = (Math.Max(cpos.x, x) - Math.Min(cpos.x, x) + 1) / 2d;
            double ry = (Math.Max(cpos.y, y) - Math.Min(cpos.y, y) + 1) / 2d;
            double rz = (Math.Max(cpos.z, z) - Math.Min(cpos.z, z) + 1) / 2d;

            double rx2 = 1 / (rx * rx);
            double ry2 = 1 / (ry * ry);
            double rz2 = 1 / (rz * rz);

            // find center points
            double cx = (Math.Max(cpos.x, x) + Math.Min(cpos.x, x)) / 2d;
            double cy = (Math.Max(cpos.y, y) + Math.Min(cpos.y, y) + 1) / 2d;
            double cz = (Math.Max(cpos.z, z) + Math.Min(cpos.z, z)) / 2d;

            switch (cpos.brush)
            {
                case BrushType.sphere:
                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); xx += 8)
                        for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy += 8)
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); zz += 8)
                                for (int z3 = 0; z3 < 8 && zz + z3 <= Math.Max(cpos.z, z); z3++)
                                    for (int y3 = 0; y3 < 8 && yy + y3 <= Math.Max(cpos.y, y); y3++)
                                        for (int x3 = 0; x3 < 8 && xx + x3 <= Math.Max(cpos.x, x); x3++)
                                        {
                                            // get relative coordinates
                                            double dx = (xx + x3 - cx);
                                            double dy = (yy + y3 - cy);
                                            double dz = (zz + z3 - cz);

                                            // test if it's inside ellipse
                                            if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1)
                                                if (p.level.GetTile((ushort)(xx + x3), (ushort)(yy + y3), (ushort)(zz + z3)) != type)
                                                    BufferAdd(buffer, (ushort)(xx + x3), (ushort)(yy + y3), (ushort)(zz + z3));
                                        }
                    break;
                case BrushType.cube:
                    buffer.Capacity = Math.Abs(cpos.x - x) * Math.Abs(cpos.y - y) * Math.Abs(cpos.z - z);
                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); ++xx)
                        for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); ++yy)
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); ++zz)
                            {
                                if (p.level.GetTile(xx, yy, zz) != type) { BufferAdd(buffer, xx, yy, zz); }
                            }
                    break;
                case BrushType.random:
                    Random rand = new Random();
                    for (xx = Math.Min(cpos.x, x); xx <= Math.Max(cpos.x, x); xx += 8)
                        for (yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy += 8)
                            for (zz = Math.Min(cpos.z, z); zz <= Math.Max(cpos.z, z); zz += 8)
                                for (int z3 = 0; z3 < 8 && zz + z3 <= Math.Max(cpos.z, z); z3++)
                                    for (int y3 = 0; y3 < 8 && yy + y3 <= Math.Max(cpos.y, y); y3++)
                                        for (int x3 = 0; x3 < 8 && xx + x3 <= Math.Max(cpos.x, x); x3++)
                                        {
                                            // get relative coordinates
                                            double dx = (xx + x3 - cx);
                                            double dy = (yy + y3 - cy);
                                            double dz = (zz + z3 - cz);

                                            // test if it's inside ellipse
                                            if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1)
                                                if (p.level.GetTile((ushort)(xx + x3), (ushort)(yy + y3), (ushort)(zz + z3)) != type)
                                                    if (rand.Next(1, 11) <= 5)
                                                        BufferAdd(buffer, (ushort)(xx + x3), (ushort)(yy + y3), (ushort)(zz + z3));
                                        }
                    break;
            }

            Level l = p.level;
            p.activeCuboids++;
            Thread t = new Thread(new ThreadStart(delegate
            {
                try
                {
                    int c;
                    if (Server.forceCuboid)
                    {
                        int counter = 1;
                        c = 0;
                        for (int i = 0; i < buffer.Count; i++)
                        {
                            if (counter <= p.group.maxBlocks)
                            {
                                c++;
                                if (p.activeCuboids == 0) return;
                                counter++;
                                l.Blockchange(p, buffer[i].x, buffer[i].y, buffer[i].z, type);
                                if (Server.throttle > 0)
                                {
                                    while (Server.pauseCuboids) { Thread.Sleep(1000); }
                                    if (c >= Server.throttle)
                                    {
                                        c = 0;
                                        if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                                    }
                                }
                            }
                        }
                        if (counter >= p.group.maxBlocks)
                        {
                            Player.SendMessage(p, "Tried to brush " + buffer.Count + " blocks, but your limit is " + p.group.maxBlocks + ".");
                            Player.SendMessage(p, "Executed brush up to limit.");
                        }
                        else
                        {
                            Player.SendMessage(p, buffer.Count.ToString() + " blocks.");
                        }

                        if (p.activeCuboids > 0) p.activeCuboids--;
                        p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                        return;
                    }

                    if (buffer.Count > p.group.maxBlocks)
                    {
                        Player.SendMessage(p, "You tried to brush " + buffer.Count + " blocks.");
                        Player.SendMessage(p, "You cannot brush more than " + p.group.maxBlocks + ".");
                        return;
                    }

                    Player.SendMessage(p, buffer.Count.ToString() + " blocks.");

                    c = 0;
                    for (int i = 0; i < buffer.Count; i++)
                    {
                        c++;
                        if (p.activeCuboids == 0) return;
                        l.Blockchange(p, buffer[i].x, buffer[i].y, buffer[i].z, type);
                        if (Server.throttle > 0)
                        {
                            while (Server.pauseCuboids) { Thread.Sleep(1000); }
                            if (c >= Server.throttle)
                            {
                                c = 0;
                                if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                            }
                        }
                    }

                    if (p.activeCuboids > 0) p.activeCuboids--;
                    p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                }
                catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
            })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();
        }
Beispiel #26
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            try
            {
                p.ClearBlockchange();
                CatchPos cpos = (CatchPos)p.blockchangeObject;
                if (cpos.type == Block.Zero) cpos.type = p.bindings[type];

                byte oldType = p.level.GetTile(x, y, z);
                p.SendBlockchange(x, y, z, oldType);

                if (cpos.type == oldType) { Player.SendMessage(p, "Cannot fill the same time"); return; }
                if (!Block.canPlace(p, oldType) && !Block.BuildIn(oldType)) { Player.SendMessage(p, "Cannot fill that."); return; }

                byte[] mapBlocks = new byte[p.level.blocks.Length];
                List<Pos> buffer = new List<Pos>();
                p.level.blocks.CopyTo(mapBlocks, 0);

                fromWhere.Clear();
                deep = 0;
                FloodFill(p, x, y, z, cpos.type, oldType, cpos.FillType, ref mapBlocks, ref buffer);

                int totalFill = fromWhere.Count;
                for (int i = 0; i < totalFill; i++)
                {
                    totalFill = fromWhere.Count;
                    Pos pos = fromWhere[i];
                    deep = 0;
                    FloodFill(p, pos.x, pos.y, pos.z, cpos.type, oldType, cpos.FillType, ref mapBlocks, ref buffer);
                    totalFill = fromWhere.Count;
                }
                fromWhere.Clear();

                Level l = p.level;
                p.activeCuboids++;
                Thread t = new Thread(new ThreadStart(delegate
                {
                    try
                    {
                        int c;
                        if (Server.forceCuboid)
                        {
                            c = 0;
                            int counter = 1;
                            buffer.ForEach(delegate(Pos pos)
                            {
                                c++;
                                if (counter <= p.group.maxBlocks)
                                {
                                    if (p.activeCuboids == 0) return;
                                    counter++;
                                    l.Blockchange(p, pos.x, pos.y, pos.z, cpos.type);
                                    while (Server.pauseCuboids) { Thread.Sleep(1000); }
                                    if (c >= Server.throttle)
                                    {
                                        c = 0;
                                        if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                                    }
                                }
                            });
                            if (counter >= p.group.maxBlocks)
                            {
                                Player.SendMessage(p, "Tried to cuboid " + buffer.Count + " blocks, but your limit is " + p.group.maxBlocks + ".");
                                Player.SendMessage(p, "Executed cuboid up to limit.");
                            }
                            else
                            {
                                Player.SendMessage(p, "Filled " + buffer.Count + " blocks.");
                                buffer.Clear();
                            }

                            if (p.activeCuboids > 0) p.activeCuboids--;
                            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                            return;
                        }

                        if (buffer.Count > p.group.maxBlocks)
                        {
                            Player.SendMessage(p, "You tried to fill " + buffer.Count + " blocks.");
                            Player.SendMessage(p, "You cannot fill more than " + p.group.maxBlocks + ".");
                            return;
                        }

                        c = 0;
                        buffer.ForEach(delegate(Pos pos)
                        {
                            c++;
                            if (p.activeCuboids == 0) return;
                            l.Blockchange(p, pos.x, pos.y, pos.z, cpos.type);
                            while (Server.pauseCuboids) { Thread.Sleep(1000); }
                            if (c >= Server.throttle)
                            {
                                c = 0;
                                if (l.players.Count > 0 && !l.Instant) Thread.Sleep(100);
                            }
                        });

                        Player.SendMessage(p, "Filled " + buffer.Count + " blocks.");
                        buffer.Clear();

                        if (p.activeCuboids > 0) p.activeCuboids--;
                        if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
                    }
                    catch (Exception ex) { Server.ErrorLog(ex); Player.SendMessage(p, "Error!"); return; }
                })); t.IsBackground = true; t.Priority = ThreadPriority.Lowest; t.Start();
            }
            catch (Exception e)
            {
                Server.ErrorLog(e);
            }
        }
Beispiel #27
0
        public override void Use(Player p, string message)
        {
            CatchPos cpos;

            int number = message.Split(' ').Length;
            if (number > 2) { Help(p); return; }
            if (number == 2)
            {
                int pos = message.IndexOf(' ');
                string t = message.Substring(0, pos).ToLower();
                string s = message.Substring(pos + 1).ToLower();
                cpos.type = Block.Byte(t);
                if (cpos.type == 255) { Player.SendMessage(p, "There is no block \"" + t + "\"."); return; }

                if (!Block.canPlace(p, cpos.type)) { Player.SendMessage(p, "Cannot place that."); return; }

                if (s == "up") cpos.FillType = 1;
                else if (s == "down") cpos.FillType = 2;
                else if (s == "layer") cpos.FillType = 3;
                else if (s == "vertical_x") cpos.FillType = 4;
                else if (s == "vertical_z") cpos.FillType = 5;
                else { Player.SendMessage(p, "Invalid fill type"); return; }
            }
            else if (message != "")
            {
                message = message.ToLower();
                if (message == "up") { cpos.FillType = 1; cpos.type = Block.Zero; }
                else if (message == "down") { cpos.FillType = 2; cpos.type = Block.Zero; }
                else if (message == "layer") { cpos.FillType = 3; cpos.type = Block.Zero; }
                else if (message == "vertical_x") { cpos.FillType = 4; cpos.type = Block.Zero; }
                else if (message == "vertical_z") { cpos.FillType = 5; cpos.type = Block.Zero; }
                else
                {
                    cpos.type = Block.Byte(message);
                    if (cpos.type == (byte)255) { Player.SendMessage(p, "Invalid block or fill type"); return; }
                    if (!Block.canPlace(p, cpos.type)) { Player.SendMessage(p, "Cannot place that."); return; }

                    cpos.FillType = 0;
                }
            }
            else
            {
                cpos.type = Block.Zero; cpos.FillType = 0;
            }

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;

            Player.SendMessage(p, "Destroy the block you wish to fill."); p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
        public override void Use(Player p, string message)
        {
            if (message == "") { Help(p); return; }

            //if (!Server.useMySQL) { p.SendMessage("MySQL has not been configured! Please configure MySQL to use Command Blocks!"); return; }
            //if (Server.mono) { p.SendMessage("Command Blocks are not possible due to Lua not being supported on Mono."); }

            CatchPos cpos;
            cpos.message = "";

            try
            {
                switch (message.Split(' ')[0])
                {
                    case "white": cpos.type = Block.cmdblock; break;
                    default: cpos.type = Block.cmdblock; cpos.message = message; break;
                }
            }
            catch { cpos.type = Block.MsgWhite; cpos.message = message; }

            if (cpos.message == "") cpos.message = message.Substring(message.IndexOf(' ') + 1);
            p.blockchangeObject = cpos;

            Player.SendMessage(p, "Place where you wish the command block to go."); p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
Beispiel #29
0
 public override void Use(Player p, string message)
 {
     CatchPos cpos;
     cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
     Player.SendMessage(p, "Place two blocks to determine the height.");
     p.ClearBlockchange();
     p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
 }
Beispiel #30
0
        public override void Use(Player p, string message)
        {
            int number = message.Split(' ').Length;
            if (number != 2) { Help(p); return; }

            int pos = message.IndexOf(' ');
            string t = message.Substring(0, pos).ToLower();
            string t2 = message.Substring(pos + 1).ToLower();
            byte type = Block.Byte(t);
            if (type == 255) { Player.SendMessage(p, "There is no block \"" + t + "\"."); return; }
            byte type2 = Block.Byte(t2);
            if (type2 == 255) { Player.SendMessage(p, "There is no block \"" + t2 + "\"."); return; }
            if (!Block.canPlace(p, type2)) { Player.SendMessage(p, "Cannot place that block type."); return; }

            CatchPos cpos; cpos.type2 = type2; cpos.type = type;

            cpos.x = 0; cpos.y = 0; cpos.z = 0; p.blockchangeObject = cpos;
            Player.SendMessage(p, "Place two blocks to determine the edges.");
            p.ClearBlockchange();
            p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }