コード例 #1
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message == "")
            {
                Help(p); return;
            }
            if (!p.Supports("VelocityControl", 1))
            {
                p.Message("&cYour client does not support velocity changes! Please update to the latest ClassiCube version"); return;
            }
            string[] args = message.SplitSpaces(6);
            if (args.Length < 6)
            {
                Help(p); return;
            }

            float x, y, z;
            byte  xmode, ymode, zmode;

            // Input validation
            if (!float.TryParse(args[0], out x) | !float.TryParse(args[1], out y) |
                !float.TryParse(args[2], out z) | !byte.TryParse(args[3], out xmode) |
                !byte.TryParse(args[4], out ymode) | !byte.TryParse(args[5], out zmode))
            {
                Help(p); return;
            }
            if (xmode < 0 | xmode > 1)
            {
                p.Message("&cxmode must be 0 or 1!"); return;
            }
            if (ymode < 0 | ymode > 1)
            {
                p.Message("&cymode must be 0 or 1!"); return;
            }
            if (zmode < 0 | zmode > 1)
            {
                p.Message("&czmode must be 0 or 1!"); return;
            }
            if (x <-2048f | x> 2048f)
            {
                p.Message("&cX must be between -2048 and 2048"); return;
            }
            if (y <-2048f | y> 2048f)
            {
                p.Message("&cY must be between -2048 and 2048"); return;
            }
            if (z <-2048f | z> 2048f)
            {
                p.Message("&cZ must be between -2048 and 2048"); return;
            }

            p.Send(Packet.VelocityControl(x, y, z, xmode, ymode, zmode));

            // Allow air message block to repeat every time
            p.prevMsg = "";
        }
コード例 #2
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p);
                return;
            }
            if (!p.Supports(CpeExt.HeldBlock))
            {
                p.Message("Your client doesn't support changing your held block.");
                return;
            }
            string[] args = message.SplitSpaces(2);

            BlockID block;

            if (!CommandParser.GetBlock(p, args[0], out block))
            {
                return;
            }
            bool locked = false;

            if (args.Length > 1 && !CommandParser.GetBool(p, args[1], ref locked))
            {
                return;
            }

            if (Block.IsPhysicsType(block))
            {
                p.Message("Cannot hold physics blocks");
                return;
            }

            BlockID raw = p.ConvertBlock(block);

            p.Send(Packet.HoldThis(raw, locked, p.hasExtBlocks));
        }