示例#1
0
        public override void Use(Player p, string message)
        {
            string[] args = message.SplitSpaces();

            if (args.Length == 0)
            {
                p.Message("You need to specify a URL to import."); return;
            }
            if (args.Length == 1)
            {
                p.Message("You need to specify the name you want the level to be called."); return;
            }

            if (File.Exists("./levels/" + args[1] + ".lvl"))
            {
                p.Message("That is already a level name, try something else.");
                return;
            }

            NbtReader reader = new NbtReader();
            Dictionary <string, NbtTag> tags;
            var req = System.Net.WebRequest.Create(args[0]);

            using (Stream stream = req.GetResponse().GetResponseStream())
            {
                tags = reader.Load(stream);
            }

            MapConverter conv = new MapConverter();

            conv.Init(tags);

            conv.SaveAsLvl("./levels/" + args[1] + ".lvl");
            //File.SetAttributes(dest, FileAttributes.Normal);

            p.Message("Finished importing level %b" + args[1] + "%S.");
        }