diff --git a/MCGalaxy/Commands/World/CmdNewLvl.cs b/MCGalaxy/Commands/World/CmdNewLvl.cs index c5684d536..49deaac58 100644 --- a/MCGalaxy/Commands/World/CmdNewLvl.cs +++ b/MCGalaxy/Commands/World/CmdNewLvl.cs @@ -48,13 +48,12 @@ namespace MCGalaxy.Commands.World { internal Level GenerateMap(Player p, string[] args, CommandData data) { if (args.Length < 5) return null; MapGen gen = MapGen.Find(args[4]); - if (gen == null) { MapGen.PrintThemes(p); return null; } - ushort x = 0, y = 0, z = 0; + if (!MapGen.GetDimensions(p, args, 1, ref x, ref y, ref z)) return null; string seed = args.Length == 6 ? args[5] : ""; - if (gen.Type == GenType.Advanced && !CheckExtraPerm(p, data, 1)) return null; + if (gen != null && gen.Type == GenType.Advanced && !CheckExtraPerm(p, data, 1)) return null; return MapGen.Generate(p, gen, args[0], x, y, z, seed); } diff --git a/MCGalaxy/Economy/LevelItem.cs b/MCGalaxy/Economy/LevelItem.cs index 891b915ba..c7d24ba8d 100644 --- a/MCGalaxy/Economy/LevelItem.cs +++ b/MCGalaxy/Economy/LevelItem.cs @@ -92,19 +92,25 @@ namespace MCGalaxy.Eco { } } - if (LevelInfo.MapExists(name)) { - p.Message("%WLevel \"{0}\" already exists", name); return; - } - p.Message("&aCreating level: '&f" + name + "&a' . . ."); - UseCommand(p, "NewLvl", name + " " + preset.x + " " + preset.y + " " + preset.z + " " + preset.type); - Level level = LevelActions.Load(Player.Console, name, true); - CmdOverseer.SetPerms(p, level); - level.SaveSettings(); - PlayerActions.ChangeMap(p, name); - - p.Message("&aSuccessfully created your map: '&f" + name + "&a'"); + ushort x = 0, y = 0, z = 0; + string[] xyz = { preset.x, preset.y, preset.z }; + if (!MapGen.GetDimensions(p, xyz, 0, ref x, ref y, ref z)) return; + + MapGen gen = MapGen.Find(preset.type); + Level lvl = MapGen.Generate(p, gen, name, x, y, z, ""); + if (lvl == null) return; + + CmdOverseer.SetPerms(p, lvl); + lvl.SaveSettings(); + + try { + lvl.Save(true); + } finally { + lvl.Dispose(); + Server.DoGC(); + } Economy.MakePurchase(p, preset.price, "%3Map: %f" + preset.name); } diff --git a/MCGalaxy/Generator/MapGen.cs b/MCGalaxy/Generator/MapGen.cs index 42f53905a..eef9c81e7 100644 --- a/MCGalaxy/Generator/MapGen.cs +++ b/MCGalaxy/Generator/MapGen.cs @@ -91,7 +91,9 @@ namespace MCGalaxy.Generator { public static Level Generate(Player p, MapGen gen, string name, ushort x, ushort y, ushort z, string seed) { name = name.ToLower(); + if (gen == null) { PrintThemes(p); return null; } if (!Formatter.ValidMapName(p, name)) return null; + if (LevelInfo.MapExists(name)) { p.Message("%WLevel \"{0}\" already exists", name); return null; } diff --git a/MCGalaxy/Scripting/Backends.cs b/MCGalaxy/Scripting/Backends.cs index badce5132..73df47b7c 100644 --- a/MCGalaxy/Scripting/Backends.cs +++ b/MCGalaxy/Scripting/Backends.cs @@ -150,7 +150,6 @@ Namespace MCGalaxy ' This one controls what happens when you use /Help [commandname]. \t\tPublic Overrides Sub Help(p As Player) \t\t\tp.Message(""/{0} - Does stuff. Example command."") - \t\tEnd Sub \tEnd Class End Namespace";