mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-02 01:53:10 -04:00
Fix /buy level erroring if level failed to generate
This commit is contained in:
parent
c7dff51acd
commit
fd9676456d
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user