コード例 #1
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (!(p.group.Permission >= LevelPermission.Operator))
            {
                if (!Hacks.CanUseHacks(p))
                {
                    if (data.Context != CommandContext.MessageBlock)
                    {
                        p.Message("%cYou cannot use this command manually when hacks are disabled.");
                        return;
                    }
                }
            }

            BlockID block = p.GetHeldBlock();

            string[] parts = message.SplitSpaces();
            Vec3S32  pos;

            pos.X = p.Pos.BlockX;
            pos.Y = (p.Pos.Y - 32) / 32;
            pos.Z = p.Pos.BlockZ;

            switch (parts.Length)
            {
            case 1:
                if (message == "")
                {
                    break;
                }

                if (!CommandParser.GetBlock(p, parts[0], out block))
                {
                    return;
                }
                break;

            case 3:
                if (!CommandParser.GetCoords(p, parts, 0, ref pos))
                {
                    return;
                }
                break;

            case 4:
                if (!CommandParser.GetBlock(p, parts[0], out block))
                {
                    return;
                }
                if (!CommandParser.GetCoords(p, parts, 1, ref pos))
                {
                    return;
                }
                break;

            default:
                p.Message("Invalid number of parameters"); return;
            }
            if (!CommandParser.IsBlockAllowed(p, "place ", block))
            {
                return;
            }

            pos = p.level.ClampPos(pos);
            p.SendBlockchange((ushort)pos.X, (ushort)pos.Y, (ushort)pos.Z, block);
            //string blockName = Block.GetName(p, block);
            //p.Message("{3} block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z, blockName);
        }
コード例 #2
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (!(p.group.Permission >= LevelPermission.Operator))
            {
                if (!Hacks.CanUseHacks(p))
                {
                    if (data.Context != CommandContext.MessageBlock)
                    {
                        p.Message("%cYou cannot use this command manually when hacks are disabled.");
                        return;
                    }
                }
            }

            BlockID block = p.GetHeldBlock();
            int     x = p.Pos.BlockX, y = (p.Pos.Y - 32) / 32, z = p.Pos.BlockZ;

            try {
                string[] parts = message.Split(' ');
                switch (parts.Length)
                {
                case 1:
                    if (message == "")
                    {
                        break;
                    }

                    if (!CommandParser.GetBlock(p, parts[0], out block))
                    {
                        return;
                    }
                    break;

                case 3:
                    x = int.Parse(parts[0]);
                    y = int.Parse(parts[1]);
                    z = int.Parse(parts[2]);
                    break;

                case 4:
                    if (!CommandParser.GetBlock(p, parts[0], out block))
                    {
                        return;
                    }

                    x = int.Parse(parts[1]);
                    y = int.Parse(parts[2]);
                    z = int.Parse(parts[3]);
                    break;

                default: Player.Message(p, "Invalid number of parameters"); return;
                }
            } catch {
                p.Message("Invalid parameters"); return;
            }

            if (!CommandParser.IsBlockAllowed(p, "place ", block))
            {
                return;
            }

            x = Clamp(x, p.level.Width);
            y = Clamp(y, p.level.Height);
            z = Clamp(z, p.level.Length);

            p.SendBlockchange((ushort)x, (ushort)y, (ushort)z, block);
            //string blockName = Block.GetName(p, block);
            //Player.Message(p, "{3} block was placed at ({0}, {1}, {2}).", P.X, P.Y, P.Z, blockName);
        }