mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-10-02 10:01:34 -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) {
|
internal Level GenerateMap(Player p, string[] args, CommandData data) {
|
||||||
if (args.Length < 5) return null;
|
if (args.Length < 5) return null;
|
||||||
MapGen gen = MapGen.Find(args[4]);
|
MapGen gen = MapGen.Find(args[4]);
|
||||||
if (gen == null) { MapGen.PrintThemes(p); return null; }
|
|
||||||
|
|
||||||
ushort x = 0, y = 0, z = 0;
|
ushort x = 0, y = 0, z = 0;
|
||||||
|
|
||||||
if (!MapGen.GetDimensions(p, args, 1, ref x, ref y, ref z)) return null;
|
if (!MapGen.GetDimensions(p, args, 1, ref x, ref y, ref z)) return null;
|
||||||
string seed = args.Length == 6 ? args[5] : "";
|
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);
|
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' . . .");
|
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);
|
ushort x = 0, y = 0, z = 0;
|
||||||
CmdOverseer.SetPerms(p, level);
|
string[] xyz = { preset.x, preset.y, preset.z };
|
||||||
level.SaveSettings();
|
if (!MapGen.GetDimensions(p, xyz, 0, ref x, ref y, ref z)) return;
|
||||||
PlayerActions.ChangeMap(p, name);
|
|
||||||
|
|
||||||
p.Message("&aSuccessfully created your map: '&f" + name + "&a'");
|
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);
|
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,
|
public static Level Generate(Player p, MapGen gen, string name,
|
||||||
ushort x, ushort y, ushort z, string seed) {
|
ushort x, ushort y, ushort z, string seed) {
|
||||||
name = name.ToLower();
|
name = name.ToLower();
|
||||||
|
if (gen == null) { PrintThemes(p); return null; }
|
||||||
if (!Formatter.ValidMapName(p, name)) return null;
|
if (!Formatter.ValidMapName(p, name)) return null;
|
||||||
|
|
||||||
if (LevelInfo.MapExists(name)) {
|
if (LevelInfo.MapExists(name)) {
|
||||||
p.Message("%WLevel \"{0}\" already exists", name); return null;
|
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].
|
' This one controls what happens when you use /Help [commandname].
|
||||||
\t\tPublic Overrides Sub Help(p As Player)
|
\t\tPublic Overrides Sub Help(p As Player)
|
||||||
\t\t\tp.Message(""/{0} - Does stuff. Example command."")
|
\t\t\tp.Message(""/{0} - Does stuff. Example command."")
|
||||||
|
|
||||||
\t\tEnd Sub
|
\t\tEnd Sub
|
||||||
\tEnd Class
|
\tEnd Class
|
||||||
End Namespace";
|
End Namespace";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user