Пример #1
0
        public static void Selclaim(User user)
        {
            try
            {
                Vector3i    pos      = user.Position.Round;
                Vector2i    claimPos = PlotUtil.NearestPlotPosInWorld(pos.XZ);
                UserSession session  = WorldEditManager.GetUserSession(user);

                session.SetFirstPosition(claimPos.X_Z(pos.Y - 1));
                session.SetSecondPosition(WorldEditUtils.SecondPlotPos(claimPos).X_Z(pos.Y - 1));

                user.Player.MsgLoc($"First Position set to {session.Selection.min}");
                user.Player.MsgLoc($"Second Position set to {session.Selection.max}");
            }
            catch (Exception e)
            {
                Log.WriteError(Localizer.Do($"{e}"));
            }
        }
Пример #2
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}"));
            }
        }