示例#1
0
        /// <summary>
        /// Parses the given command parameters for the sender and returns the area to regenerate chunks for.
        /// </summary>
        /// <param name="parameters"></param>
        /// <param name="senderInfo"></param>
        /// <returns>The area from pos1 to pos2 for which chunks should be regenerated; y value should be ignored</returns>
        private static (Vector3i pos1, Vector3i pos2) ParseParams(List <string> parameters, CommandSenderInfo senderInfo)
        {
            Vector3i pos1, pos2;

            switch (parameters.Count)
            {
            case 0:
                // one point is enough; area will extend to the chunk
                pos1 = pos2 = senderInfo.GetRemoteClientInfo().GetEntityPlayer().GetServerPos().ToVector3i();
                break;

            case 1:
                var ci         = senderInfo.GetRemoteClientInfo();
                var currentPos = ci.GetEntityPlayer().GetServerPos().ToVector3i();
                switch (parameters[0])
                {
                case "from":
                    savedPos[ci.entityId] = currentPos;
                    throw new FriendlyMessageException("Your current position was saved: " + savedPos[ci.entityId]);

                case "to":
                    if (!savedPos.ContainsKey(ci.entityId))
                    {
                        throw new FriendlyMessageException("Please save start point of the area first. See help for details.");
                    }
                    pos1 = savedPos[ci.entityId];
                    pos2 = currentPos;
                    break;

                default:
                    throw new FriendlyMessageException("Parameter unknown. See help for details.");
                }
                break;

            case 4:
                pos1 = CommandTools.ParseXZ(parameters, 0);
                pos2 = CommandTools.ParseXZ(parameters, 2);
                break;

            default:
                throw new FriendlyMessageException(Resources.ErrorParameerCountNotValid);
            }

            return(pos1, pos2);
        }