Exemplo n.º 1
0
        public MoveCommand(User user, string args) : base(user)
        {
            if (!this.UserSession.Selection.IsSet())
            {
                throw new WorldEditCommandException("Please set both points first!");
            }

            this.direction = WorldEditUtils.ParseDirectionAndAmountArgs(user, args, out this.amount);
            if (this.direction == Direction.Unknown || this.direction == Direction.None)
            {
                throw new WorldEditCommandException("Unable to determine direction");
            }
        }
Exemplo n.º 2
0
        private SelectionCommand(User user, Command commandType, string args) : base(user)
        {
            this._commandType = commandType;

            if (!this.UserSession.Selection.IsSet())
            {
                throw new WorldEditCommandException("Please set both points first!");
            }
            this.direction = WorldEditUtils.ParseDirectionAndAmountArgs(user, args, out this.amount);
            if (this.direction == Direction.Unknown || (this._commandType == Command.SHIFT && this.direction == Direction.None))
            {
                throw new WorldEditCommandException("Unable to determine direction");
            }
        }
Exemplo n.º 3
0
        public static void Expclaim(User user, string args = "1")
        {
            try
            {
                UserSession session = WorldEditManager.GetUserSession(user);
                if (!session.Selection.IsSet())
                {
                    throw new WorldEditCommandException("Please set both points first!");
                }
                Direction direction = WorldEditUtils.ParseDirectionAndAmountArgs(user, args, out int amount);
                if (direction == Direction.Unknown ||
                    direction == Direction.None ||
                    direction == Direction.Up ||
                    direction == Direction.Down)
                {
                    throw new WorldEditCommandException("Unable to determine direction");
                }
                WorldRange range = session.Selection;
                Vector3i   pos   = default;
                if (range.min.y <= range.max.y)
                {
                    pos.y = range.min.y;
                }
                else
                {
                    pos.y = range.max.y;
                }
                switch (direction)
                {
                case Direction.Left:
                case Direction.Back:
                    if (range.min.x <= range.max.x)
                    {
                        pos.x = range.min.x;
                    }
                    else
                    {
                        pos.x = range.max.x;
                    }
                    if (range.min.z <= range.max.z)
                    {
                        pos.z = range.min.z;
                    }
                    else
                    {
                        pos.z = range.max.z;
                    }
                    break;

                case Direction.Right:
                case Direction.Forward:
                    if (range.min.x <= range.max.x)
                    {
                        pos.x = range.max.x;
                    }
                    else
                    {
                        pos.x = range.min.x;
                    }
                    if (range.min.z <= range.max.z)
                    {
                        pos.z = range.max.z;
                    }
                    else
                    {
                        pos.z = range.min.z;
                    }
                    break;
                }
                pos += direction.ToVec() * (PlotUtil.PropertyPlotLength - 1) * amount;
                Vector2i claimPos = PlotUtil.NearestPlotPosInWorld(pos.XZ);
                range.ExtendToInclude(claimPos.X_Z(pos.Y));
                range.ExtendToInclude(WorldEditUtils.SecondPlotPos(claimPos).X_Z(pos.Y));
                session.SetSelection(range);

                user.Player.MsgLoc($"First Position now at {session.Selection.min}");
                user.Player.MsgLoc($"Second Position now at {session.Selection.max}");
            }
            catch (WorldEditCommandException e)
            {
                user.Player.ErrorLocStr(e.Message);
            }
            catch (Exception e)
            {
                Log.WriteError(Localizer.Do($"{e}"));
            }
        }