예제 #1
0
        /// <summary>
        /// Attempts to determine the best matching world type of the given path, and open the world as that type.
        /// </summary>
        /// <param name="path">The path to the directory containing the world.</param>
        /// <returns>A concrete <see cref="NbtWorld"/> type, or null if the world cannot be opened or is ambiguos.</returns>
        public static NbtWorld Open (string path)
        {
            if (ResolveOpen == null) {
                return null;
            }

            OpenWorldEventArgs eventArgs = new OpenWorldEventArgs(path);
            ResolveOpen(null, eventArgs);

            if (eventArgs.HandlerCount != 1) {
                return null;
            }


            foreach (OpenWorldCallback callback in eventArgs.Handlers) {
                return callback(path);
            }

            return null;
        }
예제 #2
0
        internal static void OnResolveOpen (object sender, OpenWorldEventArgs e)
        {
            try {
                AnvilWorld world = new AnvilWorld().OpenWorld(e.Path);
                if (world == null) {
                    return;
                }

                string regPath = IO.Path.Combine(e.Path, _REGION_DIR);
                if (!Directory.Exists(regPath)) {
                    return;
                }

                if (world.Level.Version < 19133) {
                    return;
                }

                e.AddHandler(Open);
            }
            catch (Exception) {
                return;
            }
        }
예제 #3
0
        internal static void OnResolveOpen(object sender, OpenWorldEventArgs e)
        {
            try {
                AlphaWorld world = new AlphaWorld().OpenWorld(e.Path);
                if (world == null) {
                    return;
                }

                if (world.Level.Version != 0) {
                    return;
                }

                e.AddHandler(Open);
            }
            catch (Exception) {
                return;
            }
        }